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

Fix false positive PHP 7 job in Travis CI #254

Merged
merged 1 commit into from
Jan 5, 2019

Conversation

Krinkle
Copy link
Contributor

@Krinkle Krinkle commented Jan 5, 2019

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:

PHPUnit 6

No tests executed!

The command "bash .travis/run.sh" exited with 0.
SUCCESS

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 and composer test, which
is 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.

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:

> PHPUnit 6
>
> No tests executed!
>
> The command "bash .travis/run.sh" exited with 0.
> SUCCESS

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` and `composer test`, which
is 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.
@markstory markstory merged commit 0f10bfc into perftools:master Jan 5, 2019
@Krinkle Krinkle deleted the fail-pass branch January 5, 2019 03:22
@glensc glensc mentioned this pull request Jun 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants