Skip to content

Commit 7415785

Browse files
author
Frazer Clews
committed
test: Add color to test.sh stdout for easier readability
Closes: #86
1 parent 28a61e8 commit 7415785

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

test.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,24 @@ message()
4343
sed "s/$gi_re/gi/"
4444
}
4545

46+
RED=''
47+
GREEN=''
48+
NC=''
49+
if [ -t 1 ] && command -v tput > /dev/null 2>&1 && [ "$(tput colors)" -gt 2 ] ; then
50+
RED=$(tput setaf 1)
51+
GREEN=$(tput setaf 2)
52+
NC=$(tput sgr0)
53+
fi
54+
4655
ok()
4756
{
48-
message ok "$*"
57+
message ${GREEN}ok${NC} "$*"
4958
}
5059

5160
fail()
5261
{
5362
printf "%d " "$ntest" >>"$TopDir/failure"
54-
message fail "$*"
63+
message ${RED}fail${NC} "$*"
5564
}
5665

5766
# Test specified command, which should succeed

0 commit comments

Comments
 (0)