Skip to content

Shuffle tests for a single worker #17149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions run-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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.
Expand Down
Loading