-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[PHPUnit-Bridge] Fail-fast in simple-phpunit if one of the passthru() commands fails #35254
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
[PHPUnit-Bridge] Fail-fast in simple-phpunit if one of the passthru() commands fails #35254
Conversation
|
We still fox bugs in lower branches so 3.4 might be a fit. |
94ba72a to
6635484
Compare
|
Rebased onto 3.4 |
|
Updated |
|
|
||
| error_reporting(-1); | ||
|
|
||
| $passthru_or_fail = function ($command) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we use camel case :)
but $passthru would be fine as a name to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will change, but prefer to keep the orFail to make clear there's a difference to plain passthru()
| $passthru_or_fail = function ($command) { | ||
| passthru($command, $return); | ||
| if ($return !== 0) { | ||
| exit(99); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ($return) {
exit($return);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will change
| chdir($PHPUNIT_DIR); | ||
| if (file_exists("phpunit-$PHPUNIT_VERSION")) { | ||
| passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s > NUL': 'rm -rf %s', "phpunit-$PHPUNIT_VERSION.old")); | ||
| $passthru_or_fail(sprintf('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s > NUL': 'rm -rf %s', "phpunit-$PHPUNIT_VERSION.old")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can and should fail silently by design, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is it trying to do here at all?
remove the -.old version if it is there, then rename phpunit-$VERSION to phpunit-$VERSION.old, and then try removing that again?
Doesn't that effectively remove both the .old and current one?
| $passthru_or_fail(sprintf('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s > NUL': 'rm -rf %s', "phpunit-$PHPUNIT_VERSION.old")); | ||
| rename("phpunit-$PHPUNIT_VERSION", "phpunit-$PHPUNIT_VERSION.old"); | ||
| passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s': 'rm -rf %s', "phpunit-$PHPUNIT_VERSION.old")); | ||
| $passthru_or_fail(sprintf('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s': 'rm -rf %s', "phpunit-$PHPUNIT_VERSION.old")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
fbbb23d to
576e185
Compare
|
Thank you @mpdude. |
… passthru() commands fails (mpdude) This PR was squashed before being merged into the 3.4 branch. Discussion ---------- [PHPUnit-Bridge] Fail-fast in simple-phpunit if one of the passthru() commands fails | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | Some commands executed by the `simple-phpunit` script are not checked for success. For example [here](https://travis-ci.org/twigphp/Twig/jobs/634110681), Composer fails with the message ``` [InvalidArgumentException] Could not find package phpunit/phpunit with version 7.5.* in a version inst allable using your PHP version 7.0.25. ``` Yet, the `simple-phpunit` script happily continues, going over failing `chdir()`, `file_get_contents()` and `include()` calls and eventually returns a successful `0` exit code. So CI tests look OK when in fact PHPUnit was not even downloaded. Commits ------- 576e185 [PHPUnit-Bridge] Fail-fast in simple-phpunit if one of the passthru() commands fails
Some commands executed by the
simple-phpunitscript are not checked for success. For example here, Composer fails with the messageYet, the
simple-phpunitscript happily continues, going over failingchdir(),file_get_contents()andinclude()calls and eventually returns a successful0exit code. So CI tests look OK when in fact PHPUnit was not even downloaded.