2 test_description='Configuration of mail-root and database path'
3 . $(dirname "$0")/test-lib.sh || exit 1
5 test_require_external_prereq xapian-metdata
8 local test_name=$(basename $0 .sh)
9 cp ${NOTMUCH_CONFIG} notmuch-config-backup.${test_name}
13 local test_name=$(basename $0 .sh)
14 export NOTMUCH_CONFIG="${TMP_DIRECTORY}/notmuch-config"
21 cp notmuch-config-backup.${test_name} ${NOTMUCH_CONFIG}
27 dir="$TMP_DIRECTORY/database.$test_count"
30 notmuch config set database.path $dir
31 notmuch config set database.mail_root $MAIL_DIR
33 XAPIAN_PATH="$dir/xapian"
39 dir="$TMP_DIRECTORY/link.$test_count"
41 notmuch config set database.path $dir
42 notmuch config set database.mail_root $MAIL_DIR
43 XAPIAN_PATH="$MAIL_DIR/.notmuch/xapian"
53 notmuch config set database.path
54 notmuch config set database.mail_root
55 XAPIAN_PATH="$MAIL_DIR/.notmuch/xapian"
59 maildir_env_config () {
62 dir="${HOME}/env_points_here"
65 notmuch config set database.path
66 notmuch config set database.mail_root
67 XAPIAN_PATH="${MAIL_DIR}/.notmuch/xapian"
73 local profile=${1:-default}
75 if [[ $profile != default ]]; then
76 export NOTMUCH_PROFILE=$profile
80 DATABASE_PATH="${HOME}/.local/share/notmuch/${profile}"
82 mkdir -p $DATABASE_PATH
84 config_dir="${HOME}/.config/notmuch/${profile}"
85 mkdir -p ${config_dir}
86 CONFIG_PATH=$config_dir/config
87 mv ${NOTMUCH_CONFIG} $CONFIG_PATH
90 XAPIAN_PATH="${DATABASE_PATH}/xapian"
91 notmuch --config=${CONFIG_PATH} config set database.mail_root ${TMP_DIRECTORY}/mail
92 notmuch --config=${CONFIG_PATH} config set database.path
95 for config in traditional split XDG XDG+profile symlink home_mail maildir_env; do
96 #start each set of tests with an known set of messages
102 XAPIAN_PATH="$MAIL_DIR/.notmuch/xapian"
106 mv mail/.notmuch/xapian $DATABASE_PATH
110 mv mail/.notmuch/xapian $DATABASE_PATH
114 mv mail/.notmuch/xapian $DATABASE_PATH
127 test_begin_subtest "count ($config)"
128 output=$(notmuch count '*')
129 test_expect_equal "$output" '52'
131 test_begin_subtest "count+tag ($config)"
133 notmuch tag +$tag '*'
134 output=$(notmuch count tag:$tag)
135 notmuch tag -$tag '*'
136 test_expect_equal "$output" '52'
138 test_begin_subtest "address ($config)"
139 notmuch address --deduplicate=no --sort=newest-first --output=sender --output=recipients path:foo >OUTPUT
141 Carl Worth <cworth@cworth.org>
142 notmuch@notmuchmail.org
144 test_expect_equal_file EXPECTED OUTPUT
146 test_begin_subtest "dump ($config)"
147 notmuch dump is:attachment and is:signed | sort > OUTPUT
149 #notmuch-dump batch-tag:3 config,properties,tags
150 +attachment +inbox +signed +unread -- id:20091118005829.GB25380@dottiness.seas.harvard.edu
151 +attachment +inbox +signed +unread -- id:20091118010116.GC25380@dottiness.seas.harvard.edu
153 test_expect_equal_file EXPECTED OUTPUT
155 test_begin_subtest "dump + tag + restore ($config)"
156 notmuch dump '*' > EXPECTED
157 notmuch tag -inbox '*'
158 notmuch restore < EXPECTED
159 notmuch dump > OUTPUT
160 test_expect_equal_file_nonempty EXPECTED OUTPUT
162 test_begin_subtest "reindex ($config)"
163 notmuch search --output=messages '*' > EXPECTED
165 notmuch search --output=messages '*' > OUTPUT
166 test_expect_equal_file_nonempty EXPECTED OUTPUT
168 test_begin_subtest "use existing database ($config)"
169 output=$(notmuch new)
170 test_expect_equal "$output" 'No new mail.'
172 test_begin_subtest "create database ($config)"
173 rm -rf $DATABASE_PATH/{.notmuch,}/xapian
175 output=$(notmuch count '*')
176 test_expect_equal "$output" '52'
178 test_begin_subtest "detect new files ($config)"
182 output=$(notmuch count '*')
183 test_expect_equal "$output" '54'
185 test_begin_subtest "Show a raw message ($config)"
187 notmuch show --format=raw id:$gen_msg_id > OUTPUT
188 test_expect_equal_file_nonempty $gen_msg_filename OUTPUT
189 rm -f $gen_msg_filename
191 test_begin_subtest "reply ($config)"
192 add_message '[from]="Sender <sender@example.com>"' \
193 [to]=test_suite@notmuchmail.org \
194 [subject]=notmuch-reply-test \
195 '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
196 '[body]="basic reply test"'
197 notmuch reply id:${gen_msg_id} 2>&1 > OUTPUT
199 From: Notmuch Test Suite <test_suite@notmuchmail.org>
200 Subject: Re: notmuch-reply-test
201 To: Sender <sender@example.com>
202 In-Reply-To: <${gen_msg_id}>
203 References: <${gen_msg_id}>
205 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
208 test_expect_equal_file EXPECTED OUTPUT
210 test_begin_subtest "insert+search ($config)"
212 "[subject]=\"insert-subject\"" \
213 "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \
214 "[body]=\"insert-message\""
215 mkdir -p "$MAIL_DIR"/{cur,new,tmp}
216 notmuch insert < "$gen_msg_filename"
217 cur_msg_filename=$(notmuch search --output=files "subject:insert-subject")
218 test_expect_equal_file_nonempty "$cur_msg_filename" "$gen_msg_filename"
220 test_begin_subtest "compact+search ($config)"
221 notmuch search --output=messages '*' | sort > EXPECTED
223 notmuch search --output=messages '*' | sort > OUTPUT
224 test_expect_equal_file_nonempty EXPECTED OUTPUT
226 test_begin_subtest "upgrade backup ($config)"
227 features=$(xapian-metadata get $XAPIAN_PATH features | grep -v "^relative directory paths")
228 xapian-metadata set $XAPIAN_PATH features "$features"
229 output=$(notmuch new | grep Welcome)
232 "Welcome to a new version of notmuch! Your database will now be upgraded."
234 test_begin_subtest "notmuch +config -database suggests notmuch new ($config)"
235 mv "$XAPIAN_PATH" "${XAPIAN_PATH}.bak"
238 Notmuch is configured, but no database was found.
239 You probably want to run "notmuch new" now to create a database.
241 Note that the first run of "notmuch new" can take a very long time
242 and that the resulting database will use roughly the same amount of
243 storage space as the email being indexed.
246 mv "${XAPIAN_PATH}.bak" "$XAPIAN_PATH"
248 test_expect_equal_file EXPECTED OUTPUT
250 test_begin_subtest "Set config value ($config)"
253 notmuch config set test${test_count}.${name} ${value}
254 output=$(notmuch config get test${test_count}.${name})
255 notmuch config set test${test_count}.${name}
256 output2=$(notmuch config get test${test_count}.${name})
257 test_expect_equal "${output}+${output2}" "${value}+"
259 test_begin_subtest "Set config value in database ($config)"
262 notmuch config set --database test${test_count}.${name} ${value}
263 output=$(notmuch config get test${test_count}.${name})
264 notmuch config set --database test${test_count}.${name}
265 output2=$(notmuch config get test${test_count}.${name})
266 test_expect_equal "${output}+${output2}" "${value}+"
268 test_begin_subtest "Config list ($config)"
269 notmuch config list | notmuch_config_sanitize | \
270 sed -e "s/^database.backup_dir=.*$/database.backup_dir/" \
271 -e "s/^database.hook_dir=.*$/database.hook_dir/" \
272 -e "s/^database.path=.*$/database.path/" \
273 -e "s,^database.mail_root=CWD/home/mail,database.mail_root=MAIL_DIR," \
274 -e "s,^database.mail_root=CWD/home/env_points_here,database.mail_root=MAIL_DIR," \
277 built_with.compact=something
278 built_with.field_processor=something
279 built_with.retry_lock=something
280 built_with.sexp_queries=something
281 database.autocommit=8000
284 database.mail_root=MAIL_DIR
286 maildir.synchronize_flags=true
288 new.tags=unread;inbox
290 user.name=Notmuch Test Suite
291 user.other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org
292 user.primary_email=test_suite@notmuchmail.org
294 test_expect_equal_file EXPECTED OUTPUT
296 test_begin_subtest "Config list from python ($config)"
297 test_python <<EOF > OUTPUT
298 from notmuch2 import Database
299 db=Database(config=Database.CONFIG.SEARCH)
300 for key in list(db.config):
309 maildir.synchronize_flags
315 test_expect_equal_file EXPECTED OUTPUT
318 test_begin_subtest "Set shadowed config value in database ($config)"
321 key=test${test_count}.${name}
322 notmuch config set --database ${key} ${value}
323 notmuch config set ${key} shadow${value}
324 output=$(notmuch --config='' config get ${key})
325 notmuch config set --database ${key}
326 output2=$(notmuch --config='' config get ${key})
327 notmuch config set ${key}
328 test_expect_equal "${output}+${output2}" "${value}+"
331 test_begin_subtest "'to' header does not crash (python-cffi) ($config)"
332 echo 'notmuch@notmuchmail.org' > EXPECTED
334 from notmuch2 import Database
335 db=Database(config=Database.CONFIG.SEARCH)
336 m=db.find('20091117232137.GA7669@griffis1.net')
340 test_expect_equal_file EXPECTED OUTPUT
342 test_begin_subtest ".notmuch not ignored in split config ($config)"
343 test_subtest_known_broken
344 generate_message '[dir]=.notmuch/cur' '[subject]="Do not ignore, very important"'
346 notmuch search subject:Do-not-ignore | notmuch_search_sanitize >> OUTPUT
348 Added 1 new message to the database.
349 thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Do not ignore, very important (inbox unread)
351 test_expect_equal_file EXPECTED OUTPUT
355 test_begin_subtest ".notmuch without xapian/ handled gracefully ($config)"
357 test_expect_success "notmuch new"