More dense test output
This commit is contained in:
parent
3d48c2eae0
commit
6a2e12ebfe
20
src/tests.sh
20
src/tests.sh
|
@ -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 "[0;32m$PASSES tests PASSED[0m"
|
echo "[0m"
|
||||||
if (($FAILS != 0)); then
|
if (($FAILS != 0)); then
|
||||||
echo "[0;31m$FAILS tests FAILED[0m"
|
echo -e "$FAIL_OUTPUT"
|
||||||
|
FAIL_OUTPUT=""
|
||||||
fi
|
fi
|
||||||
PASSES=0
|
|
||||||
FAILS=0
|
FAILS=0
|
||||||
echo ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
title() {
|
title() {
|
||||||
echo "[1m$1[0m"
|
echo -n "[[0m$1] "
|
||||||
}
|
}
|
||||||
|
|
||||||
pass() {
|
pass() {
|
||||||
((PASSES++))
|
echo -n "[1;32m✓"
|
||||||
((TOTAL_PASSES++))
|
((TOTAL_PASSES++))
|
||||||
}
|
}
|
||||||
|
|
||||||
fail() {
|
fail() {
|
||||||
echo "[1;31m$1 test FAILED [0;34m$2[0m"
|
echo -n "[1;31mX"
|
||||||
|
FAIL_OUTPUT="$FAIL_OUTPUT [1;31m$1 test FAILED [0;34m$2[0m"
|
||||||
((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 [31mExpected '$3' but received '$output'"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "[1;33mSTARTING TESTS[0;m"
|
echo "[1;33mSTARTING TESTS[0;m"
|
||||||
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"
|
||||||
|
|
Loading…
Reference in New Issue