mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Shuffle tests for a single worker
Even when tests are not run in parallel, shuffling can help discover tests that unintentionally depend on other tests being run before them. Closes GH-17149.
This commit is contained in:
parent
23ccd06ede
commit
71dfa931eb
2 changed files with 11 additions and 6 deletions
3
NEWS
3
NEWS
|
@ -93,6 +93,9 @@ PHP NEWS
|
||||||
. Fixed bug GH-16889 (stream_select() timeout useless for pipes on Windows).
|
. Fixed bug GH-16889 (stream_select() timeout useless for pipes on Windows).
|
||||||
(cmb)
|
(cmb)
|
||||||
|
|
||||||
|
- Tests:
|
||||||
|
. Allow to shuffle tests even in non-parallell mode. (dhuang00)
|
||||||
|
|
||||||
- Windows:
|
- Windows:
|
||||||
. Fixed bug GH-10992 (Improper long path support for relative paths). (cmb,
|
. Fixed bug GH-10992 (Improper long path support for relative paths). (cmb,
|
||||||
nielsdos)
|
nielsdos)
|
||||||
|
|
|
@ -1231,7 +1231,7 @@ function system_with_timeout(
|
||||||
|
|
||||||
function run_all_tests(array $test_files, array $env, ?string $redir_tested = null): void
|
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;
|
global $preload;
|
||||||
// Parallel testing
|
// Parallel testing
|
||||||
global $PHP_FAILED_TESTS, $workers, $workerID, $workerSock;
|
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. */
|
/* Ignore -jN if there is only one file to analyze. */
|
||||||
if ($workers !== null && count($test_files) > 1 && !$workerID) {
|
if ($workers !== null && count($test_files) > 1 && !$workerID) {
|
||||||
run_all_tests_parallel($test_files, $env, $redir_tested);
|
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
|
// 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
|
// $test_files, so reverse its order here. This makes sure that order is preserved at least
|
||||||
// for tests with a common conflict key.
|
// for tests with a common conflict key.
|
||||||
$test_files = array_reverse($test_files);
|
if (!$shuffle) {
|
||||||
|
$test_files = array_reverse($test_files);
|
||||||
// To discover parallelization issues it is useful to randomize the test order.
|
|
||||||
if ($shuffle) {
|
|
||||||
shuffle($test_files);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't start more workers than test files.
|
// Don't start more workers than test files.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue