1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Automatically mark tests as flaky

Marking all of these tests as flaky is annoying, so attempt to recognize them
automatically.

Closes GH-12638
This commit is contained in:
Ilija Tovilo
2023-11-09 11:53:55 +01:00
committed by Ben Ramsey
parent 28c312c994
commit 9bdd0f0de9

View File

@@ -2873,10 +2873,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);
}
/**