@@ -53,7 +53,7 @@ function main()
53
53
$ repeat , $ result_tests_file , $ slow_min_ms , $ start_time , $ switch ,
54
54
$ temp_source , $ temp_target , $ temp_urlbase , $ test_cnt , $ test_dirs ,
55
55
$ test_files , $ test_idx , $ test_list , $ test_results , $ testfile ,
56
- $ user_tests , $ valgrind , $ sum_results ;
56
+ $ user_tests , $ valgrind , $ sum_results, $ shuffle ;
57
57
// Parallel testing
58
58
global $ workers , $ workerID ;
59
59
@@ -320,6 +320,7 @@ function main()
320
320
$ no_clean = false ;
321
321
$ slow_min_ms = INF ;
322
322
$ preload = false ;
323
+ $ shuffle = false ;
323
324
$ workers = null ;
324
325
325
326
$ cfgtypes = array ('show ' , 'keep ' );
@@ -502,6 +503,9 @@ function main()
502
503
case '--offline ' :
503
504
$ environment ['SKIP_ONLINE_TESTS ' ] = 1 ;
504
505
break ;
506
+ case '--shuffle ' :
507
+ $ shuffle = true ;
508
+ break ;
505
509
//case 'w'
506
510
case '- ' :
507
511
// repeat check with full switch
@@ -1333,7 +1337,7 @@ function run_all_tests($test_files, $env, $redir_tested = null)
1333
1337
1334
1338
/** The heart of parallel testing. */
1335
1339
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 ;
1337
1341
1338
1342
// The PHP binary running run-tests.php, and run-tests.php itself
1339
1343
// 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) {
1378
1382
// for tests with a common conflict key.
1379
1383
$ test_files = array_reverse ($ test_files );
1380
1384
1385
+ // To discover parallelization issues it is useful to randomize the test order.
1386
+ if ($ shuffle ) {
1387
+ shuffle ($ test_files );
1388
+ }
1389
+
1381
1390
echo "Spawning workers… " ;
1382
1391
1383
1392
// 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) {
1518
1527
case "ready " :
1519
1528
// Batch multiple tests to reduce communication overhead.
1520
1529
$ files = [];
1521
- $ batchSize = 32 ;
1530
+ $ batchSize = $ shuffle ? 4 : 32 ;
1522
1531
while (count ($ files ) <= $ batchSize && $ file = array_pop ($ test_files )) {
1523
1532
foreach ($ fileConflictsWith [$ file ] as $ conflictKey ) {
1524
1533
if (isset ($ activeConflicts [$ conflictKey ])) {
@@ -1964,7 +1973,7 @@ function run_test($php, $file, $env)
1964
1973
$ temp_clean = $ temp_dir . DIRECTORY_SEPARATOR . $ main_file_name . 'clean.php ' ;
1965
1974
$ test_clean = $ test_dir . DIRECTORY_SEPARATOR . $ main_file_name . 'clean.php ' ;
1966
1975
$ 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 ' ;
1968
1977
$ tmp_relative_file = str_replace (__DIR__ . DIRECTORY_SEPARATOR , '' , $ test_file ) . 't ' ;
1969
1978
1970
1979
if ($ temp_source && $ temp_target ) {
0 commit comments