From 7415785abb72b098998fa98361e9ca13c05146bc Mon Sep 17 00:00:00 2001 From: Frazer Clews Date: Thu, 9 Jun 2022 15:14:35 +0100 Subject: [PATCH] test: Add color to test.sh stdout for easier readability Closes: #86 --- test.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test.sh b/test.sh index a830c24..1dd5204 100755 --- a/test.sh +++ b/test.sh @@ -43,15 +43,24 @@ message() sed "s/$gi_re/gi/" } +RED='' +GREEN='' +NC='' +if [ -t 1 ] && command -v tput > /dev/null 2>&1 && [ "$(tput colors)" -gt 2 ] ; then + RED=$(tput setaf 1) + GREEN=$(tput setaf 2) + NC=$(tput sgr0) +fi + ok() { - message ok "$*" + message ${GREEN}ok${NC} "$*" } fail() { printf "%d " "$ntest" >>"$TopDir/failure" - message fail "$*" + message ${RED}fail${NC} "$*" } # Test specified command, which should succeed