Skip to content

Commit 94ba72a

Browse files
committed
Fail in simple-phpunit if one of the passthru() commands fails
1 parent 20bf17f commit 94ba72a

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@
5353
return $default;
5454
};
5555

56+
function passthru_or_fail($command) {
57+
passthru($command, $return);
58+
if ($return !== 0) {
59+
exit(99);
60+
}
61+
}
62+
5663
if (PHP_VERSION_ID >= 70200) {
5764
// PHPUnit 8 requires PHP 7.2+
5865
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '8.3');
@@ -118,29 +125,29 @@
118125
@mkdir($PHPUNIT_DIR, 0777, true);
119126
chdir($PHPUNIT_DIR);
120127
if (file_exists("$PHPUNIT_VERSION_DIR")) {
121-
passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s > NUL': 'rm -rf %s', "$PHPUNIT_VERSION_DIR.old"));
128+
passthru_or_fail(sprintf('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s > NUL': 'rm -rf %s', "$PHPUNIT_VERSION_DIR.old"));
122129
rename("$PHPUNIT_VERSION_DIR", "$PHPUNIT_VERSION_DIR.old");
123-
passthru(sprintf('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s': 'rm -rf %s', "$PHPUNIT_VERSION_DIR.old"));
130+
passthru_or_fail(sprintf('\\' === DIRECTORY_SEPARATOR ? 'rmdir /S /Q %s': 'rm -rf %s', "$PHPUNIT_VERSION_DIR.old"));
124131
}
125-
passthru("$COMPOSER create-project --no-install --prefer-dist --no-scripts --no-plugins --no-progress --ansi phpunit/phpunit $PHPUNIT_VERSION_DIR \"$PHPUNIT_VERSION.*\"");
132+
passthru_or_fail("$COMPOSER create-project --no-install --prefer-dist --no-scripts --no-plugins --no-progress --ansi phpunit/phpunit $PHPUNIT_VERSION_DIR \"$PHPUNIT_VERSION.*\"");
126133
@copy("$PHPUNIT_VERSION_DIR/phpunit.xsd", 'phpunit.xsd');
127134
chdir("$PHPUNIT_VERSION_DIR");
128135
if ($SYMFONY_PHPUNIT_REMOVE) {
129-
passthru("$COMPOSER remove --no-update ".$SYMFONY_PHPUNIT_REMOVE);
136+
passthru_or_fail("$COMPOSER remove --no-update ".$SYMFONY_PHPUNIT_REMOVE);
130137
}
131138
if (5.1 <= $PHPUNIT_VERSION && $PHPUNIT_VERSION < 5.4) {
132-
passthru("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\"");
139+
passthru_or_fail("$COMPOSER require --no-update phpunit/phpunit-mock-objects \"~3.1.0\"");
133140
}
134141

135-
passthru("$COMPOSER config --unset platform");
142+
passthru_or_fail("$COMPOSER config --unset platform");
136143
if (file_exists($path = $root.'/vendor/symfony/phpunit-bridge')) {
137-
passthru("$COMPOSER require --no-update symfony/phpunit-bridge \"*@dev\"");
138-
passthru("$COMPOSER config repositories.phpunit-bridge path ".escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $path)));
144+
passthru_or_fail("$COMPOSER require --no-update symfony/phpunit-bridge \"*@dev\"");
145+
passthru_or_fail("$COMPOSER config repositories.phpunit-bridge path ".escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $path)));
139146
if ('\\' === DIRECTORY_SEPARATOR) {
140147
file_put_contents('composer.json', preg_replace('/^( {8})"phpunit-bridge": \{$/m', "$0\n$1 ".'"options": {"symlink": false},', file_get_contents('composer.json')));
141148
}
142149
} else {
143-
passthru("$COMPOSER require --no-update symfony/phpunit-bridge \"*\"");
150+
passthru_or_fail("$COMPOSER require --no-update symfony/phpunit-bridge \"*\"");
144151
}
145152
$prevRoot = getenv('COMPOSER_ROOT_VERSION');
146153
putenv("COMPOSER_ROOT_VERSION=$PHPUNIT_VERSION.99");

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy