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