Skip to content

Commit 6d59640

Browse files
committed
Automatically mark tests as flaky
Marking all of these tests as flaky is annoying, so attempt to recognize them automatically. Closes GH-12638
1 parent 9b07b01 commit 6d59640

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

run-tests.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2804,10 +2804,30 @@ function run_test(string $php, $file, array $env): string
28042804
return $restype[0] . 'ED';
28052805
}
28062806

2807+
function is_flaky(TestFile $test): bool
2808+
{
2809+
if ($test->hasSection('FLAKY')) {
2810+
return true;
2811+
}
2812+
if (!$test->hasSection('FILE')) {
2813+
return false;
2814+
}
2815+
$file = $test->getSection('FILE');
2816+
$flaky_functions = [
2817+
'disk_free_space',
2818+
'hrtime',
2819+
'microtime',
2820+
'sleep',
2821+
'usleep',
2822+
];
2823+
$regex = '(\b(' . implode('|', $flaky_functions) . ')\()i';
2824+
return preg_match($regex, $file) === 1;
2825+
}
2826+
28072827
function error_may_be_retried(TestFile $test, string $output): bool
28082828
{
28092829
return preg_match('((timed out)|(connection refused)|(404: page not found)|(address already in use)|(mailbox already exists))i', $output) === 1
2810-
|| $test->hasSection('FLAKY');
2830+
|| is_flaky($test);
28112831
}
28122832

28132833
/**

0 commit comments

Comments
 (0)