Skip to content

Commit 152e539

Browse files
committed
Add special "all" conflict
If a test conflicts with "all", then no other tests may be run in parallel. This is needed for windows_mb_path tests, which rely on the console codepage, which is shared across all parallel workers. Also add support for comments in the CONFLICTS section/file.
1 parent 6b110b1 commit 152e539

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
windows_mb_path
1+
# These tests depend on the console codepage, which is shared across all parallel workers.
2+
# Force these tests to run sequentially to make sure the codepage isn't change by another process.
3+
all

run-tests.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,24 +1356,32 @@ function run_all_tests_parallel($test_files, $env, $redir_tested) {
13561356
// specified either in the --CONFLICTS-- section, or CONFLICTS file inside a directory.
13571357
$dirConflictsWith = [];
13581358
$fileConflictsWith = [];
1359-
foreach ($test_files as $file) {
1359+
$sequentialTests = [];
1360+
foreach ($test_files as $i => $file) {
13601361
$contents = file_get_contents($file);
13611362
if (preg_match('/^--CONFLICTS--(.+?)^--/ms', $contents, $matches)) {
1362-
$conflicts = array_map('trim', explode("\n", trim($matches[1])));
1363+
$conflicts = parse_conflicts($matches[1]);
13631364
} else {
13641365
// Cache per-directory conflicts in a separate map, so we compute these only once.
13651366
$dir = dirname($file);
13661367
if (!isset($dirConflictsWith[$dir])) {
13671368
$dirConflicts = [];
13681369
if (file_exists($dir . '/CONFLICTS')) {
13691370
$contents = file_get_contents($dir . '/CONFLICTS');
1370-
$dirConflicts = array_map('trim', explode("\n", trim($contents)));
1371+
$dirConflicts = parse_conflicts($contents);
13711372
}
13721373
$dirConflictsWith[$dir] = $dirConflicts;
13731374
}
13741375
$conflicts = $dirConflictsWith[$dir];
13751376
}
13761377

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+
13771385
$fileConflictsWith[$file] = $conflicts;
13781386
}
13791387

@@ -1480,7 +1488,7 @@ function run_all_tests_parallel($test_files, $env, $redir_tested) {
14801488
$waitingTests = [];
14811489

14821490
escape:
1483-
while ($test_files || $testsInProgress > 0) {
1491+
while ($test_files || $sequentialTests || $testsInProgress > 0) {
14841492
$toRead = array_values($workerSocks);
14851493
$toWrite = NULL;
14861494
$toExcept = NULL;
@@ -1525,6 +1533,11 @@ function run_all_tests_parallel($test_files, $env, $redir_tested) {
15251533
}
15261534
// intentional fall-through
15271535
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+
}
15281541
// Batch multiple tests to reduce communication overhead.
15291542
$files = [];
15301543
$batchSize = $shuffle ? 4 : 32;
@@ -3190,6 +3203,12 @@ function clear_show_test() {
31903203
}
31913204
}
31923205

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+
31933212
function show_result($result, $tested, $tested_file, $extra = '', $temp_filenames = null)
31943213
{
31953214
global $html_output, $html_file, $temp_target, $temp_urlbase, $line_length, $SHOW_ONLY_GROUPS;

0 commit comments

Comments
 (0)