]> git.notmuchmail.org Git - notmuch/blob - test/T310-emacs.sh
lib: query make exclude handling non-destructive
[notmuch] / test / T310-emacs.sh
1 #!/usr/bin/env bash
2
3 test_description="emacs interface"
4 . ./test-lib.sh || exit 1
5
6 EXPECTED=$TEST_DIRECTORY/emacs.expected-output
7
8 add_email_corpus
9
10 # syntax errors in test-lib.el cause mysterious failures
11 test_expect_success 'Syntax of emacs test library' \
12     "${TEST_EMACS} -Q --batch --load $TEST_DIRECTORY/test-lib.el"
13
14 test_begin_subtest "Basic notmuch-hello view in emacs"
15 test_emacs '(notmuch-hello)
16             (test-output)'
17 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello
18
19 test_begin_subtest "Saved search with 0 results"
20 test_emacs '(let ((notmuch-show-empty-saved-searches t)
21                   (notmuch-saved-searches
22                    '\''(("inbox" . "tag:inbox")
23                         ("unread" . "tag:unread")
24                         ("empty" . "tag:doesnotexist"))))
25               (notmuch-hello)
26               (test-output))'
27 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-with-empty
28
29 test_begin_subtest "No saved searches displayed (all with 0 results)"
30 test_emacs '(let ((notmuch-saved-searches
31                    '\''(("empty" . "tag:doesnotexist"))))
32               (notmuch-hello)
33               (test-output))'
34 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-no-saved-searches
35
36 test_begin_subtest "Basic notmuch-search view in emacs"
37 test_emacs '(notmuch-search "tag:inbox")
38             (notmuch-test-wait)
39             (test-output)'
40 test_expect_equal_file OUTPUT $EXPECTED/notmuch-search-tag-inbox
41
42 test_begin_subtest "Incremental parsing of search results"
43 test_emacs "(ad-enable-advice 'notmuch-search-process-filter 'around 'pessimal)
44             (ad-activate 'notmuch-search-process-filter)
45             (notmuch-search \"tag:inbox\")
46             (notmuch-test-wait)
47             (ad-disable-advice 'notmuch-search-process-filter 'around 'pessimal)
48             (ad-activate 'notmuch-search-process-filter)
49             (test-output)"
50 test_expect_equal_file OUTPUT $EXPECTED/notmuch-search-tag-inbox
51
52 test_begin_subtest "Navigation of notmuch-hello to search results"
53 test_emacs '(notmuch-hello)
54             (goto-char (point-min))
55             (re-search-forward "inbox")
56             (widget-button-press (1- (point)))
57             (notmuch-test-wait)
58             (test-output)'
59 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-view-inbox
60
61 test_begin_subtest "Basic notmuch-show view in emacs"
62 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
63 test_emacs "(notmuch-show \"$maildir_storage_thread\")
64             (test-output)"
65 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
66
67 test_begin_subtest "Basic notmuch-show view in emacs default indentation"
68 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
69 test_emacs "(let ((notmuch-show-indent-messages-width 1))
70               (notmuch-show \"$maildir_storage_thread\")
71               (test-output))"
72 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
73
74 test_begin_subtest "Basic notmuch-show view in emacs without indentation"
75 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
76 test_emacs "(let ((notmuch-show-indent-messages-width 0))
77               (notmuch-show \"$maildir_storage_thread\")
78               (test-output))"
79 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage-without-indentation
80
81 test_begin_subtest "Basic notmuch-show view in emacs with fourfold indentation"
82 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
83 test_emacs "(let ((notmuch-show-indent-messages-width 4))
84               (notmuch-show \"$maildir_storage_thread\")
85               (test-output))"
86 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage-with-fourfold-indentation
87
88 test_begin_subtest "notmuch-show for message with invalid From"
89 add_message "[subject]=\"message-with-invalid-from\"" \
90             "[from]=\"\\\"Invalid \\\" From\\\" <test_suite@notmuchmail.org>\""
91 thread=$(notmuch search --output=threads subject:message-with-invalid-from)
92 test_emacs "(notmuch-show \"$thread\")
93             (test-output \"OUTPUT.raw\")"
94 cat <<EOF >EXPECTED
95 "Invalid " (2001-01-05) (inbox)
96 Subject: message-with-invalid-from
97 To: Notmuch Test Suite <test_suite@notmuchmail.org>
98 Date: GENERATED_DATE
99
100 This is just a test message (#1)
101 EOF
102 notmuch_date_sanitize < OUTPUT.raw > OUTPUT
103 test_expect_equal_file OUTPUT EXPECTED
104
105 test_begin_subtest "Navigation of notmuch-search to thread view"
106 test_emacs '(notmuch-search "tag:inbox")
107             (notmuch-test-wait)
108             (goto-char (point-min))
109             (re-search-forward "Working with Maildir")
110             (notmuch-search-show-thread)
111             (notmuch-test-wait)
112             (test-output)'
113 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
114
115 test_begin_subtest "Add tag from search view"
116 os_x_darwin_thread=$(notmuch search --output=threads id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com)
117 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
118             (notmuch-test-wait)
119             (execute-kbd-macro \"+tag-from-search-view\")"
120 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
121 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox tag-from-search-view unread)"
122
123 test_begin_subtest "Remove tag from search view"
124 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
125             (notmuch-test-wait)
126             (execute-kbd-macro \"-tag-from-search-view\")"
127 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
128 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox unread)"
129
130 test_begin_subtest "Add tag (large query)"
131 # We use a long query to force us into batch mode and use a funny tag
132 # that requires escaping for batch tagging.
133 test_emacs "(notmuch-tag (concat \"$os_x_darwin_thread\" \" or \" (mapconcat #'identity (make-list notmuch-tag-argument-limit \"x\") \"-\")) (list \"+tag-from-%-large-query\"))"
134 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
135 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox tag-from-%-large-query unread)"
136 notmuch tag -tag-from-%-large-query $os_x_darwin_thread
137
138 test_begin_subtest "notmuch-show: add single tag to single message"
139 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
140             (execute-kbd-macro \"+tag-from-show-view\")"
141 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
142 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox tag-from-show-view unread)"
143
144 test_begin_subtest "notmuch-show: remove single tag from single message"
145 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
146             (execute-kbd-macro \"-tag-from-show-view\")"
147 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
148 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox unread)"
149
150 test_begin_subtest "notmuch-show: add multiple tags to single message"
151 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
152             (execute-kbd-macro \"+tag1-from-show-view +tag2-from-show-view\")"
153 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
154 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox tag1-from-show-view tag2-from-show-view unread)"
155
156 test_begin_subtest "notmuch-show: remove multiple tags from single message"
157 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
158             (execute-kbd-macro \"-tag1-from-show-view -tag2-from-show-view\")"
159 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
160 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox unread)"
161
162 test_begin_subtest "Message with .. in Message-Id:"
163 add_message [id]=123..456@example '[subject]="Message with .. in Message-Id"'
164 test_emacs '(notmuch-search "id:\"123..456@example\"")
165             (notmuch-test-wait)
166             (execute-kbd-macro "+search-add")
167             (execute-kbd-macro "+search-remove")
168             (execute-kbd-macro "-search-remove")
169             (notmuch-show "id:\"123..456@example\"")
170             (notmuch-test-wait)
171             (execute-kbd-macro "+show-add")
172             (execute-kbd-macro "+show-remove")
173             (execute-kbd-macro "-show-remove")'
174 output=$(notmuch search 'id:"123..456@example"' | notmuch_search_sanitize)
175 test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Message with .. in Message-Id (inbox search-add show-add)"
176
177 test_begin_subtest "Message with quote in Message-Id:"
178 add_message '[id]="\"quote\"@example"' '[subject]="Message with quote in Message-Id"'
179 test_emacs '(notmuch-search "subject:\"Message with quote\"")
180             (notmuch-test-wait)
181             (execute-kbd-macro "+search-add")
182             (notmuch-search-show-thread)
183             (notmuch-test-wait)
184             (execute-kbd-macro "+show-add")'
185 output=$(notmuch search 'id:"""quote""@example"' | notmuch_search_sanitize)
186 test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Message with quote in Message-Id (inbox search-add show-add)"
187
188 test_begin_subtest "Sending a message via (fake) SMTP"
189 emacs_deliver_message \
190     'Testing message sent via SMTP' \
191     'This is a test that messages are sent via SMTP' \
192     '(message-goto-to)
193      (kill-whole-line)
194      (insert "To: user@example.com\n")'
195 sed \
196     -e s',^Message-ID: <.*>$,Message-ID: <XXX>,' \
197     -e s',^\(Content-Type: text/plain\); charset=us-ascii$,\1,' < sent_message >OUTPUT
198 cat <<EOF >EXPECTED
199 From: Notmuch Test Suite <test_suite@notmuchmail.org>
200 To: user@example.com
201 Subject: Testing message sent via SMTP
202 Date: 01 Jan 2000 12:00:00 -0000
203 Message-ID: <XXX>
204 MIME-Version: 1.0
205 Content-Type: text/plain
206
207 This is a test that messages are sent via SMTP
208 EOF
209 test_expect_equal_file OUTPUT EXPECTED
210
211 test_begin_subtest "Verify that sent messages are saved/searchable (via FCC)"
212 notmuch new > /dev/null
213 output=$(notmuch search 'subject:"testing message sent via SMTP"' | notmuch_search_sanitize)
214 test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; Testing message sent via SMTP (inbox)"
215
216 test_begin_subtest "notmuch-fcc-dirs set to nil"
217 test_emacs "(let ((notmuch-fcc-dirs nil))
218               (notmuch-mua-mail)
219               (test-output))"
220 cat <<EOF >EXPECTED
221 From: Notmuch Test Suite <test_suite@notmuchmail.org>
222 To: 
223 Subject: 
224 --text follows this line--
225 EOF
226 test_expect_equal_file OUTPUT EXPECTED
227
228 # Make another FCC maildir specific for the next test
229 mkdir -p mail/sent-string/cur
230 mkdir -p mail/sent-string/new
231 mkdir -p mail/sent-string/tmp
232
233 test_begin_subtest "notmuch-fcc-dirs set to a string"
234 test_emacs "(let ((notmuch-fcc-dirs \"sent-string\"))
235               (notmuch-mua-mail)
236               (test-output))"
237 cat <<EOF >EXPECTED
238 From: Notmuch Test Suite <test_suite@notmuchmail.org>
239 To: 
240 Subject: 
241 Fcc: ${MAIL_DIR}/sent-string
242 --text follows this line--
243 EOF
244 test_expect_equal_file OUTPUT EXPECTED
245
246 # Make more FCC maildirs specific for the next test
247 mkdir -p mail/sent-list-match/cur
248 mkdir -p mail/sent-list-match/new
249 mkdir -p mail/sent-list-match/tmp
250 mkdir -p mail/failure/cur
251 mkdir -p mail/failure/new
252 mkdir -p mail/failure/tmp
253
254 test_begin_subtest "notmuch-fcc-dirs set to a list (with match)"
255 test_emacs "(let ((notmuch-fcc-dirs
256                    '((\"notmuchmail.org\" . \"sent-list-match\")
257                      (\".*\" . \"failure\"))))
258               (notmuch-mua-mail)
259               (test-output))"
260 cat <<EOF >EXPECTED
261 From: Notmuch Test Suite <test_suite@notmuchmail.org>
262 To: 
263 Subject: 
264 Fcc: ${MAIL_DIR}/sent-list-match
265 --text follows this line--
266 EOF
267 test_expect_equal_file OUTPUT EXPECTED
268
269 # Make another FCC maildir specific for the next test
270 mkdir -p mail/sent-list-catch-all/cur
271 mkdir -p mail/sent-list-catch-all/new
272 mkdir -p mail/sent-list-catch-all/tmp
273
274 test_begin_subtest "notmuch-fcc-dirs set to a list (catch-all)"
275 test_emacs "(let ((notmuch-fcc-dirs
276                    '((\"example.com\" . \"failure\")
277                      (\".*\" . \"sent-list-catch-all\"))))
278               (notmuch-mua-mail)
279               (test-output))"
280 cat <<EOF >EXPECTED
281 From: Notmuch Test Suite <test_suite@notmuchmail.org>
282 To: 
283 Subject: 
284 Fcc: ${MAIL_DIR}/sent-list-catch-all
285 --text follows this line--
286 EOF
287 test_expect_equal_file OUTPUT EXPECTED
288
289 test_begin_subtest "notmuch-fcc-dirs set to a list (no match)"
290 test_emacs "(let ((notmuch-fcc-dirs
291                    '((\"example.com\" . \"failure\")
292                      (\"nomatchhere.net\" . \"failure\"))))
293               (notmuch-mua-mail)
294               (test-output))"
295 cat <<EOF >EXPECTED
296 From: Notmuch Test Suite <test_suite@notmuchmail.org>
297 To: 
298 Subject: 
299 --text follows this line--
300 EOF
301 test_expect_equal_file OUTPUT EXPECTED
302
303 test_begin_subtest "Reply within emacs"
304 test_emacs '(let ((message-hidden-headers ''()))
305             (notmuch-search "subject:\"testing message sent via SMTP\"")
306             (notmuch-test-wait)
307             (notmuch-search-reply-to-thread)
308             (test-output))'
309 sed -i -e 's/^In-Reply-To: <.*>$/In-Reply-To: <XXX>/' OUTPUT
310 sed -i -e 's/^References: <.*>$/References: <XXX>/' OUTPUT
311 cat <<EOF >EXPECTED
312 From: Notmuch Test Suite <test_suite@notmuchmail.org>
313 To: user@example.com
314 Subject: Re: Testing message sent via SMTP
315 In-Reply-To: <XXX>
316 Fcc: ${MAIL_DIR}/sent
317 References: <XXX>
318 --text follows this line--
319 Notmuch Test Suite <test_suite@notmuchmail.org> writes:
320
321 > This is a test that messages are sent via SMTP
322 EOF
323 test_expect_equal_file OUTPUT EXPECTED
324
325 test_begin_subtest "Reply from alternate address within emacs"
326 add_message '[from]="Sender <sender@example.com>"' \
327              [to]=test_suite_other@notmuchmail.org
328
329 test_emacs "(let ((message-hidden-headers '()))
330             (notmuch-search \"id:\\\"${gen_msg_id}\\\"\")
331             (notmuch-test-wait)
332             (notmuch-search-reply-to-thread)
333             (test-output))"
334 cat <<EOF >EXPECTED
335 From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
336 To: Sender <sender@example.com>
337 Subject: Re: ${test_subtest_name}
338 In-Reply-To: <${gen_msg_id}>
339 Fcc: ${MAIL_DIR}/sent
340 References: <${gen_msg_id}>
341 --text follows this line--
342 Sender <sender@example.com> writes:
343
344 > This is just a test message (#${gen_msg_cnt})
345 EOF
346 test_expect_equal_file OUTPUT EXPECTED
347
348 test_begin_subtest "Reply from address in named group list within emacs"
349 add_message '[from]="Sender <sender@example.com>"' \
350             '[to]=group:test_suite@notmuchmail.org,someone@example.com\;' \
351              [cc]=test_suite_other@notmuchmail.org
352
353 test_emacs "(let ((message-hidden-headers '()))
354             (notmuch-search \"id:\\\"${gen_msg_id}\\\"\")
355             (notmuch-test-wait)
356             (notmuch-search-reply-to-thread)
357             (test-output))"
358 cat <<EOF >EXPECTED
359 From: Notmuch Test Suite <test_suite@notmuchmail.org>
360 To: Sender <sender@example.com>, someone@example.com
361 Subject: Re: ${test_subtest_name}
362 In-Reply-To: <${gen_msg_id}>
363 Fcc: ${MAIL_DIR}/sent
364 References: <${gen_msg_id}>
365 --text follows this line--
366 Sender <sender@example.com> writes:
367
368 > This is just a test message (#${gen_msg_cnt})
369 EOF
370 test_expect_equal_file OUTPUT EXPECTED
371
372 test_begin_subtest "Reply within emacs to a multipart/mixed message"
373 test_emacs '(let ((message-hidden-headers ''()))
374             (notmuch-show "id:20091118002059.067214ed@hikari")
375                 (notmuch-show-reply)
376                 (test-output))'
377 cat <<EOF >EXPECTED
378 From: Notmuch Test Suite <test_suite@notmuchmail.org>
379 To: Adrian Perez de Castro <aperez@igalia.com>, notmuch@notmuchmail.org
380 Subject: Re: [notmuch] Introducing myself
381 In-Reply-To: <20091118002059.067214ed@hikari>
382 Fcc: ${MAIL_DIR}/sent
383 References: <20091118002059.067214ed@hikari>
384 --text follows this line--
385 Adrian Perez de Castro <aperez@igalia.com> writes:
386
387 > Hello to all,
388 >
389 > I have just heard about Not Much today in some random Linux-related news
390 > site (LWN?), my name is Adrian Perez and I work as systems administrator
391 > (although I can do some code as well :P). I have always thought that the
392 > ideas behind Sup were great, but after some time using it, I got tired of
393 > the oddities that it has. I also do not like doing things like having to
394 > install Ruby just for reading and sorting mails. Some time ago I thought
395 > about doing something like Not Much and in fact I played a bit with the
396 > Python+Xapian and the Python+Whoosh combinations, because I find relaxing
397 > to code things in Python when I am not working and also it is installed
398 > by default on most distribution. I got to have some mailboxes indexed and
399 > basic searching working a couple of months ago. Lately I have been very
400 > busy and had no time for coding, and them... boom! Not Much appears -- and
401 > it is almost exactly what I was trying to do, but faster. I have been
402 > playing a bit with Not Much today, and I think it has potential.
403 >
404 > Also, I would like to share one idea I had in mind, that you might find
405 > interesting: One thing I have found very annoying is having to re-tag my
406 > mail when the indexes get b0rked (it happened a couple of times to me while
407 > using Sup), so I was planning to mails as read/unread and adding the tags
408 > not just to the index, but to the mail text itself, e.g. by adding a
409 > "X-Tags" header field or by reusing the "Keywords" one. This way, the index
410 > could be totally recreated by re-reading the mail directories, and this
411 > would also allow to a tools like OfflineIMAP [1] to get the mails into a
412 > local maildir, tagging and indexing the mails with the e-mail reader and
413 > then syncing back the messages with the "X-Tags" header to the IMAP server.
414 > This would allow to use the mail reader from a different computer and still
415 > have everything tagged finely.
416 >
417 > Best regards,
418 >
419 >
420 > ---
421 > [1] http://software.complete.org/software/projects/show/offlineimap
422 >
423 > -- 
424 > Adrian Perez de Castro <aperez@igalia.com>
425 > Igalia - Free Software Engineering
426 > _______________________________________________
427 > notmuch mailing list
428 > notmuch@notmuchmail.org
429 > http://notmuchmail.org/mailman/listinfo/notmuch
430 EOF
431 test_expect_equal_file OUTPUT EXPECTED
432
433 test_begin_subtest "Reply within emacs to a multipart/alternative message"
434 test_emacs '(let ((message-hidden-headers ''()))
435             (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
436                 (notmuch-show-reply)
437                 (test-output))'
438 cat <<EOF >EXPECTED
439 From: Notmuch Test Suite <test_suite@notmuchmail.org>
440 To: Alex Botero-Lowry <alex.boterolowry@gmail.com>, notmuch@notmuchmail.org
441 Subject: Re: [notmuch] preliminary FreeBSD support
442 In-Reply-To: <cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com>
443 Fcc: ${MAIL_DIR}/sent
444 References: <cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com>
445 --text follows this line--
446 Alex Botero-Lowry <alex.boterolowry@gmail.com> writes:
447
448 > I saw the announcement this morning, and was very excited, as I had been
449 > hoping sup would be turned into a library,
450 > since I like the concept more than the UI (I'd rather an emacs interface).
451 >
452 > I did a preliminary compile which worked out fine, but
453 > sysconf(_SC_SC_GETPW_R_SIZE_MAX) returns -1 on
454 > FreeBSD, so notmuch_config_open segfaulted.
455 >
456 > Attached is a patch that supplies a default buffer size of 64 in cases where
457 > -1 is returned.
458 >
459 > http://www.opengroup.org/austin/docs/austin_328.txt - seems to indicate this
460 > is acceptable behavior,
461 > and http://mail-index.netbsd.org/pkgsrc-bugs/2006/06/07/msg016808.htmlspecifically
462 > uses 64 as the
463 > buffer size.
464 > From e3bc4bbd7b9d0d086816ab5f8f2d6ffea1dd3ea4 Mon Sep 17 00:00:00 2001
465 > From: Alexander Botero-Lowry <alex.boterolowry@gmail.com>
466 > Date: Tue, 17 Nov 2009 11:30:39 -0800
467 > Subject: [PATCH] Deal with situation where sysconf(_SC_GETPW_R_SIZE_MAX) returns -1
468 >
469 > ---
470 >  notmuch-config.c |    2 ++
471 >  1 files changed, 2 insertions(+), 0 deletions(-)
472 >
473 > diff --git a/notmuch-config.c b/notmuch-config.c
474 > index 248149c..e7220d8 100644
475 > --- a/notmuch-config.c
476 > +++ b/notmuch-config.c
477 > @@ -77,6 +77,7 @@ static char *
478 >  get_name_from_passwd_file (void *ctx)
479 >  {
480 >      long pw_buf_size = sysconf(_SC_GETPW_R_SIZE_MAX);
481 > +    if (pw_buf_size == -1) pw_buf_size = 64;
482 >      char *pw_buf = talloc_zero_size (ctx, pw_buf_size);
483 >      struct passwd passwd, *ignored;
484 >      char *name;
485 > @@ -101,6 +102,7 @@ static char *
486 >  get_username_from_passwd_file (void *ctx)
487 >  {
488 >      long pw_buf_size = sysconf(_SC_GETPW_R_SIZE_MAX);
489 > +    if (pw_buf_size == -1) pw_buf_size = 64;
490 >      char *pw_buf = talloc_zero_size (ctx, pw_buf_size);
491 >      struct passwd passwd, *ignored;
492 >      char *name;
493 > -- 
494 > 1.6.5.2
495 >
496 > _______________________________________________
497 > notmuch mailing list
498 > notmuch@notmuchmail.org
499 > http://notmuchmail.org/mailman/listinfo/notmuch
500 EOF
501 test_expect_equal_file OUTPUT EXPECTED
502
503 test_begin_subtest "Reply within emacs to an html-only message"
504 add_message '[content-type]="text/html"' \
505             '[body]="Hi,<br />This is an <b>HTML</b> test message.<br /><br />OK?"'
506 test_emacs "(let ((message-hidden-headers '()))
507             (notmuch-show \"id:${gen_msg_id}\")
508             (notmuch-show-reply)
509             (test-output))"
510 cat <<EOF >EXPECTED
511 From: Notmuch Test Suite <test_suite@notmuchmail.org>
512 To: 
513 Subject: Re: Reply within emacs to an html-only message
514 In-Reply-To: <${gen_msg_id}>
515 Fcc: ${MAIL_DIR}/sent
516 References: <${gen_msg_id}>
517 --text follows this line--
518 Notmuch Test Suite <test_suite@notmuchmail.org> writes:
519
520 > Hi,This is an HTML test message.OK?
521 EOF
522 test_expect_equal_file OUTPUT EXPECTED
523
524 test_begin_subtest "Reply within emacs to message from self"
525 test_subtest_known_broken
526 add_message '[from]="test_suite@notmuchmail.org"' \
527             '[to]="test_suite@notmuchmail.org"'
528 test_emacs "(let ((message-hidden-headers '()))
529             (notmuch-show \"id:${gen_msg_id}\")
530             (notmuch-show-reply)
531             (test-output))"
532 sed -i -e 's/^In-Reply-To: <.*>$/In-Reply-To: <XXX>/' OUTPUT
533 sed -i -e 's/^References: <.*>$/References: <XXX>/' OUTPUT
534 cat <<EOF >EXPECTED
535 From: Notmuch Test Suite <test_suite@notmuchmail.org>
536 To: test_suite@notmuchmail.org
537 Subject: Re: Reply within emacs to message from self
538 In-Reply-To: <XXX>
539 Fcc: ${MAIL_DIR}/sent
540 References: <XXX>
541 --text follows this line--
542 test_suite@notmuchmail.org writes:
543
544 > This is just a test message (#7)
545 EOF
546 test_expect_equal_file EXPECTED OUTPUT
547
548 test_begin_subtest "Quote MML tags in reply"
549 message_id='test-emacs-mml-quoting@message.id'
550 add_message [id]="$message_id" \
551             "[subject]='$test_subtest_name'" \
552             '[body]="<#part disposition=inline>"'
553 test_emacs "(let ((message-hidden-headers '()))
554               (notmuch-show \"id:$message_id\")
555               (notmuch-show-reply)
556               (test-output))"
557 cat <<EOF >EXPECTED
558 From: Notmuch Test Suite <test_suite@notmuchmail.org>
559 To: 
560 Subject: Re: Quote MML tags in reply
561 In-Reply-To: <test-emacs-mml-quoting@message.id>
562 Fcc: ${MAIL_DIR}/sent
563 References: <test-emacs-mml-quoting@message.id>
564 --text follows this line--
565 Notmuch Test Suite <test_suite@notmuchmail.org> writes:
566
567 > <#!part disposition=inline>
568 EOF
569 test_expect_equal_file OUTPUT EXPECTED
570
571 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-attachments"
572 # save as archive to test that Emacs does not re-compress .gz
573 test_emacs '(let ((standard-input "\"attachment1.gz\""))
574               (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
575               (notmuch-show-save-attachments))'
576 test_expect_equal_file attachment1.gz "$EXPECTED/attachment"
577
578 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-part"
579 # save as archive to test that Emacs does not re-compress .gz
580 test_emacs '(let ((standard-input "\"attachment2.gz\""))
581               (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
582               (search-forward "0001-Deal-with")
583               (notmuch-show-save-part))'
584 test_expect_equal_file attachment2.gz "$EXPECTED/attachment"
585
586 test_begin_subtest "Save 8bit attachment from within emacs using notmuch-show-save-attachments"
587
588 add_message '[subject]="Attachment with 8bit chars"' \
589         '[header]="MIME-Version: 1.0"' \
590         '[content-type]="multipart/mixed; boundary=\"abcd\""' \
591         '[body]="--abcd
592 Content-Type: text/plain
593
594 Attachment follows:
595
596 --abcd
597 Content-Type: application/octet-stream; name=\"sample\"
598 Content-Transfer-Encoding: 8bit
599 Content-Disposition: attachment; filename=\"sample\"
600
601 “¡ Hey ! It compiles ¡ Ship it !”
602
603 --abcd--
604 "'
605 test_emacs '(notmuch-show "id:'"${gen_msg_id}"'")
606             (delete-file "OUTPUT")
607             (let ((standard-input "\"OUTPUT\""))
608               (notmuch-show-save-attachments))'
609
610 test_expect_equal "$(cat OUTPUT)" '“¡ Hey ! It compiles ¡ Ship it !”'
611
612 test_begin_subtest "View raw message within emacs"
613 test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
614             (notmuch-show-view-raw-message)
615             (test-output)'
616 test_expect_equal_file OUTPUT $EXPECTED/raw-message-cf0c4d-52ad0a
617
618 test_begin_subtest "Hiding/showing signature in notmuch-show view"
619 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
620 test_emacs "(notmuch-show \"$maildir_storage_thread\")
621             (search-forward \"Click/Enter to show.\")
622             (button-activate (button-at (point)))
623             (search-backward \"Click/Enter to hide.\")
624             (button-activate (button-at (point)))
625             (test-output)"
626 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
627
628 test_begin_subtest "Detection and hiding of top-post quoting of message"
629 add_message '[subject]="The problem with top-posting"' \
630             [id]=top-post-target \
631             '[body]="A: Because it messes up the order in which people normally read text.
632 Q: Why is top-posting such a bad thing?
633 A: Top-posting.
634 Q: What is the most annoying thing in e-mail?"'
635 add_message '[from]="Top Poster <top@poster.com>"' \
636             [in-reply-to]=top-post-target \
637             [references]=top-post-target \
638             '[subject]="Re: The problem with top-posting"' \
639             '[body]="Thanks for the advice! I will be sure to put it to good use.
640
641 -Top Poster
642
643 ----- Original Message -----
644 From: Notmuch Test Suite <test_suite@notmuchmail.org>
645 To: Notmuch Test Suite <test_suite@notmuchmai.org>
646 Sent: Fri, 05 Jan 2001 15:43:57 +0000
647 Subject: The problem with top-posting
648
649 Q: Why is top-posting such a bad thing?
650 A: Top-posting.
651 Q: What is the most annoying thing in e-mail?"'
652 test_emacs "(notmuch-show \"top-posting\")
653             (test-visible-output \"OUTPUT.raw\")"
654 echo "Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox)
655 Subject: The problem with top-posting
656 To: Notmuch Test Suite <test_suite@notmuchmail.org>
657 Date: GENERATED_DATE
658
659 A: Because it messes up the order in which people normally read text.
660 Q: Why is top-posting such a bad thing?
661 A: Top-posting.
662 Q: What is the most annoying thing in e-mail?
663 Top Poster <top@poster.com> (2001-01-05) (inbox unread)
664 Subject: Re: The problem with top-posting
665 To: Notmuch Test Suite <test_suite@notmuchmail.org>
666 Date: GENERATED_DATE
667
668 Thanks for the advice! I will be sure to put it to good use.
669
670 -Top Poster
671
672 [ 9-line hidden original message. Click/Enter to show. ]" > EXPECTED
673 notmuch_date_sanitize < OUTPUT.raw > OUTPUT
674 test_expect_equal_file OUTPUT EXPECTED
675
676 test_begin_subtest "Hiding message in notmuch-show view"
677 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
678             (notmuch-show-toggle-message)
679             (test-visible-output)'
680 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
681
682 test_begin_subtest "Hiding message with visible citation in notmuch-show view"
683 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
684             (search-forward "Click/Enter to show.")
685             (button-activate (button-at (point)))
686             (notmuch-show-toggle-message)
687             (test-visible-output)'
688 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
689
690 test_begin_subtest "notmuch-show: show message headers"
691 test_emacs \
692         '(let ((notmuch-message-headers '\''("Subject" "To" "Cc" "Date"))
693                (notmuch-message-headers-visible t))
694            (notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
695            (test-visible-output))'
696 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-message-with-headers-visible
697
698 test_begin_subtest "notmuch-show: hide message headers"
699 test_emacs \
700         '(let ((notmuch-message-headers '\''("Subject" "To" "Cc" "Date"))
701                (notmuch-message-headers-visible nil))
702            (notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
703            (test-visible-output))'
704 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-message-with-headers-hidden
705
706 test_begin_subtest "notmuch-show: hide message headers (w/ notmuch-show-toggle-visibility-headers)"
707 test_emacs \
708         '(let ((notmuch-message-headers '\''("Subject" "To" "Cc" "Date"))
709                (notmuch-message-headers-visible t))
710            (notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
711            (notmuch-show-toggle-visibility-headers)
712            (test-visible-output))'
713 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-message-with-headers-hidden
714
715 test_begin_subtest "notmuch-show: collapse all messages in thread"
716 test_emacs '(notmuch-show "id:f35dbb950911171435ieecd458o853c873e35f4be95@mail.gmail.com")
717         (let ((current-prefix-arg t))
718           (notmuch-show-open-or-close-all)
719           (test-visible-output))'
720 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-all-messages-collapsed
721
722 test_begin_subtest "notmuch-show: uncollapse all messages in thread"
723 test_emacs '(notmuch-show "id:f35dbb950911171435ieecd458o853c873e35f4be95@mail.gmail.com")
724         (notmuch-show-open-or-close-all)
725         (test-visible-output)'
726 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-all-messages-uncollapsed
727
728 test_begin_subtest "Stashing in notmuch-show"
729 add_message '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' \
730     '[from]="Some One <someone@somewhere.org>"' \
731     '[to]="Some One Else <notsomeone@somewhere.org>"' \
732     '[cc]="Notmuch <notmuch@notmuchmail.org>"' \
733     '[subject]="Stash my stashables"' \
734     '[id]="bought"' \
735     '[body]="Unable to stash body. Where did you get it in the first place?!?"'
736 notmuch tag +stashtest id:${gen_msg_id}
737 test_emacs '(notmuch-show "id:\"bought\"")
738         (notmuch-show-stash-date)
739         (notmuch-show-stash-from)
740         (notmuch-show-stash-to)
741         (notmuch-show-stash-cc)
742         (notmuch-show-stash-subject)
743         (notmuch-show-stash-message-id)
744         (notmuch-show-stash-message-id-stripped)
745         (notmuch-show-stash-tags)
746         (notmuch-show-stash-filename)
747         (notmuch-show-stash-mlarchive-link "Gmane")
748         (notmuch-show-stash-mlarchive-link "MARC")
749         (notmuch-show-stash-mlarchive-link "Mail Archive, The")
750         (switch-to-buffer
751           (generate-new-buffer "*test-stashing*"))
752         (dotimes (i 12)
753           (yank)
754           (insert "\n")
755           (rotate-yank-pointer 1))
756         (reverse-region (point-min) (point-max))
757             (test-output)'
758 cat <<EOF >EXPECTED
759 Sat, 01 Jan 2000 12:00:00 +0000
760 Some One <someone@somewhere.org>
761 Some One Else <notsomeone@somewhere.org>
762 Notmuch <notmuch@notmuchmail.org>
763 Stash my stashables
764 id:bought
765 bought
766 inbox,stashtest
767 ${gen_msg_filename}
768 http://mid.gmane.org/bought
769 https://marc.info/?i=bought
770 https://mid.mail-archive.com/bought
771 EOF
772 test_expect_equal_file OUTPUT EXPECTED
773
774 test_begin_subtest "Stashing in notmuch-search"
775 test_emacs '(notmuch-search "id:\"bought\"")
776         (notmuch-test-wait)
777         (notmuch-search-stash-thread-id)
778         (switch-to-buffer
779           (generate-new-buffer "*test-stashing*"))
780         (yank)
781             (test-output)'
782 sed -i -e 's/^thread:.*$/thread:XXX/' OUTPUT
783 test_expect_equal "$(cat OUTPUT)" "thread:XXX"
784
785 test_begin_subtest 'notmuch-show-advance-and-archive with invisible signature'
786 message1='id:20091118010116.GC25380@dottiness.seas.harvard.edu'
787 message2='id:1258491078-29658-1-git-send-email-dottedmag@dottedmag.net'
788 test_emacs "(notmuch-show \"$message2\")
789             (test-output \"EXPECTED\")"
790 test_emacs "(notmuch-search \"$message1 or $message2\")
791             (notmuch-test-wait)
792             (notmuch-search-show-thread)
793             (goto-char (point-max))
794             (redisplay)
795             (notmuch-show-advance-and-archive)
796             (test-output)"
797 test_expect_equal_file OUTPUT EXPECTED
798
799 test_begin_subtest "Refresh show buffer"
800 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
801             (test-visible-output "EXPECTED")
802             (notmuch-show-refresh-view)
803             (test-visible-output)'
804 test_expect_equal_file OUTPUT EXPECTED
805
806 test_begin_subtest "Refresh modified show buffer"
807 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
808             (notmuch-show-toggle-message)
809             (notmuch-show-next-message)
810             (notmuch-show-toggle-message)
811             (test-visible-output "EXPECTED")
812             (notmuch-show-refresh-view)
813             (test-visible-output)'
814 test_expect_equal_file OUTPUT EXPECTED
815
816 test_begin_subtest "Do not call notmuch for non-inlinable application/mpeg parts"
817 id='message-with-application/mpeg-attachment@notmuchmail.org'
818 emacs_fcc_message \
819     'Message with application/mpeg attachment' \
820     '' \
821     "(message-goto-eoh)
822      (insert \"Message-ID: <$id>\n\")
823      (message-goto-body)
824      (mml-insert-part \"application/mpeg\")
825      (insert \"a fake mp3 file\")"
826 notmuch_counter_reset
827 test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))
828               (notmuch-show \"id:$id\"))"
829 test_expect_equal $(notmuch_counter_value) 1
830
831 test_begin_subtest "Do not call notmuch for non-inlinable audio/mpeg parts"
832 id='message-with-audio/mpeg-attachment@notmuchmail.org'
833 emacs_fcc_message \
834     'Message with audio/mpeg attachment' \
835     '' \
836     "(message-goto-eoh)
837      (insert \"Message-ID: <$id>\n\")
838      (message-goto-body)
839      (mml-insert-part \"audio/mpeg\")
840      (insert \"a fake mp3 file\")"
841 notmuch_counter_reset
842 test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))
843               (notmuch-show \"id:$id\"))"
844 test_expect_equal $(notmuch_counter_value) 1
845
846 test_begin_subtest "notmuch-hello-mode hook is called"
847 counter=$(test_emacs \
848     '(let ((notmuch-hello-mode-hook-counter 0))
849        (kill-buffer "*notmuch-hello*")
850        (notmuch-hello)
851        notmuch-hello-mode-hook-counter)'
852 )
853 test_expect_equal "$counter" 1
854
855 test_begin_subtest "notmuch-hello-mode hook is not called on updates"
856 counter=$(test_emacs \
857     '(let ((notmuch-hello-mode-hook-counter 0))
858        (kill-buffer "*notmuch-hello*")
859        (notmuch-hello)
860        (notmuch-hello-update)
861        notmuch-hello-mode-hook-counter)'
862 )
863 test_expect_equal "$counter" 1
864
865 test_begin_subtest "notmuch-hello-refresh hook is called"
866 counter=$(test_emacs \
867     '(let ((notmuch-hello-refresh-hook-counter 0))
868        (kill-buffer "*notmuch-hello*")
869        (notmuch-hello)
870        notmuch-hello-refresh-hook-counter)'
871 )
872 test_expect_equal "$counter" 1
873
874 test_begin_subtest "notmuch-hello-refresh hook is called on updates"
875 counter=$(test_emacs \
876     '(let ((notmuch-hello-refresh-hook-counter 0))
877        (kill-buffer "*notmuch-hello*")
878        (notmuch-hello)
879        (notmuch-hello-update)
880        notmuch-hello-refresh-hook-counter)'
881 )
882 test_expect_equal "$counter" 2
883
884
885 add_message '[subject]="HTML mail with images"' \
886     '[content-type]="multipart/related; boundary=abcd"' \
887     '[body]="--abcd
888 Content-Type: text/html
889
890 <img src="cid:330@goomoji.gmail"> smiley
891
892 --abcd
893 Content-Type: image/gif
894 Content-Transfer-Encoding: base64
895 Content-ID: <330@goomoji.gmail>
896
897 R0lGODlhDAAMAKIFAF5LAP/zxAAAANyuAP/gaP///wAAAAAAACH5BAEAAAUALAAAAAAMAAwAAAMl
898 WLPcGjDKFYi9lxKBOaGcF35DhWHamZUW0K4mAbiwWtuf0uxFAgA7
899 --abcd--"'
900 test_emacs "(let ((mm-text-html-renderer
901                    (if (assq 'shr mm-text-html-renderer-alist)
902                        'shr 'html2text)))
903               (notmuch-show \"id:${gen_msg_id}\"))
904             (test-output)" > /dev/null
905 # Different Emacs versions and renderers give very different results,
906 # so just check that something reasonable showed up.  We first cat the
907 # output so the test framework will print it if the test fails.
908 test_expect_success "Rendering HTML mail with images" \
909     'cat OUTPUT && grep -q smiley OUTPUT'
910
911
912 test_begin_subtest "Search handles subprocess error exit codes"
913 cat > notmuch_fail <<EOF
914 #!/bin/sh
915 echo '()'
916 exit 1
917 EOF
918 chmod a+x notmuch_fail
919 test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\"))
920                (with-current-buffer \"*Messages*\"
921                  (let ((inhibit-read-only t)) (erase-buffer)))
922                (with-current-buffer (get-buffer-create \"*Notmuch errors*\")
923                  (erase-buffer))
924                (notmuch-search \"tag:inbox\")
925                (notmuch-test-wait)
926                (with-current-buffer \"*Messages*\"
927                   (test-output \"MESSAGES\"))
928                (with-current-buffer \"*Notmuch errors*\"
929                   (test-output \"ERROR\"))
930                (test-output))"
931
932 test_expect_equal "$(notmuch_emacs_error_sanitize notmuch_fail OUTPUT MESSAGES ERROR)" "\
933 === OUTPUT ===
934 End of search results.
935 === MESSAGES ===
936 YYY/notmuch_fail exited with status 1 (see *Notmuch errors* for more details)
937 === ERROR ===
938 [XXX]
939 YYY/notmuch_fail exited with status 1
940 command: YYY/notmuch_fail search --format\=sexp --format-version\=2 --sort\=newest-first tag\:inbox
941 exit status: 1"
942
943 test_begin_subtest "Search handles subprocess warnings"
944 cat > notmuch_fail <<EOF
945 #!/bin/sh
946 echo '()'
947 echo This is a warning >&2
948 echo This is another warning >&2
949 exit 0
950 EOF
951 chmod a+x notmuch_fail
952 test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\"))
953                (with-current-buffer \"*Messages*\"
954                  (let ((inhibit-read-only t)) (erase-buffer)))
955                (with-current-buffer (get-buffer-create \"*Notmuch errors*\")
956                  (erase-buffer))
957                (notmuch-search \"tag:inbox\")
958                (notmuch-test-wait)
959                (with-current-buffer \"*Messages*\"
960                   (test-output \"MESSAGES\"))
961                (with-current-buffer \"*Notmuch errors*\"
962                   (test-output \"ERROR\"))
963                (test-output))"
964 sed -i -e 's/^\[.*\]$/[XXX]/' ERROR
965 test_expect_equal "$(cat OUTPUT; echo ---; cat MESSAGES; echo ---; cat ERROR)" "\
966 End of search results.
967 ---
968 This is a warning (see *Notmuch errors* for more details)
969 ---
970 [XXX]
971 This is a warning
972 This is another warning"
973
974 test_begin_subtest "Search thread tag operations are race-free"
975 add_message '[subject]="Search race test"'
976 gen_msg_id_1=$gen_msg_id
977 generate_message '[in-reply-to]="<'$gen_msg_id_1'>"' \
978             '[references]="<'$gen_msg_id_1'>"' \
979             '[subject]="Search race test two"'
980 test_emacs '(notmuch-search "subject:\"search race test\"")
981             (notmuch-test-wait)
982             (notmuch-poll)
983             (execute-kbd-macro "+search-thread-race-tag")'
984 output=$(notmuch search --output=messages 'tag:search-thread-race-tag')
985 test_expect_equal "$output" "id:$gen_msg_id_1"
986
987 test_begin_subtest "Search global tag operations are race-free"
988 generate_message '[in-reply-to]="<'$gen_msg_id_1'>"' \
989             '[references]="<'$gen_msg_id_1'>"' \
990             '[subject]="Re: Search race test"'
991 test_emacs '(notmuch-search "subject:\"search race test\" -subject:two")
992             (notmuch-test-wait)
993             (notmuch-poll)
994             (execute-kbd-macro "*+search-global-race-tag")'
995 output=$(notmuch search --output=messages 'tag:search-global-race-tag')
996 test_expect_equal "$output" "id:$gen_msg_id_1"
997
998 test_begin_subtest "Term escaping"
999 output=$(test_emacs "(mapcar 'notmuch-escape-boolean-term (list
1000         \"\"
1001         \"abc\`~\!@#\$%^&*-=_+123\"
1002         \"(abc\"
1003         \")abc\"
1004         \"\\\"abc\"
1005         \"\x01xyz\"
1006         \"\\x201cxyz\\x201d\"))")
1007 test_expect_equal "$output" '("\"\"" "abc`~!@#$%^&*-=_+123" "\"(abc\"" "\")abc\"" "\"\"\"abc\"" "\"'$'\x01''xyz\"" "\"“xyz”\"")'
1008
1009 test_done