IMP: tests readability and runtime error handling

Change describe display to add underline in order to make it more
noticeable in a stream of logs
Add a `fatal` message when catching a runtime error (until
`$totalerrors` has not been modified yet)
This commit is contained in:
Charles Herlin 2019-01-24 15:53:09 +01:00
parent d2e456b7d8
commit 5f7cb58dd4
2 changed files with 7 additions and 2 deletions

View File

@ -12,6 +12,9 @@ totalerrors=255
cleanup_and_exit() {
rm -rf "$mytmpdir"
if [ "$totalerrors" -eq 255 ]; then
fatal "RUNTIME ERROR"
fi
exit $totalerrors
}
trap "cleanup_and_exit" EXIT HUP INT
@ -42,9 +45,11 @@ declare -a REGISTERED_TESTS
#####################
# in case a fatal event occurs, fatal logs and exits with return code 1
fatal() {
printf "\033[1;91m###### \033[0m\n" >&2
printf "%b %b\n" "\033[1;91mFATAL\033[0m" "$*" >&2
printf "%b \n" "\033[1;91mEXIT TEST SUITE WITH FAILURE\033[0m" >&2
exit 1
trap - EXIT
exit 255
}
# prints that a test failed
fail() {

View File

@ -8,7 +8,7 @@
# describe <STRING>
describe() {
# shellcheck disable=2154
printf "\033[36mxxx %s::%s \033[0m\n" "$name" "$*"
printf "\033[4;36mxxx %s::%s \033[0m\n" "$name" "$*"
}
# Register an assertion on an audit before running it