diff --git a/run-tests.php b/run-tests.php index 404fd3e457a6a..f198a215ea3ae 100755 --- a/run-tests.php +++ b/run-tests.php @@ -2873,10 +2873,32 @@ function run_test(string $php, $file, array $env): string 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 = [ + 'clearstatcache', + 'hrtime', + 'lstat', + 'microtime', + 'sleep', + 'stat', + '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); } /**