@@ -1886,6 +1886,10 @@ function run_test(string $php, $file, array $env): string
1886
1886
$ skipCache = new SkipCache ($ enableSkipCache , $ cfg ['keep ' ]['skip ' ]);
1887
1887
}
1888
1888
1889
+ $ retriable = true ;
1890
+ $ retried = false ;
1891
+ retry:
1892
+
1889
1893
$ temp_filenames = null ;
1890
1894
$ org_file = $ file ;
1891
1895
$ orig_php = $ php ;
@@ -1930,8 +1934,11 @@ function run_test(string $php, $file, array $env): string
1930
1934
1931
1935
$ tested = $ test ->getName ();
1932
1936
1933
- if ($ num_repeats > 1 && $ test ->hasSection ('FILE_EXTERNAL ' )) {
1934
- return skip_test ($ tested , $ tested_file , $ shortname , 'Test with FILE_EXTERNAL might not be repeatable ' );
1937
+ if ($ test ->hasSection ('FILE_EXTERNAL ' )) {
1938
+ $ retriable = false ;
1939
+ if ($ num_repeats > 1 ) {
1940
+ return skip_test ($ tested , $ tested_file , $ shortname , 'Test with FILE_EXTERNAL might not be repeatable ' );
1941
+ }
1935
1942
}
1936
1943
1937
1944
if ($ test ->hasSection ('CAPTURE_STDIO ' )) {
@@ -1957,6 +1964,7 @@ function run_test(string $php, $file, array $env): string
1957
1964
}
1958
1965
$ php = $ php_cgi . ' -C ' ;
1959
1966
$ uses_cgi = true ;
1967
+ $ retriable = false ;
1960
1968
if ($ num_repeats > 1 ) {
1961
1969
return skip_test ($ tested , $ tested_file , $ shortname , 'CGI does not support --repeat ' );
1962
1970
}
@@ -1974,20 +1982,18 @@ function run_test(string $php, $file, array $env): string
1974
1982
} else {
1975
1983
return skip_test ($ tested , $ tested_file , $ shortname , 'phpdbg not available ' );
1976
1984
}
1985
+ $ retriable = false ;
1977
1986
if ($ num_repeats > 1 ) {
1978
1987
return skip_test ($ tested , $ tested_file , $ shortname , 'phpdbg does not support --repeat ' );
1979
1988
}
1980
1989
}
1981
1990
1982
- if ($ num_repeats > 1 ) {
1983
- if ($ test ->hasSection ('CLEAN ' )) {
1984
- return skip_test ($ tested , $ tested_file , $ shortname , 'Test with CLEAN might not be repeatable ' );
1985
- }
1986
- if ($ test ->hasSection ('STDIN ' )) {
1987
- return skip_test ($ tested , $ tested_file , $ shortname , 'Test with STDIN might not be repeatable ' );
1988
- }
1989
- if ($ test ->hasSection ('CAPTURE_STDIO ' )) {
1990
- return skip_test ($ tested , $ tested_file , $ shortname , 'Test with CAPTURE_STDIO might not be repeatable ' );
1991
+ foreach (['CLEAN ' , 'STDIN ' , 'CAPTURE_STDIO ' ] as $ section ) {
1992
+ if ($ test ->hasSection ($ section )) {
1993
+ $ retriable = false ;
1994
+ if ($ num_repeats > 1 ) {
1995
+ return skip_test ($ tested , $ tested_file , $ shortname , "Test with $ section might not be repeatable " );
1996
+ }
1991
1997
}
1992
1998
}
1993
1999
@@ -2166,8 +2172,11 @@ function run_test(string $php, $file, array $env): string
2166
2172
$ ini = preg_replace ('/{MAIL:(\S+)}/ ' , $ replacement , $ ini );
2167
2173
settings2array (preg_split ("/[ \n\r]+/ " , $ ini ), $ ini_settings );
2168
2174
2169
- if ($ num_repeats > 1 && isset ($ ini_settings ['opcache.opt_debug_level ' ])) {
2170
- return skip_test ($ tested , $ tested_file , $ shortname , 'opt_debug_level tests are not repeatable ' );
2175
+ if (isset ($ ini_settings ['opcache.opt_debug_level ' ])) {
2176
+ $ retriable = false ;
2177
+ if ($ num_repeats > 1 ) {
2178
+ return skip_test ($ tested , $ tested_file , $ shortname , 'opt_debug_level tests are not repeatable ' );
2179
+ }
2171
2180
}
2172
2181
}
2173
2182
@@ -2693,6 +2702,9 @@ function run_test(string $php, $file, array $env): string
2693
2702
} elseif ($ test ->hasSection ('XLEAK ' )) {
2694
2703
$ warn = true ;
2695
2704
$ info = " (warn: XLEAK section but test passes) " ;
2705
+ } elseif ($ retried ) {
2706
+ $ warn = true ;
2707
+ $ info = " (warn: Test passed on retry attempt) " ;
2696
2708
} else {
2697
2709
show_result ("PASS " , $ tested , $ tested_file , '' , $ temp_filenames );
2698
2710
$ junit ->markTestAs ('PASS ' , $ shortname , $ tested );
@@ -2722,6 +2734,9 @@ function run_test(string $php, $file, array $env): string
2722
2734
} elseif ($ test ->hasSection ('XLEAK ' )) {
2723
2735
$ warn = true ;
2724
2736
$ info = " (warn: XLEAK section but test passes) " ;
2737
+ } elseif ($ retried ) {
2738
+ $ warn = true ;
2739
+ $ info = " (warn: Test passed on retry attempt) " ;
2725
2740
} else {
2726
2741
show_result ("PASS " , $ tested , $ tested_file , '' , $ temp_filenames );
2727
2742
$ junit ->markTestAs ('PASS ' , $ shortname , $ tested );
@@ -2732,6 +2747,10 @@ function run_test(string $php, $file, array $env): string
2732
2747
2733
2748
$ wanted_re = null ;
2734
2749
}
2750
+ if (!$ passed && !$ retried && $ retriable && error_may_be_retried ($ output )) {
2751
+ $ retried = true ;
2752
+ goto retry;
2753
+ }
2735
2754
2736
2755
// Test failed so we need to report details.
2737
2756
if ($ failed_headers ) {
@@ -2856,6 +2875,11 @@ function run_test(string $php, $file, array $env): string
2856
2875
return $ restype [0 ] . 'ED ' ;
2857
2876
}
2858
2877
2878
+ function error_may_be_retried (string $ output ): bool
2879
+ {
2880
+ return preg_match ('((timed out)|(connection refused))i ' , $ output ) === 1 ;
2881
+ }
2882
+
2859
2883
/**
2860
2884
* @return bool|int
2861
2885
*/
0 commit comments