]> git.notmuchmail.org Git - notmuch/blobdiff - test/test-lib.sh
test: move subtest variables reset into a dedicated function
[notmuch] / test / test-lib.sh
old mode 100755 (executable)
new mode 100644 (file)
index 87f78c9..0735b5c
@@ -398,6 +398,8 @@ emacs_deliver_message ()
           (insert \"${body}\")
           $@
           (message-send-and-exit))"
+    # opportunistically quit smtp-dummy in case above fails.
+    { echo QUIT > /dev/tcp/localhost/25025; } 2>/dev/null
     wait ${smtp_dummy_pid}
     notmuch new >/dev/null
 }
@@ -427,7 +429,7 @@ test_begin_subtest ()
        error "bug in test script: Missing test_expect_equal in ${BASH_SOURCE[1]}:${BASH_LINENO[0]}"
     fi
     test_subtest_name="$1"
-    test_subtest_known_broken_=
+    test_reset_state_
     # Remember stdout and stderr file descriptors and redirect test
     # output to the previously prepared file descriptors 3 and 4 (see
     # below)
@@ -579,14 +581,14 @@ test_failure_message_ () {
 }
 
 test_known_broken_ok_ () {
-       test_subtest_known_broken_=
+       test_reset_state_
        test_fixed=$(($test_fixed+1))
        say_color pass "%-6s" "FIXED"
        echo " $@"
 }
 
 test_known_broken_failure_ () {
-       test_subtest_known_broken_=
+       test_reset_state_
        test_broken=$(($test_broken+1))
        test_failure_message_ "BROKEN" "$@"
        return 1
@@ -622,7 +624,7 @@ test_skip () {
        fi
        case "$to_skip" in
        t)
-               test_subtest_known_broken_=
+               test_reset_state_
                say_color skip >&3 "skipping test: $@"
                say_color skip "%-6s" "SKIP"
                echo " $1"
@@ -847,7 +849,7 @@ test_emacs () {
                # start a detached session with an emacs server
                # user's TERM is given to dtach which assumes a minimally
                # VT100-compatible terminal -- and emacs inherits that
-               TERM=$ORIGINAL_TERM dtach -n "$TMP_DIRECTORY/emacs-dtach-socket.$$" \
+               TERM=$ORIGINAL_TERM dtach -n "$TEST_TMPDIR/emacs-dtach-socket.$$" \
                        sh -c "stty rows 24 cols 80; exec '$TMP_DIRECTORY/run_emacs' \
                                --no-window-system \
                                --eval '(setq server-name \"$EMACS_SERVER\")' \
@@ -862,6 +864,10 @@ test_emacs () {
        emacsclient --socket-name="$EMACS_SERVER" --eval "(progn $@)"
 }
 
+test_reset_state_ () {
+       test_subtest_known_broken_=
+}
+
 
 find_notmuch_path ()
 {