From 6d5964098084bab1507b0b787b46bfcfd60a73a9 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Thu, 9 Nov 2023 11:53:55 +0100 Subject: [PATCH] Automatically mark tests as flaky Marking all of these tests as flaky is annoying, so attempt to recognize them automatically. Closes GH-12638 --- run-tests.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/run-tests.php b/run-tests.php index 19335cbf697..bb991aaf987 100755 --- a/run-tests.php +++ b/run-tests.php @@ -2804,10 +2804,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); } /**