Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 79 / 8fd4368479785825bd6ad7143304d4e2026f7e
1 Return-Path: <amdragon@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 9CEB0431FD0\r
6         for <notmuch@notmuchmail.org>; Mon, 27 Jun 2011 13:02:15 -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.699\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001,\r
13         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 r+t7R3j7oRzQ for <notmuch@notmuchmail.org>;\r
17         Mon, 27 Jun 2011 13:02:14 -0700 (PDT)\r
18 Received: from mail-qw0-f53.google.com (mail-qw0-f53.google.com\r
19         [209.85.216.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 CEC3D431FB6\r
22         for <notmuch@notmuchmail.org>; Mon, 27 Jun 2011 13:02:13 -0700 (PDT)\r
23 Received: by qwb7 with SMTP id 7so3029177qwb.26\r
24         for <notmuch@notmuchmail.org>; Mon, 27 Jun 2011 13:02:13 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
26         h=domainkey-signature:mime-version:sender:in-reply-to:references:date\r
27         :x-google-sender-auth:message-id:subject:from:to:cc:content-type\r
28         :content-transfer-encoding;\r
29         bh=g0fn8cOw3LUHNjKg/ZqatePchiyE4lRQxfkbJ3GESK4=;\r
30         b=QOfV0Zgc5uznIpYVy7iH3quXEh7r754aqaaCTyV9YSIZSQ9lYSaEYI0oMpBIeQ/w+v\r
31         NzYCUQU2eTB5e1wxcNicbYiWXVHF0d9RjWP7MpWZ+SbSgXerpNO3qq4L6u2myrFTOGSC\r
32         MhCOmlZRHtKufJ5jKkeTgI/FaSAbEzlB5j5Zc=\r
33 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;\r
34         h=mime-version:sender:in-reply-to:references:date\r
35         :x-google-sender-auth:message-id:subject:from:to:cc:content-type\r
36         :content-transfer-encoding;\r
37         b=fIZEg/5qLTt4wreQaQUE015xw4MjezudVASYkf7Qi0NRCcaGfP3q3OrIe5P0glCF07\r
38         AXcHl0Xwx8X/52pAoVa6VbFUZFYqgmypTfAmgo0iuwa81tKI2X75+fjxiC9EEuO+5JDV\r
39         +aWUKPRo2BbcnepJJsf73N76VyT7vNd84z9CY=\r
40 MIME-Version: 1.0\r
41 Received: by 10.229.31.1 with SMTP id w1mr5017289qcc.138.1309204932843; Mon,\r
42         27 Jun 2011 13:02:12 -0700 (PDT)\r
43 Sender: amdragon@gmail.com\r
44 Received: by 10.229.32.197 with HTTP; Mon, 27 Jun 2011 13:02:12 -0700 (PDT)\r
45 In-Reply-To: <1309146846-30991-2-git-send-email-dmitry.kurochkin@gmail.com>\r
46 References: <1309132379-24089-1-git-send-email-dmitry.kurochkin@gmail.com>\r
47         <1309146846-30991-1-git-send-email-dmitry.kurochkin@gmail.com>\r
48         <1309146846-30991-2-git-send-email-dmitry.kurochkin@gmail.com>\r
49 Date: Mon, 27 Jun 2011 16:02:12 -0400\r
50 X-Google-Sender-Auth: sYb_aZUXipdxhfxamd47bUKh1w8\r
51 Message-ID: <BANLkTi=nwHRndz367K5oh4=tPaU-KNeZ8Q@mail.gmail.com>\r
52 Subject: Re: [PATCH 2/2] test: use emacsclient(1) for Emacs tests\r
53 From: Austin Clements <amdragon@mit.edu>\r
54 To: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
55 Content-Type: text/plain; charset=ISO-8859-1\r
56 Content-Transfer-Encoding: quoted-printable\r
57 Cc: notmuch@notmuchmail.org\r
58 X-BeenThere: notmuch@notmuchmail.org\r
59 X-Mailman-Version: 2.1.13\r
60 Precedence: list\r
61 List-Id: "Use and development of the notmuch mail system."\r
62         <notmuch.notmuchmail.org>\r
63 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
65 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
66 List-Post: <mailto:notmuch@notmuchmail.org>\r
67 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
68 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
69         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
70 X-List-Received-Date: Mon, 27 Jun 2011 20:02:15 -0000\r
71 \r
72 This looks like a great idea!  The test suite has been getting irritating s=\r
73 low.\r
74 \r
75 A few minor comments: This patch would be clearer if it the\r
76 setq-to-let translation were a separate patch.  It would also be worth\r
77 adding a big comment at the top of the test explaining why all of the\r
78 tests let-bind everything instead of setq'ing, primarily for the\r
79 benefit of people writing new tests.\r
80 \r
81 I might just be having trouble reading the patch, but the difference\r
82 between emacs_start and emacs_server_start seems unclear.  Perhaps the\r
83 comments should explain how somebody would use these scripts?\r
84 \r
85 \r
86 My bigger concern with this change is that it may leave behind stale\r
87 emacs daemons if the script gets interrupted.  The only way I know to\r
88 reliably kill a child process is to open a pipe to it and have it exit\r
89 on its own when it reads EOF.  Unfortunately, I couldn't find a way to\r
90 do this with an emacs daemon (it appears daemon mode aggressively\r
91 cleans up things like pipes), but here's a different approach:\r
92 \r
93     coproc emacs --batch --eval "(while t (eval (read)))"\r
94     EMACSFD=3D${COPROC[1]}\r
95     trap "echo '(kill-emacs)' >&$EMACSFD" EXIT\r
96 \r
97     echo '(message "Hi")' >&$EMACSFD\r
98     # ...\r
99 \r
100 This is, basically, a poor man's emacs server, but the coprocess pipe\r
101 binds it tightly to the shell.  If the shell exits for *any* reason,\r
102 the pipe will be closed by the kernel, emacs will read an EOF, and\r
103 exit.  The trap is there just to cleanly shut down in case of a normal\r
104 exit [1].  This also has the advantage that read-from-minibuffer still\r
105 works:\r
106 \r
107     echo '(message (read-from-minibuffer ""))' >&$EMACSFD\r
108     echo 'Test' >&$EMACSFD\r
109 \r
110 Thoughts?\r
111 \r
112 [1] If you don't do this, emacs complains that it can't read from\r
113 stdin before it exits.  It would be nice to catch this condition in\r
114 the elisp code and not bother with the trap, but the error thrown is\r
115 just an 'error, so I don't think we can catch and ignore it without\r
116 catching and ignoring *all* errors.\r
117 \r
118 On Sun, Jun 26, 2011 at 11:54 PM, Dmitry Kurochkin\r
119 <dmitry.kurochkin@gmail.com> wrote:\r
120 > Before the change, every Emacs tests ran in a separate Emacs\r
121 > instance. =A0Starting Emacs many times wastes considerable time and\r
122 > it gets worse as the test suite grows. =A0The patch solves this by\r
123 > using a single Emacs server and emacsclient(1) to run multiple\r
124 > tests. =A0Emacs server is started on the first test_emacs call and\r
125 > stopped when test_done is called or the test is killed by a\r
126 > signal. =A0Several auxiliary scripts useful for debugging and test\r
127 > development are generated instead of the run_emacs script:\r
128 >\r
129 > =A0* emacs_server_start - start Emacs server\r
130 > =A0* emacs_server_stop =A0- stop Emacs server\r
131 > =A0* emacs_start =A0 =A0 =A0 =A0- start Emacs\r
132 > =A0* emacs_run =A0 =A0 =A0 =A0 =A0- execute ELisp expressions in running =\r
133 Emacs server\r
134 >\r
135 > Since multiple tests are run in a single Emacs instance, they\r
136 > must not change Emacs environment because it may affect other\r
137 > tests. =A0For now, the only Emacs environment modifications done by\r
138 > the tests are variable settings. =A0Before the change, variables\r
139 > were set with `setq' which affected other tests. =A0The patch\r
140 > changes all variables to use `let', so the scope of the change is\r
141 > limited to a single test.\r
142 > ---\r
143 > =A0test/emacs =A0 =A0 =A0 | =A0 74 +++++++++++++-------------\r
144 > =A0test/test-lib.el | =A0 =A06 ++\r
145 > =A0test/test-lib.sh | =A0149 ++++++++++++++++++++++++++++++++++++++++++--=\r
146 ---------\r
147 > =A03 files changed, 161 insertions(+), 68 deletions(-)\r
148 >\r
149 > diff --git a/test/emacs b/test/emacs\r
150 > index 4f16b41..f1939dc 100755\r
151 > --- a/test/emacs\r
152 > +++ b/test/emacs\r
153 > @@ -12,20 +12,20 @@ test_emacs '(notmuch-hello)\r
154 > =A0test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello\r
155 >\r
156 > =A0test_begin_subtest "Saved search with 0 results"\r
157 > -test_emacs '(setq notmuch-show-empty-saved-searches t)\r
158 > - =A0 =A0 =A0 =A0 =A0 (setq notmuch-saved-searches\r
159 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 '\''(("inbox" . "tag:inbox")\r
160 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0("unread" . "tag:unread")\r
161 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0("empty" . "tag:doesnotexist=\r
162 ")))\r
163 > - =A0 =A0 =A0 =A0 =A0 (notmuch-hello)\r
164 > - =A0 =A0 =A0 =A0 =A0 (test-output)'\r
165 > +test_emacs '(let ((notmuch-show-empty-saved-searches t)\r
166 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-saved-searches\r
167 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0'\''(("inbox" . "tag:inbox")\r
168 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ("unread" . "tag:unread")\r
169 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ("empty" . "tag:doesnotexis=\r
170 t"))))\r
171 > + =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-hello)\r
172 > + =A0 =A0 =A0 =A0 =A0 =A0 (test-output))'\r
173 > =A0test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-with-empty\r
174 >\r
175 > =A0test_begin_subtest "No saved searches displayed (all with 0 results)"\r
176 > -test_emacs '(setq notmuch-saved-searches\r
177 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 '\''(("empty" . "tag:doesnotexist")))\r
178 > - =A0 =A0 =A0 =A0 =A0 (notmuch-hello)\r
179 > - =A0 =A0 =A0 =A0 =A0 (test-output)'\r
180 > +test_emacs '(let ((notmuch-saved-searches\r
181 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0'\''(("empty" . "tag:doesnotexist"))=\r
182 ))\r
183 > + =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-hello)\r
184 > + =A0 =A0 =A0 =A0 =A0 =A0 (test-output))'\r
185 > =A0test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-no-saved-searche=\r
186 s\r
187 >\r
188 > =A0test_begin_subtest "Basic notmuch-search view in emacs"\r
189 > @@ -147,9 +147,9 @@ output=3D$(notmuch search 'subject:"testing message s=\r
190 ent via SMTP"' | notmuch_sear\r
191 > =A0test_expect_equal "$output" "thread:XXX =A0 2000-01-01 [1/1] Notmuch T=\r
192 est Suite; Testing message sent via SMTP (inbox)"\r
193 >\r
194 > =A0test_begin_subtest "notmuch-fcc-dirs set to nil"\r
195 > -test_emacs "(setq notmuch-fcc-dirs nil)\r
196 > - =A0 =A0 =A0 =A0 =A0 (notmuch-mua-mail)\r
197 > - =A0 =A0 =A0 =A0 =A0 (test-output)"\r
198 > +test_emacs "(let ((notmuch-fcc-dirs nil))\r
199 > + =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-mua-mail)\r
200 > + =A0 =A0 =A0 =A0 =A0 =A0 (test-output))"\r
201 > =A0cat <<EOF >EXPECTED\r
202 > =A0From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
203 > =A0To:\r
204 > @@ -164,9 +164,9 @@ mkdir -p mail/sent-string/new\r
205 > =A0mkdir -p mail/sent-string/tmp\r
206 >\r
207 > =A0test_begin_subtest "notmuch-fcc-dirs set to a string"\r
208 > -test_emacs "(setq notmuch-fcc-dirs \"sent-string\")\r
209 > - =A0 =A0 =A0 =A0 =A0 (notmuch-mua-mail)\r
210 > - =A0 =A0 =A0 =A0 =A0 (test-output)"\r
211 > +test_emacs "(let ((notmuch-fcc-dirs \"sent-string\"))\r
212 > + =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-mua-mail)\r
213 > + =A0 =A0 =A0 =A0 =A0 =A0 (test-output))"\r
214 > =A0cat <<EOF >EXPECTED\r
215 > =A0From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
216 > =A0To:\r
217 > @@ -185,11 +185,11 @@ mkdir -p mail/failure/new\r
218 > =A0mkdir -p mail/failure/tmp\r
219 >\r
220 > =A0test_begin_subtest "notmuch-fcc-dirs set to a list (with match)"\r
221 > -test_emacs "(setq notmuch-fcc-dirs\r
222 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 '((\"notmuchmail.org\" . \"sent-list-ma=\r
223 tch\")\r
224 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (\".*\" . \"failure\")))\r
225 > - =A0 =A0 =A0 =A0 =A0 (notmuch-mua-mail)\r
226 > - =A0 =A0 =A0 =A0 =A0 (test-output)"\r
227 > +test_emacs "(let ((notmuch-fcc-dirs\r
228 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0'((\"notmuchmail.org\" . \"sent-list=\r
229 -match\")\r
230 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(\".*\" . \"failure\"))))\r
231 > + =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-mua-mail)\r
232 > + =A0 =A0 =A0 =A0 =A0 =A0 (test-output))"\r
233 > =A0cat <<EOF >EXPECTED\r
234 > =A0From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
235 > =A0To:\r
236 > @@ -205,11 +205,11 @@ mkdir -p mail/sent-list-catch-all/new\r
237 > =A0mkdir -p mail/sent-list-catch-all/tmp\r
238 >\r
239 > =A0test_begin_subtest "notmuch-fcc-dirs set to a list (catch-all)"\r
240 > -test_emacs "(setq notmuch-fcc-dirs\r
241 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 '((\"example.com\" . \"failure\")\r
242 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (\".*\" . \"sent-list-catch-all\"))=\r
243 )\r
244 > - =A0 =A0 =A0 =A0 =A0 (notmuch-mua-mail)\r
245 > - =A0 =A0 =A0 =A0 =A0 (test-output)"\r
246 > +test_emacs "(let ((notmuch-fcc-dirs\r
247 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0'((\"example.com\" . \"failure\")\r
248 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(\".*\" . \"sent-list-catch-all\=\r
249 "))))\r
250 > + =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-mua-mail)\r
251 > + =A0 =A0 =A0 =A0 =A0 =A0 (test-output))"\r
252 > =A0cat <<EOF >EXPECTED\r
253 > =A0From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
254 > =A0To:\r
255 > @@ -220,11 +220,11 @@ EOF\r
256 > =A0test_expect_equal_file OUTPUT EXPECTED\r
257 >\r
258 > =A0test_begin_subtest "notmuch-fcc-dirs set to a list (no match)"\r
259 > -test_emacs "(setq notmuch-fcc-dirs\r
260 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 '((\"example.com\" . \"failure\")\r
261 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (\"nomatchhere.net\" . \"failure\")=\r
262 ))\r
263 > - =A0 =A0 =A0 =A0 =A0 (notmuch-mua-mail)\r
264 > - =A0 =A0 =A0 =A0 =A0 (test-output)"\r
265 > +test_emacs "(let ((notmuch-fcc-dirs\r
266 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0'((\"example.com\" . \"failure\")\r
267 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(\"nomatchhere.net\" . \"failure=\r
268 \"))))\r
269 > + =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-mua-mail)\r
270 > + =A0 =A0 =A0 =A0 =A0 =A0 (test-output))"\r
271 > =A0cat <<EOF >EXPECTED\r
272 > =A0From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
273 > =A0To:\r
274 > @@ -253,15 +253,15 @@ test_expect_equal_file OUTPUT EXPECTED\r
275 >\r
276 > =A0test_begin_subtest "Save attachment from within emacs using notmuch-sh=\r
277 ow-save-attachments"\r
278 > =A0# save as archive to test that Emacs does not re-compress .gz\r
279 > -echo ./attachment1.gz |\r
280 > -test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad=\r
281 0a@mail.gmail.com")\r
282 > - =A0 =A0 =A0 =A0 =A0 (notmuch-show-save-attachments)' > /dev/null 2>&1\r
283 > +test_emacs '(let ((standard-input "\"attachment1.gz\""))\r
284 > + =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-show "id:cf0c4d610911171136h1713aa59w9=\r
285 cf9aa31f052ad0a@mail.gmail.com")\r
286 > + =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-show-save-attachments))'\r
287 > =A0test_expect_equal_file "$EXPECTED/attachment" attachment1.gz\r
288 >\r
289 > =A0test_begin_subtest "Save attachment from within emacs using notmuch-sh=\r
290 ow-save-part"\r
291 > =A0# save as archive to test that Emacs does not re-compress .gz\r
292 > -echo ./attachment2.gz |\r
293 > -test_emacs '(notmuch-show-save-part "id:cf0c4d610911171136h1713aa59w9cf9=\r
294 aa31f052ad0a@mail.gmail.com" 5)' > /dev/null 2>&1\r
295 > +test_emacs '(let ((standard-input "\"attachment2.gz\""))\r
296 > + =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-show-save-part "id:cf0c4d610911171136h=\r
297 1713aa59w9cf9aa31f052ad0a@mail.gmail.com" 5))' > /dev/null 2>&1\r
298 > =A0test_expect_equal_file "$EXPECTED/attachment" attachment2.gz\r
299 >\r
300 > =A0test_begin_subtest "View raw message within emacs"\r
301 > diff --git a/test/test-lib.el b/test/test-lib.el\r
302 > index 4e7f5cf..a5a3125 100644\r
303 > --- a/test/test-lib.el\r
304 > +++ b/test/test-lib.el\r
305 > @@ -23,6 +23,12 @@\r
306 > =A0;; avoid crazy 10-column default of --batch\r
307 > =A0(set-frame-width (window-frame (get-buffer-window)) 80)\r
308 >\r
309 > +;; `read-file-name' by default uses `completing-read' function to read\r
310 > +;; user input. =A0It does not respect `standard-input' variable which we\r
311 > +;; use in tests to provide user input. =A0So replace it with a plain\r
312 > +;; `read' call.\r
313 > +(setq read-file-name-function (lambda (&rest _) (read)))\r
314 > +\r
315 > =A0(defun notmuch-test-wait ()\r
316 > =A0 "Wait for process completion."\r
317 > =A0 (while (get-buffer-process (current-buffer))\r
318 > diff --git a/test/test-lib.sh b/test/test-lib.sh\r
319 > index ad1506c..1c1581b 100755\r
320 > --- a/test/test-lib.sh\r
321 > +++ b/test/test-lib.sh\r
322 > @@ -57,6 +57,9 @@ unset CDPATH\r
323 >\r
324 > =A0unset GREP_OPTIONS\r
325 >\r
326 > +# PID of running Emacs server\r
327 > +emacs_server_pid=3D\r
328 > +\r
329 > =A0# Convenience\r
330 > =A0#\r
331 > =A0# A regexp to match 5 and 40 hexdigits\r
332 > @@ -174,6 +177,7 @@ test_success=3D0\r
333 >\r
334 > =A0die () {\r
335 > =A0 =A0 =A0 =A0code=3D$?\r
336 > + =A0 =A0 =A0 emacs_server_stop\r
337 > =A0 =A0 =A0 =A0if test -n "$GIT_EXIT_OK"\r
338 > =A0 =A0 =A0 =A0then\r
339 > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0exit $code\r
340 > @@ -394,19 +398,20 @@ emacs_deliver_message ()\r
341 > =A0 =A0 mkdir -p "$MAIL_DIR"/sent/{cur,new,tmp}\r
342 > =A0 =A0 ../smtp-dummy sent_message &\r
343 > =A0 =A0 smtp_dummy_pid=3D$!\r
344 > - =A0 =A0test_emacs "(setq message-send-mail-function 'message-smtpmail-s=\r
345 end-it)\r
346 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 (setq smtpmail-smtp-server \"localhost\")\r
347 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 (setq smtpmail-smtp-service \"25025\")\r
348 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-hello)\r
349 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 (notmuch-mua-mail)\r
350 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 (message-goto-to)\r
351 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 (insert \"test_suite@notmuchmail.org\nDate:=\r
352  01 Jan 2000 12:00:00 -0000\")\r
353 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 (message-goto-subject)\r
354 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 (insert \"${subject}\")\r
355 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 (message-goto-body)\r
356 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 (insert \"${body}\")\r
357 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 $@\r
358 > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 (message-send-and-exit)" >/dev/null 2>&1\r
359 > + =A0 =A0test_emacs \\r
360 > + =A0 =A0 =A0 "(let ((message-send-mail-function 'message-smtpmail-send-i=\r
361 t)\r
362 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0(smtpmail-smtp-server \"localhost\")\r
363 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0(smtpmail-smtp-service \"25025\"))\r
364 > + =A0 =A0 =A0 =A0 =A0(notmuch-hello)\r
365 > + =A0 =A0 =A0 =A0 =A0(notmuch-mua-mail)\r
366 > + =A0 =A0 =A0 =A0 =A0(message-goto-to)\r
367 > + =A0 =A0 =A0 =A0 =A0(insert \"test_suite@notmuchmail.org\nDate: 01 Jan 2=\r
368 000 12:00:00 -0000\")\r
369 > + =A0 =A0 =A0 =A0 =A0(message-goto-subject)\r
370 > + =A0 =A0 =A0 =A0 =A0(insert \"${subject}\")\r
371 > + =A0 =A0 =A0 =A0 =A0(message-goto-body)\r
372 > + =A0 =A0 =A0 =A0 =A0(insert \"${body}\")\r
373 > + =A0 =A0 =A0 =A0 =A0$@\r
374 > + =A0 =A0 =A0 =A0 =A0(message-send-and-exit))" >/dev/null 2>&1\r
375 > =A0 =A0 wait ${smtp_dummy_pid}\r
376 > =A0 =A0 notmuch new >/dev/null\r
377 > =A0}\r
378 > @@ -828,6 +833,8 @@ test_done () {\r
379 >\r
380 > =A0 =A0 =A0 =A0echo\r
381 >\r
382 > + =A0 =A0 =A0 emacs_server_stop\r
383 > +\r
384 > =A0 =A0 =A0 =A0if [ "$test_failure" =3D "0" ]; then\r
385 > =A0 =A0 =A0 =A0 =A0 =A0if [ "$test_broken" =3D "0" ]; then\r
386 > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0rm -rf "$remove_tmp"\r
387 > @@ -838,24 +845,26 @@ test_done () {\r
388 > =A0 =A0 =A0 =A0fi\r
389 > =A0}\r
390 >\r
391 > -test_emacs () {\r
392 > - =A0 =A0 =A0 # Construct a little test script here for the benefit of th=\r
393 e user,\r
394 > - =A0 =A0 =A0 # (who can easily run "run_emacs" to get the same emacs env=\r
395 ironment\r
396 > - =A0 =A0 =A0 # for investigating any failures).\r
397 > - =A0 =A0 =A0 cat <<EOF > run_emacs\r
398 > +# Generate some scripts for running Emacs tests. =A0These scripts are\r
399 > +# used by Emacs tests and help investigating failures. =A0The following\r
400 > +# scripts are generated:\r
401 > +#\r
402 > +# * emacs_server_start - start Emacs server\r
403 > +# * emacs_server_stop =A0- stop Emacs server\r
404 > +# * emacs_start =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0- start Emacs\r
405 > +# * emacs_run =A0 =A0 =A0 =A0 =A0- execute ELisp expressions in running =\r
406 Emacs server\r
407 > +emacs_generate_scripts ()\r
408 > +{\r
409 > + =A0 =A0 =A0 server_name=3D"notmuch-test-suite-$$"\r
410 > +\r
411 > + =A0 =A0 =A0 cat <<EOF > "$TMP_DIRECTORY/emacs_server_start"\r
412 > =A0#!/bin/sh\r
413 > =A0export PATH=3D$PATH\r
414 > =A0export NOTMUCH_CONFIG=3D$NOTMUCH_CONFIG\r
415 >\r
416 > -# We assume that the user will give a command-line argument only if\r
417 > -# wanting to run in batch mode.\r
418 > -if [ \$# -gt 0 ]; then\r
419 > - =A0 =A0 =A0 BATCH=3D--batch\r
420 > -fi\r
421 > -\r
422 > =A0# Here's what we are using here:\r
423 > =A0#\r
424 > -# --batch: =A0 =A0 =A0 =A0 =A0 =A0 Quit after given commands and print a=\r
425 ll (messages)\r
426 > +# --daemon =A0 =A0 =A0 =A0 =A0 =A0 Start Emacs as a daemon\r
427 > =A0#\r
428 > =A0# --no-init-file =A0 =A0 =A0 Don't load users ~/.emacs\r
429 > =A0#\r
430 > @@ -865,13 +874,90 @@ fi\r
431 > =A0#\r
432 > =A0# --load =A0 =A0 =A0 =A0 =A0 =A0 =A0 Force loading of notmuch.el and t=\r
433 est-lib.el\r
434 >\r
435 > -emacs \$BATCH --no-init-file --no-site-file \\r
436 > - =A0 =A0 =A0 --directory ../../emacs --load notmuch.el \\r
437 > - =A0 =A0 =A0 --directory .. --load test-lib.el \\r
438 > - =A0 =A0 =A0 --eval "(progn \$@)"\r
439 > +emacs --daemon --no-init-file --no-site-file \\r
440 > + =A0 =A0 =A0 --directory "$TEST_DIRECTORY/../emacs" --load notmuch.el \\r
441 > + =A0 =A0 =A0 --directory "$TEST_DIRECTORY" --load test-lib.el \\r
442 > + =A0 =A0 =A0 --eval '(setq server-name "$server_name")'\r
443 > +EOF\r
444 > + =A0 =A0 =A0 chmod a+x "$TMP_DIRECTORY/emacs_server_start"\r
445 > +\r
446 > + =A0 =A0 =A0 cat <<EOF > "$TMP_DIRECTORY/emacs_server_stop"\r
447 > +#!/bin/sh\r
448 > +\r
449 > +dir=3D\$(dirname "\$0")\r
450 > +"\$dir"/emacs_run '(kill-emacs)'\r
451 > =A0EOF\r
452 > - =A0 =A0 =A0 chmod a+x ./run_emacs\r
453 > - =A0 =A0 =A0 ./run_emacs "$@"\r
454 > + =A0 =A0 =A0 chmod a+x "$TMP_DIRECTORY/emacs_server_stop"\r
455 > +\r
456 > + =A0 =A0 =A0 cat <<EOF > "$TMP_DIRECTORY/emacs_start"\r
457 > +#!/bin/sh\r
458 > +export PATH=3D$PATH\r
459 > +export NOTMUCH_CONFIG=3D$NOTMUCH_CONFIG\r
460 > +\r
461 > +# Here's what we are using here:\r
462 > +#\r
463 > +# --no-init-file =A0 =A0 =A0 Don't load users ~/.emacs\r
464 > +#\r
465 > +# --no-site-file =A0 =A0 =A0 Don't load the site-wide startup stuff\r
466 > +#\r
467 > +# --directory =A0 =A0 =A0 =A0 =A0Ensure that the local elisp sources are=\r
468  found\r
469 > +#\r
470 > +# --load =A0 =A0 =A0 =A0 =A0 =A0 =A0 Force loading of notmuch.el and tes=\r
471 t-lib.el\r
472 > +\r
473 > +emacs --no-init-file --no-site-file \\r
474 > + =A0 =A0 =A0 --directory "$TEST_DIRECTORY/../emacs" --load notmuch.el \\r
475 > + =A0 =A0 =A0 --directory "$TEST_DIRECTORY" --load test-lib.el\r
476 > +EOF\r
477 > + =A0 =A0 =A0 chmod a+x "$TMP_DIRECTORY/emacs_start"\r
478 > +\r
479 > + =A0 =A0 =A0 cat <<EOF > "$TMP_DIRECTORY/emacs_run"\r
480 > +#!/bin/sh\r
481 > +\r
482 > +# Here's what we are using here:\r
483 > +#\r
484 > +# --socket-name =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Emacs server name\r
485 > +#\r
486 > +# --eval =A0 =A0 =A0 =A0 =A0 =A0 =A0 Evaluate ELisp expressions\r
487 > +\r
488 > +emacsclient --socket-name "$server_name" --eval "(progn \$@)"\r
489 > +EOF\r
490 > + =A0 =A0 =A0 chmod a+x "$TMP_DIRECTORY/emacs_run"\r
491 > +}\r
492 > +\r
493 > +# Start Emacs server if it is not running.\r
494 > +emacs_server_start ()\r
495 > +{\r
496 > + =A0 =A0 =A0 [ -n "$emacs_server_pid" ] && return\r
497 > +\r
498 > + =A0 =A0 =A0 output=3D$("$TMP_DIRECTORY/emacs_server_start" 2>&1)\r
499 > + =A0 =A0 =A0 if [ "$?" -ne 0 ]; then\r
500 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 echo "$output"\r
501 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return 1\r
502 > + =A0 =A0 =A0 fi\r
503 > +\r
504 > + =A0 =A0 =A0 emacs_server_pid=3D$("$TMP_DIRECTORY/emacs_run" '(emacs-pid=\r
505 )')\r
506 > + =A0 =A0 =A0 [ "$?" -eq 0 -a -n "$emacs_server_pid" ]\r
507 > +}\r
508 > +\r
509 > +# Stop Emacs server if it is running.\r
510 > +emacs_server_stop ()\r
511 > +{\r
512 > + =A0 =A0 =A0 [ -z "$emacs_server_pid" ] && return\r
513 > +\r
514 > + =A0 =A0 =A0 emacs_server_pid=3D\r
515 > + =A0 =A0 =A0 output=3D$("$TMP_DIRECTORY/emacs_server_stop" 2>&1)\r
516 > + =A0 =A0 =A0 if [ "$?" -ne 0 ]; then\r
517 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 echo "$output"\r
518 > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return 1\r
519 > + =A0 =A0 =A0 fi\r
520 > +}\r
521 > +\r
522 > +# Evaluate ELisp expressions in Emacs server. =A0Server is started if it\r
523 > +# is not running.\r
524 > +test_emacs () {\r
525 > + =A0 =A0 =A0 emacs_server_start || return\r
526 > +\r
527 > + =A0 =A0 =A0 "$TMP_DIRECTORY/emacs_run" "$@"\r
528 > =A0}\r
529 >\r
530 >\r
531 > @@ -999,6 +1085,7 @@ primary_email=3Dtest_suite@notmuchmail.org\r
532 > =A0other_email=3Dtest_suite_other@notmuchmail.org;test_suite@otherdomain.=\r
533 org\r
534 > =A0EOF\r
535 >\r
536 > +emacs_generate_scripts\r
537 >\r
538 > =A0# Use -P to resolve symlinks in our working directory so that the cwd\r
539 > =A0# in subprocesses like git equals our $PWD (for pathname comparisons).\r
540 > --\r
541 > 1.7.5.4\r
542 >\r
543 > _______________________________________________\r
544 > notmuch mailing list\r
545 > notmuch@notmuchmail.org\r
546 > http://notmuchmail.org/mailman/listinfo/notmuch\r
547 >\r