From ca7e4f285cfb68bae13e8df770dc2b5856559ecd Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Fri, 13 Nov 2015 11:15:15 +1100 Subject: [PATCH] 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 --- tests/unittest.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/unittest.sh b/tests/unittest.sh index df7a8b4534..2570319fbf 100644 --- a/tests/unittest.sh +++ b/tests/unittest.sh @@ -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 }