@@ -1851,11 +1851,16 @@ function run_test(string $php, $file, array $env): string
1851
1851
$ skipCache = new SkipCache ($ enableSkipCache , $ cfg ['keep ' ]['skip ' ]);
1852
1852
}
1853
1853
1854
+ $ php = escapeshellarg ($ php );
1855
+
1856
+ $ retriable = true ;
1857
+ $ retried = false ;
1858
+ retry:
1859
+
1854
1860
$ temp_filenames = null ;
1855
1861
$ org_file = $ file ;
1856
1862
$ orig_php = $ php ;
1857
1863
1858
- $ php = escapeshellarg ($ php );
1859
1864
$ php_cgi = $ env ['TEST_PHP_CGI_EXECUTABLE ' ] ?? null ;
1860
1865
$ phpdbg = $ env ['TEST_PHPDBG_EXECUTABLE ' ] ?? null ;
1861
1866
@@ -1891,8 +1896,11 @@ function run_test(string $php, $file, array $env): string
1891
1896
1892
1897
$ tested = $ test ->getName ();
1893
1898
1894
- if ($ num_repeats > 1 && $ test ->hasSection ('FILE_EXTERNAL ' )) {
1895
- return skip_test ($ tested , $ tested_file , $ shortname , 'Test with FILE_EXTERNAL might not be repeatable ' );
1899
+ if ($ test ->hasSection ('FILE_EXTERNAL ' )) {
1900
+ $ retriable = false ;
1901
+ if ($ num_repeats > 1 ) {
1902
+ return skip_test ($ tested , $ tested_file , $ shortname , 'Test with FILE_EXTERNAL might not be repeatable ' );
1903
+ }
1896
1904
}
1897
1905
1898
1906
if ($ test ->hasSection ('CAPTURE_STDIO ' )) {
@@ -1918,6 +1926,7 @@ function run_test(string $php, $file, array $env): string
1918
1926
}
1919
1927
$ php = escapeshellarg ($ php_cgi ) . ' -C ' ;
1920
1928
$ uses_cgi = true ;
1929
+ $ retriable = false ;
1921
1930
if ($ num_repeats > 1 ) {
1922
1931
return skip_test ($ tested , $ tested_file , $ shortname , 'CGI does not support --repeat ' );
1923
1932
}
@@ -1935,20 +1944,18 @@ function run_test(string $php, $file, array $env): string
1935
1944
} else {
1936
1945
return skip_test ($ tested , $ tested_file , $ shortname , 'phpdbg not available ' );
1937
1946
}
1947
+ $ retriable = false ;
1938
1948
if ($ num_repeats > 1 ) {
1939
1949
return skip_test ($ tested , $ tested_file , $ shortname , 'phpdbg does not support --repeat ' );
1940
1950
}
1941
1951
}
1942
1952
1943
- if ($ num_repeats > 1 ) {
1944
- if ($ test ->hasSection ('CLEAN ' )) {
1945
- return skip_test ($ tested , $ tested_file , $ shortname , 'Test with CLEAN might not be repeatable ' );
1946
- }
1947
- if ($ test ->hasSection ('STDIN ' )) {
1948
- return skip_test ($ tested , $ tested_file , $ shortname , 'Test with STDIN might not be repeatable ' );
1949
- }
1950
- if ($ test ->hasSection ('CAPTURE_STDIO ' )) {
1951
- return skip_test ($ tested , $ tested_file , $ shortname , 'Test with CAPTURE_STDIO might not be repeatable ' );
1953
+ foreach (['CLEAN ' , 'STDIN ' , 'CAPTURE_STDIO ' ] as $ section ) {
1954
+ if ($ test ->hasSection ($ section )) {
1955
+ $ retriable = false ;
1956
+ if ($ num_repeats > 1 ) {
1957
+ return skip_test ($ tested , $ tested_file , $ shortname , "Test with $ section might not be repeatable " );
1958
+ }
1952
1959
}
1953
1960
}
1954
1961
@@ -2113,7 +2120,7 @@ function run_test(string $php, $file, array $env): string
2113
2120
// even though all the files are re-created.
2114
2121
$ ini_settings ['opcache.validate_timestamps ' ] = '0 ' ;
2115
2122
}
2116
- } else if ($ num_repeats > 1 ) {
2123
+ } else if ($ num_repeats > 1 || $ retried ) {
2117
2124
// Make sure warnings still show up on the second run.
2118
2125
$ ini_settings ['opcache.record_warnings ' ] = '1 ' ;
2119
2126
}
@@ -2140,8 +2147,11 @@ function run_test(string $php, $file, array $env): string
2140
2147
}
2141
2148
settings2array (preg_split ("/[ \n\r]+/ " , $ ini ), $ ini_settings );
2142
2149
2143
- if ($ num_repeats > 1 && isset ($ ini_settings ['opcache.opt_debug_level ' ])) {
2144
- return skip_test ($ tested , $ tested_file , $ shortname , 'opt_debug_level tests are not repeatable ' );
2150
+ if (isset ($ ini_settings ['opcache.opt_debug_level ' ])) {
2151
+ $ retriable = false ;
2152
+ if ($ num_repeats > 1 ) {
2153
+ return skip_test ($ tested , $ tested_file , $ shortname , 'opt_debug_level tests are not repeatable ' );
2154
+ }
2145
2155
}
2146
2156
}
2147
2157
@@ -2672,6 +2682,10 @@ function run_test(string $php, $file, array $env): string
2672
2682
2673
2683
$ wanted_re = null ;
2674
2684
}
2685
+ if (!$ passed && !$ retried && $ retriable && error_may_be_retried ($ output )) {
2686
+ $ retried = true ;
2687
+ goto retry;
2688
+ }
2675
2689
2676
2690
if ($ passed ) {
2677
2691
if (!$ cfg ['keep ' ]['php ' ] && !$ leaked ) {
@@ -2702,6 +2716,9 @@ function run_test(string $php, $file, array $env): string
2702
2716
} elseif ($ test ->hasSection ('XLEAK ' )) {
2703
2717
$ warn = true ;
2704
2718
$ info = " (warn: XLEAK section but test passes) " ;
2719
+ } elseif ($ retried ) {
2720
+ $ warn = true ;
2721
+ $ info = " (warn: Test passed on retry attempt) " ;
2705
2722
} else {
2706
2723
show_result ("PASS " , $ tested , $ tested_file , '' , $ temp_filenames );
2707
2724
$ junit ->markTestAs ('PASS ' , $ shortname , $ tested );
@@ -2845,6 +2862,11 @@ function run_test(string $php, $file, array $env): string
2845
2862
return $ restype [0 ] . 'ED ' ;
2846
2863
}
2847
2864
2865
+ function error_may_be_retried (string $ output ): bool
2866
+ {
2867
+ return preg_match ('((timed out)|(connection refused))i ' , $ output ) === 1 ;
2868
+ }
2869
+
2848
2870
/**
2849
2871
* Map "Zend OPcache" to "opcache" and convert all ext names to lowercase.
2850
2872
*/
0 commit comments