diff options
author | Tyson Andre <tysonandre775@hotmail.com> | 2020-08-12 19:27:00 -0400 |
---|---|---|
committer | Tyson Andre <tysonandre775@hotmail.com> | 2020-08-13 11:27:32 -0400 |
commit | 7be61bec8037e601c989e5002198f77bf39e8d59 (patch) | |
tree | 7d5328b3ba251db6923a4c878e399b0997eadbc1 /run-tests.php | |
parent | c3ddda4e3c97c11ae538d44bafa4793fac94a533 (diff) | |
download | php-git-7be61bec8037e601c989e5002198f77bf39e8d59.tar.gz |
Colorize --show-diff, only on stdout
Don't add colors to the saved `.diff` file.
Related to a41cf3e1d2ed3ae38ad6115a8b65e5f14dae0b49
Diffstat (limited to 'run-tests.php')
-rwxr-xr-x | run-tests.php | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/run-tests.php b/run-tests.php index c89b6971eb..9d7397d615 100755 --- a/run-tests.php +++ b/run-tests.php @@ -1774,11 +1774,17 @@ function run_worker(): void function show_file_block(string $file, string $block, ?string $section = null): void { global $cfg; + global $colorize; if ($cfg['show'][$file]) { if (is_null($section)) { $section = strtoupper($file); } + if ($section === 'DIFF' && $colorize) { + // '-' is Light Red for removal, '+' is Light Green for addition + $block = preg_replace('/^[0-9]+\-\s.*$/m', "\e[1;31m\\0\e[0m", $block); + $block = preg_replace('/^[0-9]+\+\s.*$/m', "\e[1;32m\\0\e[0m", $block); + } echo "\n========" . $section . "========\n"; echo rtrim($block); |