@@ -1807,6 +1807,10 @@ function run_test(string $php, $file, array $env): string
1807
1807
$ skipCache = new SkipCache ($ enableSkipCache , $ cfg ['keep ' ]['skip ' ]);
1808
1808
}
1809
1809
1810
+ $ retriable = true ;
1811
+ $ retried = false ;
1812
+ retry:
1813
+
1810
1814
$ temp_filenames = null ;
1811
1815
$ org_file = $ file ;
1812
1816
$ orig_php = $ php ;
@@ -1846,8 +1850,11 @@ function run_test(string $php, $file, array $env): string
1846
1850
1847
1851
$ tested = $ test ->getName ();
1848
1852
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
+ }
1851
1858
}
1852
1859
1853
1860
if ($ test ->hasSection ('CAPTURE_STDIO ' )) {
@@ -1873,6 +1880,7 @@ function run_test(string $php, $file, array $env): string
1873
1880
}
1874
1881
$ php = $ php_cgi . ' -C ' ;
1875
1882
$ uses_cgi = true ;
1883
+ $ retriable = false ;
1876
1884
if ($ num_repeats > 1 ) {
1877
1885
return skip_test ($ tested , $ tested_file , $ shortname , 'CGI does not support --repeat ' );
1878
1886
}
@@ -1890,20 +1898,18 @@ function run_test(string $php, $file, array $env): string
1890
1898
} else {
1891
1899
return skip_test ($ tested , $ tested_file , $ shortname , 'phpdbg not available ' );
1892
1900
}
1901
+ $ retriable = false ;
1893
1902
if ($ num_repeats > 1 ) {
1894
1903
return skip_test ($ tested , $ tested_file , $ shortname , 'phpdbg does not support --repeat ' );
1895
1904
}
1896
1905
}
1897
1906
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
+ }
1907
1913
}
1908
1914
}
1909
1915
@@ -2085,8 +2091,11 @@ function run_test(string $php, $file, array $env): string
2085
2091
$ ini = preg_replace ('/{MAIL:(\S+)}/ ' , $ replacement , $ ini );
2086
2092
settings2array (preg_split ("/[ \n\r]+/ " , $ ini ), $ ini_settings );
2087
2093
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
+ }
2090
2099
}
2091
2100
}
2092
2101
@@ -2617,6 +2626,10 @@ function run_test(string $php, $file, array $env): string
2617
2626
2618
2627
$ wanted_re = null ;
2619
2628
}
2629
+ if (!$ passed && !$ retried && $ retriable && error_may_be_retried ($ output )) {
2630
+ $ retried = true ;
2631
+ goto retry;
2632
+ }
2620
2633
2621
2634
if ($ passed ) {
2622
2635
if (!$ cfg ['keep ' ]['php ' ] && !$ leaked ) {
@@ -2647,6 +2660,9 @@ function run_test(string $php, $file, array $env): string
2647
2660
} elseif ($ test ->hasSection ('XLEAK ' )) {
2648
2661
$ warn = true ;
2649
2662
$ info = " (warn: XLEAK section but test passes) " ;
2663
+ } elseif ($ retried ) {
2664
+ $ warn = true ;
2665
+ $ info = " (warn: Test passed on retry attempt) " ;
2650
2666
} else {
2651
2667
show_result ("PASS " , $ tested , $ tested_file , '' , $ temp_filenames );
2652
2668
$ junit ->markTestAs ('PASS ' , $ shortname , $ tested );
@@ -2790,6 +2806,11 @@ function run_test(string $php, $file, array $env): string
2790
2806
return $ restype [0 ] . 'ED ' ;
2791
2807
}
2792
2808
2809
+ function error_may_be_retried (string $ output ): bool
2810
+ {
2811
+ return preg_match ('((timed out)|(connection refused))i ' , $ output ) === 1 ;
2812
+ }
2813
+
2793
2814
/**
2794
2815
* @return bool|int
2795
2816
*/
0 commit comments