X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=test%2Ftest-lib.sh;h=4a8ef1f46b478b376728b3c15965fbddf9a4a9df;hb=36492f20a71906413d9922dbad5e18571059f57a;hp=29ec0083e4170e1053bd6e94a56c52c3a4274cb6;hpb=6a833a6e83865f6999707cc30768d07e1351c2cb;p=notmuch diff --git a/test/test-lib.sh b/test/test-lib.sh index 29ec0083..4a8ef1f4 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -223,15 +223,15 @@ test_fixed=0 test_broken=0 test_success=0 -_die_common () { +_exit_common () { code=$? trap - EXIT set +ex rm -rf "$TEST_TMPDIR" } -die () { - _die_common +trap_exit () { + _exit_common if test -n "$GIT_EXIT_OK" then exit $code @@ -245,17 +245,27 @@ die () { fi } -die_signal () { - _die_common +trap_signal () { + _exit_common echo >&6 "FATAL: $0: interrupted by signal" $((code - 128)) exit $code } +die () { + _exit_common + exec >&6 + say_color error '%-6s' FATAL + echo " $*" + echo + echo "Unexpected exit while executing $0." + exit 1 +} + GIT_EXIT_OK= # Note: TEST_TMPDIR *NOT* exported! TEST_TMPDIR=$(mktemp -d "${TMPDIR:-/tmp}/notmuch-test-$$.XXXXXX") -trap 'die' EXIT -trap 'die_signal' HUP INT TERM +trap 'trap_exit' EXIT +trap 'trap_signal' HUP INT TERM test_decode_color () { sed -e 's/.\[1m//g' \ @@ -544,7 +554,7 @@ add_email_corpus () cp -a $TEST_DIRECTORY/corpus.mail ${MAIL_DIR} else cp -a $TEST_DIRECTORY/corpus ${MAIL_DIR} - notmuch new >/dev/null + notmuch new >/dev/null || die "'notmuch new' failed while adding email corpus" cp -a ${MAIL_DIR} $TEST_DIRECTORY/corpus.mail fi }