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 17334429E25 for ; Mon, 27 Jun 2011 13:22:52 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-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 88oTrq9qn0xg for ; Mon, 27 Jun 2011 13:22:50 -0700 (PDT) Received: from mail-bw0-f53.google.com (mail-bw0-f53.google.com [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 89EF7431FD0 for ; Mon, 27 Jun 2011 13:22:49 -0700 (PDT) Received: by bwg12 with SMTP id 12so4635608bwg.26 for ; Mon, 27 Jun 2011 13:22:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:in-reply-to:references :user-agent:date:message-id:mime-version:content-type :content-transfer-encoding; bh=R3lOOMzx3P466dphUKSbShg0z9A8lQ6ELEsk3Asxss4=; b=suBfpI/Consa6VbIzqKTaPa/tbsa+qY6JyOg783qv9I4zFPdxpC2ffKCbGyMkK1SMZ Ad9Jdoy3l/hTXjhCwKpOruzUY89Y7s59bQTvcZyxrltgMC9j8AffAl03N5hm5Hk+qsYN jg3IId8Xk/5+6J0IHUppJuu3owKj86Y2X+9ng= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-type:content-transfer-encoding; b=o+/caSXrebhasFTGfJlhgQobPB2JBCdCi4TcIiyAoIZQmEuU6yAphyhKPiz8wKpCyb RWEvtLblRmfe1ygFLZ2OaNfGFVYL43CVzvfZqUl4WH0Ne2T+GtOtTJha7LSV0MiNIdho xogOw7z7NwT+8Wp96LQ+QB+wr80O3iqYJjuho= Received: by 10.204.138.78 with SMTP id z14mr4261008bkt.44.1309206167873; Mon, 27 Jun 2011 13:22:47 -0700 (PDT) Received: from localhost ([91.144.186.21]) by mx.google.com with ESMTPS id c13sm989630bkc.2.2011.06.27.13.22.45 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 27 Jun 2011 13:22:46 -0700 (PDT) From: Dmitry Kurochkin To: Austin Clements Subject: Re: [PATCH 2/2] test: use emacsclient(1) for Emacs tests In-Reply-To: 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> User-Agent: Notmuch/0.5-275-g75c95e5 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) Date: Tue, 28 Jun 2011 00:22:41 +0400 Message-ID: <87hb7byqge.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 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:22:52 -0000 On Mon, 27 Jun 2011 16:02:12 -0400, Austin Clements wrot= e: > This looks like a great idea! The test suite has been getting irritating= slow. >=20 > 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. >=20 Agreed, will separate and add the warning. > 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? >=20 emacs_start start a normal Emacs in non-daemon mode. Something you might prefer when debugging. >=20 > My bigger concern with this change is that it may leave behind stale > emacs daemons if the script gets interrupted. That is an issue indeed. I would probably do smth like a periodic check inside Emacs that the shell is alive, but your approach below looks more reliable. > 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: >=20 > coproc emacs --batch --eval "(while t (eval (read)))" > EMACSFD=3D${COPROC[1]} > trap "echo '(kill-emacs)' >&$EMACSFD" EXIT >=20 > echo '(message "Hi")' >&$EMACSFD > # ... >=20 > 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. I like this idea. > The trap is there just to cleanly shut down in case of a normal > exit [1]. For normal exit we should just put this into test_done. Otherwise it is not a normal exit and we do not care about Emacs error message. No? > This also has the advantage that read-from-minibuffer still > works: >=20 > echo '(message (read-from-minibuffer ""))' >&$EMACSFD > echo 'Test' >&$EMACSFD >=20 > Thoughts? >=20 I like it and I will implement it. Thanks for the idea. Regards, Dmitry > [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. >=20 > On Sun, Jun 26, 2011 at 11:54 PM, Dmitry Kurochkin > wrote: > > Before the change, every Emacs tests ran in a separate Emacs > > instance. =C2=A0Starting Emacs many times wastes considerable time and > > it gets worse as the test suite grows. =C2=A0The patch solves this by > > using a single Emacs server and emacsclient(1) to run multiple > > tests. =C2=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. =C2=A0Several auxiliary scripts useful for debugging and test > > development are generated instead of the run_emacs script: > > > > =C2=A0* emacs_server_start - start Emacs server > > =C2=A0* emacs_server_stop =C2=A0- stop Emacs server > > =C2=A0* emacs_start =C2=A0 =C2=A0 =C2=A0 =C2=A0- start Emacs > > =C2=A0* emacs_run =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0- execute ELisp exp= ressions 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. =C2=A0For now, the only Emacs environment modifications done by > > the tests are variable settings. =C2=A0Before the change, variables > > were set with `setq' which affected other tests. =C2=A0The patch > > changes all variables to use `let', so the scope of the change is > > limited to a single test. > > --- > > =C2=A0test/emacs =C2=A0 =C2=A0 =C2=A0 | =C2=A0 74 +++++++++++++--------= ----- > > =C2=A0test/test-lib.el | =C2=A0 =C2=A06 ++ > > =C2=A0test/test-lib.sh | =C2=A0149 ++++++++++++++++++++++++++++++++++++= ++++++----------- > > =C2=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) > > =C2=A0test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello > > > > =C2=A0test_begin_subtest "Saved search with 0 results" > > -test_emacs '(setq notmuch-show-empty-saved-searches t) > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq notmuch-saved-searches > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 '\''(("inbox"= . "tag:inbox") > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0("unread" . "tag:unread") > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0("empty" . "tag:doesnotexist"))) > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-hello) > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output)' > > +test_emacs '(let ((notmuch-show-empty-saved-searches t) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-save= d-searches > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'\''(("= inbox" . "tag:inbox") > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 ("unread" . "tag:unread") > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 ("empty" . "tag:doesnotexist")))) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-hello) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output))' > > =C2=A0test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-with-empty > > > > =C2=A0test_begin_subtest "No saved searches displayed (all with 0 resul= ts)" > > -test_emacs '(setq notmuch-saved-searches > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 '\''(("empty"= . "tag:doesnotexist"))) > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-hello) > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output)' > > +test_emacs '(let ((notmuch-saved-searches > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'\''(("= empty" . "tag:doesnotexist")))) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-hello) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output))' > > =C2=A0test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-no-saved-se= arches > > > > =C2=A0test_begin_subtest "Basic notmuch-search view in emacs" > > @@ -147,9 +147,9 @@ output=3D$(notmuch search 'subject:"testing message= sent via SMTP"' | notmuch_sear > > =C2=A0test_expect_equal "$output" "thread:XXX =C2=A0 2000-01-01 [1/1] N= otmuch Test Suite; Testing message sent via SMTP (inbox)" > > > > =C2=A0test_begin_subtest "notmuch-fcc-dirs set to nil" > > -test_emacs "(setq notmuch-fcc-dirs nil) > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail) > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output)" > > +test_emacs "(let ((notmuch-fcc-dirs nil)) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output))" > > =C2=A0cat <EXPECTED > > =C2=A0From: Notmuch Test Suite > > =C2=A0To: > > @@ -164,9 +164,9 @@ mkdir -p mail/sent-string/new > > =C2=A0mkdir -p mail/sent-string/tmp > > > > =C2=A0test_begin_subtest "notmuch-fcc-dirs set to a string" > > -test_emacs "(setq notmuch-fcc-dirs \"sent-string\") > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail) > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output)" > > +test_emacs "(let ((notmuch-fcc-dirs \"sent-string\")) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output))" > > =C2=A0cat <EXPECTED > > =C2=A0From: Notmuch Test Suite > > =C2=A0To: > > @@ -185,11 +185,11 @@ mkdir -p mail/failure/new > > =C2=A0mkdir -p mail/failure/tmp > > > > =C2=A0test_begin_subtest "notmuch-fcc-dirs set to a list (with match)" > > -test_emacs "(setq notmuch-fcc-dirs > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 '((\"notmuchm= ail.org\" . \"sent-list-match\") > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (\".*\= " . \"failure\"))) > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail) > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output)" > > +test_emacs "(let ((notmuch-fcc-dirs > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'((\"no= tmuchmail.org\" . \"sent-list-match\") > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= (\".*\" . \"failure\")))) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output))" > > =C2=A0cat <EXPECTED > > =C2=A0From: Notmuch Test Suite > > =C2=A0To: > > @@ -205,11 +205,11 @@ mkdir -p mail/sent-list-catch-all/new > > =C2=A0mkdir -p mail/sent-list-catch-all/tmp > > > > =C2=A0test_begin_subtest "notmuch-fcc-dirs set to a list (catch-all)" > > -test_emacs "(setq notmuch-fcc-dirs > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 '((\"example.= com\" . \"failure\") > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (\".*\= " . \"sent-list-catch-all\"))) > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail) > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output)" > > +test_emacs "(let ((notmuch-fcc-dirs > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'((\"ex= ample.com\" . \"failure\") > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= (\".*\" . \"sent-list-catch-all\")))) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output))" > > =C2=A0cat <EXPECTED > > =C2=A0From: Notmuch Test Suite > > =C2=A0To: > > @@ -220,11 +220,11 @@ EOF > > =C2=A0test_expect_equal_file OUTPUT EXPECTED > > > > =C2=A0test_begin_subtest "notmuch-fcc-dirs set to a list (no match)" > > -test_emacs "(setq notmuch-fcc-dirs > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 '((\"example.= com\" . \"failure\") > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (\"nom= atchhere.net\" . \"failure\"))) > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail) > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output)" > > +test_emacs "(let ((notmuch-fcc-dirs > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'((\"ex= ample.com\" . \"failure\") > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= (\"nomatchhere.net\" . \"failure\")))) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output))" > > =C2=A0cat <EXPECTED > > =C2=A0From: Notmuch Test Suite > > =C2=A0To: > > @@ -253,15 +253,15 @@ test_expect_equal_file OUTPUT EXPECTED > > > > =C2=A0test_begin_subtest "Save attachment from within emacs using notmu= ch-show-save-attachments" > > =C2=A0# save as archive to test that Emacs does not re-compress .gz > > -echo ./attachment1.gz | > > -test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052= ad0a@mail.gmail.com") > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-show-save-attachments)' >= /dev/null 2>&1 > > +test_emacs '(let ((standard-input "\"attachment1.gz\"")) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-show "id:cf0c4d610= 911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com") > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-show-save-attachme= nts))' > > =C2=A0test_expect_equal_file "$EXPECTED/attachment" attachment1.gz > > > > =C2=A0test_begin_subtest "Save attachment from within emacs using notmu= ch-show-save-part" > > =C2=A0# save as archive to test that Emacs does not re-compress .gz > > -echo ./attachment2.gz | > > -test_emacs '(notmuch-show-save-part "id:cf0c4d610911171136h1713aa59w9c= f9aa31f052ad0a@mail.gmail.com" 5)' > /dev/null 2>&1 > > +test_emacs '(let ((standard-input "\"attachment2.gz\"")) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-show-save-part "id= :cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com" 5))' > /dev/n= ull 2>&1 > > =C2=A0test_expect_equal_file "$EXPECTED/attachment" attachment2.gz > > > > =C2=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 @@ > > =C2=A0;; avoid crazy 10-column default of --batch > > =C2=A0(set-frame-width (window-frame (get-buffer-window)) 80) > > > > +;; `read-file-name' by default uses `completing-read' function to read > > +;; user input. =C2=A0It does not respect `standard-input' variable whi= ch we > > +;; use in tests to provide user input. =C2=A0So replace it with a plain > > +;; `read' call. > > +(setq read-file-name-function (lambda (&rest _) (read))) > > + > > =C2=A0(defun notmuch-test-wait () > > =C2=A0 "Wait for process completion." > > =C2=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 > > > > =C2=A0unset GREP_OPTIONS > > > > +# PID of running Emacs server > > +emacs_server_pid=3D > > + > > =C2=A0# Convenience > > =C2=A0# > > =C2=A0# A regexp to match 5 and 40 hexdigits > > @@ -174,6 +177,7 @@ test_success=3D0 > > > > =C2=A0die () { > > =C2=A0 =C2=A0 =C2=A0 =C2=A0code=3D$? > > + =C2=A0 =C2=A0 =C2=A0 emacs_server_stop > > =C2=A0 =C2=A0 =C2=A0 =C2=A0if test -n "$GIT_EXIT_OK" > > =C2=A0 =C2=A0 =C2=A0 =C2=A0then > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0exit $code > > @@ -394,19 +398,20 @@ emacs_deliver_message () > > =C2=A0 =C2=A0 mkdir -p "$MAIL_DIR"/sent/{cur,new,tmp} > > =C2=A0 =C2=A0 ../smtp-dummy sent_message & > > =C2=A0 =C2=A0 smtp_dummy_pid=3D$! > > - =C2=A0 =C2=A0test_emacs "(setq message-send-mail-function 'message-sm= tpmail-send-it) > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq smtpmail-smtp-= server \"localhost\") > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq smtpmail-smtp-= service \"25025\") > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-hello) > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail) > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (message-goto-to) > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (insert \"test_suite= @notmuchmail.org\nDate: 01 Jan 2000 12:00:00 -0000\") > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (message-goto-subjec= t) > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (insert \"${subject}= \") > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (message-goto-body) > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (insert \"${body}\") > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $@ > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (message-send-and-ex= it)" >/dev/null 2>&1 > > + =C2=A0 =C2=A0test_emacs \ > > + =C2=A0 =C2=A0 =C2=A0 "(let ((message-send-mail-function 'message-smtp= mail-send-it) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(smtpmail-smtp-server= \"localhost\") > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(smtpmail-smtp-servic= e \"25025\")) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(notmuch-hello) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(notmuch-mua-mail) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(message-goto-to) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(insert \"test_suite@notmuchmail.or= g\nDate: 01 Jan 2000 12:00:00 -0000\") > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(message-goto-subject) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(insert \"${subject}\") > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(message-goto-body) > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(insert \"${body}\") > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0$@ > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(message-send-and-exit))" >/dev/nul= l 2>&1 > > =C2=A0 =C2=A0 wait ${smtp_dummy_pid} > > =C2=A0 =C2=A0 notmuch new >/dev/null > > =C2=A0} > > @@ -828,6 +833,8 @@ test_done () { > > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0echo > > > > + =C2=A0 =C2=A0 =C2=A0 emacs_server_stop > > + > > =C2=A0 =C2=A0 =C2=A0 =C2=A0if [ "$test_failure" =3D "0" ]; then > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if [ "$test_broken" =3D "0" ];= then > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0rm -rf "$remove_= tmp" > > @@ -838,24 +845,26 @@ test_done () { > > =C2=A0 =C2=A0 =C2=A0 =C2=A0fi > > =C2=A0} > > > > -test_emacs () { > > - =C2=A0 =C2=A0 =C2=A0 # Construct a little test script here for the be= nefit of the user, > > - =C2=A0 =C2=A0 =C2=A0 # (who can easily run "run_emacs" to get the sam= e emacs environment > > - =C2=A0 =C2=A0 =C2=A0 # for investigating any failures). > > - =C2=A0 =C2=A0 =C2=A0 cat < run_emacs > > +# Generate some scripts for running Emacs tests. =C2=A0These scripts a= re > > +# used by Emacs tests and help investigating failures. =C2=A0The follo= wing > > +# scripts are generated: > > +# > > +# * emacs_server_start - start Emacs server > > +# * emacs_server_stop =C2=A0- stop Emacs server > > +# * emacs_start =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0- start Emacs > > +# * emacs_run =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0- execute ELisp expres= sions in running Emacs server > > +emacs_generate_scripts () > > +{ > > + =C2=A0 =C2=A0 =C2=A0 server_name=3D"notmuch-test-suite-$$" > > + > > + =C2=A0 =C2=A0 =C2=A0 cat < "$TMP_DIRECTORY/emacs_server_start" > > =C2=A0#!/bin/sh > > =C2=A0export PATH=3D$PATH > > =C2=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 > > - =C2=A0 =C2=A0 =C2=A0 BATCH=3D--batch > > -fi > > - > > =C2=A0# Here's what we are using here: > > =C2=A0# > > -# --batch: =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Quit after given = commands and print all (messages) > > +# --daemon =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Start Emacs as a = daemon > > =C2=A0# > > =C2=A0# --no-init-file =C2=A0 =C2=A0 =C2=A0 Don't load users ~/.emacs > > =C2=A0# > > @@ -865,13 +874,90 @@ fi > > =C2=A0# > > =C2=A0# --load =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Force l= oading of notmuch.el and test-lib.el > > > > -emacs \$BATCH --no-init-file --no-site-file \ > > - =C2=A0 =C2=A0 =C2=A0 --directory ../../emacs --load notmuch.el \ > > - =C2=A0 =C2=A0 =C2=A0 --directory .. --load test-lib.el \ > > - =C2=A0 =C2=A0 =C2=A0 --eval "(progn \$@)" > > +emacs --daemon --no-init-file --no-site-file \ > > + =C2=A0 =C2=A0 =C2=A0 --directory "$TEST_DIRECTORY/../emacs" --load no= tmuch.el \ > > + =C2=A0 =C2=A0 =C2=A0 --directory "$TEST_DIRECTORY" --load test-lib.el= \ > > + =C2=A0 =C2=A0 =C2=A0 --eval '(setq server-name "$server_name")' > > +EOF > > + =C2=A0 =C2=A0 =C2=A0 chmod a+x "$TMP_DIRECTORY/emacs_server_start" > > + > > + =C2=A0 =C2=A0 =C2=A0 cat < "$TMP_DIRECTORY/emacs_server_stop" > > +#!/bin/sh > > + > > +dir=3D\$(dirname "\$0") > > +"\$dir"/emacs_run '(kill-emacs)' > > =C2=A0EOF > > - =C2=A0 =C2=A0 =C2=A0 chmod a+x ./run_emacs > > - =C2=A0 =C2=A0 =C2=A0 ./run_emacs "$@" > > + =C2=A0 =C2=A0 =C2=A0 chmod a+x "$TMP_DIRECTORY/emacs_server_stop" > > + > > + =C2=A0 =C2=A0 =C2=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 =C2=A0 =C2=A0 =C2=A0 Don't load users ~/.emacs > > +# > > +# --no-site-file =C2=A0 =C2=A0 =C2=A0 Don't load the site-wide startup= stuff > > +# > > +# --directory =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Ensure that the local = elisp sources are found > > +# > > +# --load =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Force loadin= g of notmuch.el and test-lib.el > > + > > +emacs --no-init-file --no-site-file \ > > + =C2=A0 =C2=A0 =C2=A0 --directory "$TEST_DIRECTORY/../emacs" --load no= tmuch.el \ > > + =C2=A0 =C2=A0 =C2=A0 --directory "$TEST_DIRECTORY" --load test-lib.el > > +EOF > > + =C2=A0 =C2=A0 =C2=A0 chmod a+x "$TMP_DIRECTORY/emacs_start" > > + > > + =C2=A0 =C2=A0 =C2=A0 cat < "$TMP_DIRECTORY/emacs_run" > > +#!/bin/sh > > + > > +# Here's what we are using here: > > +# > > +# --socket-name =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0Emacs server name > > +# > > +# --eval =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Evaluate ELi= sp expressions > > + > > +emacsclient --socket-name "$server_name" --eval "(progn \$@)" > > +EOF > > + =C2=A0 =C2=A0 =C2=A0 chmod a+x "$TMP_DIRECTORY/emacs_run" > > +} > > + > > +# Start Emacs server if it is not running. > > +emacs_server_start () > > +{ > > + =C2=A0 =C2=A0 =C2=A0 [ -n "$emacs_server_pid" ] && return > > + > > + =C2=A0 =C2=A0 =C2=A0 output=3D$("$TMP_DIRECTORY/emacs_server_start" 2= >&1) > > + =C2=A0 =C2=A0 =C2=A0 if [ "$?" -ne 0 ]; then > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 echo "$output" > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return 1 > > + =C2=A0 =C2=A0 =C2=A0 fi > > + > > + =C2=A0 =C2=A0 =C2=A0 emacs_server_pid=3D$("$TMP_DIRECTORY/emacs_run" = '(emacs-pid)') > > + =C2=A0 =C2=A0 =C2=A0 [ "$?" -eq 0 -a -n "$emacs_server_pid" ] > > +} > > + > > +# Stop Emacs server if it is running. > > +emacs_server_stop () > > +{ > > + =C2=A0 =C2=A0 =C2=A0 [ -z "$emacs_server_pid" ] && return > > + > > + =C2=A0 =C2=A0 =C2=A0 emacs_server_pid=3D > > + =C2=A0 =C2=A0 =C2=A0 output=3D$("$TMP_DIRECTORY/emacs_server_stop" 2>= &1) > > + =C2=A0 =C2=A0 =C2=A0 if [ "$?" -ne 0 ]; then > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 echo "$output" > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return 1 > > + =C2=A0 =C2=A0 =C2=A0 fi > > +} > > + > > +# Evaluate ELisp expressions in Emacs server. =C2=A0Server is started = if it > > +# is not running. > > +test_emacs () { > > + =C2=A0 =C2=A0 =C2=A0 emacs_server_start || return > > + > > + =C2=A0 =C2=A0 =C2=A0 "$TMP_DIRECTORY/emacs_run" "$@" > > =C2=A0} > > > > > > @@ -999,6 +1085,7 @@ primary_email=3Dtest_suite@notmuchmail.org > > =C2=A0other_email=3Dtest_suite_other@notmuchmail.org;test_suite@otherdo= main.org > > =C2=A0EOF > > > > +emacs_generate_scripts > > > > =C2=A0# Use -P to resolve symlinks in our working directory so that the= cwd > > =C2=A0# in subprocesses like git equals our $PWD (for pathname comparis= ons). > > -- > > 1.7.5.4 > > > > _______________________________________________ > > notmuch mailing list > > notmuch@notmuchmail.org > > http://notmuchmail.org/mailman/listinfo/notmuch > >