- EMACS_SERVER="notmuch-test-suite-$$"
- "$TMP_DIRECTORY/run_emacs" \
- --daemon \
- --eval "(setq server-name \"$EMACS_SERVER\")" \
- --eval "(orphan-watchdog $$)" || return
+ emacs_tests="${this_test}.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 (or 'vt100' in case user's TERM is unset, empty
+ # or 'dumb') is given to dtach which assumes a minimally
+ # VT100-compatible terminal -- and emacs inherits that
+ TERM=$DTACH_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 '()' >/dev/null 2>/dev/null; do
+ sleep 1
+ done