Bug#703250: apt: failing tests in test/libapt does not cause FTBFS
On Mon, Mar 18, 2013 at 08:54:02AM +0800, Daniel Hartwig wrote:
> On 18 March 2013 04:05, Michael Vogt <mvo@debian.org> wrote:
> > This patch looks good! I commited it to bzr. Unfortunately its not
> > sufficient as current a msgfail() in framework will not cause a != 0
> > exit status. So to properly fix this some more work is needed.
> >
> > The attached (additional) patch should make it work now.
>
> Hello
>
> This makes it so the first failure prevents later tests in the same
> file from running. It can be bothersome to diagnose faults if e.g.
> individual tests are not properly ordered, or are otherwise
> independent of each other. Some test frameworks avoid such early
> abort and run all tests.
Great! I like this better than my original approach of failing too
early. Attached is a small variation that will also count the number
of failures, the obvious issue is that failure numbers > 255 in a
single test can not be reported via the exit code. The diff is against
your patch (and also against the "debian-sid" branch in bzr).
Cheers,
Michael
=== modified file 'test/integration/framework'
--- test/integration/framework 2013-03-18 07:08:37 +0000
+++ test/integration/framework 2013-03-18 07:22:26 +0000
@@ -1,6 +1,6 @@
#!/bin/sh -- # no runable script, just for vi
-TESTFAILURES="no"
+TESTFAILURES=0
# we all like colorful messages
if expr match "$(readlink -f /proc/$$/fd/1)" '/dev/pts/[0-9]\+' > /dev/null && \
@@ -38,7 +38,7 @@
}
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; TESTFAILURES=$((TESTFAILURES+1)); }
# enable / disable Debugging
MSGLEVEL=${MSGLEVEL:-3}
@@ -116,7 +116,8 @@
}
exitwithstatus() {
- [ "$TESTFAILURES" = "yes" ] && exit 1 || exit 0;
+ # the "% 255" ensures the exit it != 0 even on overflow
+ exit $((TESTFAILURES | TESTFAILURES % 255));
}
addtrap() {
Reply to: