diff options
author | Dmitry Kurochkin <dmitry.kurochkin@gmail.com> | 2011-06-28 08:56:17 +0400 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2011-06-28 17:10:55 -0700 |
commit | a854d06e92645350b7ec3f6cd1a10a2f6933104f (patch) | |
tree | 652225103630b0f9af84a90d6a191ea9acd826dd /test/test-lib.sh | |
parent | 6ea26cfb81c68526b157a213d00b593d4e7b1335 (diff) |
test: use emacsclient(1) for Emacs tests
Before the change, every Emacs test ran in a separate Emacs
instance. Starting Emacs many times wastes considerable time and
it gets worse as the test suite grows. The patch solves this by
using a single Emacs server and emacsclient(1) to run multiple
tests. Emacs server is started on the first test_emacs call and
stopped when test_done is called. We take care not to leave
orphan Emacs processes behind when test is terminated by whatever
reason: Emacs server runs a watchdog that periodically checks
that the test is still running.
Some tests need to provide user input. Before the change, this
was done using echo(1) to Emacs stdin. This no longer works and
instead `standard-input' variable is set accordingly to make
`read' return the appropriate string.
Diffstat (limited to 'test/test-lib.sh')
-rwxr-xr-x | test/test-lib.sh | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/test/test-lib.sh b/test/test-lib.sh index 7d39d27..079d7db 100755 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -831,6 +831,8 @@ test_done () { echo + [ -n "$EMACS_SERVER" ] && test_emacs '(kill-emacs)' + if [ "$test_failure" = "0" ]; then if [ "$test_broken" = "0" ]; then rm -rf "$remove_tmp" @@ -850,16 +852,8 @@ emacs_generate_script () { export PATH=$PATH export NOTMUCH_CONFIG=$NOTMUCH_CONFIG -# We assume that the user will give a command-line argument only if -# wanting to run in batch mode. -if [ \$# -gt 0 ]; then - BATCH=--batch -fi - # Here's what we are using here: # -# --batch: Quit after given commands and print all (messages) -# # --no-init-file Don't load users ~/.emacs # # --no-site-file Don't load the site-wide startup stuff @@ -868,16 +862,24 @@ fi # # --load Force loading of notmuch.el and test-lib.el -emacs \$BATCH --no-init-file --no-site-file \ +emacs --no-init-file --no-site-file \ --directory "$TEST_DIRECTORY/../emacs" --load notmuch.el \ --directory "$TEST_DIRECTORY" --load test-lib.el \ - --eval "(progn \$@)" + "\$@" EOF chmod a+x "$TMP_DIRECTORY/run_emacs" } test_emacs () { - "$TMP_DIRECTORY/run_emacs" "$@" + if [ -z "$EMACS_SERVER" ]; then + EMACS_SERVER="notmuch-test-suite-$$" + "$TMP_DIRECTORY/run_emacs" \ + --daemon \ + --eval "(setq server-name \"$EMACS_SERVER\")" \ + --eval "(orphan-watchdog $$)" || return + fi + + emacsclient --socket-name="$EMACS_SERVER" --eval "(progn $@)" } |