Skip to content

Commit 45d69fb

Browse files
committed
Support NO_COLOR environment variable in run-tests.php
And add a --color option for run-tests.php See https://no-color.org/ > an informal standard is hereby proposed: > > All command-line software which outputs text with ANSI color added should check > for the presence of a `NO_COLOR` environment variable that, when present > (regardless of its value), prevents the addition of ANSI color.
1 parent b480e68 commit 45d69fb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

run-tests.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ function show_usage(): void
114114
115115
--no-clean Do not execute clean section if any.
116116
117-
--no-color Do not colorize the result type in the test result
117+
--color
118+
--no-color Do/Don't colorize the result type in the test result.
118119
119120
120121
HELP;
@@ -390,6 +391,9 @@ function main(): void
390391
if (function_exists('sapi_windows_vt100_support') && !sapi_windows_vt100_support(STDOUT, true)) {
391392
$colorize = false;
392393
}
394+
if (array_key_exists('NO_COLOR', $_ENV)) {
395+
$colorize = false;
396+
}
393397
$selected_tests = false;
394398
$slow_min_ms = INF;
395399
$preload = false;
@@ -536,6 +540,9 @@ function main(): void
536540
case '--no-clean':
537541
$no_clean = true;
538542
break;
543+
case '--color':
544+
$colorize = true;
545+
break;
539546
case '--no-color':
540547
$colorize = false;
541548
break;

0 commit comments

Comments
 (0)