1
1
#!/usr/bin/env php
2
2
<?php
3
3
4
+ use Symfony \Component \Process \ProcessUtils ;
5
+
4
6
error_reporting (-1 );
7
+ require __DIR__ .'/src/Symfony/Component/Process/ProcessUtils.php ' ;
5
8
6
9
$ PHPUNIT_VERSION = '4.8 ' ;
7
10
$ PHPUNIT_DIR = __DIR__ .'/.phpunit ' ;
@@ -32,7 +35,7 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit")) {
32
35
chdir ($ oldPwd );
33
36
}
34
37
35
- $ cmd = array_map ('escapeshellarg ' , $ argv );
38
+ $ cmd = array_map ('Symfony\Component\Process\ProcessUtils::escapeArgument ' , $ argv );
36
39
$ exit = 0 ;
37
40
38
41
if (isset ($ argv [1 ]) && 'symfony ' === $ argv [1 ]) {
@@ -51,11 +54,13 @@ if ($phpIniMatrix) {
51
54
52
55
$ phpDir = dirname (`where.exe php `);
53
56
54
- $ newCmd = '(SET X=0 ' ;
57
+ $ newCmd = 'cmd /v:on /d /c " (SET X=0 ' ;
55
58
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) " ;
57
60
}
58
- $ cmd = $ newCmd .= ' & exit %%X%%) ' ;
61
+ $ cmd = $ newCmd .= ' & exit !X!)%2$s" ' ;
62
+ } else {
63
+ $ cmd .= ' %2$s ' ;
59
64
}
60
65
61
66
if (isset ($ argv [1 ]) && 'symfony ' === $ argv [1 ]) {
@@ -73,9 +78,9 @@ if (isset($argv[1]) && 'symfony' === $argv[1]) {
73
78
74
79
// Run phpunit tests in parallel
75
80
76
- $ c = escapeshellarg ($ component );
81
+ $ c = ProcessUtils:: escapeArgument ($ component );
77
82
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 )) {
79
84
$ runningProcs [$ component ] = $ proc ;
80
85
} else {
81
86
$ exit = 1 ;
@@ -137,7 +142,7 @@ if (isset($argv[1]) && 'symfony' === $argv[1]) {
137
142
// Run regular phpunit in a subprocess
138
143
139
144
$ 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 )) {
141
146
stream_copy_to_stream ($ pipes [1 ], STDOUT );
142
147
fclose ($ pipes [1 ]);
143
148
$ exit = proc_close ($ proc );
0 commit comments