2 test_description='Various options for reading configuration'
3 . $(dirname "$0")/test-lib.sh || exit 1
6 local test_name=$(basename $0 .sh)
7 cp ${NOTMUCH_CONFIG} notmuch-config-backup.${test_name}
12 local profile=${1:-default}
13 if [[ $profile != default ]]; then
14 export NOTMUCH_PROFILE=$profile
17 dir="${HOME}/.config/notmuch/${profile}"
20 CONFIG_PATH=$dir/config
21 mv ${NOTMUCH_CONFIG} ${CONFIG_PATH}
26 local test_name=$(basename $0 .sh)
27 export NOTMUCH_CONFIG="${TMP_DIRECTORY}/notmuch-config"
30 cp notmuch-config-backup.${test_name} ${NOTMUCH_CONFIG}
35 test_begin_subtest "count with saved query from config file"
37 query_name="test${RANDOM}"
38 notmuch count query:$query_name > OUTPUT
39 printf "\n[query]\n${query_name} = tag:inbox\n" >> notmuch-config
40 notmuch count query:$query_name >> OUTPUT
46 test_expect_equal_file EXPECTED OUTPUT
48 test_begin_subtest "count with saved query from config file (xdg)"
49 query_name="test${RANDOM}"
51 notmuch count query:$query_name > OUTPUT
52 printf "\n[query]\n${query_name} = tag:inbox\n" >> ${CONFIG_PATH}
53 notmuch count query:$query_name >> OUTPUT
59 test_expect_equal_file EXPECTED OUTPUT
61 test_begin_subtest "count with saved query from config file (xdg+profile)"
62 query_name="test${RANDOM}"
64 notmuch count query:$query_name > OUTPUT
65 printf "\n[query]\n${query_name} = tag:inbox\n" >> ${CONFIG_PATH}
66 notmuch count query:$query_name >> OUTPUT
72 test_expect_equal_file EXPECTED OUTPUT
76 #notmuch-dump batch-tag:3 tags
79 #notmuch-dump batch-tag:3 tags
80 +attachment +inbox +signed +unread -- id:20091118005829.GB25380@dottiness.seas.harvard.edu
81 +attachment +inbox +signed +unread -- id:20091118010116.GC25380@dottiness.seas.harvard.edu
82 +inbox +signed +unread -- id:20091117190054.GU3165@dottiness.seas.harvard.edu
83 +inbox +signed +unread -- id:20091117203301.GV3165@dottiness.seas.harvard.edu
84 +inbox +signed +unread -- id:20091118002059.067214ed@hikari
85 +inbox +signed +unread -- id:20091118005040.GA25380@dottiness.seas.harvard.edu
86 +inbox +signed +unread -- id:87iqd9rn3l.fsf@vertex.dottedmag
89 test_begin_subtest "dump with saved query from config file"
91 query_name="test${RANDOM}"
92 CONFIG_PATH=notmuch-config
93 printf "Before:\n" > OUTPUT
94 notmuch dump --include=tags query:$query_name | sort >> OUTPUT
95 printf "\nAfter:\n" >> OUTPUT
96 printf "\n[query]\n${query_name} = tag:signed\n" >> ${CONFIG_PATH}
97 notmuch dump --include=tags query:$query_name | sort >> OUTPUT
99 test_expect_equal_file EXPECTED OUTPUT
101 test_begin_subtest "dump with saved query from config file (xdg)"
103 query_name="test${RANDOM}"
105 printf "Before:\n" > OUTPUT
106 notmuch dump --include=tags query:$query_name | sort >> OUTPUT
107 printf "\nAfter:\n" >> OUTPUT
108 printf "\n[query]\n${query_name} = tag:signed\n" >> ${CONFIG_PATH}
109 notmuch dump --include=tags query:$query_name | sort >> OUTPUT
111 test_expect_equal_file EXPECTED OUTPUT
113 test_begin_subtest "dump with saved query from config file (xdg+profile)"
115 query_name="test${RANDOM}"
117 printf "Before:\n" > OUTPUT
118 notmuch dump --include=tags query:$query_name | sort >> OUTPUT
119 printf "\nAfter:\n" >> OUTPUT
120 printf "\n[query]\n${query_name} = tag:signed\n" >> ${CONFIG_PATH}
121 notmuch dump --include=tags query:$query_name | sort >> OUTPUT
123 test_expect_equal_file EXPECTED OUTPUT
125 test_begin_subtest "restore with xdg config"
127 notmuch dump '*' > EXPECTED
128 notmuch tag -inbox '*'
130 notmuch restore --input=EXPECTED
131 notmuch dump > OUTPUT
133 test_expect_equal_file EXPECTED OUTPUT
135 test_begin_subtest "restore with xdg+profile config"
137 notmuch dump '*' > EXPECTED
138 notmuch tag -inbox '*'
140 notmuch restore --input=EXPECTED
141 notmuch dump > OUTPUT
143 test_expect_equal_file EXPECTED OUTPUT
145 test_begin_subtest "Insert message with custom new.tags (xdg)"
149 notmuch --config=${CONFIG_PATH} config set new.tags $tag
151 "[subject]=\"insert-subject\"" \
152 "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \
153 "[body]=\"insert-message\""
154 mkdir -p ${MAIL_DIR}/{cur,new,tmp}
155 notmuch insert < "$gen_msg_filename"
156 notmuch dump id:$gen_msg_id > OUTPUT
158 #notmuch-dump batch-tag:3 config,properties,tags
159 +$tag -- id:$gen_msg_id
162 test_expect_equal_file EXPECTED OUTPUT
164 test_begin_subtest "Insert message with custom new.tags (xdg+profile)"
168 notmuch --config=${CONFIG_PATH} config set new.tags $tag
170 "[subject]=\"insert-subject\"" \
171 "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \
172 "[body]=\"insert-message\""
173 mkdir -p ${MAIL_DIR}/{cur,new,tmp}
174 notmuch insert < "$gen_msg_filename"
175 notmuch dump id:$gen_msg_id > OUTPUT
177 #notmuch-dump batch-tag:3 config,properties,tags
178 +$tag -- id:$gen_msg_id
181 test_expect_equal_file EXPECTED OUTPUT
183 test_begin_subtest "reindex with saved query from config file"
185 query_name="test${RANDOM}"
186 count1=$(notmuch count --lastmod '*' | cut -f3)
187 printf "\n[query]\n${query_name} = tag:inbox\n" >> notmuch-config
188 notmuch reindex query:$query_name
189 count2=$(notmuch count --lastmod '*' | cut -f3)
191 test_expect_success "test '$count2 -gt $count1'"
193 test_begin_subtest "reindex with saved query from config file (xdg)"
194 query_name="test${RANDOM}"
195 count1=$(notmuch count --lastmod '*' | cut -f3)
197 printf "\n[query]\n${query_name} = tag:inbox\n" >> ${CONFIG_PATH}
198 notmuch reindex query:$query_name
199 count2=$(notmuch count --lastmod '*' | cut -f3)
201 test_expect_success "test '$count2 -gt $count1'"
203 test_begin_subtest "reindex with saved query from config file (xdg+profile)"
204 query_name="test${RANDOM}"
205 count1=$(notmuch count --lastmod '*' | cut -f3)
206 xdg_config $query_name
207 printf "\n[query]\n${query_name} = tag:inbox\n" >> ${CONFIG_PATH}
208 notmuch reindex query:$query_name
209 count2=$(notmuch count --lastmod '*' | cut -f3)
211 test_expect_success "test '$count2 -gt $count1'"
215 add_message '[from]="Sender <sender@example.com>"' \
216 [to]=test_suite@notmuchmail.org \
217 '[cc]="Other Parties <cc@example.com>"' \
218 [subject]=notmuch-reply-test \
219 '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
220 '[body]="reply with CC"'
225 From: Notmuch Test Suite <test_suite@notmuchmail.org>
226 Subject: Re: notmuch-reply-test
227 To: Sender <sender@example.com>
228 Cc: Other Parties <cc@example.com>
229 In-Reply-To: <${gen_msg_id}>
230 References: <${gen_msg_id}>
232 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
236 test_begin_subtest "reply with saved query from config file"
238 query_name="test${RANDOM}"
239 printf "Before:\n" > OUTPUT
240 notmuch reply query:$query_name 2>&1 >> OUTPUT
241 printf "\n[query]\n${query_name} = id:${gen_msg_id}\n" >> notmuch-config
242 printf "After:\n" >> OUTPUT
243 notmuch reply query:$query_name >> OUTPUT
245 test_expect_equal_file EXPECTED OUTPUT
247 test_begin_subtest "reply with saved query from config file (xdg)"
249 query_name="test${RANDOM}"
251 printf "Before:\n" > OUTPUT
252 notmuch reply query:$query_name 2>&1 >> OUTPUT
253 printf "\n[query]\n${query_name} = id:${gen_msg_id}\n" >> ${CONFIG_PATH}
254 printf "After:\n" >> OUTPUT
255 notmuch reply query:$query_name >> OUTPUT
257 test_expect_equal_file EXPECTED OUTPUT
259 test_begin_subtest "reply with saved query from config file (xdg+profile)"
261 query_name="test${RANDOM}"
262 xdg_config $query_name
263 printf "Before:\n" > OUTPUT
264 notmuch reply query:$query_name 2>&1 >> OUTPUT
265 printf "\n[query]\n${query_name} = id:${gen_msg_id}\n" >> ${CONFIG_PATH}
266 printf "After:\n" >> OUTPUT
267 notmuch reply query:$query_name >> OUTPUT
269 test_expect_equal_file EXPECTED OUTPUT
272 test_begin_subtest "search with alternate config"
273 notmuch tag -- +foobar17 '*'
274 cp notmuch-config alt-config
275 notmuch --config=alt-config config set search.exclude_tags foobar17
276 output=$(notmuch --config=alt-config count '*')
277 test_expect_equal "$output" "0"
283 thread:XXX 2009-11-18 [1/2] Carl Worth| Alex Botero-Lowry; [notmuch] [PATCH] Error out if no query is supplied to search instead of going into an infinite loop (attachment inbox unread)
284 thread:XXX 2009-11-18 [1/2] Carl Worth| Ingmar Vanhassel; [notmuch] [PATCH] Typsos (inbox unread)
285 thread:XXX 2009-11-18 [1/3] Carl Worth| Adrian Perez de Castro, Keith Packard; [notmuch] Introducing myself (inbox signed unread)
286 thread:XXX 2009-11-18 [1/3] Carl Worth| Israel Herraiz, Keith Packard; [notmuch] New to the list (inbox unread)
287 thread:XXX 2009-11-18 [1/3] Carl Worth| Jan Janak; [notmuch] What a great idea! (inbox unread)
288 thread:XXX 2009-11-18 [1/2] Carl Worth| Jan Janak; [notmuch] [PATCH] Older versions of install do not support -C. (inbox unread)
289 thread:XXX 2009-11-18 [1/3(4)] Carl Worth| Aron Griffis, Keith Packard; [notmuch] archive (inbox unread)
290 thread:XXX 2009-11-18 [1/2] Carl Worth| Keith Packard; [notmuch] [PATCH] Make notmuch-show 'X' (and 'x') commands remove inbox (and unread) tags (inbox unread)
291 thread:XXX 2009-11-18 [1/7] Carl Worth| Lars Kellogg-Stedman, Mikhail Gusarov, Keith Packard; [notmuch] Working with Maildir storage? (inbox signed unread)
292 thread:XXX 2009-11-18 [2/5] Carl Worth| Mikhail Gusarov, Keith Packard; [notmuch] [PATCH 1/2] Close message file after parsing message headers (inbox unread)
293 thread:XXX 2009-11-17 [1/2] Carl Worth| Alex Botero-Lowry; [notmuch] preliminary FreeBSD support (attachment inbox unread)
296 test_begin_subtest "search with saved query from config file"
297 query_name="test${RANDOM}"
299 printf "Before:\n" > OUTPUT
300 notmuch search query:$query_name 2>&1 | notmuch_search_sanitize >> OUTPUT
301 printf "\n[query]\n${query_name} = from:cworth\n" >> notmuch-config
302 printf "After:\n" >> OUTPUT
303 notmuch search query:$query_name 2>&1 | notmuch_search_sanitize >> OUTPUT
305 test_expect_equal_file EXPECTED OUTPUT
307 test_begin_subtest "search with saved query from config file (xdg)"
308 query_name="test${RANDOM}"
310 printf "Before:\n" > OUTPUT
311 notmuch search query:$query_name 2>&1 | notmuch_search_sanitize >> OUTPUT
312 printf "\n[query]\n${query_name} = from:cworth\n" >> ${CONFIG_PATH}
313 printf "After:\n" >> OUTPUT
314 notmuch search query:$query_name 2>&1 | notmuch_search_sanitize >> OUTPUT
316 test_expect_equal_file EXPECTED OUTPUT
318 test_begin_subtest "search with saved query from config file (xdg + profile)"
319 query_name="test${RANDOM}"
320 xdg_config $query_name
321 printf "Before:\n" > OUTPUT
322 notmuch search query:$query_name 2>&1 | notmuch_search_sanitize >> OUTPUT
323 printf "\n[query]\n${query_name} = from:cworth\n" >> ${CONFIG_PATH}
324 printf "After:\n" >> OUTPUT
325 notmuch search query:$query_name 2>&1 | notmuch_search_sanitize >> OUTPUT
327 test_expect_equal_file EXPECTED OUTPUT
332 Alex Botero-Lowry <alex.boterolowry@gmail.com>
333 Alexander Botero-Lowry <alex.boterolowry@gmail.com>
334 François Boulogne <boulogne.f@gmail.com>
335 Jjgod Jiang <gzjjgod@gmail.com>
338 test_begin_subtest "address: saved query from config file"
340 query_name="test${RANDOM}"
341 printf "Before:\n" > OUTPUT
342 notmuch address --deduplicate=no --output=sender query:$query_name 2>&1 | sort >> OUTPUT
343 printf "\n[query]\n${query_name} = from:gmail.com\n" >> notmuch-config
344 printf "After:\n" >> OUTPUT
345 notmuch address --output=sender query:$query_name | sort >> OUTPUT
347 test_expect_equal_file EXPECTED OUTPUT
349 test_begin_subtest "address: saved query from config file (xdg)"
350 query_name="test${RANDOM}"
352 printf "Before:\n" > OUTPUT
353 notmuch address --deduplicate=no --output=sender query:$query_name 2>&1 | sort >> OUTPUT
354 printf "\n[query]\n${query_name} = from:gmail.com\n" >> ${CONFIG_PATH}
355 printf "After:\n" >> OUTPUT
356 notmuch address --output=sender query:$query_name | sort >> OUTPUT
358 test_expect_equal_file EXPECTED OUTPUT
360 test_begin_subtest "address: saved query from config file (xdg+profile)"
361 query_name="test${RANDOM}"
362 xdg_config $query_name
363 printf "Before:\n" > OUTPUT
364 notmuch address --deduplicate=no --output=sender query:$query_name 2>&1 | sort >> OUTPUT
365 printf "\n[query]\n${query_name} = from:gmail.com\n" >> ${CONFIG_PATH}
366 printf "After:\n" >> OUTPUT
367 notmuch address --output=sender query:$query_name | sort >> OUTPUT
369 test_expect_equal_file EXPECTED OUTPUT
371 test_begin_subtest "show with alternate config"
373 cp notmuch-config alt-config
374 notmuch --config=alt-config config set search.exclude_tags foobar17
375 notmuch tag -- +foobar17 '*'
376 output=$(notmuch --config=alt-config show '*' && echo OK)
378 test_expect_equal "$output" "OK"
380 test_begin_subtest "show with alternate config (xdg)"
382 notmuch tag -- +foobar17 '*'
384 notmuch --config=${CONFIG_PATH} config set search.exclude_tags foobar17
385 output=$(notmuch show '*' && echo OK)
388 test_expect_equal "$output" "OK"
390 test_begin_subtest "show with alternate config (xdg+profile)"
392 notmuch tag -- +foobar17 '*'
394 notmuch --config=${CONFIG_PATH} config set search.exclude_tags foobar17
395 output=$(notmuch show '*' && echo OK)
398 test_expect_equal "$output" "OK"
400 # reset to known state
403 test_begin_subtest "tag with saved query from config file"
405 query_name="test${RANDOM}"
406 tag_name="tag${RANDOM}"
407 notmuch count query:$query_name > OUTPUT
408 printf "\n[query]\n${query_name} = tag:inbox\n" >> notmuch-config
409 notmuch tag +$tag_name -- query:${query_name}
410 notmuch count tag:$tag_name >> OUTPUT
416 test_expect_equal_file EXPECTED OUTPUT
418 test_begin_subtest "tag with saved query from config file (xdg)"
420 query_name="test${RANDOM}"
421 tag_name="tag${RANDOM}"
422 notmuch count query:$query_name > OUTPUT
423 printf "\n[query]\n${query_name} = tag:inbox\n" >> ${CONFIG_PATH}
424 notmuch tag +$tag_name -- query:${query_name}
425 notmuch count tag:$tag_name >> OUTPUT
431 test_expect_equal_file EXPECTED OUTPUT
433 test_begin_subtest "tag with saved query from config file (xdg+profile)"
434 query_name="test${RANDOM}"
435 xdg_config ${query_name}
436 tag_name="tag${RANDOM}"
437 notmuch count query:$query_name > OUTPUT
438 printf "\n[query]\n${query_name} = tag:inbox\n" >> ${CONFIG_PATH}
439 notmuch tag +$tag_name -- query:${query_name}
440 notmuch count tag:$tag_name >> OUTPUT
446 test_expect_equal_file EXPECTED OUTPUT
448 test_begin_subtest "running compact (xdg)"
451 output=$(notmuch count '*')
453 test_expect_equal "52" "$output"
455 test_begin_subtest "running compact (xdg + profile)"
458 output=$(notmuch count '*')
460 test_expect_equal "52" "$output"
462 test_begin_subtest "run notmuch-new (xdg)"
465 output=$(NOTMUCH_NEW --debug)
467 test_expect_equal "$output" "Added 1 new message to the database."
469 test_begin_subtest "run notmuch-new (xdg + profile)"
472 output=$(NOTMUCH_NEW --debug)
474 test_expect_equal "$output" "Added 1 new message to the database."