@@ -1356,24 +1356,32 @@ function run_all_tests_parallel($test_files, $env, $redir_tested) {
1356
1356
// specified either in the --CONFLICTS-- section, or CONFLICTS file inside a directory.
1357
1357
$ dirConflictsWith = [];
1358
1358
$ fileConflictsWith = [];
1359
- foreach ($ test_files as $ file ) {
1359
+ $ sequentialTests = [];
1360
+ foreach ($ test_files as $ i => $ file ) {
1360
1361
$ contents = file_get_contents ($ file );
1361
1362
if (preg_match ('/^--CONFLICTS--(.+?)^--/ms ' , $ contents , $ matches )) {
1362
- $ conflicts = array_map ( ' trim ' , explode ( "\n" , trim ( $ matches [1 ])) );
1363
+ $ conflicts = parse_conflicts ( $ matches [1 ]);
1363
1364
} else {
1364
1365
// Cache per-directory conflicts in a separate map, so we compute these only once.
1365
1366
$ dir = dirname ($ file );
1366
1367
if (!isset ($ dirConflictsWith [$ dir ])) {
1367
1368
$ dirConflicts = [];
1368
1369
if (file_exists ($ dir . '/CONFLICTS ' )) {
1369
1370
$ contents = file_get_contents ($ dir . '/CONFLICTS ' );
1370
- $ dirConflicts = array_map ( ' trim ' , explode ( "\n" , trim ( $ contents)) );
1371
+ $ dirConflicts = parse_conflicts ( $ contents );
1371
1372
}
1372
1373
$ dirConflictsWith [$ dir ] = $ dirConflicts ;
1373
1374
}
1374
1375
$ conflicts = $ dirConflictsWith [$ dir ];
1375
1376
}
1376
1377
1378
+ // For tests conflicting with "all", no other tests may run in parallel. We'll run these
1379
+ // tests separately at the end, when only one worker is left.
1380
+ if (in_array ('all ' , $ conflicts , true )) {
1381
+ $ sequentialTests [] = $ file ;
1382
+ unset($ test_files [$ i ]);
1383
+ }
1384
+
1377
1385
$ fileConflictsWith [$ file ] = $ conflicts ;
1378
1386
}
1379
1387
@@ -1480,7 +1488,7 @@ function run_all_tests_parallel($test_files, $env, $redir_tested) {
1480
1488
$ waitingTests = [];
1481
1489
1482
1490
escape:
1483
- while ($ test_files || $ testsInProgress > 0 ) {
1491
+ while ($ test_files || $ sequentialTests || $ testsInProgress > 0 ) {
1484
1492
$ toRead = array_values ($ workerSocks );
1485
1493
$ toWrite = NULL ;
1486
1494
$ toExcept = NULL ;
@@ -1525,6 +1533,11 @@ function run_all_tests_parallel($test_files, $env, $redir_tested) {
1525
1533
}
1526
1534
// intentional fall-through
1527
1535
case "ready " :
1536
+ // Schedule sequential tests only once we are down to one worker.
1537
+ if (count ($ workerProcs ) === 1 && $ sequentialTests ) {
1538
+ $ test_files = array_merge ($ test_files , $ sequentialTests );
1539
+ $ sequentialTests = [];
1540
+ }
1528
1541
// Batch multiple tests to reduce communication overhead.
1529
1542
$ files = [];
1530
1543
$ batchSize = $ shuffle ? 4 : 32 ;
@@ -3190,6 +3203,12 @@ function clear_show_test() {
3190
3203
}
3191
3204
}
3192
3205
3206
+ function parse_conflicts (string $ text ) : array {
3207
+ // Strip comments
3208
+ $ text = preg_replace ('/#.*/ ' , '' , $ text );
3209
+ return array_map ('trim ' , explode ("\n" , trim ($ text )));
3210
+ }
3211
+
3193
3212
function show_result ($ result , $ tested , $ tested_file , $ extra = '' , $ temp_filenames = null )
3194
3213
{
3195
3214
global $ html_output , $ html_file , $ temp_target , $ temp_urlbase , $ line_length , $ SHOW_ONLY_GROUPS ;
0 commit comments