summaryrefslogtreecommitdiff
path: root/run-tests.php
diff options
context:
space:
mode:
authorTyson Andre <tysonandre775@hotmail.com>2020-01-20 17:00:56 -0500
committerTyson Andre <tysonandre775@hotmail.com>2020-01-21 20:05:06 -0500
commit549f55fc3f1bb6bd8901748d9eb608e22779fb4a (patch)
tree01f3e19f3bec7262e8b0fac108f969d510a6ba95 /run-tests.php
parent85ea04b747a58d32cd75894f8bc96b7878005cd1 (diff)
downloadphp-git-549f55fc3f1bb6bd8901748d9eb608e22779fb4a.tar.gz
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.
Diffstat (limited to 'run-tests.php')
-rwxr-xr-xrun-tests.php7
1 files 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<workers> Run <workers> simultaneous testing processes in parallel for
+ -j<workers> Run up to <workers> 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… ";