@@ -114,6 +114,8 @@ function show_usage()
114
114
115
115
--no-clean Do not execute clean section if any.
116
116
117
+ --no-color Do not colorise the result type in the test result
118
+
117
119
118
120
HELP ;
119
121
}
@@ -133,7 +135,7 @@ function main()
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 , $ colorise ,
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()
384
386
$ temp_urlbase = null ;
385
387
$ conf_passed = null ;
386
388
$ no_clean = false ;
389
+ $ colorise = true ;
390
+ if (function_exists ('sapi_windows_vt100_support ' ) && !sapi_windows_vt100_support (STDOUT , true )) {
391
+ $ colorise = false ;
392
+ }
387
393
$ selected_tests = false ;
388
394
$ slow_min_ms = INF ;
389
395
$ preload = false ;
@@ -530,6 +536,9 @@ function main()
530
536
case '--no-clean ' :
531
537
$ no_clean = true ;
532
538
break ;
539
+ case '--no-color ' :
540
+ $ colorise = false ;
541
+ break ;
533
542
case 'p ' :
534
543
$ php = $ argv [++$ i ];
535
544
putenv ("TEST_PHP_EXECUTABLE= $ php " );
@@ -3223,10 +3232,30 @@ function parse_conflicts(string $text): array
3223
3232
3224
3233
function show_result ($ result , $ tested , $ tested_file , $ extra = '' , $ temp_filenames = null )
3225
3234
{
3226
- global $ temp_target , $ temp_urlbase , $ line_length , $ SHOW_ONLY_GROUPS ;
3235
+ global $ SHOW_ONLY_GROUPS , $ colorise ;
3227
3236
3228
3237
if (!$ SHOW_ONLY_GROUPS || in_array ($ result , $ SHOW_ONLY_GROUPS )) {
3229
- echo "$ result $ tested [ $ tested_file] $ extra \n" ;
3238
+ if ($ colorise ) {
3239
+ /* Use ANSI escape codes for coloring test result */
3240
+ switch ( $ result ) {
3241
+ case 'PASS ' : // Light Green
3242
+ $ color = "\e[1;32m {$ result }\e[0m " ; break ;
3243
+ case 'SKIP ' : // Light Gray
3244
+ $ color = "\e[0;37m {$ result }" ; break ;
3245
+ case 'FAIL ' : // Light Red
3246
+ $ color = "\e[1;31m {$ result }\e[0m " ; break ;
3247
+ case 'BORK ' : // Purple
3248
+ $ color = "\e[0;35m {$ result }\e[0m " ; break ;
3249
+ case 'LEAK ' : // Dark Blue
3250
+ $ color = "\e[2;34m {$ result }\e[0m " ; break ;
3251
+ default : // Yellow
3252
+ $ color = "\e[1;33m {$ result }\e[0m " ; break ;
3253
+ }
3254
+
3255
+ echo "$ color $ tested [ $ tested_file] $ extra \e[0m \n" ;
3256
+ } else {
3257
+ echo "$ result $ tested [ $ tested_file] $ extra \n" ;
3258
+ }
3230
3259
} elseif (!$ SHOW_ONLY_GROUPS ) {
3231
3260
clear_show_test ();
3232
3261
}
0 commit comments