From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 9CEB0431FD0 for ; Mon, 27 Jun 2011 13:02:15 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.699 X-Spam-Level: X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id r+t7R3j7oRzQ for ; Mon, 27 Jun 2011 13:02:14 -0700 (PDT) Received: from mail-qw0-f53.google.com (mail-qw0-f53.google.com [209.85.216.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id CEC3D431FB6 for ; Mon, 27 Jun 2011 13:02:13 -0700 (PDT) Received: by qwb7 with SMTP id 7so3029177qwb.26 for ; Mon, 27 Jun 2011 13:02:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=g0fn8cOw3LUHNjKg/ZqatePchiyE4lRQxfkbJ3GESK4=; b=QOfV0Zgc5uznIpYVy7iH3quXEh7r754aqaaCTyV9YSIZSQ9lYSaEYI0oMpBIeQ/w+v NzYCUQU2eTB5e1wxcNicbYiWXVHF0d9RjWP7MpWZ+SbSgXerpNO3qq4L6u2myrFTOGSC MhCOmlZRHtKufJ5jKkeTgI/FaSAbEzlB5j5Zc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=fIZEg/5qLTt4wreQaQUE015xw4MjezudVASYkf7Qi0NRCcaGfP3q3OrIe5P0glCF07 AXcHl0Xwx8X/52pAoVa6VbFUZFYqgmypTfAmgo0iuwa81tKI2X75+fjxiC9EEuO+5JDV +aWUKPRo2BbcnepJJsf73N76VyT7vNd84z9CY= MIME-Version: 1.0 Received: by 10.229.31.1 with SMTP id w1mr5017289qcc.138.1309204932843; Mon, 27 Jun 2011 13:02:12 -0700 (PDT) Sender: amdragon@gmail.com Received: by 10.229.32.197 with HTTP; Mon, 27 Jun 2011 13:02:12 -0700 (PDT) In-Reply-To: <1309146846-30991-2-git-send-email-dmitry.kurochkin@gmail.com> References: <1309132379-24089-1-git-send-email-dmitry.kurochkin@gmail.com> <1309146846-30991-1-git-send-email-dmitry.kurochkin@gmail.com> <1309146846-30991-2-git-send-email-dmitry.kurochkin@gmail.com> Date: Mon, 27 Jun 2011 16:02:12 -0400 X-Google-Sender-Auth: sYb_aZUXipdxhfxamd47bUKh1w8 Message-ID: Subject: Re: [PATCH 2/2] test: use emacsclient(1) for Emacs tests From: Austin Clements To: Dmitry Kurochkin Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: notmuch@notmuchmail.org X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Jun 2011 20:02:15 -0000 This looks like a great idea! The test suite has been getting irritating s= low. A few minor comments: This patch would be clearer if it the setq-to-let translation were a separate patch. It would also be worth adding a big comment at the top of the test explaining why all of the tests let-bind everything instead of setq'ing, primarily for the benefit of people writing new tests. I might just be having trouble reading the patch, but the difference between emacs_start and emacs_server_start seems unclear. Perhaps the comments should explain how somebody would use these scripts? My bigger concern with this change is that it may leave behind stale emacs daemons if the script gets interrupted. The only way I know to reliably kill a child process is to open a pipe to it and have it exit on its own when it reads EOF. Unfortunately, I couldn't find a way to do this with an emacs daemon (it appears daemon mode aggressively cleans up things like pipes), but here's a different approach: coproc emacs --batch --eval "(while t (eval (read)))" EMACSFD=3D${COPROC[1]} trap "echo '(kill-emacs)' >&$EMACSFD" EXIT echo '(message "Hi")' >&$EMACSFD # ... This is, basically, a poor man's emacs server, but the coprocess pipe binds it tightly to the shell. If the shell exits for *any* reason, the pipe will be closed by the kernel, emacs will read an EOF, and exit. The trap is there just to cleanly shut down in case of a normal exit [1]. This also has the advantage that read-from-minibuffer still works: echo '(message (read-from-minibuffer ""))' >&$EMACSFD echo 'Test' >&$EMACSFD Thoughts? [1] If you don't do this, emacs complains that it can't read from stdin before it exits. It would be nice to catch this condition in the elisp code and not bother with the trap, but the error thrown is just an 'error, so I don't think we can catch and ignore it without catching and ignoring *all* errors. On Sun, Jun 26, 2011 at 11:54 PM, Dmitry Kurochkin wrote: > Before the change, every Emacs tests ran in a separate Emacs > instance. =A0Starting Emacs many times wastes considerable time and > it gets worse as the test suite grows. =A0The patch solves this by > using a single Emacs server and emacsclient(1) to run multiple > tests. =A0Emacs server is started on the first test_emacs call and > stopped when test_done is called or the test is killed by a > signal. =A0Several auxiliary scripts useful for debugging and test > development are generated instead of the run_emacs script: > > =A0* emacs_server_start - start Emacs server > =A0* emacs_server_stop =A0- stop Emacs server > =A0* emacs_start =A0 =A0 =A0 =A0- start Emacs > =A0* emacs_run =A0 =A0 =A0 =A0 =A0- execute ELisp expressions in running = Emacs server > > Since multiple tests are run in a single Emacs instance, they > must not change Emacs environment because it may affect other > tests. =A0For now, the only Emacs environment modifications done by > the tests are variable settings. =A0Before the change, variables > were set with `setq' which affected other tests. =A0The patch > changes all variables to use `let', so the scope of the change is > limited to a single test. > --- > =A0test/emacs =A0 =A0 =A0 | =A0 74 +++++++++++++------------- > =A0test/test-lib.el | =A0 =A06 ++ > =A0test/test-lib.sh | =A0149 ++++++++++++++++++++++++++++++++++++++++++--= --------- > =A03 files changed, 161 insertions(+), 68 deletions(-) > > diff --git a/test/emacs b/test/emacs > index 4f16b41..f1939dc 100755 > --- a/test/emacs > +++ b/test/emacs > @@ -12,20 +12,20 @@ test_emacs '(notmuch-hello) > =A0test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello > > =A0test_begin_subtest "Saved search with 0 results" > -test_emacs '(setq notmuch-show-empty-saved-searches t) > - =A0 =A0 =A0 =A0 =A0 (setq notmuch-saved-searches > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 '\''(("inbox" . "tag:inbox") > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0("unread" . "tag:unread") > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0("empty" . "tag:doesnotexist= "))) > - =A0 =A0 =A0 =A0 =A0 (notmuch-hello) > - =A0 =A0 =A0 =A0 =A0 (test-output)' > +test_emacs '(let ((notmuch-show-empty-saved-searches t) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-saved-searches > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0'\''(("inbox" . "tag:inbox") > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ("unread" . "tag:unread") > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ("empty" . "tag:doesnotexis= t")))) > + =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-hello) > + =A0 =A0 =A0 =A0 =A0 =A0 (test-output))' > =A0test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-with-empty > > =A0test_begin_subtest "No saved searches displayed (all with 0 results)" > -test_emacs '(setq notmuch-saved-searches > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 '\''(("empty" . "tag:doesnotexist"))) > - =A0 =A0 =A0 =A0 =A0 (notmuch-hello) > - =A0 =A0 =A0 =A0 =A0 (test-output)' > +test_emacs '(let ((notmuch-saved-searches > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0'\''(("empty" . "tag:doesnotexist"))= )) > + =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-hello) > + =A0 =A0 =A0 =A0 =A0 =A0 (test-output))' > =A0test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-no-saved-searche= s > > =A0test_begin_subtest "Basic notmuch-search view in emacs" > @@ -147,9 +147,9 @@ output=3D$(notmuch search 'subject:"testing message s= ent via SMTP"' | notmuch_sear > =A0test_expect_equal "$output" "thread:XXX =A0 2000-01-01 [1/1] Notmuch T= est Suite; Testing message sent via SMTP (inbox)" > > =A0test_begin_subtest "notmuch-fcc-dirs set to nil" > -test_emacs "(setq notmuch-fcc-dirs nil) > - =A0 =A0 =A0 =A0 =A0 (notmuch-mua-mail) > - =A0 =A0 =A0 =A0 =A0 (test-output)" > +test_emacs "(let ((notmuch-fcc-dirs nil)) > + =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-mua-mail) > + =A0 =A0 =A0 =A0 =A0 =A0 (test-output))" > =A0cat <EXPECTED > =A0From: Notmuch Test Suite > =A0To: > @@ -164,9 +164,9 @@ mkdir -p mail/sent-string/new > =A0mkdir -p mail/sent-string/tmp > > =A0test_begin_subtest "notmuch-fcc-dirs set to a string" > -test_emacs "(setq notmuch-fcc-dirs \"sent-string\") > - =A0 =A0 =A0 =A0 =A0 (notmuch-mua-mail) > - =A0 =A0 =A0 =A0 =A0 (test-output)" > +test_emacs "(let ((notmuch-fcc-dirs \"sent-string\")) > + =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-mua-mail) > + =A0 =A0 =A0 =A0 =A0 =A0 (test-output))" > =A0cat <EXPECTED > =A0From: Notmuch Test Suite > =A0To: > @@ -185,11 +185,11 @@ mkdir -p mail/failure/new > =A0mkdir -p mail/failure/tmp > > =A0test_begin_subtest "notmuch-fcc-dirs set to a list (with match)" > -test_emacs "(setq notmuch-fcc-dirs > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 '((\"notmuchmail.org\" . \"sent-list-ma= tch\") > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (\".*\" . \"failure\"))) > - =A0 =A0 =A0 =A0 =A0 (notmuch-mua-mail) > - =A0 =A0 =A0 =A0 =A0 (test-output)" > +test_emacs "(let ((notmuch-fcc-dirs > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0'((\"notmuchmail.org\" . \"sent-list= -match\") > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(\".*\" . \"failure\")))) > + =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-mua-mail) > + =A0 =A0 =A0 =A0 =A0 =A0 (test-output))" > =A0cat <EXPECTED > =A0From: Notmuch Test Suite > =A0To: > @@ -205,11 +205,11 @@ mkdir -p mail/sent-list-catch-all/new > =A0mkdir -p mail/sent-list-catch-all/tmp > > =A0test_begin_subtest "notmuch-fcc-dirs set to a list (catch-all)" > -test_emacs "(setq notmuch-fcc-dirs > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 '((\"example.com\" . \"failure\") > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (\".*\" . \"sent-list-catch-all\"))= ) > - =A0 =A0 =A0 =A0 =A0 (notmuch-mua-mail) > - =A0 =A0 =A0 =A0 =A0 (test-output)" > +test_emacs "(let ((notmuch-fcc-dirs > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0'((\"example.com\" . \"failure\") > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(\".*\" . \"sent-list-catch-all\= ")))) > + =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-mua-mail) > + =A0 =A0 =A0 =A0 =A0 =A0 (test-output))" > =A0cat <EXPECTED > =A0From: Notmuch Test Suite > =A0To: > @@ -220,11 +220,11 @@ EOF > =A0test_expect_equal_file OUTPUT EXPECTED > > =A0test_begin_subtest "notmuch-fcc-dirs set to a list (no match)" > -test_emacs "(setq notmuch-fcc-dirs > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 '((\"example.com\" . \"failure\") > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (\"nomatchhere.net\" . \"failure\")= )) > - =A0 =A0 =A0 =A0 =A0 (notmuch-mua-mail) > - =A0 =A0 =A0 =A0 =A0 (test-output)" > +test_emacs "(let ((notmuch-fcc-dirs > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0'((\"example.com\" . \"failure\") > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(\"nomatchhere.net\" . \"failure= \")))) > + =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-mua-mail) > + =A0 =A0 =A0 =A0 =A0 =A0 (test-output))" > =A0cat <EXPECTED > =A0From: Notmuch Test Suite > =A0To: > @@ -253,15 +253,15 @@ test_expect_equal_file OUTPUT EXPECTED > > =A0test_begin_subtest "Save attachment from within emacs using notmuch-sh= ow-save-attachments" > =A0# save as archive to test that Emacs does not re-compress .gz > -echo ./attachment1.gz | > -test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad= 0a@mail.gmail.com") > - =A0 =A0 =A0 =A0 =A0 (notmuch-show-save-attachments)' > /dev/null 2>&1 > +test_emacs '(let ((standard-input "\"attachment1.gz\"")) > + =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-show "id:cf0c4d610911171136h1713aa59w9= cf9aa31f052ad0a@mail.gmail.com") > + =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-show-save-attachments))' > =A0test_expect_equal_file "$EXPECTED/attachment" attachment1.gz > > =A0test_begin_subtest "Save attachment from within emacs using notmuch-sh= ow-save-part" > =A0# save as archive to test that Emacs does not re-compress .gz > -echo ./attachment2.gz | > -test_emacs '(notmuch-show-save-part "id:cf0c4d610911171136h1713aa59w9cf9= aa31f052ad0a@mail.gmail.com" 5)' > /dev/null 2>&1 > +test_emacs '(let ((standard-input "\"attachment2.gz\"")) > + =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-show-save-part "id:cf0c4d610911171136h= 1713aa59w9cf9aa31f052ad0a@mail.gmail.com" 5))' > /dev/null 2>&1 > =A0test_expect_equal_file "$EXPECTED/attachment" attachment2.gz > > =A0test_begin_subtest "View raw message within emacs" > diff --git a/test/test-lib.el b/test/test-lib.el > index 4e7f5cf..a5a3125 100644 > --- a/test/test-lib.el > +++ b/test/test-lib.el > @@ -23,6 +23,12 @@ > =A0;; avoid crazy 10-column default of --batch > =A0(set-frame-width (window-frame (get-buffer-window)) 80) > > +;; `read-file-name' by default uses `completing-read' function to read > +;; user input. =A0It does not respect `standard-input' variable which we > +;; use in tests to provide user input. =A0So replace it with a plain > +;; `read' call. > +(setq read-file-name-function (lambda (&rest _) (read))) > + > =A0(defun notmuch-test-wait () > =A0 "Wait for process completion." > =A0 (while (get-buffer-process (current-buffer)) > diff --git a/test/test-lib.sh b/test/test-lib.sh > index ad1506c..1c1581b 100755 > --- a/test/test-lib.sh > +++ b/test/test-lib.sh > @@ -57,6 +57,9 @@ unset CDPATH > > =A0unset GREP_OPTIONS > > +# PID of running Emacs server > +emacs_server_pid=3D > + > =A0# Convenience > =A0# > =A0# A regexp to match 5 and 40 hexdigits > @@ -174,6 +177,7 @@ test_success=3D0 > > =A0die () { > =A0 =A0 =A0 =A0code=3D$? > + =A0 =A0 =A0 emacs_server_stop > =A0 =A0 =A0 =A0if test -n "$GIT_EXIT_OK" > =A0 =A0 =A0 =A0then > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0exit $code > @@ -394,19 +398,20 @@ emacs_deliver_message () > =A0 =A0 mkdir -p "$MAIL_DIR"/sent/{cur,new,tmp} > =A0 =A0 ../smtp-dummy sent_message & > =A0 =A0 smtp_dummy_pid=3D$! > - =A0 =A0test_emacs "(setq message-send-mail-function 'message-smtpmail-s= end-it) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 (setq smtpmail-smtp-server \"localhost\") > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 (setq smtpmail-smtp-service \"25025\") > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-hello) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-mua-mail) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 (message-goto-to) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 (insert \"test_suite@notmuchmail.org\nDate:= 01 Jan 2000 12:00:00 -0000\") > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 (message-goto-subject) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 (insert \"${subject}\") > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 (message-goto-body) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 (insert \"${body}\") > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 $@ > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 (message-send-and-exit)" >/dev/null 2>&1 > + =A0 =A0test_emacs \ > + =A0 =A0 =A0 "(let ((message-send-mail-function 'message-smtpmail-send-i= t) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0(smtpmail-smtp-server \"localhost\") > + =A0 =A0 =A0 =A0 =A0 =A0 =A0(smtpmail-smtp-service \"25025\")) > + =A0 =A0 =A0 =A0 =A0(notmuch-hello) > + =A0 =A0 =A0 =A0 =A0(notmuch-mua-mail) > + =A0 =A0 =A0 =A0 =A0(message-goto-to) > + =A0 =A0 =A0 =A0 =A0(insert \"test_suite@notmuchmail.org\nDate: 01 Jan 2= 000 12:00:00 -0000\") > + =A0 =A0 =A0 =A0 =A0(message-goto-subject) > + =A0 =A0 =A0 =A0 =A0(insert \"${subject}\") > + =A0 =A0 =A0 =A0 =A0(message-goto-body) > + =A0 =A0 =A0 =A0 =A0(insert \"${body}\") > + =A0 =A0 =A0 =A0 =A0$@ > + =A0 =A0 =A0 =A0 =A0(message-send-and-exit))" >/dev/null 2>&1 > =A0 =A0 wait ${smtp_dummy_pid} > =A0 =A0 notmuch new >/dev/null > =A0} > @@ -828,6 +833,8 @@ test_done () { > > =A0 =A0 =A0 =A0echo > > + =A0 =A0 =A0 emacs_server_stop > + > =A0 =A0 =A0 =A0if [ "$test_failure" =3D "0" ]; then > =A0 =A0 =A0 =A0 =A0 =A0if [ "$test_broken" =3D "0" ]; then > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0rm -rf "$remove_tmp" > @@ -838,24 +845,26 @@ test_done () { > =A0 =A0 =A0 =A0fi > =A0} > > -test_emacs () { > - =A0 =A0 =A0 # Construct a little test script here for the benefit of th= e user, > - =A0 =A0 =A0 # (who can easily run "run_emacs" to get the same emacs env= ironment > - =A0 =A0 =A0 # for investigating any failures). > - =A0 =A0 =A0 cat < run_emacs > +# Generate some scripts for running Emacs tests. =A0These scripts are > +# used by Emacs tests and help investigating failures. =A0The following > +# scripts are generated: > +# > +# * emacs_server_start - start Emacs server > +# * emacs_server_stop =A0- stop Emacs server > +# * emacs_start =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0- start Emacs > +# * emacs_run =A0 =A0 =A0 =A0 =A0- execute ELisp expressions in running = Emacs server > +emacs_generate_scripts () > +{ > + =A0 =A0 =A0 server_name=3D"notmuch-test-suite-$$" > + > + =A0 =A0 =A0 cat < "$TMP_DIRECTORY/emacs_server_start" > =A0#!/bin/sh > =A0export PATH=3D$PATH > =A0export NOTMUCH_CONFIG=3D$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 > - =A0 =A0 =A0 BATCH=3D--batch > -fi > - > =A0# Here's what we are using here: > =A0# > -# --batch: =A0 =A0 =A0 =A0 =A0 =A0 Quit after given commands and print a= ll (messages) > +# --daemon =A0 =A0 =A0 =A0 =A0 =A0 Start Emacs as a daemon > =A0# > =A0# --no-init-file =A0 =A0 =A0 Don't load users ~/.emacs > =A0# > @@ -865,13 +874,90 @@ fi > =A0# > =A0# --load =A0 =A0 =A0 =A0 =A0 =A0 =A0 Force loading of notmuch.el and t= est-lib.el > > -emacs \$BATCH --no-init-file --no-site-file \ > - =A0 =A0 =A0 --directory ../../emacs --load notmuch.el \ > - =A0 =A0 =A0 --directory .. --load test-lib.el \ > - =A0 =A0 =A0 --eval "(progn \$@)" > +emacs --daemon --no-init-file --no-site-file \ > + =A0 =A0 =A0 --directory "$TEST_DIRECTORY/../emacs" --load notmuch.el \ > + =A0 =A0 =A0 --directory "$TEST_DIRECTORY" --load test-lib.el \ > + =A0 =A0 =A0 --eval '(setq server-name "$server_name")' > +EOF > + =A0 =A0 =A0 chmod a+x "$TMP_DIRECTORY/emacs_server_start" > + > + =A0 =A0 =A0 cat < "$TMP_DIRECTORY/emacs_server_stop" > +#!/bin/sh > + > +dir=3D\$(dirname "\$0") > +"\$dir"/emacs_run '(kill-emacs)' > =A0EOF > - =A0 =A0 =A0 chmod a+x ./run_emacs > - =A0 =A0 =A0 ./run_emacs "$@" > + =A0 =A0 =A0 chmod a+x "$TMP_DIRECTORY/emacs_server_stop" > + > + =A0 =A0 =A0 cat < "$TMP_DIRECTORY/emacs_start" > +#!/bin/sh > +export PATH=3D$PATH > +export NOTMUCH_CONFIG=3D$NOTMUCH_CONFIG > + > +# Here's what we are using here: > +# > +# --no-init-file =A0 =A0 =A0 Don't load users ~/.emacs > +# > +# --no-site-file =A0 =A0 =A0 Don't load the site-wide startup stuff > +# > +# --directory =A0 =A0 =A0 =A0 =A0Ensure that the local elisp sources are= found > +# > +# --load =A0 =A0 =A0 =A0 =A0 =A0 =A0 Force loading of notmuch.el and tes= t-lib.el > + > +emacs --no-init-file --no-site-file \ > + =A0 =A0 =A0 --directory "$TEST_DIRECTORY/../emacs" --load notmuch.el \ > + =A0 =A0 =A0 --directory "$TEST_DIRECTORY" --load test-lib.el > +EOF > + =A0 =A0 =A0 chmod a+x "$TMP_DIRECTORY/emacs_start" > + > + =A0 =A0 =A0 cat < "$TMP_DIRECTORY/emacs_run" > +#!/bin/sh > + > +# Here's what we are using here: > +# > +# --socket-name =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Emacs server name > +# > +# --eval =A0 =A0 =A0 =A0 =A0 =A0 =A0 Evaluate ELisp expressions > + > +emacsclient --socket-name "$server_name" --eval "(progn \$@)" > +EOF > + =A0 =A0 =A0 chmod a+x "$TMP_DIRECTORY/emacs_run" > +} > + > +# Start Emacs server if it is not running. > +emacs_server_start () > +{ > + =A0 =A0 =A0 [ -n "$emacs_server_pid" ] && return > + > + =A0 =A0 =A0 output=3D$("$TMP_DIRECTORY/emacs_server_start" 2>&1) > + =A0 =A0 =A0 if [ "$?" -ne 0 ]; then > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 echo "$output" > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return 1 > + =A0 =A0 =A0 fi > + > + =A0 =A0 =A0 emacs_server_pid=3D$("$TMP_DIRECTORY/emacs_run" '(emacs-pid= )') > + =A0 =A0 =A0 [ "$?" -eq 0 -a -n "$emacs_server_pid" ] > +} > + > +# Stop Emacs server if it is running. > +emacs_server_stop () > +{ > + =A0 =A0 =A0 [ -z "$emacs_server_pid" ] && return > + > + =A0 =A0 =A0 emacs_server_pid=3D > + =A0 =A0 =A0 output=3D$("$TMP_DIRECTORY/emacs_server_stop" 2>&1) > + =A0 =A0 =A0 if [ "$?" -ne 0 ]; then > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 echo "$output" > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return 1 > + =A0 =A0 =A0 fi > +} > + > +# Evaluate ELisp expressions in Emacs server. =A0Server is started if it > +# is not running. > +test_emacs () { > + =A0 =A0 =A0 emacs_server_start || return > + > + =A0 =A0 =A0 "$TMP_DIRECTORY/emacs_run" "$@" > =A0} > > > @@ -999,6 +1085,7 @@ primary_email=3Dtest_suite@notmuchmail.org > =A0other_email=3Dtest_suite_other@notmuchmail.org;test_suite@otherdomain.= org > =A0EOF > > +emacs_generate_scripts > > =A0# Use -P to resolve symlinks in our working directory so that the cwd > =A0# in subprocesses like git equals our $PWD (for pathname comparisons). > -- > 1.7.5.4 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch >