]> git.notmuchmail.org Git - notmuch/blobdiff - test/test-lib.sh
python: move Threads class into its own file
[notmuch] / test / test-lib.sh
index 0da60fbbf5e3a03e9ffc0b173cb738196b71815a..063a2b273049c18a9ba95cbede3348063a174d3b 100644 (file)
@@ -503,6 +503,35 @@ test_expect_equal_file ()
     fi
 }
 
+test_emacs_expect_t () {
+       test "$#" = 2 && { prereq=$1; shift; } || prereq=
+       test "$#" = 1 ||
+       error "bug in the test script: not 1 or 2 parameters to test_emacs_expect_t"
+
+       # Run the test.
+       if ! test_skip "$test_subtest_name"
+       then
+               test_emacs "(notmuch-test-run $1)" >/dev/null
+
+               # Restore state after the test.
+               exec 1>&6 2>&7          # Restore stdout and stderr
+               inside_subtest=
+
+               # Report success/failure.
+               result=$(cat OUTPUT)
+               if [ "$result" = t ]
+               then
+                       test_ok_ "$test_subtest_name"
+               else
+                       test_failure_ "$test_subtest_name" "${result}"
+               fi
+       else
+               # Restore state after the (non) test.
+               exec 1>&6 2>&7          # Restore stdout and stderr
+               inside_subtest=
+       fi
+}
+
 NOTMUCH_NEW ()
 {
     notmuch new | grep -v -E -e '^Processed [0-9]*( total)? file|Found [0-9]* total file'
@@ -673,8 +702,8 @@ test_skip () {
 
 test_check_missing_external_prereqs_ () {
        if test -n "$test_subtest_missing_external_prereqs_"; then
-               say_color skip >&3 "missing prerequisites:"
-               echo "$test_subtest_missing_external_prereqs_" >&3
+               say_color skip >&1 "missing prerequisites:"
+               echo "$test_subtest_missing_external_prereqs_" >&1
                test_report_skip_ "$@"
        else
                false
@@ -914,6 +943,12 @@ test_emacs () {
        test -z "$missing_dependencies" || return
 
        if [ -z "$EMACS_SERVER" ]; then
+               emacs_tests="$(basename $0).el"
+               if [ -f "$TEST_DIRECTORY/$emacs_tests" ]; then
+                       load_emacs_tests="--eval '(load \"$emacs_tests\")'"
+               else
+                       load_emacs_tests=
+               fi
                server_name="notmuch-test-suite-$$"
                # start a detached session with an emacs server
                # user's TERM is given to dtach which assumes a minimally
@@ -921,12 +956,13 @@ test_emacs () {
                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 \
+                               $load_emacs_tests \
                                --eval '(setq server-name \"$server_name\")' \
                                --eval '(server-start)' \
                                --eval '(orphan-watchdog $$)'" || return
                EMACS_SERVER="$server_name"
                # wait until the emacs server is up
-               until test_emacs '()' 2>/dev/null; do
+               until test_emacs '()' >/dev/null 2>/dev/null; do
                        sleep 1
                done
        fi