@@ -1231,7 +1231,7 @@ function system_with_timeout(
12311231
12321232function  run_all_tests (array  $ test_filesarray  $ envstring  $ redir_testednull ): void 
12331233{
1234-     global  $ test_results$ failed_tests_file$ result_tests_file$ php$ test_idx$ file_cache
1234+     global  $ test_results$ failed_tests_file$ result_tests_file$ php$ test_idx$ file_cache,  $ shuffle 
12351235    global  $ preload
12361236    // Parallel testing 
12371237    global  $ PHP_FAILED_TESTS $ workers$ workerID$ workerSock
@@ -1253,6 +1253,11 @@ function run_all_tests(array $test_files, array $env, ?string $redir_tested = nu
12531253        });
12541254    }
12551255
1256+     // To discover parallelization issues and order dependent tests it is useful to randomize the test order. 
1257+     if  ($ shuffle
1258+         shuffle ($ test_files
1259+     }
1260+ 
12561261    /* Ignore -jN if there is only one file to analyze. */ 
12571262    if  ($ workersnull  && count ($ test_files1  && !$ workerID
12581263        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
13581363    // Some tests assume that they are executed in a certain order. We will be popping from 
13591364    // $test_files, so reverse its order here. This makes sure that order is preserved at least 
13601365    // for tests with a common conflict key. 
1361-     $ test_filesarray_reverse ($ test_files
1362- 
1363-     // To discover parallelization issues it is useful to randomize the test order. 
1364-     if  ($ shuffle
1365-         shuffle ($ test_files
1366+     if  (!$ shuffle
1367+         $ test_filesarray_reverse ($ test_files
13661368    }
13671369
13681370    // Don't start more workers than test files. 
0 commit comments