1 Return-Path: <dmitry.kurochkin@gmail.com>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 17334429E25
\r
6 for <notmuch@notmuchmail.org>; Mon, 27 Jun 2011 13:22:52 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id 88oTrq9qn0xg for <notmuch@notmuchmail.org>;
\r
17 Mon, 27 Jun 2011 13:22:50 -0700 (PDT)
\r
18 Received: from mail-bw0-f53.google.com (mail-bw0-f53.google.com
\r
19 [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 89EF7431FD0
\r
22 for <notmuch@notmuchmail.org>; Mon, 27 Jun 2011 13:22:49 -0700 (PDT)
\r
23 Received: by bwg12 with SMTP id 12so4635608bwg.26
\r
24 for <notmuch@notmuchmail.org>; Mon, 27 Jun 2011 13:22:48 -0700 (PDT)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
\r
26 h=domainkey-signature:from:to:cc:subject:in-reply-to:references
\r
27 :user-agent:date:message-id:mime-version:content-type
\r
28 :content-transfer-encoding;
\r
29 bh=R3lOOMzx3P466dphUKSbShg0z9A8lQ6ELEsk3Asxss4=;
\r
30 b=suBfpI/Consa6VbIzqKTaPa/tbsa+qY6JyOg783qv9I4zFPdxpC2ffKCbGyMkK1SMZ
\r
31 Ad9Jdoy3l/hTXjhCwKpOruzUY89Y7s59bQTvcZyxrltgMC9j8AffAl03N5hm5Hk+qsYN
\r
32 jg3IId8Xk/5+6J0IHUppJuu3owKj86Y2X+9ng=
\r
33 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
\r
34 h=from:to:cc:subject:in-reply-to:references:user-agent:date
\r
35 :message-id:mime-version:content-type:content-transfer-encoding;
\r
36 b=o+/caSXrebhasFTGfJlhgQobPB2JBCdCi4TcIiyAoIZQmEuU6yAphyhKPiz8wKpCyb
\r
37 RWEvtLblRmfe1ygFLZ2OaNfGFVYL43CVzvfZqUl4WH0Ne2T+GtOtTJha7LSV0MiNIdho
\r
38 xogOw7z7NwT+8Wp96LQ+QB+wr80O3iqYJjuho=
\r
39 Received: by 10.204.138.78 with SMTP id z14mr4261008bkt.44.1309206167873;
\r
40 Mon, 27 Jun 2011 13:22:47 -0700 (PDT)
\r
41 Received: from localhost ([91.144.186.21])
\r
42 by mx.google.com with ESMTPS id c13sm989630bkc.2.2011.06.27.13.22.45
\r
43 (version=TLSv1/SSLv3 cipher=OTHER);
\r
44 Mon, 27 Jun 2011 13:22:46 -0700 (PDT)
\r
45 From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
\r
46 To: Austin Clements <amdragon@mit.edu>
\r
47 Subject: Re: [PATCH 2/2] test: use emacsclient(1) for Emacs tests
\r
48 In-Reply-To: <BANLkTi=nwHRndz367K5oh4=tPaU-KNeZ8Q@mail.gmail.com>
\r
49 References: <1309132379-24089-1-git-send-email-dmitry.kurochkin@gmail.com>
\r
50 <1309146846-30991-1-git-send-email-dmitry.kurochkin@gmail.com>
\r
51 <1309146846-30991-2-git-send-email-dmitry.kurochkin@gmail.com>
\r
52 <BANLkTi=nwHRndz367K5oh4=tPaU-KNeZ8Q@mail.gmail.com>
\r
53 User-Agent: Notmuch/0.5-275-g75c95e5 (http://notmuchmail.org) Emacs/23.3.1
\r
54 (x86_64-pc-linux-gnu)
\r
55 Date: Tue, 28 Jun 2011 00:22:41 +0400
\r
56 Message-ID: <87hb7byqge.fsf@gmail.com>
\r
58 Content-Type: text/plain; charset=utf-8
\r
59 Content-Transfer-Encoding: quoted-printable
\r
60 Cc: notmuch@notmuchmail.org
\r
61 X-BeenThere: notmuch@notmuchmail.org
\r
62 X-Mailman-Version: 2.1.13
\r
64 List-Id: "Use and development of the notmuch mail system."
\r
65 <notmuch.notmuchmail.org>
\r
66 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
67 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
68 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
69 List-Post: <mailto:notmuch@notmuchmail.org>
\r
70 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
71 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
72 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
73 X-List-Received-Date: Mon, 27 Jun 2011 20:22:52 -0000
\r
75 On Mon, 27 Jun 2011 16:02:12 -0400, Austin Clements <amdragon@mit.edu> wrot=
\r
77 > This looks like a great idea! The test suite has been getting irritating=
\r
80 > A few minor comments: This patch would be clearer if it the
\r
81 > setq-to-let translation were a separate patch. It would also be worth
\r
82 > adding a big comment at the top of the test explaining why all of the
\r
83 > tests let-bind everything instead of setq'ing, primarily for the
\r
84 > benefit of people writing new tests.
\r
87 Agreed, will separate and add the warning.
\r
89 > I might just be having trouble reading the patch, but the difference
\r
90 > between emacs_start and emacs_server_start seems unclear. Perhaps the
\r
91 > comments should explain how somebody would use these scripts?
\r
94 emacs_start start a normal Emacs in non-daemon mode. Something you
\r
95 might prefer when debugging.
\r
98 > My bigger concern with this change is that it may leave behind stale
\r
99 > emacs daemons if the script gets interrupted.
\r
101 That is an issue indeed. I would probably do smth like a periodic check
\r
102 inside Emacs that the shell is alive, but your approach below looks more
\r
105 > The only way I know to
\r
106 > reliably kill a child process is to open a pipe to it and have it exit
\r
107 > on its own when it reads EOF. Unfortunately, I couldn't find a way to
\r
108 > do this with an emacs daemon (it appears daemon mode aggressively
\r
109 > cleans up things like pipes), but here's a different approach:
\r
111 > coproc emacs --batch --eval "(while t (eval (read)))"
\r
112 > EMACSFD=3D${COPROC[1]}
\r
113 > trap "echo '(kill-emacs)' >&$EMACSFD" EXIT
\r
115 > echo '(message "Hi")' >&$EMACSFD
\r
118 > This is, basically, a poor man's emacs server, but the coprocess pipe
\r
119 > binds it tightly to the shell. If the shell exits for *any* reason,
\r
120 > the pipe will be closed by the kernel, emacs will read an EOF, and
\r
125 > The trap is there just to cleanly shut down in case of a normal
\r
128 For normal exit we should just put this into test_done. Otherwise it is
\r
129 not a normal exit and we do not care about Emacs error message. No?
\r
131 > This also has the advantage that read-from-minibuffer still
\r
134 > echo '(message (read-from-minibuffer ""))' >&$EMACSFD
\r
135 > echo 'Test' >&$EMACSFD
\r
140 I like it and I will implement it. Thanks for the idea.
\r
145 > [1] If you don't do this, emacs complains that it can't read from
\r
146 > stdin before it exits. It would be nice to catch this condition in
\r
147 > the elisp code and not bother with the trap, but the error thrown is
\r
148 > just an 'error, so I don't think we can catch and ignore it without
\r
149 > catching and ignoring *all* errors.
\r
151 > On Sun, Jun 26, 2011 at 11:54 PM, Dmitry Kurochkin
\r
152 > <dmitry.kurochkin@gmail.com> wrote:
\r
153 > > Before the change, every Emacs tests ran in a separate Emacs
\r
154 > > instance. =C2=A0Starting Emacs many times wastes considerable time and
\r
155 > > it gets worse as the test suite grows. =C2=A0The patch solves this by
\r
156 > > using a single Emacs server and emacsclient(1) to run multiple
\r
157 > > tests. =C2=A0Emacs server is started on the first test_emacs call and
\r
158 > > stopped when test_done is called or the test is killed by a
\r
159 > > signal. =C2=A0Several auxiliary scripts useful for debugging and test
\r
160 > > development are generated instead of the run_emacs script:
\r
162 > > =C2=A0* emacs_server_start - start Emacs server
\r
163 > > =C2=A0* emacs_server_stop =C2=A0- stop Emacs server
\r
164 > > =C2=A0* emacs_start =C2=A0 =C2=A0 =C2=A0 =C2=A0- start Emacs
\r
165 > > =C2=A0* emacs_run =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0- execute ELisp exp=
\r
166 ressions in running Emacs server
\r
168 > > Since multiple tests are run in a single Emacs instance, they
\r
169 > > must not change Emacs environment because it may affect other
\r
170 > > tests. =C2=A0For now, the only Emacs environment modifications done by
\r
171 > > the tests are variable settings. =C2=A0Before the change, variables
\r
172 > > were set with `setq' which affected other tests. =C2=A0The patch
\r
173 > > changes all variables to use `let', so the scope of the change is
\r
174 > > limited to a single test.
\r
176 > > =C2=A0test/emacs =C2=A0 =C2=A0 =C2=A0 | =C2=A0 74 +++++++++++++--------=
\r
178 > > =C2=A0test/test-lib.el | =C2=A0 =C2=A06 ++
\r
179 > > =C2=A0test/test-lib.sh | =C2=A0149 ++++++++++++++++++++++++++++++++++++=
\r
181 > > =C2=A03 files changed, 161 insertions(+), 68 deletions(-)
\r
183 > > diff --git a/test/emacs b/test/emacs
\r
184 > > index 4f16b41..f1939dc 100755
\r
185 > > --- a/test/emacs
\r
186 > > +++ b/test/emacs
\r
187 > > @@ -12,20 +12,20 @@ test_emacs '(notmuch-hello)
\r
188 > > =C2=A0test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello
\r
190 > > =C2=A0test_begin_subtest "Saved search with 0 results"
\r
191 > > -test_emacs '(setq notmuch-show-empty-saved-searches t)
\r
192 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq notmuch-saved-searches
\r
193 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 '\''(("inbox"=
\r
195 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
\r
196 =C2=A0("unread" . "tag:unread")
\r
197 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
\r
198 =C2=A0("empty" . "tag:doesnotexist")))
\r
199 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-hello)
\r
200 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output)'
\r
201 > > +test_emacs '(let ((notmuch-show-empty-saved-searches t)
\r
202 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-save=
\r
204 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'\''(("=
\r
205 inbox" . "tag:inbox")
\r
206 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
\r
207 =C2=A0 ("unread" . "tag:unread")
\r
208 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
\r
209 =C2=A0 ("empty" . "tag:doesnotexist"))))
\r
210 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-hello)
\r
211 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output))'
\r
212 > > =C2=A0test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-with-empty
\r
214 > > =C2=A0test_begin_subtest "No saved searches displayed (all with 0 resul=
\r
216 > > -test_emacs '(setq notmuch-saved-searches
\r
217 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 '\''(("empty"=
\r
218 . "tag:doesnotexist")))
\r
219 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-hello)
\r
220 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output)'
\r
221 > > +test_emacs '(let ((notmuch-saved-searches
\r
222 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'\''(("=
\r
223 empty" . "tag:doesnotexist"))))
\r
224 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-hello)
\r
225 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output))'
\r
226 > > =C2=A0test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-no-saved-se=
\r
229 > > =C2=A0test_begin_subtest "Basic notmuch-search view in emacs"
\r
230 > > @@ -147,9 +147,9 @@ output=3D$(notmuch search 'subject:"testing message=
\r
231 sent via SMTP"' | notmuch_sear
\r
232 > > =C2=A0test_expect_equal "$output" "thread:XXX =C2=A0 2000-01-01 [1/1] N=
\r
233 otmuch Test Suite; Testing message sent via SMTP (inbox)"
\r
235 > > =C2=A0test_begin_subtest "notmuch-fcc-dirs set to nil"
\r
236 > > -test_emacs "(setq notmuch-fcc-dirs nil)
\r
237 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail)
\r
238 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output)"
\r
239 > > +test_emacs "(let ((notmuch-fcc-dirs nil))
\r
240 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail)
\r
241 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output))"
\r
242 > > =C2=A0cat <<EOF >EXPECTED
\r
243 > > =C2=A0From: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
245 > > @@ -164,9 +164,9 @@ mkdir -p mail/sent-string/new
\r
246 > > =C2=A0mkdir -p mail/sent-string/tmp
\r
248 > > =C2=A0test_begin_subtest "notmuch-fcc-dirs set to a string"
\r
249 > > -test_emacs "(setq notmuch-fcc-dirs \"sent-string\")
\r
250 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail)
\r
251 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output)"
\r
252 > > +test_emacs "(let ((notmuch-fcc-dirs \"sent-string\"))
\r
253 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail)
\r
254 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output))"
\r
255 > > =C2=A0cat <<EOF >EXPECTED
\r
256 > > =C2=A0From: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
258 > > @@ -185,11 +185,11 @@ mkdir -p mail/failure/new
\r
259 > > =C2=A0mkdir -p mail/failure/tmp
\r
261 > > =C2=A0test_begin_subtest "notmuch-fcc-dirs set to a list (with match)"
\r
262 > > -test_emacs "(setq notmuch-fcc-dirs
\r
263 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 '((\"notmuchm=
\r
264 ail.org\" . \"sent-list-match\")
\r
265 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (\".*\=
\r
267 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail)
\r
268 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output)"
\r
269 > > +test_emacs "(let ((notmuch-fcc-dirs
\r
270 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'((\"no=
\r
271 tmuchmail.org\" . \"sent-list-match\")
\r
272 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
\r
273 (\".*\" . \"failure\"))))
\r
274 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail)
\r
275 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output))"
\r
276 > > =C2=A0cat <<EOF >EXPECTED
\r
277 > > =C2=A0From: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
279 > > @@ -205,11 +205,11 @@ mkdir -p mail/sent-list-catch-all/new
\r
280 > > =C2=A0mkdir -p mail/sent-list-catch-all/tmp
\r
282 > > =C2=A0test_begin_subtest "notmuch-fcc-dirs set to a list (catch-all)"
\r
283 > > -test_emacs "(setq notmuch-fcc-dirs
\r
284 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 '((\"example.=
\r
285 com\" . \"failure\")
\r
286 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (\".*\=
\r
287 " . \"sent-list-catch-all\")))
\r
288 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail)
\r
289 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output)"
\r
290 > > +test_emacs "(let ((notmuch-fcc-dirs
\r
291 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'((\"ex=
\r
292 ample.com\" . \"failure\")
\r
293 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
\r
294 (\".*\" . \"sent-list-catch-all\"))))
\r
295 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail)
\r
296 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output))"
\r
297 > > =C2=A0cat <<EOF >EXPECTED
\r
298 > > =C2=A0From: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
300 > > @@ -220,11 +220,11 @@ EOF
\r
301 > > =C2=A0test_expect_equal_file OUTPUT EXPECTED
\r
303 > > =C2=A0test_begin_subtest "notmuch-fcc-dirs set to a list (no match)"
\r
304 > > -test_emacs "(setq notmuch-fcc-dirs
\r
305 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 '((\"example.=
\r
306 com\" . \"failure\")
\r
307 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (\"nom=
\r
308 atchhere.net\" . \"failure\")))
\r
309 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail)
\r
310 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output)"
\r
311 > > +test_emacs "(let ((notmuch-fcc-dirs
\r
312 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'((\"ex=
\r
313 ample.com\" . \"failure\")
\r
314 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
\r
315 (\"nomatchhere.net\" . \"failure\"))))
\r
316 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail)
\r
317 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output))"
\r
318 > > =C2=A0cat <<EOF >EXPECTED
\r
319 > > =C2=A0From: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
321 > > @@ -253,15 +253,15 @@ test_expect_equal_file OUTPUT EXPECTED
\r
323 > > =C2=A0test_begin_subtest "Save attachment from within emacs using notmu=
\r
324 ch-show-save-attachments"
\r
325 > > =C2=A0# save as archive to test that Emacs does not re-compress .gz
\r
326 > > -echo ./attachment1.gz |
\r
327 > > -test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052=
\r
328 ad0a@mail.gmail.com")
\r
329 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-show-save-attachments)' >=
\r
331 > > +test_emacs '(let ((standard-input "\"attachment1.gz\""))
\r
332 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-show "id:cf0c4d610=
\r
333 911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
\r
334 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-show-save-attachme=
\r
336 > > =C2=A0test_expect_equal_file "$EXPECTED/attachment" attachment1.gz
\r
338 > > =C2=A0test_begin_subtest "Save attachment from within emacs using notmu=
\r
340 > > =C2=A0# save as archive to test that Emacs does not re-compress .gz
\r
341 > > -echo ./attachment2.gz |
\r
342 > > -test_emacs '(notmuch-show-save-part "id:cf0c4d610911171136h1713aa59w9c=
\r
343 f9aa31f052ad0a@mail.gmail.com" 5)' > /dev/null 2>&1
\r
344 > > +test_emacs '(let ((standard-input "\"attachment2.gz\""))
\r
345 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-show-save-part "id=
\r
346 :cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com" 5))' > /dev/n=
\r
348 > > =C2=A0test_expect_equal_file "$EXPECTED/attachment" attachment2.gz
\r
350 > > =C2=A0test_begin_subtest "View raw message within emacs"
\r
351 > > diff --git a/test/test-lib.el b/test/test-lib.el
\r
352 > > index 4e7f5cf..a5a3125 100644
\r
353 > > --- a/test/test-lib.el
\r
354 > > +++ b/test/test-lib.el
\r
355 > > @@ -23,6 +23,12 @@
\r
356 > > =C2=A0;; avoid crazy 10-column default of --batch
\r
357 > > =C2=A0(set-frame-width (window-frame (get-buffer-window)) 80)
\r
359 > > +;; `read-file-name' by default uses `completing-read' function to read
\r
360 > > +;; user input. =C2=A0It does not respect `standard-input' variable whi=
\r
362 > > +;; use in tests to provide user input. =C2=A0So replace it with a plain
\r
363 > > +;; `read' call.
\r
364 > > +(setq read-file-name-function (lambda (&rest _) (read)))
\r
366 > > =C2=A0(defun notmuch-test-wait ()
\r
367 > > =C2=A0 "Wait for process completion."
\r
368 > > =C2=A0 (while (get-buffer-process (current-buffer))
\r
369 > > diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
370 > > index ad1506c..1c1581b 100755
\r
371 > > --- a/test/test-lib.sh
\r
372 > > +++ b/test/test-lib.sh
\r
373 > > @@ -57,6 +57,9 @@ unset CDPATH
\r
375 > > =C2=A0unset GREP_OPTIONS
\r
377 > > +# PID of running Emacs server
\r
378 > > +emacs_server_pid=3D
\r
380 > > =C2=A0# Convenience
\r
382 > > =C2=A0# A regexp to match 5 and 40 hexdigits
\r
383 > > @@ -174,6 +177,7 @@ test_success=3D0
\r
386 > > =C2=A0 =C2=A0 =C2=A0 =C2=A0code=3D$?
\r
387 > > + =C2=A0 =C2=A0 =C2=A0 emacs_server_stop
\r
388 > > =C2=A0 =C2=A0 =C2=A0 =C2=A0if test -n "$GIT_EXIT_OK"
\r
389 > > =C2=A0 =C2=A0 =C2=A0 =C2=A0then
\r
390 > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0exit $code
\r
391 > > @@ -394,19 +398,20 @@ emacs_deliver_message ()
\r
392 > > =C2=A0 =C2=A0 mkdir -p "$MAIL_DIR"/sent/{cur,new,tmp}
\r
393 > > =C2=A0 =C2=A0 ../smtp-dummy sent_message &
\r
394 > > =C2=A0 =C2=A0 smtp_dummy_pid=3D$!
\r
395 > > - =C2=A0 =C2=A0test_emacs "(setq message-send-mail-function 'message-sm=
\r
397 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq smtpmail-smtp-=
\r
398 server \"localhost\")
\r
399 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq smtpmail-smtp-=
\r
401 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-hello)
\r
402 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail)
\r
403 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (message-goto-to)
\r
404 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (insert \"test_suite=
\r
405 @notmuchmail.org\nDate: 01 Jan 2000 12:00:00 -0000\")
\r
406 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (message-goto-subjec=
\r
408 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (insert \"${subject}=
\r
410 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (message-goto-body)
\r
411 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (insert \"${body}\")
\r
412 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $@
\r
413 > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (message-send-and-ex=
\r
414 it)" >/dev/null 2>&1
\r
415 > > + =C2=A0 =C2=A0test_emacs \
\r
416 > > + =C2=A0 =C2=A0 =C2=A0 "(let ((message-send-mail-function 'message-smtp=
\r
418 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(smtpmail-smtp-server=
\r
420 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(smtpmail-smtp-servic=
\r
422 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(notmuch-hello)
\r
423 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(notmuch-mua-mail)
\r
424 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(message-goto-to)
\r
425 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(insert \"test_suite@notmuchmail.or=
\r
426 g\nDate: 01 Jan 2000 12:00:00 -0000\")
\r
427 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(message-goto-subject)
\r
428 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(insert \"${subject}\")
\r
429 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(message-goto-body)
\r
430 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(insert \"${body}\")
\r
431 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0$@
\r
432 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(message-send-and-exit))" >/dev/nul=
\r
434 > > =C2=A0 =C2=A0 wait ${smtp_dummy_pid}
\r
435 > > =C2=A0 =C2=A0 notmuch new >/dev/null
\r
437 > > @@ -828,6 +833,8 @@ test_done () {
\r
439 > > =C2=A0 =C2=A0 =C2=A0 =C2=A0echo
\r
441 > > + =C2=A0 =C2=A0 =C2=A0 emacs_server_stop
\r
443 > > =C2=A0 =C2=A0 =C2=A0 =C2=A0if [ "$test_failure" =3D "0" ]; then
\r
444 > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if [ "$test_broken" =3D "0" ];=
\r
446 > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0rm -rf "$remove_=
\r
448 > > @@ -838,24 +845,26 @@ test_done () {
\r
449 > > =C2=A0 =C2=A0 =C2=A0 =C2=A0fi
\r
452 > > -test_emacs () {
\r
453 > > - =C2=A0 =C2=A0 =C2=A0 # Construct a little test script here for the be=
\r
455 > > - =C2=A0 =C2=A0 =C2=A0 # (who can easily run "run_emacs" to get the sam=
\r
456 e emacs environment
\r
457 > > - =C2=A0 =C2=A0 =C2=A0 # for investigating any failures).
\r
458 > > - =C2=A0 =C2=A0 =C2=A0 cat <<EOF > run_emacs
\r
459 > > +# Generate some scripts for running Emacs tests. =C2=A0These scripts a=
\r
461 > > +# used by Emacs tests and help investigating failures. =C2=A0The follo=
\r
463 > > +# scripts are generated:
\r
465 > > +# * emacs_server_start - start Emacs server
\r
466 > > +# * emacs_server_stop =C2=A0- stop Emacs server
\r
467 > > +# * emacs_start =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
\r
469 > > +# * emacs_run =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0- execute ELisp expres=
\r
470 sions in running Emacs server
\r
471 > > +emacs_generate_scripts ()
\r
473 > > + =C2=A0 =C2=A0 =C2=A0 server_name=3D"notmuch-test-suite-$$"
\r
475 > > + =C2=A0 =C2=A0 =C2=A0 cat <<EOF > "$TMP_DIRECTORY/emacs_server_start"
\r
476 > > =C2=A0#!/bin/sh
\r
477 > > =C2=A0export PATH=3D$PATH
\r
478 > > =C2=A0export NOTMUCH_CONFIG=3D$NOTMUCH_CONFIG
\r
480 > > -# We assume that the user will give a command-line argument only if
\r
481 > > -# wanting to run in batch mode.
\r
482 > > -if [ \$# -gt 0 ]; then
\r
483 > > - =C2=A0 =C2=A0 =C2=A0 BATCH=3D--batch
\r
486 > > =C2=A0# Here's what we are using here:
\r
488 > > -# --batch: =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Quit after given =
\r
489 commands and print all (messages)
\r
490 > > +# --daemon =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Start Emacs as a =
\r
493 > > =C2=A0# --no-init-file =C2=A0 =C2=A0 =C2=A0 Don't load users ~/.emacs
\r
495 > > @@ -865,13 +874,90 @@ fi
\r
497 > > =C2=A0# --load =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Force l=
\r
498 oading of notmuch.el and test-lib.el
\r
500 > > -emacs \$BATCH --no-init-file --no-site-file \
\r
501 > > - =C2=A0 =C2=A0 =C2=A0 --directory ../../emacs --load notmuch.el \
\r
502 > > - =C2=A0 =C2=A0 =C2=A0 --directory .. --load test-lib.el \
\r
503 > > - =C2=A0 =C2=A0 =C2=A0 --eval "(progn \$@)"
\r
504 > > +emacs --daemon --no-init-file --no-site-file \
\r
505 > > + =C2=A0 =C2=A0 =C2=A0 --directory "$TEST_DIRECTORY/../emacs" --load no=
\r
507 > > + =C2=A0 =C2=A0 =C2=A0 --directory "$TEST_DIRECTORY" --load test-lib.el=
\r
509 > > + =C2=A0 =C2=A0 =C2=A0 --eval '(setq server-name "$server_name")'
\r
511 > > + =C2=A0 =C2=A0 =C2=A0 chmod a+x "$TMP_DIRECTORY/emacs_server_start"
\r
513 > > + =C2=A0 =C2=A0 =C2=A0 cat <<EOF > "$TMP_DIRECTORY/emacs_server_stop"
\r
516 > > +dir=3D\$(dirname "\$0")
\r
517 > > +"\$dir"/emacs_run '(kill-emacs)'
\r
519 > > - =C2=A0 =C2=A0 =C2=A0 chmod a+x ./run_emacs
\r
520 > > - =C2=A0 =C2=A0 =C2=A0 ./run_emacs "$@"
\r
521 > > + =C2=A0 =C2=A0 =C2=A0 chmod a+x "$TMP_DIRECTORY/emacs_server_stop"
\r
523 > > + =C2=A0 =C2=A0 =C2=A0 cat <<EOF > "$TMP_DIRECTORY/emacs_start"
\r
525 > > +export PATH=3D$PATH
\r
526 > > +export NOTMUCH_CONFIG=3D$NOTMUCH_CONFIG
\r
528 > > +# Here's what we are using here:
\r
530 > > +# --no-init-file =C2=A0 =C2=A0 =C2=A0 Don't load users ~/.emacs
\r
532 > > +# --no-site-file =C2=A0 =C2=A0 =C2=A0 Don't load the site-wide startup=
\r
535 > > +# --directory =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Ensure that the local =
\r
536 elisp sources are found
\r
538 > > +# --load =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Force loadin=
\r
539 g of notmuch.el and test-lib.el
\r
541 > > +emacs --no-init-file --no-site-file \
\r
542 > > + =C2=A0 =C2=A0 =C2=A0 --directory "$TEST_DIRECTORY/../emacs" --load no=
\r
544 > > + =C2=A0 =C2=A0 =C2=A0 --directory "$TEST_DIRECTORY" --load test-lib.el
\r
546 > > + =C2=A0 =C2=A0 =C2=A0 chmod a+x "$TMP_DIRECTORY/emacs_start"
\r
548 > > + =C2=A0 =C2=A0 =C2=A0 cat <<EOF > "$TMP_DIRECTORY/emacs_run"
\r
551 > > +# Here's what we are using here:
\r
553 > > +# --socket-name =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
\r
554 =A0Emacs server name
\r
556 > > +# --eval =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Evaluate ELi=
\r
559 > > +emacsclient --socket-name "$server_name" --eval "(progn \$@)"
\r
561 > > + =C2=A0 =C2=A0 =C2=A0 chmod a+x "$TMP_DIRECTORY/emacs_run"
\r
564 > > +# Start Emacs server if it is not running.
\r
565 > > +emacs_server_start ()
\r
567 > > + =C2=A0 =C2=A0 =C2=A0 [ -n "$emacs_server_pid" ] && return
\r
569 > > + =C2=A0 =C2=A0 =C2=A0 output=3D$("$TMP_DIRECTORY/emacs_server_start" 2=
\r
571 > > + =C2=A0 =C2=A0 =C2=A0 if [ "$?" -ne 0 ]; then
\r
572 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 echo "$output"
\r
573 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return 1
\r
574 > > + =C2=A0 =C2=A0 =C2=A0 fi
\r
576 > > + =C2=A0 =C2=A0 =C2=A0 emacs_server_pid=3D$("$TMP_DIRECTORY/emacs_run" =
\r
578 > > + =C2=A0 =C2=A0 =C2=A0 [ "$?" -eq 0 -a -n "$emacs_server_pid" ]
\r
581 > > +# Stop Emacs server if it is running.
\r
582 > > +emacs_server_stop ()
\r
584 > > + =C2=A0 =C2=A0 =C2=A0 [ -z "$emacs_server_pid" ] && return
\r
586 > > + =C2=A0 =C2=A0 =C2=A0 emacs_server_pid=3D
\r
587 > > + =C2=A0 =C2=A0 =C2=A0 output=3D$("$TMP_DIRECTORY/emacs_server_stop" 2>=
\r
589 > > + =C2=A0 =C2=A0 =C2=A0 if [ "$?" -ne 0 ]; then
\r
590 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 echo "$output"
\r
591 > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return 1
\r
592 > > + =C2=A0 =C2=A0 =C2=A0 fi
\r
595 > > +# Evaluate ELisp expressions in Emacs server. =C2=A0Server is started =
\r
597 > > +# is not running.
\r
598 > > +test_emacs () {
\r
599 > > + =C2=A0 =C2=A0 =C2=A0 emacs_server_start || return
\r
601 > > + =C2=A0 =C2=A0 =C2=A0 "$TMP_DIRECTORY/emacs_run" "$@"
\r
605 > > @@ -999,6 +1085,7 @@ primary_email=3Dtest_suite@notmuchmail.org
\r
606 > > =C2=A0other_email=3Dtest_suite_other@notmuchmail.org;test_suite@otherdo=
\r
610 > > +emacs_generate_scripts
\r
612 > > =C2=A0# Use -P to resolve symlinks in our working directory so that the=
\r
614 > > =C2=A0# in subprocesses like git equals our $PWD (for pathname comparis=
\r
619 > > _______________________________________________
\r
620 > > notmuch mailing list
\r
621 > > notmuch@notmuchmail.org
\r
622 > > http://notmuchmail.org/mailman/listinfo/notmuch
\r