Skip to content

Commit 9bdd0f0

Browse files
iluuu1994ramsey
authored andcommitted
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 28c312c commit 9bdd0f0

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
@@ -2873,10 +2873,30 @@ function run_test(string $php, $file, array $env): string
28732873
return $restype[0] . 'ED';
28742874
}
28752875

2876+
function is_flaky(TestFile $test): bool
2877+
{
2878+
if ($test->hasSection('FLAKY')) {
2879+
return true;
2880+
}
2881+
if (!$test->hasSection('FILE')) {
2882+
return false;
2883+
}
2884+
$file = $test->getSection('FILE');
2885+
$flaky_functions = [
2886+
'disk_free_space',
2887+
'hrtime',
2888+
'microtime',
2889+
'sleep',
2890+
'usleep',
2891+
];
2892+
$regex = '(\b(' . implode('|', $flaky_functions) . ')\()i';
2893+
return preg_match($regex, $file) === 1;
2894+
}
2895+
28762896
function error_may_be_retried(TestFile $test, string $output): bool
28772897
{
28782898
return preg_match('((timed out)|(connection refused)|(404: page not found)|(address already in use)|(mailbox already exists))i', $output) === 1
2879-
|| $test->hasSection('FLAKY');
2899+
|| is_flaky($test);
28802900
}
28812901

28822902
/**

0 commit comments

Comments
 (0)