11
11
*/
12
12
13
13
// Please update when phpunit needs to be reinstalled with fresh deps:
14
- // Cache-Id-Version: 2016-06-29 13:45 UTC
15
-
16
- use Symfony \Component \Process \ProcessUtils ;
14
+ // Cache-Id-Version: 2016-09-12 09:00 UTC
17
15
18
16
error_reporting (-1 );
19
- require __DIR__ .'/src/Symfony/Component/Process/ProcessUtils.php ' ;
20
17
21
18
// PHPUnit 4.8 does not support PHP 7, while 5.1 requires PHP 5.6+
22
19
$ PHPUNIT_VERSION = PHP_VERSION_ID >= 50600 ? '5.1 ' : '4.8 ' ;
23
- $ PHPUNIT_DIR = __DIR__ .'/.phpunit ' ;
20
+ $ oldPwd = getcwd ();
21
+ $ PHPUNIT_DIR = getenv ('SYMFONY_PHPUNIT_DIR ' ) ?: (__DIR__ .'/.phpunit ' );
24
22
$ PHP = defined ('PHP_BINARY ' ) ? PHP_BINARY : 'php ' ;
25
- $ PHP = ProcessUtils:: escapeArgument ($ PHP );
23
+ $ PHP = escapeshellarg ($ PHP );
26
24
if ('phpdbg ' === PHP_SAPI ) {
27
25
$ PHP .= ' -qrr ' ;
28
26
}
29
27
30
- $ COMPOSER = file_exists ($ COMPOSER = __DIR__ .'/composer.phar ' ) || ($ COMPOSER = rtrim ('\\' === DIRECTORY_SEPARATOR ? preg_replace ('/[\r\n].*/ ' , '' , `where.exe composer.phar `) : `which composer.phar `))
31
- ? $ PHP .' ' .ProcessUtils:: escapeArgument ($ COMPOSER )
28
+ $ COMPOSER = file_exists ($ COMPOSER = $ oldPwd .'/composer.phar ' ) || ($ COMPOSER = rtrim ('\\' === DIRECTORY_SEPARATOR ? preg_replace ('/[\r\n].*/ ' , '' , `where.exe composer.phar `) : `which composer.phar `))
29
+ ? $ PHP .' ' .escapeshellarg ($ COMPOSER )
32
30
: 'composer ' ;
33
31
34
32
if (!file_exists ("$ PHPUNIT_DIR /phpunit- $ PHPUNIT_VERSION /phpunit " ) || md5_file (__FILE__ ) !== @file_get_contents ("$ PHPUNIT_DIR /. $ PHPUNIT_VERSION .md5 " )) {
35
- // Build a standalone phpunit without symfony/yaml
33
+ // Build a standalone phpunit without symfony/yaml nor prophecy
36
34
37
- $ oldPwd = getcwd ();
38
35
@mkdir ($ PHPUNIT_DIR );
39
36
chdir ($ PHPUNIT_DIR );
40
37
if (file_exists ("phpunit- $ PHPUNIT_VERSION " )) {
@@ -65,13 +62,7 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
65
62
<?php
66
63
67
64
define('PHPUNIT_COMPOSER_INSTALL', __DIR__.'/vendor/autoload.php');
68
-
69
- $loader = require PHPUNIT_COMPOSER_INSTALL;
70
-
71
- if (getenv('SYMFONY_PHPUNIT_OVERLOAD') && file_exists(__DIR__.'/../../src/Symfony/Bridge/PhpUnit')) {
72
- $loader->addPsr4('Symfony\\Bridge\\PhpUnit\\', array('src/Symfony/Bridge/PhpUnit'), true);
73
- }
74
- unset($loader);
65
+ require PHPUNIT_COMPOSER_INSTALL;
75
66
Symfony\Bridge\PhpUnit\TextUI\Command::main();
76
67
77
68
EOPHP
@@ -82,14 +73,17 @@ EOPHP
82
73
83
74
}
84
75
85
- $ cmd = array_map ('Symfony\Component\Process\ProcessUtils::escapeArgument ' , $ argv );
76
+ $ cmd = array_map ('escapeshellarg ' , $ argv );
86
77
$ exit = 0 ;
87
78
88
- if (isset ($ argv [1 ]) && 'symfony ' === $ argv [1 ]) {
79
+ if (isset ($ argv [1 ]) && 'symfony ' === $ argv [1 ] && !file_exists ('symfony ' ) && file_exists ('src/Symfony ' )) {
80
+ $ argv [1 ] = 'src/Symfony ' ;
81
+ }
82
+ if (isset ($ argv [1 ]) && is_dir ($ argv [1 ]) && !file_exists ($ argv [1 ].'/phpunit.xml.dist ' )) {
89
83
array_shift ($ cmd );
90
84
}
91
85
92
- $ cmd [0 ] = sprintf ('%s %s --colors=always ' , $ PHP , ProcessUtils:: escapeArgument ("$ PHPUNIT_DIR /phpunit- $ PHPUNIT_VERSION /phpunit " ));
86
+ $ cmd [0 ] = sprintf ('%s %s --colors=always ' , $ PHP , escapeshellarg ("$ PHPUNIT_DIR /phpunit- $ PHPUNIT_VERSION /phpunit " ));
93
87
$ cmd = str_replace ('% ' , '%% ' , implode (' ' , $ cmd )).' %1$s ' ;
94
88
95
89
if ('\\' === DIRECTORY_SEPARATOR ) {
@@ -98,14 +92,12 @@ if ('\\' === DIRECTORY_SEPARATOR) {
98
92
$ cmd .= '%2$s ' ;
99
93
}
100
94
101
- if (isset ($ argv [1 ]) && ' symfony ' === $ argv [1 ]) {
95
+ if (isset ($ argv [1 ]) && is_dir ( $ argv [ 1 ]) && ! file_exists ( $ argv [1 ]. ' /phpunit.xml.dist ' ) ) {
102
96
// Find Symfony components in plain php for Windows portability
103
97
104
- $ oldPwd = getcwd ();
105
- chdir (__DIR__ );
106
- $ finder = new RecursiveDirectoryIterator ('src/Symfony ' , FilesystemIterator::KEY_AS_FILENAME | FilesystemIterator::UNIX_PATHS );
98
+ $ finder = new RecursiveDirectoryIterator ($ argv [1 ], FilesystemIterator::KEY_AS_FILENAME | FilesystemIterator::UNIX_PATHS );
107
99
$ finder = new RecursiveIteratorIterator ($ finder );
108
- $ finder ->setMaxDepth (3 );
100
+ $ finder ->setMaxDepth (getenv ( ' SYMFONY_PHPUNIT_MAX_DEPTH ' ) ?: 3 );
109
101
110
102
$ skippedTests = isset ($ _SERVER ['SYMFONY_PHPUNIT_SKIPPED_TESTS ' ]) ? $ _SERVER ['SYMFONY_PHPUNIT_SKIPPED_TESTS ' ] : false ;
111
103
$ runningProcs = array ();
@@ -120,7 +112,7 @@ if (isset($argv[1]) && 'symfony' === $argv[1]) {
120
112
putenv ("SYMFONY_PHPUNIT_SKIPPED_TESTS= $ component/ $ skippedTests " );
121
113
}
122
114
123
- $ c = ProcessUtils:: escapeArgument ($ component );
115
+ $ c = escapeshellarg ($ component );
124
116
125
117
if ($ proc = proc_open (sprintf ($ cmd , $ c , " > $ c/phpunit.stdout 2> $ c/phpunit.stderr " ), array (), $ pipes )) {
126
118
$ runningProcs [$ component ] = $ proc ;
@@ -130,7 +122,6 @@ if (isset($argv[1]) && 'symfony' === $argv[1]) {
130
122
}
131
123
}
132
124
}
133
- chdir ($ oldPwd );
134
125
135
126
// Fixes for colors support on appveyor
136
127
// See https://github.com/appveyor/ci/issues/373
@@ -185,11 +176,11 @@ if (isset($argv[1]) && 'symfony' === $argv[1]) {
185
176
}
186
177
}
187
178
}
188
- } elseif (!isset ($ argv [1 ]) || 'install ' !== $ argv [1 ]) {
179
+ } elseif (!isset ($ argv [1 ]) || 'install ' !== $ argv [1 ] || file_exists ( ' install ' ) ) {
189
180
// Run regular phpunit in a subprocess
190
181
191
182
$ errFile = tempnam (sys_get_temp_dir (), 'phpunit.stderr. ' );
192
- if ($ proc = proc_open (sprintf ($ cmd , '' , ' 2> ' .ProcessUtils:: escapeArgument ($ errFile )), array (1 => array ('pipe ' , 'w ' )), $ pipes )) {
183
+ if ($ proc = proc_open (sprintf ($ cmd , '' , ' 2> ' .escapeshellarg ($ errFile )), array (1 => array ('pipe ' , 'w ' )), $ pipes )) {
193
184
stream_copy_to_stream ($ pipes [1 ], STDOUT );
194
185
fclose ($ pipes [1 ]);
195
186
$ exit = proc_close ($ proc );
@@ -199,7 +190,7 @@ if (isset($argv[1]) && 'symfony' === $argv[1]) {
199
190
}
200
191
201
192
if (!file_exists ($ component = array_pop ($ argv ))) {
202
- $ component = basename (getcwd () );
193
+ $ component = basename ($ oldcwd );
203
194
}
204
195
205
196
if ($ exit ) {
0 commit comments