]> git.notmuchmail.org Git - notmuch/blobdiff - test/test-lib.sh
test: avoid using screen(1) configuration files
[notmuch] / test / test-lib.sh
index 196ef49624a64995f2cc83758150deafdf5a8de1..c81c709b511ffbbbee1205379a4dd6ce8ee67e2a 100755 (executable)
@@ -50,6 +50,8 @@ TZ=UTC
 TERM=dumb
 export LANG LC_ALL PAGER TERM TZ
 GIT_TEST_CMP=${GIT_TEST_CMP:-diff -u}
+export SCREENRC=/dev/null
+export SYSSCREENRC=/dev/null
 
 # Protect ourselves from common misconfiguration to export
 # CDPATH into the environment
@@ -449,7 +451,7 @@ test_expect_equal ()
 
        output="$1"
        expected="$2"
-       if ! test_skip "$@"
+       if ! test_skip "$test_subtest_name"
        then
                if [ "$output" = "$expected" ]; then
                        test_ok_ "$test_subtest_name"
@@ -462,6 +464,7 @@ test_expect_equal ()
     fi
 }
 
+# Like test_expect_equal, but takes two filenames.
 test_expect_equal_file ()
 {
        exec 1>&6 2>&7          # Restore stdout and stderr
@@ -472,7 +475,7 @@ test_expect_equal_file ()
 
        output="$1"
        expected="$2"
-       if ! test_skip "$@"
+       if ! test_skip "$test_subtest_name"
        then
                if diff -q "$expected" "$output" >/dev/null ; then
                        test_ok_ "$test_subtest_name"
@@ -563,6 +566,7 @@ test_failure_ () {
        test_failure=$(($test_failure + 1))
        test_failure_message_ "FAIL" "$@"
        test "$immediate" = "" || { GIT_EXIT_OK=t; exit 1; }
+       return 1
 }
 
 test_failure_message_ () {
@@ -574,14 +578,17 @@ test_failure_message_ () {
 }
 
 test_known_broken_ok_ () {
+       test_subtest_known_broken_=
        test_fixed=$(($test_fixed+1))
        say_color pass "%-6s" "FIXED"
        echo " $@"
 }
 
 test_known_broken_failure_ () {
+       test_subtest_known_broken_=
        test_broken=$(($test_broken+1))
        test_failure_message_ "BROKEN" "$@"
+       return 1
 }
 
 test_debug () {
@@ -614,6 +621,7 @@ test_skip () {
        fi
        case "$to_skip" in
        t)
+               test_subtest_known_broken_=
                say_color skip >&3 "skipping test: $@"
                say_color skip "%-6s" "SKIP"
                echo " $1"
@@ -719,7 +727,7 @@ test_external_without_stderr () {
        fi
 }
 
-# This is not among top-level (test_expect_success | test_expect_failure)
+# This is not among top-level (test_expect_success)
 # but is a prefix that can be used in the test script, like:
 #
 #      test_expect_success 'complain and die' '
@@ -835,10 +843,16 @@ EOF
 test_emacs () {
        if [ -z "$EMACS_SERVER" ]; then
                EMACS_SERVER="notmuch-test-suite-$$"
-               "$TMP_DIRECTORY/run_emacs" \
-                       --daemon \
+               # start a detached screen session with an emacs server
+               screen -S "$EMACS_SERVER" -d -m "$TMP_DIRECTORY/run_emacs" \
+                       --no-window-system \
                        --eval "(setq server-name \"$EMACS_SERVER\")" \
+                       --eval '(server-start)' \
                        --eval "(orphan-watchdog $$)" || return
+               # wait until the emacs server is up
+               until test_emacs '()' 2>/dev/null; do
+                       sleep 1
+               done
        fi
 
        emacsclient --socket-name="$EMACS_SERVER" --eval "(progn $@)"