From 549f55fc3f1bb6bd8901748d9eb608e22779fb4a Mon Sep 17 00:00:00 2001 From: Tyson Andre Date: Mon, 20 Jan 2020 17:00:56 -0500 Subject: [PATCH] Don't start unnecessary processes with run-tests.php -j If there's only 2 files to test, then only start 2 workers instead of N. If there's only 1 file, then avoid parallelism entirely. A separate option such as `--force-parallel` could be added if this turns out to be something developers would want to do when debugging test failures. --- run-tests.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/run-tests.php b/run-tests.php index ca1fae1f0d..d7dd69731c 100755 --- a/run-tests.php +++ b/run-tests.php @@ -534,7 +534,7 @@ Synopsis: php run-tests.php [options] [files] [directories] Options: - -j Run simultaneous testing processes in parallel for + -j Run up to simultaneous testing processes in parallel for quicker testing on systems with multiple logical processors. Note that this is experimental feature. @@ -1285,7 +1285,8 @@ function run_all_tests($test_files, $env, $redir_tested = null) // Parallel testing global $PHP_FAILED_TESTS, $workers, $workerID, $workerSock; - if ($workers !== null && !$workerID) { + /* Ignore -jN if there is only one file to analyze. */ + if ($workers !== null && count($test_files) > 1 && !$workerID) { run_all_tests_parallel($test_files, $env, $redir_tested); return; } @@ -1397,6 +1398,8 @@ function run_all_tests_parallel($test_files, $env, $redir_tested) { if ($shuffle) { shuffle($test_files); } + /* Don't start more workers than test files */ + $workers = max(1, min($workers, count($test_files))); echo "Spawning workers… "; -- 2.40.0