More dense test output

This commit is contained in:
Sage Vaillancourt 2021-07-04 23:46:59 -04:00
parent 3d48c2eae0
commit 6a2e12ebfe
1 changed files with 10 additions and 10 deletions

View File

@ -4,8 +4,8 @@ VALCOM="valgrind -q --leak-check=full --track-origins=yes"
TOTAL_PASSES=0 TOTAL_PASSES=0
TOTAL_FAILS=0 TOTAL_FAILS=0
PASSES=0
FAILS=0 FAILS=0
FAIL_OUTPUT=""
VALGRIND=0 VALGRIND=0
CURRENT_BLOCK="" CURRENT_BLOCK=""
@ -15,26 +15,26 @@ if [ "$1" == "-val" ]; then
fi fi
endBlock() { endBlock() {
echo "$PASSES tests PASSED" echo ""
if (($FAILS != 0)); then if (($FAILS != 0)); then
echo "$FAILS tests FAILED" echo -e "$FAIL_OUTPUT"
FAIL_OUTPUT=""
fi fi
PASSES=0
FAILS=0 FAILS=0
echo ""
} }
title() { title() {
echo "$1" echo -n "[$1] "
} }
pass() { pass() {
((PASSES++)) echo -n "✓"
((TOTAL_PASSES++)) ((TOTAL_PASSES++))
} }
fail() { fail() {
echo "$1 test FAILED $2" echo -n "X"
FAIL_OUTPUT="$FAIL_OUTPUT $1 test FAILED $2"
((FAILS++)) ((FAILS++))
((TOTAL_FAILS++)) ((TOTAL_FAILS++))
} }
@ -51,14 +51,14 @@ check() {
pass $1 pass $1
else else
fail $1 "$2" fail $1 "$2"
echo " Expected '$3' but received '$output'" FAIL_OUTPUT="${FAIL_OUTPUT}\n Expected '$3' but received '$output'"
fi fi
} }
echo "STARTING TESTS" echo "STARTING TESTS"
echo "" echo ""
title "Plain return tests" title "Plain returns"
check "PlainRet" "10" "10" check "PlainRet" "10" "10"
check "StrRetrn" "\"hey\"" "hey" check "StrRetrn" "\"hey\"" "hey"
check "SingleStrRetrn" "'hey'" "hey" check "SingleStrRetrn" "'hey'" "hey"