[PATCH 06/13] test: run emacs inside screen

Subject: [PATCH 06/13] test: run emacs inside screen

Date: Mon, 3 Oct 2011 18:47:20 +0200

To: notmuch@notmuchmail.org

Cc:

From: Thomas Jost


From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>

Before the change, emacs run in daemon mode without any visible
buffers.  Turns out that this affects emacs behavior in some
cases.  In particular, `window-end' function returns `point-max'
instead of the last visible position.  That makes it hard or
impossible to implement some tests.  The patch runs emacs in a
detached screen(1) session.  So that it works exactly as if it
has a visible window.

Note: screen terminates when emacs exits.  So the patch does not
introduce new "running processes left behind" issues.
---
 test/test-lib.sh |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index 8e16a7e..f9fd73e 100755
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -852,14 +852,22 @@ EOF
 
 test_emacs () {
 	if [ -z "$EMACS_SERVER" ]; then
+		# start a detached screen session with an emacs server
+		which screen &>/dev/null || return
 		EMACS_SERVER="notmuch-test-suite-$$"
-		"$TMP_DIRECTORY/run_emacs" \
-			--daemon \
+		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
+	if [ "$EMACS_SERVER" ]; then
+		emacsclient --socket-name="$EMACS_SERVER" --eval "(progn $@)"
 	fi
-
-	emacsclient --socket-name="$EMACS_SERVER" --eval "(progn $@)"
 }
 
 
-- 
1.7.6.4


Thread: