Skip to content

Commit

Permalink
Automatically mark tests as flaky
Browse files Browse the repository at this point in the history
Marking all of these tests as flaky is annoying, so attempt to recognize them
automatically.

Closes GH-12638
  • Loading branch information
iluuu1994 authored and ramsey committed Nov 23, 2023
1 parent 28c312c commit 9bdd0f0
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion run-tests.php
Expand Up @@ -2873,10 +2873,30 @@ 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 = [
'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);
}

/**
Expand Down

0 comments on commit 9bdd0f0

Please sign in to comment.