summaryrefslogtreecommitdiffstats
path: root/tests.sh
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2019-03-20 18:30:01 -0400
committerTavian Barnes <tavianator@tavianator.com>2019-03-20 18:30:01 -0400
commit4d458a8be62f79d7a931e7ee95da3438ca07b15e (patch)
tree0abb0014f99c8c377e083ee69ba5fc4f5468907d /tests.sh
parent344f9c2f844b20a8ba206595c28429a196383e23 (diff)
downloadbfs-4d458a8be62f79d7a931e7ee95da3438ca07b15e.tar.xz
tests: Make the output more colorful and nicer
Diffstat (limited to 'tests.sh')
-rwxr-xr-xtests.sh34
1 files changed, 16 insertions, 18 deletions
diff --git a/tests.sh b/tests.sh
index a219812..3d2ac43 100755
--- a/tests.sh
+++ b/tests.sh
@@ -2078,8 +2078,18 @@ function test_L_unique_depth() {
bfs_diff -L loops/deeply/nested -unique -depth
}
-if [ -t 1 -a ! "$VERBOSE" ]; then
- in_place=yes
+EOL='\n'
+if [ -t 1 ]; then
+ RED='\033[01;31m'
+ GRN='\033[01;32m'
+ YLW='\033[01;33m'
+ RST='\033[0m'
+ if [ ! "$VERBOSE" ]; then
+ BOL='\r\033[K'
+ # Put the cursor at the last column, then write a space so the next
+ # character will wrap
+ EOL="\\033[$(tput cols)G "
+ fi
fi
passed=0
@@ -2088,11 +2098,7 @@ failed=0
for test in ${!run_*}; do
test=${test#run_}
- if [ "$in_place" ]; then
- printf '\r\033[J%s' "$test"
- else
- echo "$test"
- fi
+ printf "${BOL}${YLW}%s${RST}${EOL}" "$test"
("$test" "$dir")
status=$?
@@ -2101,22 +2107,14 @@ for test in ${!run_*}; do
((++passed))
else
((++failed))
- if [ "$in_place" ]; then
- printf '\r\033[J%s\n' "$test failed!"
- else
- echo "$test failed!"
- fi
+ printf "${BOL}${RED}%s failed!${RST}\n" "$test"
fi
done
-if [ "$in_place" ]; then
- printf '\r\033[J'
-fi
-
if [ $passed -gt 0 ]; then
- echo "tests passed: $passed"
+ printf "${BOL}${GRN}tests passed: %d${RST}\n" "$passed"
fi
if [ $failed -gt 0 ]; then
- echo "tests failed: $failed"
+ printf "${BOL}${RED}tests failed: %s${RST}\n" "$failed"
exit 1
fi