diff options
| author | Tomi Ollila <tomi.ollila@iki.fi> | 2021-05-17 11:11:09 +0300 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2021-06-07 20:16:33 -0300 |
| commit | 6f0f83660e222cfdd05b05ad134763a7ab26f097 (patch) | |
| tree | 5e95ce0a8fb9a8e02014683782ee96b4d6952173 /test/notmuch-test | |
| parent | 651a1b085be106aa9761c464429d88e34157fc2a (diff) | |
test: aggregate-results updates
notmuch-test will now call aggregate-results.sh with file list
that it compiles based on the test ran, and aggregate-results
will report failure is any of the test files are missing.
With this notmuch-test no longer has to exit in non-parallel
run if some test fail to write its report file -- so it works
as parallel tests in this sense.
Changed test_done() in test-lib.sh write report file in one write(2),
so there is (even) less chance it being partially written. Also,
now it writes 'total' last and aggregate-results.sh expects this
line to exist in all report files for reporting to be successful.
Added 'set -eu' to notmuch-test and modified code to work with
these settings. That makes it harder to get mistakes slipped
into committed code.
Diffstat (limited to 'test/notmuch-test')
| -rwxr-xr-x | test/notmuch-test | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/test/notmuch-test b/test/notmuch-test index cbd33f93..ce142f7c 100755 --- a/test/notmuch-test +++ b/test/notmuch-test @@ -18,12 +18,14 @@ fi # Ensure NOTMUCH_SRCDIR and NOTMUCH_BUILDDIR are set. . $(dirname "$0")/export-dirs.sh || exit 1 +set -eu + TESTS= -for test in $NOTMUCH_TESTS; do +for test in ${NOTMUCH_TESTS-}; do TESTS="$TESTS $NOTMUCH_SRCDIR/test/$test" done -if [[ -z "$TESTS" ]]; then +if [ -z "$TESTS" ]; then TESTS="$NOTMUCH_SRCDIR/test/T[0-9][0-9][0-9]-*.sh" fi @@ -44,43 +46,46 @@ else TEST_TIMEOUT_CMD="" fi -trap 'e=$?; kill $!; exit $e' HUP INT TERM - META_FAILURE= +RES=0 # Run the tests -if test -z "$NOTMUCH_TEST_SERIALIZE" && command -v parallel >/dev/null ; then +if test -z "${NOTMUCH_TEST_SERIALIZE-}" && command -v parallel >/dev/null ; then test -t 1 && export COLORS_WITHOUT_TTY=t || : if parallel --version 2>&1 | grep -q GNU ; then echo "INFO: running tests with GNU parallel" - printf '%s\n' $TESTS | $TEST_TIMEOUT_CMD parallel + printf '%s\n' $TESTS | $TEST_TIMEOUT_CMD parallel || RES=$? else echo "INFO: running tests with moreutils parallel" - $TEST_TIMEOUT_CMD parallel -- $TESTS + $TEST_TIMEOUT_CMD parallel -- $TESTS || RES=$? fi - RES=$? - if [[ $RES != 0 ]]; then + if [ $RES != 0 ]; then META_FAILURE="parallel test suite returned error code $RES" fi else + trap 'e=$?; trap - 0; kill ${!-}; exit $e' 0 HUP INT TERM for test in $TESTS; do $TEST_TIMEOUT_CMD $test "$@" & - wait $! - # If the test failed without producing results, then it aborted, - # so we should abort, too. - RES=$? - testname=$(basename $test .sh) - if [[ $RES != 0 && ! -e "$NOTMUCH_BUILDDIR/test/test-results/$testname" ]]; then - META_FAILURE="Aborting on $testname (returned $RES)" - break - fi + wait $! && ev=0 || ev=$? + test $ev = 0 || RES=$ev done + trap - 0 HUP INT TERM + if [ $RES != 0 ]; then + META_FAILURE="some tests failed; first failed returned error code $RES" + fi fi -trap - HUP INT TERM # Report results +RESULT_FILES= +for file in $TESTS +do + file=${file##*/} # drop leading path components + file=${file%.sh} # drop trailing '.sh' + RESULT_FILES="$RESULT_FILES $NOTMUCH_BUILDDIR/test/test-results/$file" +done + echo -$NOTMUCH_SRCDIR/test/aggregate-results.sh $NOTMUCH_BUILDDIR/test/test-results/* -ev=$? +$NOTMUCH_SRCDIR/test/aggregate-results.sh $RESULT_FILES && ev=0 || ev=$? + if [ -n "$META_FAILURE" ]; then printf 'ERROR: %s\n' "$META_FAILURE" if [ $ev = 0 ]; then |
