Print summaries at the end of test.sh scripts

This commit is contained in:
Rangi42
2024-03-07 16:45:53 -05:00
parent aed172071b
commit e701faa1bc
4 changed files with 73 additions and 21 deletions

View File

@@ -14,16 +14,21 @@ rescolors="$(tput op)"
RGBGFX=../../rgbgfx
tests=0
failed=0
rc=0
new_test() {
cmdline="$*"
echo "${bold}${green}Testing: ${cmdline}${rescolors}${resbold}" >&2
}
test() {
(( tests++ ))
eval "$cmdline"
}
fail() {
rc=1
(( failed++ ))
echo "${bold}${red}Test ${cmdline} failed!${1:+ (RC=$1)}${rescolors}${resbold}"
}
@@ -69,4 +74,10 @@ for f in *.png; do
fi
done
if [[ "$failed" -eq 0 ]]; then
echo "${bold}${green}All ${tests} tests passed!${rescolors}${resbold}"
else
echo "${bold}${red}${failed} of the tests failed!${rescolors}${resbold}"
fi
exit $rc