selftest: Catch error codes from failing testsuites
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Thu, 6 Apr 2023 04:31:09 +0000 (16:31 +1200)
committerAndreas Schneider <asn@cryptomilk.org>
Wed, 12 Apr 2023 14:57:55 +0000 (14:57 +0000)
commit2ff55b3da7141d7e290f832730750e6fad10bddc
tree8533a9f789a694e4b8ce57938888a76b83c8b45f
parent62893486c62a2cf08191cdc92f851b2815461a59
selftest: Catch error codes from failing testsuites

Testsuites declared with functions such as plantestsuite() are not run
directly, but are piped through filter-subunit. The overall exit code of
the executed test command is that returned by the last command in the
pipeline (that is, filter-subunit), and thus the actual testsuite return
code is lost.

A real consequence of this is that an error in setUpClass() in a Python
testsuite causes the whole testsuite to be skipped silently.

The --fail-on-empty option partially addressed this, but didn't help if
the testsuite contained multiple test classes, only one of which
contained an error.

We now use bash with the pipefail option, which makes the return code of
the last failing command into the return code of the entire pipeline.
That means that we properly fail if a testsuite returns a non-zero exit
code, but doesn't otherwise exhibit any failures in its output.

This doesn't help for cases where a testsuite has other failing tests
that become xfails due to knownfail entries. In that case, the overall
'testsuite-failure' will be turned into 'testsuite-xfail' by
filter-subunit and the silent failures will remain unheeded. Still, this
is better than the existing situation.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Wed Apr 12 14:57:55 UTC 2023 on atb-devel-224
selftest/selftest.pl