Fix error detection & exit in report_results

We wish to fail if we have >0 zero errors, not >1 errors (i.e. exactly
one error did not trigger a failure!)

This change also brings consistency to the pass & failure paths by
ensuring report_results exits in both cases, since report_results is
supposed to be the last thing run in a test file.

Change-Id: Id4721dffe13721e6c3cd71bca40c3395627e98bf
This commit is contained in:
Ian Wienand 2015-11-13 11:15:15 +11:00
parent d9da93ede2
commit ca7e4f285c

View File

@ -92,16 +92,17 @@ function assert_empty {
fi
}
# print a summary of passing and failing tests, exiting
# with an error if we have failed tests
# Print a summary of passing and failing tests and exit
# (with an error if we have failed tests)
# usage: report_results
function report_results {
echo "$PASS Tests PASSED"
if [[ $ERROR -gt 1 ]]; then
if [[ $ERROR -gt 0 ]]; then
echo
echo "The following $ERROR tests FAILED"
echo -e "$FAILED_FUNCS"
echo "---"
exit 1
fi
exit 0
}