]> git.saurik.com Git - apt.git/blobdiff - test/integration/framework
test/integration/framework: use EXIT_CODE to be consistent with the run-tests code
[apt.git] / test / integration / framework
index 883b65bba0f1044b7a970e030ab4786c9f0bc2fe..4a70573c89eeafca8e75159b05e7c32e26eb2d7a 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/sh -- # no runable script, just for vi
 
-TESTFAILURES="no"
+EXIT_CODE=0
 
 # we all like colorful messages
 if expr match "$(readlink -f /proc/$$/fd/1)" '/dev/pts/[0-9]\+' > /dev/null && \
@@ -38,7 +38,7 @@ msgtest() {
 }
 msgpass() { echo "${CPASS}PASS${CNORMAL}" >&2; }
 msgskip() { echo "${CWARNING}SKIP${CNORMAL}" >&2; }
-msgfail() { echo "${CFAIL}FAIL${CNORMAL}" >&2; TESTFAILURES="yes"; }
+msgfail() { echo "${CFAIL}FAIL${CNORMAL}" >&2; EXIT_CODE=$((EXIT_CODE+1)); }
 
 # enable / disable Debugging
 MSGLEVEL=${MSGLEVEL:-3}
@@ -116,7 +116,12 @@ gdb() {
 }
 
 exitwithstatus() {
-       [ "$TESTFAILURES" = "yes" ] && exit 1 || exit 0;
+        # error if we about to overflow, but ...
+        #   "255 failures ought to be enough for everybody"
+        if [ $EXIT_CODE -gt 255 ]; then
+            msgdie "Total failure count $EXIT_CODE too big"
+        fi
+        exit $((EXIT_CODE <= 255 ? EXIT_CODE : 255));
 }
 
 addtrap() {