Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generate:travis-yml command sometimes fails to detect tests in plugin #6532

Closed
wants to merge 2 commits into from

Conversation

mnapoli
Copy link
Contributor

@mnapoli mnapoli commented Oct 28, 2014

The generate:travis-yml was looking for test files in plugins, but it was looking in tests/*Test.php or tests/*/*Test.php. And of course, for plugins that had plugins in a 3 level deep subdirectory (i.e. tests/*/*/*Test.php) the command was failing because no tests were found. This is the case for example for the ActivityLog plugin.

I could have fixed it by adding another test to the list (because glob() doesn't match recursively):

$testFiles = array_merge(glob($folderPath . "/*/*Test.php"), glob($folderPath . "/*Test.php"), glob($folderPath . "/*/*/*Test.php"));
return !empty($testFiles);

But this is not really ideal, so instead of writing useless complex code I went with using Symfony's Finder component:

$finder = new Finder();
$finder->files()
    ->in($folderPath)
    ->name('*Test.php');
return count($finder) > 0;

So that's the reason I'm opening a pull request: do you think that's fine to introduce a new dependency to that component? I've been using the Finder for a while in other projects and it's really useful, I'm guessing it could be reused in many places in Piwik.

@mnapoli mnapoli self-assigned this Oct 28, 2014
@mnapoli mnapoli added this to the Piwik 2.9.0 milestone Oct 28, 2014
@mattab
Copy link
Member

mattab commented Oct 28, 2014

because glob() doesn't match recursively

Maybe globr would help here? http://developer.piwik.org/api-reference/Piwik/Filesystem#globr

@mnapoli
Copy link
Contributor Author

mnapoli commented Oct 28, 2014

Fixed with Piwik\Filesystem::globr()

@mnapoli mnapoli closed this Oct 28, 2014
@mnapoli mnapoli deleted the fix-generate-yml branch October 28, 2014 03:09
@mattab mattab changed the title Fixed generate:travis-yml command bug using Symfony Finder generate:travis-yml command sometimes fails to detect tests in plugin Oct 28, 2014
@mattab mattab added the Bug For errors / faults / flaws / inconsistencies etc. label Oct 28, 2014
@mattab
Copy link
Member

mattab commented Oct 28, 2014

done in b64e589

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants