@@ -151,7 +151,7 @@ function main(): void
151
151
global $ DETAILED , $ PHP_FAILED_TESTS , $ SHOW_ONLY_GROUPS , $ argc , $ argv , $ cfg ,
152
152
$ cfgfiles , $ cfgtypes , $ conf_passed , $ end_time , $ environment ,
153
153
$ exts_skipped , $ exts_tested , $ exts_to_test , $ failed_tests_file ,
154
- $ ignored_by_ext , $ ini_overwrites , $ is_switch , $ colorize ,
154
+ $ ignored_by_ext , $ ini_overwrites , $ is_switch , $ colorize , $ github_actions ,
155
155
$ log_format , $ matches , $ no_clean , $ no_file_cache ,
156
156
$ optionals , $ pass_option_n , $ pass_options ,
157
157
$ pattern_match , $ php , $ php_cgi , $ phpdbg , $ preload , $ redir_tests ,
@@ -351,6 +351,10 @@ function main(): void
351
351
if (array_key_exists ('NO_COLOR ' , $ environment )) {
352
352
$ colorize = false ;
353
353
}
354
+ $ github_actions = false ;
355
+ if (array_key_exists ('CI ' , $ environment ) && array_key_exists ('GITHUB_ACTIONS ' , $ environment )) {
356
+ $ github_actions = true ;
357
+ }
354
358
$ selected_tests = false ;
355
359
$ slow_min_ms = INF ;
356
360
$ preload = false ;
@@ -2117,9 +2121,9 @@ function run_test(string $php, $file, array $env): string
2117
2121
2118
2122
if (!strncasecmp ('skip ' , $ output , 4 )) {
2119
2123
if (preg_match ('/^skip\s*(.+)/i ' , $ output , $ m )) {
2120
- show_result ('SKIP ' , $ tested , $ tested_file , "reason: $ m [1 ]" , $ temp_filenames );
2124
+ show_result ('SKIP ' , $ tested , $ tested_file , "reason: $ m [1 ]" );
2121
2125
} else {
2122
- show_result ('SKIP ' , $ tested , $ tested_file , '' , $ temp_filenames );
2126
+ show_result ('SKIP ' , $ tested , $ tested_file , '' );
2123
2127
}
2124
2128
2125
2129
$ message = !empty ($ m [1 ]) ? $ m [1 ] : '' ;
@@ -2137,7 +2141,7 @@ function run_test(string $php, $file, array $env): string
2137
2141
// Pretend we have an XFAIL section
2138
2142
$ test ->setSection ('XFAIL ' , ltrim (substr ($ output , 5 )));
2139
2143
} elseif ($ output !== '' ) {
2140
- show_result ("BORK " , $ output , $ tested_file , 'reason: invalid output from SKIPIF ' , $ temp_filenames );
2144
+ show_result ("BORK " , $ output , $ tested_file , 'reason: invalid output from SKIPIF ' );
2141
2145
$ PHP_FAILED_TESTS ['BORKED ' ][] = [
2142
2146
'name ' => $ file ,
2143
2147
'test_name ' => '' ,
@@ -2153,7 +2157,7 @@ function run_test(string $php, $file, array $env): string
2153
2157
2154
2158
if (!extension_loaded ("zlib " ) && $ test ->hasAnySections ("GZIP_POST " , "DEFLATE_POST " )) {
2155
2159
$ message = "ext/zlib required " ;
2156
- show_result ('SKIP ' , $ tested , $ tested_file , "reason: $ message " , $ temp_filenames );
2160
+ show_result ('SKIP ' , $ tested , $ tested_file , "reason: $ message " );
2157
2161
$ junit ->markTestAs ('SKIP ' , $ shortname , $ tested , null , $ message );
2158
2162
return 'SKIPPED ' ;
2159
2163
}
@@ -2200,7 +2204,7 @@ function run_test(string $php, $file, array $env): string
2200
2204
}
2201
2205
2202
2206
$ bork_info = "Redirect info must contain exactly one TEST string to be used as redirect directory. " ;
2203
- show_result ("BORK " , $ bork_info , '' , '' , $ temp_filenames );
2207
+ show_result ("BORK " , $ bork_info , '' , '' );
2204
2208
$ PHP_FAILED_TESTS ['BORKED ' ][] = [
2205
2209
'name ' => $ file ,
2206
2210
'test_name ' => '' ,
@@ -2216,7 +2220,7 @@ function run_test(string $php, $file, array $env): string
2216
2220
}
2217
2221
2218
2222
$ bork_info = "Redirected test did not contain redirection info " ;
2219
- show_result ("BORK " , $ bork_info , '' , '' , $ temp_filenames );
2223
+ show_result ("BORK " , $ bork_info , '' , '' );
2220
2224
$ PHP_FAILED_TESTS ['BORKED ' ][] = [
2221
2225
'name ' => $ file ,
2222
2226
'test_name ' => '' ,
@@ -2612,7 +2616,7 @@ function run_test(string $php, $file, array $env): string
2612
2616
if (!$ leaked && !$ failed_headers ) {
2613
2617
// If the test passed and CLEAN produced output, report test as borked.
2614
2618
if ($ clean_output ) {
2615
- show_result ("BORK " , $ output , $ tested_file , 'reason: invalid output from CLEAN ' , $ temp_filenames );
2619
+ show_result ("BORK " , $ output , $ tested_file , 'reason: invalid output from CLEAN ' );
2616
2620
$ PHP_FAILED_TESTS ['BORKED ' ][] = [
2617
2621
'name ' => $ file ,
2618
2622
'test_name ' => '' ,
@@ -2632,7 +2636,7 @@ function run_test(string $php, $file, array $env): string
2632
2636
$ warn = true ;
2633
2637
$ info = " (warn: XLEAK section but test passes) " ;
2634
2638
} else {
2635
- show_result ("PASS " , $ tested , $ tested_file , '' , $ temp_filenames );
2639
+ show_result ("PASS " , $ tested , $ tested_file , '' );
2636
2640
$ junit ->markTestAs ('PASS ' , $ shortname , $ tested );
2637
2641
return 'PASSED ' ;
2638
2642
}
@@ -2750,7 +2754,9 @@ function run_test(string $php, $file, array $env): string
2750
2754
show_file_block ('mem ' , file_get_contents ($ memcheck_filename ));
2751
2755
}
2752
2756
2753
- show_result (implode ('& ' , $ restype ), $ tested , $ tested_file , $ info , $ temp_filenames );
2757
+ $ diff = empty ($ diff ) ? '' : preg_replace ('/\e/ ' , '<esc> ' , $ diff );
2758
+
2759
+ show_result (implode ('& ' , $ restype ), $ tested , $ tested_file , $ info , $ diff );
2754
2760
2755
2761
foreach ($ restype as $ type ) {
2756
2762
$ PHP_FAILED_TESTS [$ type . 'ED ' ][] = [
@@ -2762,8 +2768,6 @@ function run_test(string $php, $file, array $env): string
2762
2768
];
2763
2769
}
2764
2770
2765
- $ diff = empty ($ diff ) ? '' : preg_replace ('/\e/ ' , '<esc> ' , $ diff );
2766
-
2767
2771
$ junit ->markTestAs ($ restype , $ shortname , $ tested , null , $ info , $ diff );
2768
2772
2769
2773
return $ restype [0 ] . 'ED ' ;
@@ -3278,9 +3282,9 @@ function show_result(
3278
3282
string $ tested ,
3279
3283
string $ tested_file ,
3280
3284
string $ extra = '' ,
3281
- ? array $ temp_filenames = null
3285
+ string $ diff = ''
3282
3286
): void {
3283
- global $ SHOW_ONLY_GROUPS , $ colorize ;
3287
+ global $ SHOW_ONLY_GROUPS , $ colorize, $ github_actions ;
3284
3288
3285
3289
if (!$ SHOW_ONLY_GROUPS || in_array ($ result , $ SHOW_ONLY_GROUPS )) {
3286
3290
if ($ colorize ) {
@@ -3302,6 +3306,54 @@ function show_result(
3302
3306
} else {
3303
3307
echo "$ result $ tested [ $ tested_file] $ extra \n" ;
3304
3308
}
3309
+
3310
+ if ($ github_actions ) {
3311
+ $ title = $ tested ;
3312
+ $ message = '' ;
3313
+
3314
+ $ type = null ;
3315
+ switch ( $ result ) {
3316
+ case 'FAIL ' :
3317
+ $ type = 'error ' ;
3318
+ $ message = "Test failed " . ($ extra ? " - {$ extra }" : '' );
3319
+ break ;
3320
+ case 'BORK ' :
3321
+ $ type = 'error ' ;
3322
+ $ message = "Test borked " . ($ extra ? " - {$ extra }" : '' );
3323
+ break ;
3324
+ case 'LEAK ' :
3325
+ $ type = 'error ' ;
3326
+ $ message = "Test leaked " . ($ extra ? " - {$ extra }" : '' );
3327
+ break ;
3328
+ case 'LEAK&FAIL ' :
3329
+ $ type = 'error ' ;
3330
+ $ message = "Test failed and leaked " . ($ extra ? " - {$ extra }" : '' );
3331
+ break ;
3332
+ case 'WARN ' :
3333
+ $ type = 'warning ' ;
3334
+ $ message = "Test warned " . ($ extra ? " - {$ extra }" : '' );
3335
+ break ;
3336
+ }
3337
+
3338
+ $ message .= "\n\n{$ diff }" ;
3339
+
3340
+ if ($ type !== null ) {
3341
+ $ title = strtr ($ title , [
3342
+ "% " => '%25 ' ,
3343
+ "\r" => '%0D ' ,
3344
+ "\n" => '%0A ' ,
3345
+ ": " => '%3A ' ,
3346
+ ", " => '%2C ' ,
3347
+ ]);
3348
+ $ message = strtr ($ message , [
3349
+ "% " => '%25 ' ,
3350
+ "\r" => '%0D ' ,
3351
+ "\n" => '%0A ' ,
3352
+ ]);
3353
+
3354
+ echo ":: {$ type } file= {$ tested_file },title= {$ title }:: {$ message }\n" ;
3355
+ }
3356
+ }
3305
3357
} elseif (!$ SHOW_ONLY_GROUPS ) {
3306
3358
clear_show_test ();
3307
3359
}
0 commit comments