Fix false positive PHP 7 job in Travis CI #254
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The job for PHP 7 was passing unconditionally, even when the tests would
fail, such as https://travis-ci.org/perftools/xhgui/builds/475018345.
Turns out this is because phpunit is run directly from the shell
context, where composer/vendor doesn't apply. And Travis CI is
nice enough to bundle a version of phpunit with the environment.
The problem is, that default version of PHPUnit is 6.x on Travis CI
for PHP 7; which no longer recognises the non-namespaces TestCase
classes, and simply prints:
Fix this by specifying the test in a composer run script, which
is run in a subshell where vendor/bin from Composer is also in
the PATH.
This also makes it easier for developers to run the tests locally
by only having to do
composer install
andcomposer test
, whichis a common idiom for PHP-based projects. Previously, one had
to install the correct version globally, or use something like
./vendor/bin/phunit to run the tests.