diff --git a/NEWS b/NEWS index f260c806545..4cd6786e138 100644 --- a/NEWS +++ b/NEWS @@ -93,6 +93,9 @@ PHP NEWS . Fixed bug GH-16889 (stream_select() timeout useless for pipes on Windows). (cmb) +- Tests: + . Allow to shuffle tests even in non-parallell mode. (dhuang00) + - Windows: . Fixed bug GH-10992 (Improper long path support for relative paths). (cmb, nielsdos) diff --git a/run-tests.php b/run-tests.php index 9dffecca8d2..0ff11c2c95d 100755 --- a/run-tests.php +++ b/run-tests.php @@ -1231,7 +1231,7 @@ function system_with_timeout( function run_all_tests(array $test_files, array $env, ?string $redir_tested = null): void { - global $test_results, $failed_tests_file, $result_tests_file, $php, $test_idx, $file_cache; + global $test_results, $failed_tests_file, $result_tests_file, $php, $test_idx, $file_cache, $shuffle; global $preload; // Parallel testing global $PHP_FAILED_TESTS, $workers, $workerID, $workerSock; @@ -1253,6 +1253,11 @@ function run_all_tests(array $test_files, array $env, ?string $redir_tested = nu }); } + // To discover parallelization issues and order dependent tests it is useful to randomize the test order. + if ($shuffle) { + shuffle($test_files); + } + /* 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); @@ -1358,11 +1363,8 @@ function run_all_tests_parallel(array $test_files, array $env, ?string $redir_te // Some tests assume that they are executed in a certain order. We will be popping from // $test_files, so reverse its order here. This makes sure that order is preserved at least // for tests with a common conflict key. - $test_files = array_reverse($test_files); - - // To discover parallelization issues it is useful to randomize the test order. - if ($shuffle) { - shuffle($test_files); + if (!$shuffle) { + $test_files = array_reverse($test_files); } // Don't start more workers than test files.