summaryrefslogtreecommitdiffstats
path: root/tests/shell/run-tests.sh
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2023-09-14 15:16:07 +0200
committerFlorian Westphal <fw@strlen.de>2023-09-15 16:29:45 +0200
commitffbcf6cc7976533cd3e2dc5eae68aa9f82867889 (patch)
tree13303335fd6c011de554cd717ff9fe77f50f7597 /tests/shell/run-tests.sh
parent45cc3d9b238dadfd9929f0de14139238077ddb03 (diff)
tests/shell: honor CLICOLOR_FORCE to force coloring in run-tests.sh
We honor NO_COLOR= to disable coloring, let's also honor CLICOLOR_FORCE= to enable it. The purpose will be for `make` calling the script and redirecting to a file, while enabling colors. See-also: https://bixense.com/clicolors/ Signed-off-by: Thomas Haller <thaller@redhat.com> Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'tests/shell/run-tests.sh')
-rwxr-xr-xtests/shell/run-tests.sh15
1 files changed, 10 insertions, 5 deletions
diff --git a/tests/shell/run-tests.sh b/tests/shell/run-tests.sh
index 9114eba2..c5d6307d 100755
--- a/tests/shell/run-tests.sh
+++ b/tests/shell/run-tests.sh
@@ -4,11 +4,16 @@ GREEN=""
YELLOW=""
RED=""
RESET=""
-if [[ -t 1 && -z "$NO_COLOR" ]] ; then
- GREEN=$'\e[32m'
- YELLOW=$'\e[33m'
- RED=$'\e[31m'
- RESET=$'\e[0m'
+if [ -z "$NO_COLOR" ] ; then
+ if [ -n "$CLICOLOR_FORCE" ] || [[ -t 1 ]] ; then
+ # See https://bixense.com/clicolors/ . We only check isatty() on
+ # file descriptor 1, to decide whether colorizing happens (although,
+ # we might also colorize on other places/FDs).
+ GREEN=$'\e[32m'
+ YELLOW=$'\e[33m'
+ RED=$'\e[31m'
+ RESET=$'\e[0m'
+ fi
fi
array_contains() {