]> git.notmuchmail.org Git - notmuch/blobdiff - test/test-lib.sh
test-lib.sh: colors to test output when parallel(1) is run on tty
[notmuch] / test / test-lib.sh
index 068e1029e5f30272883c53556d89e3844e278c71..ff18fae616b2aaf1a27dae10216309ded3006349 100644 (file)
@@ -134,15 +134,7 @@ add_gnupg_home ()
 # '
 # . ./test-lib.sh || exit 1
 
-[ "x$ORIGINAL_TERM" != "xdumb" ] && (
-               TERM=$ORIGINAL_TERM &&
-               export TERM &&
-               [ -t 1 ] &&
-               tput bold >/dev/null 2>&1 &&
-               tput setaf 1 >/dev/null 2>&1 &&
-               tput sgr0 >/dev/null 2>&1
-       ) &&
-       color=t
+color=maybe
 
 while test "$#" -ne 0
 do
@@ -183,6 +175,21 @@ else
     }
 fi
 
+test -n "$COLORS_WITHOUT_TTY" || [ -t 1 ] || color=
+
+if [ -n "$color" ] && [ "$ORIGINAL_TERM" != 'dumb' ] && (
+               TERM=$ORIGINAL_TERM &&
+               export TERM &&
+               tput bold
+               tput setaf
+               tput sgr0
+       ) >/dev/null 2>&1
+then
+       color=t
+else
+       color=
+fi
+
 if test -n "$color"; then
        say_color () {
                (