@@ -114,6 +114,8 @@ function show_usage(): void
114
114
115
115
--no-clean Do not execute clean section if any.
116
116
117
+ --no-color Do not colorize the result type in the test result
118
+
117
119
118
120
HELP ;
119
121
}
@@ -133,7 +135,7 @@ function main(): void
133
135
global $ DETAILED , $ PHP_FAILED_TESTS , $ SHOW_ONLY_GROUPS , $ argc , $ argv , $ cfg ,
134
136
$ cfgfiles , $ cfgtypes , $ conf_passed , $ end_time , $ environment ,
135
137
$ exts_skipped , $ exts_tested , $ exts_to_test , $ failed_tests_file ,
136
- $ ignored_by_ext , $ ini_overwrites , $ is_switch ,
138
+ $ ignored_by_ext , $ ini_overwrites , $ is_switch , $ colorize ,
137
139
$ just_save_results , $ log_format , $ matches , $ no_clean , $ no_file_cache ,
138
140
$ optionals , $ output_file , $ pass_option_n , $ pass_options ,
139
141
$ pattern_match , $ php , $ php_cgi , $ phpdbg , $ preload , $ redir_tests ,
@@ -384,6 +386,10 @@ function main(): void
384
386
$ temp_urlbase = null ;
385
387
$ conf_passed = null ;
386
388
$ no_clean = false ;
389
+ $ colorize = true ;
390
+ if (function_exists ('sapi_windows_vt100_support ' ) && !sapi_windows_vt100_support (STDOUT , true )) {
391
+ $ colorize = false ;
392
+ }
387
393
$ selected_tests = false ;
388
394
$ slow_min_ms = INF ;
389
395
$ preload = false ;
@@ -530,6 +536,9 @@ function main(): void
530
536
case '--no-clean ' :
531
537
$ no_clean = true ;
532
538
break ;
539
+ case '--no-color ' :
540
+ $ colorize = false ;
541
+ break ;
533
542
case 'p ' :
534
543
$ php = $ argv [++$ i ];
535
544
putenv ("TEST_PHP_EXECUTABLE= $ php " );
@@ -3266,10 +3275,27 @@ function show_result(
3266
3275
string $ extra = '' ,
3267
3276
?array $ temp_filenames = null
3268
3277
): void {
3269
- global $ temp_target , $ temp_urlbase , $ line_length , $ SHOW_ONLY_GROUPS ;
3278
+ global $ SHOW_ONLY_GROUPS , $ colorize ;
3270
3279
3271
3280
if (!$ SHOW_ONLY_GROUPS || in_array ($ result , $ SHOW_ONLY_GROUPS )) {
3272
- echo "$ result $ tested [ $ tested_file] $ extra \n" ;
3281
+ if ($ colorize ) {
3282
+ /* Use ANSI escape codes for coloring test result */
3283
+ switch ( $ result ) {
3284
+ case 'PASS ' : // Light Green
3285
+ $ color = "\e[1;32m {$ result }\e[0m " ; break ;
3286
+ case 'FAIL ' :
3287
+ case 'BORK ' :
3288
+ case 'LEAK ' :
3289
+ // Light Red
3290
+ $ color = "\e[1;31m {$ result }\e[0m " ; break ;
3291
+ default : // Yellow
3292
+ $ color = "\e[1;33m {$ result }\e[0m " ; break ;
3293
+ }
3294
+
3295
+ echo "$ color $ tested [ $ tested_file] $ extra \n" ;
3296
+ } else {
3297
+ echo "$ result $ tested [ $ tested_file] $ extra \n" ;
3298
+ }
3273
3299
} elseif (!$ SHOW_ONLY_GROUPS ) {
3274
3300
clear_show_test ();
3275
3301
}
0 commit comments