[PATCH 3/7] test-lib: color "ok" TAP directives green under --verbose (or -x)
From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2021-03-09 16:03:19
Subsystem:
the rest · Maintainer:
Linus Torvalds
Change the color of "ok" lines to be green when we run under --verbose
or -x.
When a test fails we color the "not ok" line red, but the "ok" lines
are not colored.
I think that's the right thing to do in the default output, which is
e.g.:
$ ./t0000-basic.sh
ok 1 - verify that the running shell supports "local"
ok 2 - .git/objects should be empty after git init in an empty repo
ok 3 - .git/objects should have 3 subdirectories
[...]
Having almost every line colored green in that output would be
distracting.
However, under --verbose we'll typically might emit 10-20 lines of
non-colored stderr and "info" colored output describing the test
itself.
When paging through that output always having the boundaries between
tests highlighted makes the output more readable.
Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
t/test-lib.sh | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 9a3a3d8d16d..8562b11b817 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh@@ -545,6 +545,7 @@ then say_color_skip=$(tput setaf 4) # blue say_color_warn=$(tput setaf 3) # brown/yellow say_color_pass=$(tput setaf 2) # green + say_color_pass_all=$(tput bold; tput setaf 2) # bold green say_color_info=$(tput setaf 6) # cyan say_color_reset=$(tput sgr0) say_color_="" # no formatting for normal text
@@ -673,7 +674,7 @@ test_ok_ () { write_junit_xml_testcase "$*" fi test_success=$(($test_success + 1)) - say_color_tap "" "ok $test_count - $@" + say_color_tap "${verbose:+pass}" "ok $test_count - $@" } test_failure_ () {
--
2.31.0.rc1.210.g0f8085a843c