Merge branch 'PHP-8.1' into PHP-8.2

* PHP-8.1:
  Add retry mechanism in run-tests.php
This commit is contained in:
Ilija Tovilo 2023-05-03 13:50:04 +02:00
commit 81b2d2ee45
No known key found for this signature in database
GPG Key ID: A4F5D403F118200A

View File

@ -1807,6 +1807,10 @@ function run_test(string $php, $file, array $env): string
$skipCache = new SkipCache($enableSkipCache, $cfg['keep']['skip']); $skipCache = new SkipCache($enableSkipCache, $cfg['keep']['skip']);
} }
$retriable = true;
$retried = false;
retry:
$temp_filenames = null; $temp_filenames = null;
$org_file = $file; $org_file = $file;
$orig_php = $php; $orig_php = $php;
@ -1846,9 +1850,12 @@ TEST $file
$tested = $test->getName(); $tested = $test->getName();
if ($num_repeats > 1 && $test->hasSection('FILE_EXTERNAL')) { if ($test->hasSection('FILE_EXTERNAL')) {
$retriable = false;
if ($num_repeats > 1) {
return skip_test($tested, $tested_file, $shortname, 'Test with FILE_EXTERNAL might not be repeatable'); return skip_test($tested, $tested_file, $shortname, 'Test with FILE_EXTERNAL might not be repeatable');
} }
}
if ($test->hasSection('CAPTURE_STDIO')) { if ($test->hasSection('CAPTURE_STDIO')) {
$capture = $test->getSection('CAPTURE_STDIO'); $capture = $test->getSection('CAPTURE_STDIO');
@ -1873,6 +1880,7 @@ TEST $file
} }
$php = $php_cgi . ' -C '; $php = $php_cgi . ' -C ';
$uses_cgi = true; $uses_cgi = true;
$retriable = false;
if ($num_repeats > 1) { if ($num_repeats > 1) {
return skip_test($tested, $tested_file, $shortname, 'CGI does not support --repeat'); return skip_test($tested, $tested_file, $shortname, 'CGI does not support --repeat');
} }
@ -1890,20 +1898,18 @@ TEST $file
} else { } else {
return skip_test($tested, $tested_file, $shortname, 'phpdbg not available'); return skip_test($tested, $tested_file, $shortname, 'phpdbg not available');
} }
$retriable = false;
if ($num_repeats > 1) { if ($num_repeats > 1) {
return skip_test($tested, $tested_file, $shortname, 'phpdbg does not support --repeat'); return skip_test($tested, $tested_file, $shortname, 'phpdbg does not support --repeat');
} }
} }
foreach (['CLEAN', 'STDIN', 'CAPTURE_STDIO'] as $section) {
if ($test->hasSection($section)) {
$retriable = false;
if ($num_repeats > 1) { if ($num_repeats > 1) {
if ($test->hasSection('CLEAN')) { return skip_test($tested, $tested_file, $shortname, "Test with $section might not be repeatable");
return skip_test($tested, $tested_file, $shortname, 'Test with CLEAN might not be repeatable');
} }
if ($test->hasSection('STDIN')) {
return skip_test($tested, $tested_file, $shortname, 'Test with STDIN might not be repeatable');
}
if ($test->hasSection('CAPTURE_STDIO')) {
return skip_test($tested, $tested_file, $shortname, 'Test with CAPTURE_STDIO might not be repeatable');
} }
} }
@ -2085,10 +2091,13 @@ TEST $file
$ini = preg_replace('/{MAIL:(\S+)}/', $replacement, $ini); $ini = preg_replace('/{MAIL:(\S+)}/', $replacement, $ini);
settings2array(preg_split("/[\n\r]+/", $ini), $ini_settings); settings2array(preg_split("/[\n\r]+/", $ini), $ini_settings);
if ($num_repeats > 1 && isset($ini_settings['opcache.opt_debug_level'])) { if (isset($ini_settings['opcache.opt_debug_level'])) {
$retriable = false;
if ($num_repeats > 1) {
return skip_test($tested, $tested_file, $shortname, 'opt_debug_level tests are not repeatable'); return skip_test($tested, $tested_file, $shortname, 'opt_debug_level tests are not repeatable');
} }
} }
}
$ini_settings = settings2params($ini_settings); $ini_settings = settings2params($ini_settings);
@ -2617,6 +2626,10 @@ COMMAND $cmd
$wanted_re = null; $wanted_re = null;
} }
if (!$passed && !$retried && $retriable && error_may_be_retried($output)) {
$retried = true;
goto retry;
}
if ($passed) { if ($passed) {
if (!$cfg['keep']['php'] && !$leaked) { if (!$cfg['keep']['php'] && !$leaked) {
@ -2647,6 +2660,9 @@ COMMAND $cmd
} elseif ($test->hasSection('XLEAK')) { } elseif ($test->hasSection('XLEAK')) {
$warn = true; $warn = true;
$info = " (warn: XLEAK section but test passes)"; $info = " (warn: XLEAK section but test passes)";
} elseif ($retried) {
$warn = true;
$info = " (warn: Test passed on retry attempt)";
} else { } else {
show_result("PASS", $tested, $tested_file, '', $temp_filenames); show_result("PASS", $tested, $tested_file, '', $temp_filenames);
$junit->markTestAs('PASS', $shortname, $tested); $junit->markTestAs('PASS', $shortname, $tested);
@ -2790,6 +2806,11 @@ SH;
return $restype[0] . 'ED'; return $restype[0] . 'ED';
} }
function error_may_be_retried(string $output): bool
{
return preg_match('((timed out)|(connection refused))i', $output) === 1;
}
/** /**
* @return bool|int * @return bool|int
*/ */