@@ -159,24 +159,14 @@ function main()
159
159
160
160
define ('INIT_DIR ' , getcwd ());
161
161
162
- // change into the PHP source directory.
162
+ // Change into the PHP source directory.
163
163
if (getenv ('TEST_PHP_SRCDIR ' )) {
164
164
@chdir (getenv ('TEST_PHP_SRCDIR ' ));
165
165
}
166
- define ('TEST_PHP_SRCDIR ' , getcwd ());
167
166
168
- if (!function_exists ('proc_open ' )) {
169
- echo <<<NO_PROC_OPEN_ERROR
167
+ define ('TEST_PHP_SRCDIR ' , getcwd ());
170
168
171
- +-----------------------------------------------------------+
172
- | ! ERROR ! |
173
- | The test-suite requires that proc_open() is available. |
174
- | Please check if you disabled it in php.ini. |
175
- +-----------------------------------------------------------+
176
-
177
- NO_PROC_OPEN_ERROR ;
178
- exit (1 );
179
- }
169
+ check_proc_open_function_exists ();
180
170
181
171
// If timezone is not set, use UTC.
182
172
if (ini_get ('date.timezone ' ) == '' ) {
@@ -193,35 +183,36 @@ function main()
193
183
194
184
ini_set ('pcre.backtrack_limit ' , PHP_INT_MAX );
195
185
196
- // delete as much output buffers as possible
197
- while (@ob_end_clean ()) {
198
- }
199
- if (ob_get_level ()) {
200
- echo "Not all buffers were deleted. \n" ;
201
- }
186
+ init_output_buffers ();
202
187
203
188
error_reporting (E_ALL );
204
189
205
190
$ environment = $ _ENV ?? array ();
206
- // Note: php.ini-development sets variables_order="GPCS" not "EGPCS", in which case $_ENV is NOT populated.
207
- // detect and handle this case, or die or warn
191
+
192
+ // Some configurations like php.ini-development set variables_order="GPCS"
193
+ // not "EGPCS", in which case $_ENV is NOT populated. Detect if the $_ENV
194
+ // was empty and handle it by explicitly populating through getenv().
208
195
if (empty ($ environment )) {
209
- // not documented, but returns array of all environment variables
210
196
$ environment = getenv ();
211
197
}
198
+
212
199
if (empty ($ environment ['TEMP ' ])) {
213
200
$ environment ['TEMP ' ] = sys_get_temp_dir ();
214
201
215
202
if (empty ($ environment ['TEMP ' ])) {
216
- // for example, OpCache on Windows will fail in this case because child processes (for tests) will not get
217
- // a TEMP variable, so GetTempPath() will fallback to c:\windows, while GetTempPath() will return %TEMP% for parent
218
- // (likely a different path). The parent will initialize the OpCache in that path, and child will fail to reattach to
219
- // the OpCache because it will be using the wrong path.
203
+ // For example, OpCache on Windows will fail in this case because
204
+ // child processes (for tests) will not get a TEMP variable, so
205
+ // GetTempPath() will fallback to c:\windows, while GetTempPath()
206
+ // will return %TEMP% for parent (likely a different path). The
207
+ // parent will initialize the OpCache in that path, and child will
208
+ // fail to reattach to the OpCache because it will be using the
209
+ // wrong path.
220
210
die ("TEMP environment is NOT set " );
221
211
} else {
222
212
if (count ($ environment ) == 1 ) {
223
- // not having other environment variables, only having TEMP, is probably ok, but strange and may make a
224
- // difference in the test pass rate, so warn the user.
213
+ // Not having other environment variables, only having TEMP, is
214
+ // probably ok, but strange and may make a difference in the
215
+ // test pass rate, so warn the user.
225
216
echo "WARNING: Only 1 environment variable will be available to tests(TEMP environment variable) " . PHP_EOL ;
226
217
}
227
218
}
@@ -1417,7 +1408,8 @@ function run_all_tests_parallel($test_files, $env, $redir_tested)
1417
1408
if ($ shuffle ) {
1418
1409
shuffle ($ test_files );
1419
1410
}
1420
- /* Don't start more workers than test files */
1411
+
1412
+ // Don't start more workers than test files.
1421
1413
$ workers = max (1 , min ($ workers , count ($ test_files )));
1422
1414
1423
1415
echo "Spawning workers… " ;
@@ -3700,4 +3692,31 @@ public function wrapCommand($cmd, $memcheck_filename, $check_all)
3700
3692
}
3701
3693
}
3702
3694
3695
+ function init_output_buffers ()
3696
+ {
3697
+ // Delete as much output buffers as possible.
3698
+ while (@ob_end_clean ()) {
3699
+ }
3700
+
3701
+ if (ob_get_level ()) {
3702
+ echo "Not all buffers were deleted. \n" ;
3703
+ }
3704
+ }
3705
+
3706
+ function check_proc_open_function_exists ()
3707
+ {
3708
+ if (!function_exists ('proc_open ' )) {
3709
+ echo <<<NO_PROC_OPEN_ERROR
3710
+
3711
+ +-----------------------------------------------------------+
3712
+ | ! ERROR ! |
3713
+ | The test-suite requires that proc_open() is available. |
3714
+ | Please check if you disabled it in php.ini. |
3715
+ +-----------------------------------------------------------+
3716
+
3717
+ NO_PROC_OPEN_ERROR ;
3718
+ exit (1 );
3719
+ }
3720
+ }
3721
+
3703
3722
main ();
0 commit comments