diff --git a/run-tests.php b/run-tests.php index d6c84c667d1..5fa65c355b4 100755 --- a/run-tests.php +++ b/run-tests.php @@ -2833,10 +2833,30 @@ SH; return $restype[0] . 'ED'; } +function is_flaky(TestFile $test): bool +{ + if ($test->hasSection('FLAKY')) { + return true; + } + if (!$test->hasSection('FILE')) { + return false; + } + $file = $test->getSection('FILE'); + $flaky_functions = [ + 'disk_free_space', + 'hrtime', + 'microtime', + 'sleep', + 'usleep', + ]; + $regex = '(\b(' . implode('|', $flaky_functions) . ')\()i'; + return preg_match($regex, $file) === 1; +} + function error_may_be_retried(TestFile $test, string $output): bool { return preg_match('((timed out)|(connection refused)|(404: page not found)|(address already in use)|(mailbox already exists))i', $output) === 1 - || $test->hasSection('FLAKY'); + || is_flaky($test); } function expectf_to_regex(?string $wanted): string