From 17e86fcf26865976db74b2eb9601b97147794840 Mon Sep 17 00:00:00 2001 From: Dmitry Kurochkin Date: Tue, 28 Jun 2011 05:03:11 +0400 Subject: [PATCH] Re: [PATCH 2/2] test: use emacsclient(1) for Emacs tests --- 92/08c4f695702d9be359ca6b2c01f30799eea6ad | 644 ++++++++++++++++++++++ 1 file changed, 644 insertions(+) create mode 100644 92/08c4f695702d9be359ca6b2c01f30799eea6ad diff --git a/92/08c4f695702d9be359ca6b2c01f30799eea6ad b/92/08c4f695702d9be359ca6b2c01f30799eea6ad new file mode 100644 index 000000000..30931e037 --- /dev/null +++ b/92/08c4f695702d9be359ca6b2c01f30799eea6ad @@ -0,0 +1,644 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id A4FF0429E25 + for ; Mon, 27 Jun 2011 18:03:21 -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 cT2OPdsY99Ju for ; + Mon, 27 Jun 2011 18:03:19 -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 1D3F6431FD0 + for ; Mon, 27 Jun 2011 18:03:18 -0700 (PDT) +Received: by bwg12 with SMTP id 12so4785130bwg.26 + for ; Mon, 27 Jun 2011 18:03:17 -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=Ssmt3zhFE8vqcl5sHdeet7qu+7denH4HMjuHb4voBP0=; + b=gWqwXcupkspRWRwEii6JD1kKQsSklrhKxBsPDTWSLDuz5IX+cPlKZlR0B0Q4xC15fY + Mex565Bv7cEBUUFTzXhey+lpmyBxySQZ3JM9+JUxWNtckkYTOiU9Bh5/c5cYPsQwURXN + UzD55XYj9A9uPZiIaJxMA/haKfutdl3imKDMQ= +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=J6xE4GLzUhLNbNkdmQmJvtFUlkV/I9MYQQmGMEVn1hvgTR2zV9JKgbHzOw8nu1Qv1V + g+amqc294tl0+5cynA/fsVxKvA3llW2wZ3D61fKx80w+mnU3z2nx2zPh9ydb7LwYrTiG + JP4iEpJY8WLmdapt28vC9POrVyvWhE/+8rdlg= +Received: by 10.204.57.82 with SMTP id b18mr1585748bkh.95.1309222997435; + Mon, 27 Jun 2011 18:03:17 -0700 (PDT) +Received: from localhost ([91.144.186.21]) + by mx.google.com with ESMTPS id l24sm4630993bkw.3.2011.06.27.18.03.15 + (version=TLSv1/SSLv3 cipher=OTHER); + Mon, 27 Jun 2011 18:03:16 -0700 (PDT) +From: Dmitry Kurochkin +To: Austin Clements +Subject: Re: [PATCH 2/2] test: use emacsclient(1) for Emacs tests +In-Reply-To: <87hb7byqge.fsf@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> + + <87hb7byqge.fsf@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 05:03:11 +0400 +Message-ID: <87d3hyzs1c.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: Tue, 28 Jun 2011 01:03:21 -0000 + +Austin, + +On Tue, 28 Jun 2011 00:22:41 +0400, Dmitry Kurochkin wrote: +> On Mon, 27 Jun 2011 16:02:12 -0400, Austin Clements wr= +ote: +> > This looks like a great idea! The test suite has been getting irritati= +ng 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 +>=20 +> Agreed, will separate and add the warning. +>=20 +> > 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 +>=20 +> emacs_start start a normal Emacs in non-daemon mode. Something you +> might prefer when debugging. +>=20 +> >=20 +> > My bigger concern with this change is that it may leave behind stale +> > emacs daemons if the script gets interrupted. +>=20 +> 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. +>=20 +> > 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. +>=20 +> I like this idea. +>=20 +> > The trap is there just to cleanly shut down in case of a normal +> > exit [1]. +>=20 +> 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? +>=20 +> > This also has the advantage that read-from-minibuffer still +> > works: +> >=20 +> > echo '(message (read-from-minibuffer ""))' >&$EMACSFD +> > echo 'Test' >&$EMACSFD +> >=20 +> > Thoughts? +> >=20 +>=20 +> I like it and I will implement it. Thanks for the idea. +>=20 + +While implementing the idea, I stumbled upon a problem: we need to know +when Emacs finished what we echoed or failed with an error. At the +moment tests fail because they check for OUTPUT before Emacs creates it. + +We can tell Emacs to print some special marker and wait for it. But +there may be exceptions and errors which may make it difficult. I did +not found a good solution yet. Would love to hear your thoughts :) + +Regards, + Dmitry + +> Regards, +> Dmitry +>=20 +> > [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 e= +xpressions 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 '\''(("inbo= +x" . "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-sa= +ved-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 res= +ults)" +> > > -test_emacs '(setq notmuch-saved-searches +> > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 '\''(("empt= +y" . "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-= +searches +> > > +> > > =C2=A0test_begin_subtest "Basic notmuch-search view in emacs" +> > > @@ -147,9 +147,9 @@ output=3D$(notmuch search 'subject:"testing messa= +ge sent via SMTP"' | notmuch_sear +> > > =C2=A0test_expect_equal "$output" "thread:XXX =C2=A0 2000-01-01 [1/1]= + Notmuch 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 '((\"notmuc= +hmail.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'((\"= +notmuchmail.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 '((\"exampl= +e.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'((\"= +example.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 '((\"exampl= +e.com\" . \"failure\") +> > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (\"n= +omatchhere.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'((\"= +example.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 not= +much-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:cf0c4d610911171136h1713aa59w9cf9aa31f0= +52ad0a@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:cf0c4d6= +10911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com") +> > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-show-save-attach= +ments))' +> > > =C2=A0test_expect_equal_file "$EXPECTED/attachment" attachment1.gz +> > > +> > > =C2=A0test_begin_subtest "Save attachment from within emacs using not= +much-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:cf0c4d610911171136h1713aa59w= +9cf9aa31f052ad0a@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= +/null 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 re= +ad +> > > +;; user input. =C2=A0It does not respect `standard-input' variable w= +hich we +> > > +;; use in tests to provide user input. =C2=A0So replace it with a pl= +ain +> > > +;; `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-= +smtpmail-send-it) +> > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq smtpmail-smt= +p-server \"localhost\") +> > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq smtpmail-smt= +p-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_sui= +te@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-subj= +ect) +> > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (insert \"${subjec= +t}\") +> > > - =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-= +exit)" >/dev/null 2>&1 +> > > + =C2=A0 =C2=A0test_emacs \ +> > > + =C2=A0 =C2=A0 =C2=A0 "(let ((message-send-mail-function 'message-sm= +tpmail-send-it) +> > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(smtpmail-smtp-serv= +er \"localhost\") +> > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(smtpmail-smtp-serv= +ice \"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.= +org\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/n= +ull 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 "$remov= +e_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 = +benefit of the user, +> > > - =C2=A0 =C2=A0 =C2=A0 # (who can easily run "run_emacs" to get the s= +ame 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= + are +> > > +# used by Emacs tests and help investigating failures. =C2=A0The fol= +lowing +> > > +# 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 expr= +essions 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 give= +n 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= + loading 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 = +notmuch.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 start= +up stuff +> > > +# +> > > +# --directory =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Ensure that the loca= +l elisp sources are found +> > > +# +> > > +# --load =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Force load= +ing 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 = +notmuch.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 E= +Lisp 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 starte= +d 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@other= +domain.org +> > > =C2=A0EOF +> > > +> > > +emacs_generate_scripts +> > > +> > > =C2=A0# Use -P to resolve symlinks in our working directory so that t= +he cwd +> > > =C2=A0# in subprocesses like git equals our $PWD (for pathname compar= +isons). +> > > -- +> > > 1.7.5.4 +> > > +> > > _______________________________________________ +> > > notmuch mailing list +> > > notmuch@notmuchmail.org +> > > http://notmuchmail.org/mailman/listinfo/notmuch +> > > -- 2.26.2