diff --git a/test/notmuch-test b/test/notmuch-test index bbc2dc31..8e483383 100755 --- a/test/notmuch-test +++ b/test/notmuch-test @@ -42,6 +42,7 @@ fi trap 'e=$?; kill $!; exit $e' HUP INT TERM # Run the tests if test -z "$NOTMUCH_TEST_SERIALIZE" && command -v parallel >/dev/null ; then + test -t 1 && export COLORS_WITHOUT_TTY=t || : if parallel -h | grep -q GNU ; then echo "INFO: running tests with GNU parallel" printf '%s\n' $TESTS | $TEST_TIMEOUT_CMD parallel diff --git a/test/test-lib.sh b/test/test-lib.sh index 068e1029..ff18fae6 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -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 () { (