Merge branch 'PHP-8.2' into PHP-8.3

* PHP-8.2:
  Automatically mark tests as flaky
This commit is contained in:
Ilija Tovilo 2023-11-15 13:22:35 +01:00
commit 082219ba0e
No known key found for this signature in database
GPG key ID: A4F5D403F118200A

View file

@ -2833,10 +2833,30 @@ SH;
return $restype[0] . 'ED'; 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 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 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 function expectf_to_regex(?string $wanted): string