Skip to content

Commit 81b2d2e

Browse files
committed
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: Add retry mechanism in run-tests.php
2 parents e1fc246 + 11597d1 commit 81b2d2e

File tree

1 file changed

+34
-13
lines changed

1 file changed

+34
-13
lines changed

run-tests.php

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,6 +1807,10 @@ function run_test(string $php, $file, array $env): string
18071807
$skipCache = new SkipCache($enableSkipCache, $cfg['keep']['skip']);
18081808
}
18091809

1810+
$retriable = true;
1811+
$retried = false;
1812+
retry:
1813+
18101814
$temp_filenames = null;
18111815
$org_file = $file;
18121816
$orig_php = $php;
@@ -1846,8 +1850,11 @@ function run_test(string $php, $file, array $env): string
18461850

18471851
$tested = $test->getName();
18481852

1849-
if ($num_repeats > 1 && $test->hasSection('FILE_EXTERNAL')) {
1850-
return skip_test($tested, $tested_file, $shortname, 'Test with FILE_EXTERNAL might not be repeatable');
1853+
if ($test->hasSection('FILE_EXTERNAL')) {
1854+
$retriable = false;
1855+
if ($num_repeats > 1) {
1856+
return skip_test($tested, $tested_file, $shortname, 'Test with FILE_EXTERNAL might not be repeatable');
1857+
}
18511858
}
18521859

18531860
if ($test->hasSection('CAPTURE_STDIO')) {
@@ -1873,6 +1880,7 @@ function run_test(string $php, $file, array $env): string
18731880
}
18741881
$php = $php_cgi . ' -C ';
18751882
$uses_cgi = true;
1883+
$retriable = false;
18761884
if ($num_repeats > 1) {
18771885
return skip_test($tested, $tested_file, $shortname, 'CGI does not support --repeat');
18781886
}
@@ -1890,20 +1898,18 @@ function run_test(string $php, $file, array $env): string
18901898
} else {
18911899
return skip_test($tested, $tested_file, $shortname, 'phpdbg not available');
18921900
}
1901+
$retriable = false;
18931902
if ($num_repeats > 1) {
18941903
return skip_test($tested, $tested_file, $shortname, 'phpdbg does not support --repeat');
18951904
}
18961905
}
18971906

1898-
if ($num_repeats > 1) {
1899-
if ($test->hasSection('CLEAN')) {
1900-
return skip_test($tested, $tested_file, $shortname, 'Test with CLEAN might not be repeatable');
1901-
}
1902-
if ($test->hasSection('STDIN')) {
1903-
return skip_test($tested, $tested_file, $shortname, 'Test with STDIN might not be repeatable');
1904-
}
1905-
if ($test->hasSection('CAPTURE_STDIO')) {
1906-
return skip_test($tested, $tested_file, $shortname, 'Test with CAPTURE_STDIO might not be repeatable');
1907+
foreach (['CLEAN', 'STDIN', 'CAPTURE_STDIO'] as $section) {
1908+
if ($test->hasSection($section)) {
1909+
$retriable = false;
1910+
if ($num_repeats > 1) {
1911+
return skip_test($tested, $tested_file, $shortname, "Test with $section might not be repeatable");
1912+
}
19071913
}
19081914
}
19091915

@@ -2085,8 +2091,11 @@ function run_test(string $php, $file, array $env): string
20852091
$ini = preg_replace('/{MAIL:(\S+)}/', $replacement, $ini);
20862092
settings2array(preg_split("/[\n\r]+/", $ini), $ini_settings);
20872093

2088-
if ($num_repeats > 1 && isset($ini_settings['opcache.opt_debug_level'])) {
2089-
return skip_test($tested, $tested_file, $shortname, 'opt_debug_level tests are not repeatable');
2094+
if (isset($ini_settings['opcache.opt_debug_level'])) {
2095+
$retriable = false;
2096+
if ($num_repeats > 1) {
2097+
return skip_test($tested, $tested_file, $shortname, 'opt_debug_level tests are not repeatable');
2098+
}
20902099
}
20912100
}
20922101

@@ -2617,6 +2626,10 @@ function run_test(string $php, $file, array $env): string
26172626

26182627
$wanted_re = null;
26192628
}
2629+
if (!$passed && !$retried && $retriable && error_may_be_retried($output)) {
2630+
$retried = true;
2631+
goto retry;
2632+
}
26202633

26212634
if ($passed) {
26222635
if (!$cfg['keep']['php'] && !$leaked) {
@@ -2647,6 +2660,9 @@ function run_test(string $php, $file, array $env): string
26472660
} elseif ($test->hasSection('XLEAK')) {
26482661
$warn = true;
26492662
$info = " (warn: XLEAK section but test passes)";
2663+
} elseif ($retried) {
2664+
$warn = true;
2665+
$info = " (warn: Test passed on retry attempt)";
26502666
} else {
26512667
show_result("PASS", $tested, $tested_file, '', $temp_filenames);
26522668
$junit->markTestAs('PASS', $shortname, $tested);
@@ -2790,6 +2806,11 @@ function run_test(string $php, $file, array $env): string
27902806
return $restype[0] . 'ED';
27912807
}
27922808

2809+
function error_may_be_retried(string $output): bool
2810+
{
2811+
return preg_match('((timed out)|(connection refused))i', $output) === 1;
2812+
}
2813+
27932814
/**
27942815
* @return bool|int
27952816
*/

0 commit comments

Comments
 (0)