Skip to content

Commit f432cb5

Browse files
committed
Merge branch 'PHP-7.4'
2 parents 5ce6d2f + 967fa51 commit f432cb5

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

run-tests.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function main()
5353
$repeat, $result_tests_file, $slow_min_ms, $start_time, $switch,
5454
$temp_source, $temp_target, $temp_urlbase, $test_cnt, $test_dirs,
5555
$test_files, $test_idx, $test_list, $test_results, $testfile,
56-
$user_tests, $valgrind, $sum_results;
56+
$user_tests, $valgrind, $sum_results, $shuffle;
5757
// Parallel testing
5858
global $workers, $workerID;
5959

@@ -320,6 +320,7 @@ function main()
320320
$no_clean = false;
321321
$slow_min_ms = INF;
322322
$preload = false;
323+
$shuffle = false;
323324
$workers = null;
324325

325326
$cfgtypes = array('show', 'keep');
@@ -502,6 +503,9 @@ function main()
502503
case '--offline':
503504
$environment['SKIP_ONLINE_TESTS'] = 1;
504505
break;
506+
case '--shuffle':
507+
$shuffle = true;
508+
break;
505509
//case 'w'
506510
case '-':
507511
// repeat check with full switch
@@ -1333,7 +1337,7 @@ function run_all_tests($test_files, $env, $redir_tested = null)
13331337

13341338
/** The heart of parallel testing. */
13351339
function run_all_tests_parallel($test_files, $env, $redir_tested) {
1336-
global $workers, $test_idx, $test_cnt, $test_results, $failed_tests_file, $result_tests_file, $PHP_FAILED_TESTS;
1340+
global $workers, $test_idx, $test_cnt, $test_results, $failed_tests_file, $result_tests_file, $PHP_FAILED_TESTS, $shuffle;
13371341

13381342
// The PHP binary running run-tests.php, and run-tests.php itself
13391343
// This PHP executable is *not* necessarily the same as the tested version
@@ -1378,6 +1382,11 @@ function run_all_tests_parallel($test_files, $env, $redir_tested) {
13781382
// for tests with a common conflict key.
13791383
$test_files = array_reverse($test_files);
13801384

1385+
// To discover parallelization issues it is useful to randomize the test order.
1386+
if ($shuffle) {
1387+
shuffle($test_files);
1388+
}
1389+
13811390
echo "Spawning workers… ";
13821391

13831392
// We use sockets rather than STDIN/STDOUT for comms because on Windows,
@@ -1518,7 +1527,7 @@ function run_all_tests_parallel($test_files, $env, $redir_tested) {
15181527
case "ready":
15191528
// Batch multiple tests to reduce communication overhead.
15201529
$files = [];
1521-
$batchSize = 32;
1530+
$batchSize = $shuffle ? 4 : 32;
15221531
while (count($files) <= $batchSize && $file = array_pop($test_files)) {
15231532
foreach ($fileConflictsWith[$file] as $conflictKey) {
15241533
if (isset($activeConflicts[$conflictKey])) {
@@ -1964,7 +1973,7 @@ function run_test($php, $file, $env)
19641973
$temp_clean = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'clean.php';
19651974
$test_clean = $test_dir . DIRECTORY_SEPARATOR . $main_file_name . 'clean.php';
19661975
$preload_filename = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'preload.php';
1967-
$tmp_post = $temp_dir . DIRECTORY_SEPARATOR . uniqid('/phpt.');
1976+
$tmp_post = $temp_dir . DIRECTORY_SEPARATOR . $main_file_name . 'post';
19681977
$tmp_relative_file = str_replace(__DIR__ . DIRECTORY_SEPARATOR, '', $test_file) . 't';
19691978

19701979
if ($temp_source && $temp_target) {

0 commit comments

Comments
 (0)