8000 minor #16061 [appveyor] Fix command line (nicolas-grekas) · symfony/symfony@17edafd · GitHub
[go: up one dir, main page]

Skip to content

Commit 17edafd

Browse files
minor #16061 [appveyor] Fix command line (nicolas-grekas)
This PR was merged into the 2.3 branch. Discussion ---------- [appveyor] Fix command line | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Discovery the joy of cmd programming... Commits ------- bdcbde9 [appveyor] Fix command line
2 parents 150f52f + bdcbde9 commit 17edafd

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

phpunit

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/usr/bin/env php
22
<?php
33

4+
use Symfony\Component\Process\ProcessUtils;
5+
46
error_reporting(-1);
7+
require __DIR__.'/src/Symfony/Component/Process/ProcessUtils.php';
58

69
$PHPUNIT_VERSION = '4.8';
710
$PHPUNIT_DIR = __DIR__.'/.phpunit';
@@ -32,7 +35,7 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit")) {
3235
chdir($oldPwd);
3336
}
3437

35-
$cmd = array_map('escapeshellarg', $argv);
38+
$cmd = array_map('Symfony\Component\Process\ProcessUtils::escapeArgument', $argv);
3639
$exit = 0;
3740

3841
if (isset($argv[1]) && 'symfony' === $argv[1]) {
@@ -51,11 +54,13 @@ if ($phpIniMatrix) {
5154

5255
$phpDir = dirname(`where.exe php`);
5356

54-
$newCmd = '(SET X=0';
57+
$newCmd = 'cmd /v:on /d /c "(SET X=0';
5558
foreach ($phpIniMatrix as $iniFile) {
56-
$newCmd .= " & copy /Y $phpDir\\$iniFile $phpDir\\php.ini & echo. & echo Running tests with $iniFile: & $cmd & (if %%errorlevel%% NEQ 0 SET X=1)";
59+
$newCmd .= " & copy /Y $phpDir\\$iniFile $phpDir\\php.ini & echo. & echo Running tests with $iniFile: & ($cmd || SET X=1)";
5760
}
58-
$cmd = $newCmd .= ' & exit %%X%%)';
61+
$cmd = $newCmd .= ' & exit !X!)%2$s"';
62+
} else {
63+
$cmd .= ' %2$s';
5964
}
6065

6166
if (isset($argv[1]) && 'symfony' === $argv[1]) {
@@ -73,9 +78,9 @@ if (isset($argv[1]) && 'symfony' === $argv[1]) {
7378

7479
// Run phpunit tests in parallel
7580

76-
$c = escapeshellarg($component);
81+
$c = ProcessUtils::escapeArgument($component);
7782

78-
if ($proc = proc_open(sprintf($cmd, $c)." > $c/phpunit.stdout 2> $c/phpunit.stderr", array(), $pipes)) {
83+
if ($proc = proc_open(sprintf($cmd, $c, " > $c/phpunit.stdout 2> $c/phpunit.stderr"), array(), $pipes)) {
7984
$runningProcs[$component] = $proc;
8085
} else {
8186
$exit = 1;
@@ -137,7 +142,7 @@ if (isset($argv[1]) && 'symfony' === $argv[1]) {
137142
// Run regular phpunit in a subprocess
138143

139144
$errFile = tempnam(sys_get_temp_dir(), 'phpunit.stderr.');
140-
if ($proc = proc_open(sprintf($cmd, '').' 2> '.escapeshellarg($errFile), array(1 => array('pipe', 'w')), $pipes)) {
145+
if ($proc = proc_open(sprintf($cmd, '', ' 2> '.ProcessUtils::escapeArgument($errFile)), array(1 => array('pipe', 'w')), $pipes)) {
141146
stream_copy_to_stream($pipes[1], STDOUT);
142147
fclose($pipes[1]);
143148
$exit = proc_close($proc);

0 commit comments

Comments
 (0)
0