Re: [PATCH v4 02/16] Move crypto.c into libutil
[notmuch-archives.git] / 92 / 08c4f695702d9be359ca6b2c01f30799eea6ad
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 A4FF0429E25\r
6         for <notmuch@notmuchmail.org>; Mon, 27 Jun 2011 18:03:21 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.799\r
10 X-Spam-Level: \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 cT2OPdsY99Ju for <notmuch@notmuchmail.org>;\r
17         Mon, 27 Jun 2011 18:03:19 -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 1D3F6431FD0\r
22         for <notmuch@notmuchmail.org>; Mon, 27 Jun 2011 18:03:18 -0700 (PDT)\r
23 Received: by bwg12 with SMTP id 12so4785130bwg.26\r
24         for <notmuch@notmuchmail.org>; Mon, 27 Jun 2011 18:03:17 -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=Ssmt3zhFE8vqcl5sHdeet7qu+7denH4HMjuHb4voBP0=;\r
30         b=gWqwXcupkspRWRwEii6JD1kKQsSklrhKxBsPDTWSLDuz5IX+cPlKZlR0B0Q4xC15fY\r
31         Mex565Bv7cEBUUFTzXhey+lpmyBxySQZ3JM9+JUxWNtckkYTOiU9Bh5/c5cYPsQwURXN\r
32         UzD55XYj9A9uPZiIaJxMA/haKfutdl3imKDMQ=\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=J6xE4GLzUhLNbNkdmQmJvtFUlkV/I9MYQQmGMEVn1hvgTR2zV9JKgbHzOw8nu1Qv1V\r
37         g+amqc294tl0+5cynA/fsVxKvA3llW2wZ3D61fKx80w+mnU3z2nx2zPh9ydb7LwYrTiG\r
38         JP4iEpJY8WLmdapt28vC9POrVyvWhE/+8rdlg=\r
39 Received: by 10.204.57.82 with SMTP id b18mr1585748bkh.95.1309222997435;\r
40         Mon, 27 Jun 2011 18:03:17 -0700 (PDT)\r
41 Received: from localhost ([91.144.186.21])\r
42         by mx.google.com with ESMTPS id l24sm4630993bkw.3.2011.06.27.18.03.15\r
43         (version=TLSv1/SSLv3 cipher=OTHER);\r
44         Mon, 27 Jun 2011 18:03:16 -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: <87hb7byqge.fsf@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         <87hb7byqge.fsf@gmail.com>\r
54 User-Agent: Notmuch/0.5-275-g75c95e5 (http://notmuchmail.org) Emacs/23.3.1\r
55         (x86_64-pc-linux-gnu)\r
56 Date: Tue, 28 Jun 2011 05:03:11 +0400\r
57 Message-ID: <87d3hyzs1c.fsf@gmail.com>\r
58 MIME-Version: 1.0\r
59 Content-Type: text/plain; charset=utf-8\r
60 Content-Transfer-Encoding: quoted-printable\r
61 Cc: notmuch@notmuchmail.org\r
62 X-BeenThere: notmuch@notmuchmail.org\r
63 X-Mailman-Version: 2.1.13\r
64 Precedence: list\r
65 List-Id: "Use and development of the notmuch mail system."\r
66         <notmuch.notmuchmail.org>\r
67 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
68         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
69 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
70 List-Post: <mailto:notmuch@notmuchmail.org>\r
71 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
72 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
73         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
74 X-List-Received-Date: Tue, 28 Jun 2011 01:03:21 -0000\r
75 \r
76 Austin,\r
77 \r
78 On Tue, 28 Jun 2011 00:22:41 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmai=\r
79 l.com> wrote:\r
80 > On Mon, 27 Jun 2011 16:02:12 -0400, Austin Clements <amdragon@mit.edu> wr=\r
81 ote:\r
82 > > This looks like a great idea!  The test suite has been getting irritati=\r
83 ng slow.\r
84 > >=20\r
85 > > A few minor comments: This patch would be clearer if it the\r
86 > > setq-to-let translation were a separate patch.  It would also be worth\r
87 > > adding a big comment at the top of the test explaining why all of the\r
88 > > tests let-bind everything instead of setq'ing, primarily for the\r
89 > > benefit of people writing new tests.\r
90 > >=20\r
91 >=20\r
92 > Agreed, will separate and add the warning.\r
93 >=20\r
94 > > I might just be having trouble reading the patch, but the difference\r
95 > > between emacs_start and emacs_server_start seems unclear.  Perhaps the\r
96 > > comments should explain how somebody would use these scripts?\r
97 > >=20\r
98 >=20\r
99 > emacs_start start a normal Emacs in non-daemon mode.  Something you\r
100 > might prefer when debugging.\r
101 >=20\r
102 > >=20\r
103 > > My bigger concern with this change is that it may leave behind stale\r
104 > > emacs daemons if the script gets interrupted.\r
105 >=20\r
106 > That is an issue indeed.  I would probably do smth like a periodic check\r
107 > inside Emacs that the shell is alive, but your approach below looks more\r
108 > reliable.\r
109 >=20\r
110 > >  The only way I know to\r
111 > > reliably kill a child process is to open a pipe to it and have it exit\r
112 > > on its own when it reads EOF.  Unfortunately, I couldn't find a way to\r
113 > > do this with an emacs daemon (it appears daemon mode aggressively\r
114 > > cleans up things like pipes), but here's a different approach:\r
115 > >=20\r
116 > >     coproc emacs --batch --eval "(while t (eval (read)))"\r
117 > >     EMACSFD=3D${COPROC[1]}\r
118 > >     trap "echo '(kill-emacs)' >&$EMACSFD" EXIT\r
119 > >=20\r
120 > >     echo '(message "Hi")' >&$EMACSFD\r
121 > >     # ...\r
122 > >=20\r
123 > > This is, basically, a poor man's emacs server, but the coprocess pipe\r
124 > > binds it tightly to the shell.  If the shell exits for *any* reason,\r
125 > > the pipe will be closed by the kernel, emacs will read an EOF, and\r
126 > > exit.\r
127 >=20\r
128 > I like this idea.\r
129 >=20\r
130 > >  The trap is there just to cleanly shut down in case of a normal\r
131 > > exit [1].\r
132 >=20\r
133 > For normal exit we should just put this into test_done.  Otherwise it is\r
134 > not a normal exit and we do not care about Emacs error message.  No?\r
135 >=20\r
136 > >  This also has the advantage that read-from-minibuffer still\r
137 > > works:\r
138 > >=20\r
139 > >     echo '(message (read-from-minibuffer ""))' >&$EMACSFD\r
140 > >     echo 'Test' >&$EMACSFD\r
141 > >=20\r
142 > > Thoughts?\r
143 > >=20\r
144 >=20\r
145 > I like it and I will implement it.  Thanks for the idea.\r
146 >=20\r
147 \r
148 While implementing the idea, I stumbled upon a problem: we need to know\r
149 when Emacs finished what we echoed or failed with an error.  At the\r
150 moment tests fail because they check for OUTPUT before Emacs creates it.\r
151 \r
152 We can tell Emacs to print some special marker and wait for it.  But\r
153 there may be exceptions and errors which may make it difficult.  I did\r
154 not found a good solution yet.  Would love to hear your thoughts :)\r
155 \r
156 Regards,\r
157   Dmitry\r
158 \r
159 > Regards,\r
160 >   Dmitry\r
161 >=20\r
162 > > [1] If you don't do this, emacs complains that it can't read from\r
163 > > stdin before it exits.  It would be nice to catch this condition in\r
164 > > the elisp code and not bother with the trap, but the error thrown is\r
165 > > just an 'error, so I don't think we can catch and ignore it without\r
166 > > catching and ignoring *all* errors.\r
167 > >=20\r
168 > > On Sun, Jun 26, 2011 at 11:54 PM, Dmitry Kurochkin\r
169 > > <dmitry.kurochkin@gmail.com> wrote:\r
170 > > > Before the change, every Emacs tests ran in a separate Emacs\r
171 > > > instance. =C2=A0Starting Emacs many times wastes considerable time and\r
172 > > > it gets worse as the test suite grows. =C2=A0The patch solves this by\r
173 > > > using a single Emacs server and emacsclient(1) to run multiple\r
174 > > > tests. =C2=A0Emacs server is started on the first test_emacs call and\r
175 > > > stopped when test_done is called or the test is killed by a\r
176 > > > signal. =C2=A0Several auxiliary scripts useful for debugging and test\r
177 > > > development are generated instead of the run_emacs script:\r
178 > > >\r
179 > > > =C2=A0* emacs_server_start - start Emacs server\r
180 > > > =C2=A0* emacs_server_stop =C2=A0- stop Emacs server\r
181 > > > =C2=A0* emacs_start =C2=A0 =C2=A0 =C2=A0 =C2=A0- start Emacs\r
182 > > > =C2=A0* emacs_run =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0- execute ELisp e=\r
183 xpressions in running Emacs server\r
184 > > >\r
185 > > > Since multiple tests are run in a single Emacs instance, they\r
186 > > > must not change Emacs environment because it may affect other\r
187 > > > tests. =C2=A0For now, the only Emacs environment modifications done by\r
188 > > > the tests are variable settings. =C2=A0Before the change, variables\r
189 > > > were set with `setq' which affected other tests. =C2=A0The patch\r
190 > > > changes all variables to use `let', so the scope of the change is\r
191 > > > limited to a single test.\r
192 > > > ---\r
193 > > > =C2=A0test/emacs =C2=A0 =C2=A0 =C2=A0 | =C2=A0 74 +++++++++++++------=\r
194 -------\r
195 > > > =C2=A0test/test-lib.el | =C2=A0 =C2=A06 ++\r
196 > > > =C2=A0test/test-lib.sh | =C2=A0149 ++++++++++++++++++++++++++++++++++=\r
197 ++++++++-----------\r
198 > > > =C2=A03 files changed, 161 insertions(+), 68 deletions(-)\r
199 > > >\r
200 > > > diff --git a/test/emacs b/test/emacs\r
201 > > > index 4f16b41..f1939dc 100755\r
202 > > > --- a/test/emacs\r
203 > > > +++ b/test/emacs\r
204 > > > @@ -12,20 +12,20 @@ test_emacs '(notmuch-hello)\r
205 > > > =C2=A0test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello\r
206 > > >\r
207 > > > =C2=A0test_begin_subtest "Saved search with 0 results"\r
208 > > > -test_emacs '(setq notmuch-show-empty-saved-searches t)\r
209 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq notmuch-saved-searches\r
210 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 '\''(("inbo=\r
211 x" . "tag:inbox")\r
212 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=\r
213 =A0 =C2=A0("unread" . "tag:unread")\r
214 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=\r
215 =A0 =C2=A0("empty" . "tag:doesnotexist")))\r
216 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-hello)\r
217 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output)'\r
218 > > > +test_emacs '(let ((notmuch-show-empty-saved-searches t)\r
219 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-sa=\r
220 ved-searches\r
221 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'\''(=\r
222 ("inbox" . "tag:inbox")\r
223 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=\r
224 =A0 =C2=A0 ("unread" . "tag:unread")\r
225 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=\r
226 =A0 =C2=A0 ("empty" . "tag:doesnotexist"))))\r
227 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-hello)\r
228 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output))'\r
229 > > > =C2=A0test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-with-empty\r
230 > > >\r
231 > > > =C2=A0test_begin_subtest "No saved searches displayed (all with 0 res=\r
232 ults)"\r
233 > > > -test_emacs '(setq notmuch-saved-searches\r
234 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 '\''(("empt=\r
235 y" . "tag:doesnotexist")))\r
236 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-hello)\r
237 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output)'\r
238 > > > +test_emacs '(let ((notmuch-saved-searches\r
239 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'\''(=\r
240 ("empty" . "tag:doesnotexist"))))\r
241 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-hello)\r
242 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output))'\r
243 > > > =C2=A0test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-no-saved-=\r
244 searches\r
245 > > >\r
246 > > > =C2=A0test_begin_subtest "Basic notmuch-search view in emacs"\r
247 > > > @@ -147,9 +147,9 @@ output=3D$(notmuch search 'subject:"testing messa=\r
248 ge sent via SMTP"' | notmuch_sear\r
249 > > > =C2=A0test_expect_equal "$output" "thread:XXX =C2=A0 2000-01-01 [1/1]=\r
250  Notmuch Test Suite; Testing message sent via SMTP (inbox)"\r
251 > > >\r
252 > > > =C2=A0test_begin_subtest "notmuch-fcc-dirs set to nil"\r
253 > > > -test_emacs "(setq notmuch-fcc-dirs nil)\r
254 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail)\r
255 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output)"\r
256 > > > +test_emacs "(let ((notmuch-fcc-dirs nil))\r
257 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail)\r
258 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output))"\r
259 > > > =C2=A0cat <<EOF >EXPECTED\r
260 > > > =C2=A0From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
261 > > > =C2=A0To:\r
262 > > > @@ -164,9 +164,9 @@ mkdir -p mail/sent-string/new\r
263 > > > =C2=A0mkdir -p mail/sent-string/tmp\r
264 > > >\r
265 > > > =C2=A0test_begin_subtest "notmuch-fcc-dirs set to a string"\r
266 > > > -test_emacs "(setq notmuch-fcc-dirs \"sent-string\")\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 \"sent-string\"))\r
270 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail)\r
271 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output))"\r
272 > > > =C2=A0cat <<EOF >EXPECTED\r
273 > > > =C2=A0From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
274 > > > =C2=A0To:\r
275 > > > @@ -185,11 +185,11 @@ mkdir -p mail/failure/new\r
276 > > > =C2=A0mkdir -p mail/failure/tmp\r
277 > > >\r
278 > > > =C2=A0test_begin_subtest "notmuch-fcc-dirs set to a list (with match)"\r
279 > > > -test_emacs "(setq notmuch-fcc-dirs\r
280 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 '((\"notmuc=\r
281 hmail.org\" . \"sent-list-match\")\r
282 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (\".=\r
283 *\" . \"failure\")))\r
284 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail)\r
285 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output)"\r
286 > > > +test_emacs "(let ((notmuch-fcc-dirs\r
287 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'((\"=\r
288 notmuchmail.org\" . \"sent-list-match\")\r
289 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=\r
290 =A0(\".*\" . \"failure\"))))\r
291 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail)\r
292 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output))"\r
293 > > > =C2=A0cat <<EOF >EXPECTED\r
294 > > > =C2=A0From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
295 > > > =C2=A0To:\r
296 > > > @@ -205,11 +205,11 @@ mkdir -p mail/sent-list-catch-all/new\r
297 > > > =C2=A0mkdir -p mail/sent-list-catch-all/tmp\r
298 > > >\r
299 > > > =C2=A0test_begin_subtest "notmuch-fcc-dirs set to a list (catch-all)"\r
300 > > > -test_emacs "(setq notmuch-fcc-dirs\r
301 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 '((\"exampl=\r
302 e.com\" . \"failure\")\r
303 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (\".=\r
304 *\" . \"sent-list-catch-all\")))\r
305 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail)\r
306 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output)"\r
307 > > > +test_emacs "(let ((notmuch-fcc-dirs\r
308 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'((\"=\r
309 example.com\" . \"failure\")\r
310 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=\r
311 =A0(\".*\" . \"sent-list-catch-all\"))))\r
312 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail)\r
313 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output))"\r
314 > > > =C2=A0cat <<EOF >EXPECTED\r
315 > > > =C2=A0From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
316 > > > =C2=A0To:\r
317 > > > @@ -220,11 +220,11 @@ EOF\r
318 > > > =C2=A0test_expect_equal_file OUTPUT EXPECTED\r
319 > > >\r
320 > > > =C2=A0test_begin_subtest "notmuch-fcc-dirs set to a list (no match)"\r
321 > > > -test_emacs "(setq notmuch-fcc-dirs\r
322 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 '((\"exampl=\r
323 e.com\" . \"failure\")\r
324 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (\"n=\r
325 omatchhere.net\" . \"failure\")))\r
326 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail)\r
327 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output)"\r
328 > > > +test_emacs "(let ((notmuch-fcc-dirs\r
329 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'((\"=\r
330 example.com\" . \"failure\")\r
331 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=\r
332 =A0(\"nomatchhere.net\" . \"failure\"))))\r
333 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail)\r
334 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (test-output))"\r
335 > > > =C2=A0cat <<EOF >EXPECTED\r
336 > > > =C2=A0From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
337 > > > =C2=A0To:\r
338 > > > @@ -253,15 +253,15 @@ test_expect_equal_file OUTPUT EXPECTED\r
339 > > >\r
340 > > > =C2=A0test_begin_subtest "Save attachment from within emacs using not=\r
341 much-show-save-attachments"\r
342 > > > =C2=A0# save as archive to test that Emacs does not re-compress .gz\r
343 > > > -echo ./attachment1.gz |\r
344 > > > -test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f0=\r
345 52ad0a@mail.gmail.com")\r
346 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-show-save-attachments)'=\r
347  > /dev/null 2>&1\r
348 > > > +test_emacs '(let ((standard-input "\"attachment1.gz\""))\r
349 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-show "id:cf0c4d6=\r
350 10911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")\r
351 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-show-save-attach=\r
352 ments))'\r
353 > > > =C2=A0test_expect_equal_file "$EXPECTED/attachment" attachment1.gz\r
354 > > >\r
355 > > > =C2=A0test_begin_subtest "Save attachment from within emacs using not=\r
356 much-show-save-part"\r
357 > > > =C2=A0# save as archive to test that Emacs does not re-compress .gz\r
358 > > > -echo ./attachment2.gz |\r
359 > > > -test_emacs '(notmuch-show-save-part "id:cf0c4d610911171136h1713aa59w=\r
360 9cf9aa31f052ad0a@mail.gmail.com" 5)' > /dev/null 2>&1\r
361 > > > +test_emacs '(let ((standard-input "\"attachment2.gz\""))\r
362 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-show-save-part "=\r
363 id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com" 5))' > /dev=\r
364 /null 2>&1\r
365 > > > =C2=A0test_expect_equal_file "$EXPECTED/attachment" attachment2.gz\r
366 > > >\r
367 > > > =C2=A0test_begin_subtest "View raw message within emacs"\r
368 > > > diff --git a/test/test-lib.el b/test/test-lib.el\r
369 > > > index 4e7f5cf..a5a3125 100644\r
370 > > > --- a/test/test-lib.el\r
371 > > > +++ b/test/test-lib.el\r
372 > > > @@ -23,6 +23,12 @@\r
373 > > > =C2=A0;; avoid crazy 10-column default of --batch\r
374 > > > =C2=A0(set-frame-width (window-frame (get-buffer-window)) 80)\r
375 > > >\r
376 > > > +;; `read-file-name' by default uses `completing-read' function to re=\r
377 ad\r
378 > > > +;; user input. =C2=A0It does not respect `standard-input' variable w=\r
379 hich we\r
380 > > > +;; use in tests to provide user input. =C2=A0So replace it with a pl=\r
381 ain\r
382 > > > +;; `read' call.\r
383 > > > +(setq read-file-name-function (lambda (&rest _) (read)))\r
384 > > > +\r
385 > > > =C2=A0(defun notmuch-test-wait ()\r
386 > > > =C2=A0 "Wait for process completion."\r
387 > > > =C2=A0 (while (get-buffer-process (current-buffer))\r
388 > > > diff --git a/test/test-lib.sh b/test/test-lib.sh\r
389 > > > index ad1506c..1c1581b 100755\r
390 > > > --- a/test/test-lib.sh\r
391 > > > +++ b/test/test-lib.sh\r
392 > > > @@ -57,6 +57,9 @@ unset CDPATH\r
393 > > >\r
394 > > > =C2=A0unset GREP_OPTIONS\r
395 > > >\r
396 > > > +# PID of running Emacs server\r
397 > > > +emacs_server_pid=3D\r
398 > > > +\r
399 > > > =C2=A0# Convenience\r
400 > > > =C2=A0#\r
401 > > > =C2=A0# A regexp to match 5 and 40 hexdigits\r
402 > > > @@ -174,6 +177,7 @@ test_success=3D0\r
403 > > >\r
404 > > > =C2=A0die () {\r
405 > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0code=3D$?\r
406 > > > + =C2=A0 =C2=A0 =C2=A0 emacs_server_stop\r
407 > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0if test -n "$GIT_EXIT_OK"\r
408 > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0then\r
409 > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0exit $code\r
410 > > > @@ -394,19 +398,20 @@ emacs_deliver_message ()\r
411 > > > =C2=A0 =C2=A0 mkdir -p "$MAIL_DIR"/sent/{cur,new,tmp}\r
412 > > > =C2=A0 =C2=A0 ../smtp-dummy sent_message &\r
413 > > > =C2=A0 =C2=A0 smtp_dummy_pid=3D$!\r
414 > > > - =C2=A0 =C2=A0test_emacs "(setq message-send-mail-function 'message-=\r
415 smtpmail-send-it)\r
416 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq smtpmail-smt=\r
417 p-server \"localhost\")\r
418 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq smtpmail-smt=\r
419 p-service \"25025\")\r
420 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-hello)\r
421 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (notmuch-mua-mail)\r
422 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (message-goto-to)\r
423 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (insert \"test_sui=\r
424 te@notmuchmail.org\nDate: 01 Jan 2000 12:00:00 -0000\")\r
425 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (message-goto-subj=\r
426 ect)\r
427 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (insert \"${subjec=\r
428 t}\")\r
429 > > > - =C2=A0 =C2=A0 =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 =C2=A0 =C2=A0 (insert \"${body}\=\r
431 ")\r
432 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $@\r
433 > > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (message-send-and-=\r
434 exit)" >/dev/null 2>&1\r
435 > > > + =C2=A0 =C2=A0test_emacs \\r
436 > > > + =C2=A0 =C2=A0 =C2=A0 "(let ((message-send-mail-function 'message-sm=\r
437 tpmail-send-it)\r
438 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(smtpmail-smtp-serv=\r
439 er \"localhost\")\r
440 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(smtpmail-smtp-serv=\r
441 ice \"25025\"))\r
442 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(notmuch-hello)\r
443 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(notmuch-mua-mail)\r
444 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(message-goto-to)\r
445 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(insert \"test_suite@notmuchmail.=\r
446 org\nDate: 01 Jan 2000 12:00:00 -0000\")\r
447 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(message-goto-subject)\r
448 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(insert \"${subject}\")\r
449 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(message-goto-body)\r
450 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(insert \"${body}\")\r
451 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0$@\r
452 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(message-send-and-exit))" >/dev/n=\r
453 ull 2>&1\r
454 > > > =C2=A0 =C2=A0 wait ${smtp_dummy_pid}\r
455 > > > =C2=A0 =C2=A0 notmuch new >/dev/null\r
456 > > > =C2=A0}\r
457 > > > @@ -828,6 +833,8 @@ test_done () {\r
458 > > >\r
459 > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0echo\r
460 > > >\r
461 > > > + =C2=A0 =C2=A0 =C2=A0 emacs_server_stop\r
462 > > > +\r
463 > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0if [ "$test_failure" =3D "0" ]; then\r
464 > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if [ "$test_broken" =3D "0" =\r
465 ]; then\r
466 > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0rm -rf "$remov=\r
467 e_tmp"\r
468 > > > @@ -838,24 +845,26 @@ test_done () {\r
469 > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0fi\r
470 > > > =C2=A0}\r
471 > > >\r
472 > > > -test_emacs () {\r
473 > > > - =C2=A0 =C2=A0 =C2=A0 # Construct a little test script here for the =\r
474 benefit of the user,\r
475 > > > - =C2=A0 =C2=A0 =C2=A0 # (who can easily run "run_emacs" to get the s=\r
476 ame emacs environment\r
477 > > > - =C2=A0 =C2=A0 =C2=A0 # for investigating any failures).\r
478 > > > - =C2=A0 =C2=A0 =C2=A0 cat <<EOF > run_emacs\r
479 > > > +# Generate some scripts for running Emacs tests. =C2=A0These scripts=\r
480  are\r
481 > > > +# used by Emacs tests and help investigating failures. =C2=A0The fol=\r
482 lowing\r
483 > > > +# scripts are generated:\r
484 > > > +#\r
485 > > > +# * emacs_server_start - start Emacs server\r
486 > > > +# * emacs_server_stop =C2=A0- stop Emacs server\r
487 > > > +# * emacs_start =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=\r
488 =A0- start Emacs\r
489 > > > +# * emacs_run =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0- execute ELisp expr=\r
490 essions in running Emacs server\r
491 > > > +emacs_generate_scripts ()\r
492 > > > +{\r
493 > > > + =C2=A0 =C2=A0 =C2=A0 server_name=3D"notmuch-test-suite-$$"\r
494 > > > +\r
495 > > > + =C2=A0 =C2=A0 =C2=A0 cat <<EOF > "$TMP_DIRECTORY/emacs_server_start"\r
496 > > > =C2=A0#!/bin/sh\r
497 > > > =C2=A0export PATH=3D$PATH\r
498 > > > =C2=A0export NOTMUCH_CONFIG=3D$NOTMUCH_CONFIG\r
499 > > >\r
500 > > > -# We assume that the user will give a command-line argument only if\r
501 > > > -# wanting to run in batch mode.\r
502 > > > -if [ \$# -gt 0 ]; then\r
503 > > > - =C2=A0 =C2=A0 =C2=A0 BATCH=3D--batch\r
504 > > > -fi\r
505 > > > -\r
506 > > > =C2=A0# Here's what we are using here:\r
507 > > > =C2=A0#\r
508 > > > -# --batch: =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Quit after give=\r
509 n commands and print all (messages)\r
510 > > > +# --daemon =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Start Emacs as =\r
511 a daemon\r
512 > > > =C2=A0#\r
513 > > > =C2=A0# --no-init-file =C2=A0 =C2=A0 =C2=A0 Don't load users ~/.emacs\r
514 > > > =C2=A0#\r
515 > > > @@ -865,13 +874,90 @@ fi\r
516 > > > =C2=A0#\r
517 > > > =C2=A0# --load =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Force=\r
518  loading of notmuch.el and test-lib.el\r
519 > > >\r
520 > > > -emacs \$BATCH --no-init-file --no-site-file \\r
521 > > > - =C2=A0 =C2=A0 =C2=A0 --directory ../../emacs --load notmuch.el \\r
522 > > > - =C2=A0 =C2=A0 =C2=A0 --directory .. --load test-lib.el \\r
523 > > > - =C2=A0 =C2=A0 =C2=A0 --eval "(progn \$@)"\r
524 > > > +emacs --daemon --no-init-file --no-site-file \\r
525 > > > + =C2=A0 =C2=A0 =C2=A0 --directory "$TEST_DIRECTORY/../emacs" --load =\r
526 notmuch.el \\r
527 > > > + =C2=A0 =C2=A0 =C2=A0 --directory "$TEST_DIRECTORY" --load test-lib.=\r
528 el \\r
529 > > > + =C2=A0 =C2=A0 =C2=A0 --eval '(setq server-name "$server_name")'\r
530 > > > +EOF\r
531 > > > + =C2=A0 =C2=A0 =C2=A0 chmod a+x "$TMP_DIRECTORY/emacs_server_start"\r
532 > > > +\r
533 > > > + =C2=A0 =C2=A0 =C2=A0 cat <<EOF > "$TMP_DIRECTORY/emacs_server_stop"\r
534 > > > +#!/bin/sh\r
535 > > > +\r
536 > > > +dir=3D\$(dirname "\$0")\r
537 > > > +"\$dir"/emacs_run '(kill-emacs)'\r
538 > > > =C2=A0EOF\r
539 > > > - =C2=A0 =C2=A0 =C2=A0 chmod a+x ./run_emacs\r
540 > > > - =C2=A0 =C2=A0 =C2=A0 ./run_emacs "$@"\r
541 > > > + =C2=A0 =C2=A0 =C2=A0 chmod a+x "$TMP_DIRECTORY/emacs_server_stop"\r
542 > > > +\r
543 > > > + =C2=A0 =C2=A0 =C2=A0 cat <<EOF > "$TMP_DIRECTORY/emacs_start"\r
544 > > > +#!/bin/sh\r
545 > > > +export PATH=3D$PATH\r
546 > > > +export NOTMUCH_CONFIG=3D$NOTMUCH_CONFIG\r
547 > > > +\r
548 > > > +# Here's what we are using here:\r
549 > > > +#\r
550 > > > +# --no-init-file =C2=A0 =C2=A0 =C2=A0 Don't load users ~/.emacs\r
551 > > > +#\r
552 > > > +# --no-site-file =C2=A0 =C2=A0 =C2=A0 Don't load the site-wide start=\r
553 up stuff\r
554 > > > +#\r
555 > > > +# --directory =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Ensure that the loca=\r
556 l elisp sources are found\r
557 > > > +#\r
558 > > > +# --load =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Force load=\r
559 ing of notmuch.el and test-lib.el\r
560 > > > +\r
561 > > > +emacs --no-init-file --no-site-file \\r
562 > > > + =C2=A0 =C2=A0 =C2=A0 --directory "$TEST_DIRECTORY/../emacs" --load =\r
563 notmuch.el \\r
564 > > > + =C2=A0 =C2=A0 =C2=A0 --directory "$TEST_DIRECTORY" --load test-lib.=\r
565 el\r
566 > > > +EOF\r
567 > > > + =C2=A0 =C2=A0 =C2=A0 chmod a+x "$TMP_DIRECTORY/emacs_start"\r
568 > > > +\r
569 > > > + =C2=A0 =C2=A0 =C2=A0 cat <<EOF > "$TMP_DIRECTORY/emacs_run"\r
570 > > > +#!/bin/sh\r
571 > > > +\r
572 > > > +# Here's what we are using here:\r
573 > > > +#\r
574 > > > +# --socket-name =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=\r
575 =A0Emacs server name\r
576 > > > +#\r
577 > > > +# --eval =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Evaluate E=\r
578 Lisp expressions\r
579 > > > +\r
580 > > > +emacsclient --socket-name "$server_name" --eval "(progn \$@)"\r
581 > > > +EOF\r
582 > > > + =C2=A0 =C2=A0 =C2=A0 chmod a+x "$TMP_DIRECTORY/emacs_run"\r
583 > > > +}\r
584 > > > +\r
585 > > > +# Start Emacs server if it is not running.\r
586 > > > +emacs_server_start ()\r
587 > > > +{\r
588 > > > + =C2=A0 =C2=A0 =C2=A0 [ -n "$emacs_server_pid" ] && return\r
589 > > > +\r
590 > > > + =C2=A0 =C2=A0 =C2=A0 output=3D$("$TMP_DIRECTORY/emacs_server_start"=\r
591  2>&1)\r
592 > > > + =C2=A0 =C2=A0 =C2=A0 if [ "$?" -ne 0 ]; then\r
593 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 echo "$output"\r
594 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return 1\r
595 > > > + =C2=A0 =C2=A0 =C2=A0 fi\r
596 > > > +\r
597 > > > + =C2=A0 =C2=A0 =C2=A0 emacs_server_pid=3D$("$TMP_DIRECTORY/emacs_run=\r
598 " '(emacs-pid)')\r
599 > > > + =C2=A0 =C2=A0 =C2=A0 [ "$?" -eq 0 -a -n "$emacs_server_pid" ]\r
600 > > > +}\r
601 > > > +\r
602 > > > +# Stop Emacs server if it is running.\r
603 > > > +emacs_server_stop ()\r
604 > > > +{\r
605 > > > + =C2=A0 =C2=A0 =C2=A0 [ -z "$emacs_server_pid" ] && return\r
606 > > > +\r
607 > > > + =C2=A0 =C2=A0 =C2=A0 emacs_server_pid=3D\r
608 > > > + =C2=A0 =C2=A0 =C2=A0 output=3D$("$TMP_DIRECTORY/emacs_server_stop" =\r
609 2>&1)\r
610 > > > + =C2=A0 =C2=A0 =C2=A0 if [ "$?" -ne 0 ]; then\r
611 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 echo "$output"\r
612 > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return 1\r
613 > > > + =C2=A0 =C2=A0 =C2=A0 fi\r
614 > > > +}\r
615 > > > +\r
616 > > > +# Evaluate ELisp expressions in Emacs server. =C2=A0Server is starte=\r
617 d if it\r
618 > > > +# is not running.\r
619 > > > +test_emacs () {\r
620 > > > + =C2=A0 =C2=A0 =C2=A0 emacs_server_start || return\r
621 > > > +\r
622 > > > + =C2=A0 =C2=A0 =C2=A0 "$TMP_DIRECTORY/emacs_run" "$@"\r
623 > > > =C2=A0}\r
624 > > >\r
625 > > >\r
626 > > > @@ -999,6 +1085,7 @@ primary_email=3Dtest_suite@notmuchmail.org\r
627 > > > =C2=A0other_email=3Dtest_suite_other@notmuchmail.org;test_suite@other=\r
628 domain.org\r
629 > > > =C2=A0EOF\r
630 > > >\r
631 > > > +emacs_generate_scripts\r
632 > > >\r
633 > > > =C2=A0# Use -P to resolve symlinks in our working directory so that t=\r
634 he cwd\r
635 > > > =C2=A0# in subprocesses like git equals our $PWD (for pathname compar=\r
636 isons).\r
637 > > > --\r
638 > > > 1.7.5.4\r
639 > > >\r
640 > > > _______________________________________________\r
641 > > > notmuch mailing list\r
642 > > > notmuch@notmuchmail.org\r
643 > > > http://notmuchmail.org/mailman/listinfo/notmuch\r
644 > > >\r