mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 12:28:09 +01:00
test-lib.sh: colors to test output when parallel(1) is run on tty
Done via $COLORS_WITHOUT_TTY environment variable as passing options to commands through parallel(1) does not look trivial. Reorganized color checking in test-lib.sh a bit for this (perhaps were not fully necessary but rest still an improvement): - color checking commands in subshell are not run before arg parsing (args may disable colors with --no-color) - [ -t 1 ] is checked before forking subshell
This commit is contained in:
parent
a1aea7272e
commit
3563079be3
2 changed files with 17 additions and 9 deletions
|
@ -42,6 +42,7 @@ fi
|
||||||
trap 'e=$?; kill $!; exit $e' HUP INT TERM
|
trap 'e=$?; kill $!; exit $e' HUP INT TERM
|
||||||
# Run the tests
|
# Run the tests
|
||||||
if test -z "$NOTMUCH_TEST_SERIALIZE" && command -v parallel >/dev/null ; then
|
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
|
if parallel -h | grep -q GNU ; then
|
||||||
echo "INFO: running tests with GNU parallel"
|
echo "INFO: running tests with GNU parallel"
|
||||||
printf '%s\n' $TESTS | $TEST_TIMEOUT_CMD parallel
|
printf '%s\n' $TESTS | $TEST_TIMEOUT_CMD parallel
|
||||||
|
|
|
@ -134,15 +134,7 @@ add_gnupg_home ()
|
||||||
# '
|
# '
|
||||||
# . ./test-lib.sh || exit 1
|
# . ./test-lib.sh || exit 1
|
||||||
|
|
||||||
[ "x$ORIGINAL_TERM" != "xdumb" ] && (
|
color=maybe
|
||||||
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
|
|
||||||
|
|
||||||
while test "$#" -ne 0
|
while test "$#" -ne 0
|
||||||
do
|
do
|
||||||
|
@ -183,6 +175,21 @@ else
|
||||||
}
|
}
|
||||||
fi
|
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
|
if test -n "$color"; then
|
||||||
say_color () {
|
say_color () {
|
||||||
(
|
(
|
||||||
|
|
Loading…
Reference in a new issue