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 [[ "$config" = maildir_env ]] && test_subtest_known_broken
129 output=$(notmuch count '*')
130 test_expect_equal "$output" '52'
132 test_begin_subtest "count+tag ($config)"
133 [[ "$config" = maildir_env ]] && test_subtest_known_broken
135 notmuch tag +$tag '*'
136 output=$(notmuch count tag:$tag)
137 notmuch tag -$tag '*'
138 test_expect_equal "$output" '52'
140 test_begin_subtest "address ($config)"
141 [[ "$config" = maildir_env ]] && test_subtest_known_broken
142 notmuch address --deduplicate=no --sort=newest-first --output=sender --output=recipients path:foo >OUTPUT
144 Carl Worth <cworth@cworth.org>
145 notmuch@notmuchmail.org
147 test_expect_equal_file EXPECTED OUTPUT
149 test_begin_subtest "dump ($config)"
150 [[ "$config" = maildir_env ]] && test_subtest_known_broken
151 notmuch dump is:attachment and is:signed | sort > OUTPUT
153 #notmuch-dump batch-tag:3 config,properties,tags
154 +attachment +inbox +signed +unread -- id:20091118005829.GB25380@dottiness.seas.harvard.edu
155 +attachment +inbox +signed +unread -- id:20091118010116.GC25380@dottiness.seas.harvard.edu
157 test_expect_equal_file EXPECTED OUTPUT
159 test_begin_subtest "dump + tag + restore ($config)"
160 notmuch dump '*' > EXPECTED
161 notmuch tag -inbox '*'
162 notmuch restore < EXPECTED
163 notmuch dump > OUTPUT
164 test_expect_equal_file EXPECTED OUTPUT
166 test_begin_subtest "reindex ($config)"
167 notmuch search --output=messages '*' > EXPECTED
169 notmuch search --output=messages '*' > OUTPUT
170 test_expect_equal_file EXPECTED OUTPUT
172 test_begin_subtest "use existing database ($config)"
173 [[ "$config" = "maildir_env" ]] && test_subtest_known_broken
174 output=$(notmuch new)
175 test_expect_equal "$output" 'No new mail.'
177 test_begin_subtest "create database ($config)"
178 [[ "$config" = "maildir_env" ]] && test_subtest_known_broken
179 rm -rf $DATABASE_PATH/{.notmuch,}/xapian
181 output=$(notmuch count '*')
182 test_expect_equal "$output" '52'
184 test_begin_subtest "detect new files ($config)"
185 [[ "$config" = "maildir_env" ]] && test_subtest_known_broken
189 output=$(notmuch count '*')
190 test_expect_equal "$output" '54'
192 test_begin_subtest "Show a raw message ($config)"
193 [[ "$config" = "maildir_env" ]] && test_subtest_known_broken
195 notmuch show --format=raw id:$gen_msg_id > OUTPUT
196 test_expect_equal_file $gen_msg_filename OUTPUT
197 rm -f $gen_msg_filename
199 test_begin_subtest "reply ($config)"
200 [[ "$config" = "maildir_env" ]] && test_subtest_known_broken
201 add_message '[from]="Sender <sender@example.com>"' \
202 [to]=test_suite@notmuchmail.org \
203 [subject]=notmuch-reply-test \
204 '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
205 '[body]="basic reply test"'
206 notmuch reply id:${gen_msg_id} 2>&1 > OUTPUT
208 From: Notmuch Test Suite <test_suite@notmuchmail.org>
209 Subject: Re: notmuch-reply-test
210 To: Sender <sender@example.com>
211 In-Reply-To: <${gen_msg_id}>
212 References: <${gen_msg_id}>
214 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
217 test_expect_equal_file EXPECTED OUTPUT
219 test_begin_subtest "insert+search ($config)"
220 [[ "$config" = "maildir_env" ]] && test_subtest_known_broken
222 "[subject]=\"insert-subject\"" \
223 "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \
224 "[body]=\"insert-message\""
225 mkdir -p "$MAIL_DIR"/{cur,new,tmp}
226 notmuch insert < "$gen_msg_filename"
227 cur_msg_filename=$(notmuch search --output=files "subject:insert-subject")
228 test_expect_equal_file "$cur_msg_filename" "$gen_msg_filename"
231 test_begin_subtest "compact+search ($config)"
232 notmuch search --output=messages '*' | sort > EXPECTED
234 notmuch search --output=messages '*' | sort > OUTPUT
235 test_expect_equal_file EXPECTED OUTPUT
237 test_begin_subtest "upgrade backup ($config)"
238 [[ "$config" = "maildir_env" ]] && test_subtest_known_broken
239 features=$(xapian-metadata get $XAPIAN_PATH features | grep -v "^relative directory paths")
240 xapian-metadata set $XAPIAN_PATH features "$features"
241 output=$(notmuch new | grep Welcome)
244 "Welcome to a new version of notmuch! Your database will now be upgraded."
246 test_begin_subtest "notmuch +config -database suggests notmuch new ($config)"
247 mv "$XAPIAN_PATH" "${XAPIAN_PATH}.bak"
250 Notmuch is configured, but no database was found.
251 You probably want to run "notmuch new" now to create a database.
253 Note that the first run of "notmuch new" can take a very long time
254 and that the resulting database will use roughly the same amount of
255 storage space as the email being indexed.
258 mv "${XAPIAN_PATH}.bak" "$XAPIAN_PATH"
260 test_expect_equal_file EXPECTED OUTPUT
262 test_begin_subtest "Set config value ($config)"
265 notmuch config set test${test_count}.${name} ${value}
266 output=$(notmuch config get test${test_count}.${name})
267 notmuch config set test${test_count}.${name}
268 output2=$(notmuch config get test${test_count}.${name})
269 test_expect_equal "${output}+${output2}" "${value}+"
271 test_begin_subtest "Set config value in database ($config)"
272 [[ "$config" = "maildir_env" ]] && test_subtest_known_broken
275 notmuch config set --database test${test_count}.${name} ${value}
276 output=$(notmuch config get test${test_count}.${name})
277 notmuch config set --database test${test_count}.${name}
278 output2=$(notmuch config get test${test_count}.${name})
279 test_expect_equal "${output}+${output2}" "${value}+"
281 test_begin_subtest "Config list ($config)"
282 [[ "$config" = "maildir_env" ]] && test_subtest_known_broken
283 notmuch config list | notmuch_dir_sanitize | \
284 sed -e "s/^database.backup_dir=.*$/database.backup_dir/" \
285 -e "s/^database.hook_dir=.*$/database.hook_dir/" \
286 -e "s/^database.path=.*$/database.path/" \
287 -e "s,^database.mail_root=CWD/home/mail,database.mail_root=MAIL_DIR," \
288 -e "s,^database.mail_root=CWD/home/env_points_here,database.mail_root=MAIL_DIR," \
291 built_with.compact=true
292 built_with.field_processor=true
293 built_with.retry_lock=true
296 database.mail_root=MAIL_DIR
298 maildir.synchronize_flags=true
300 new.tags=unread;inbox
302 user.name=Notmuch Test Suite
303 user.other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org
304 user.primary_email=test_suite@notmuchmail.org
306 test_expect_equal_file EXPECTED OUTPUT
310 test_begin_subtest "Set shadowed config value in database ($config)"
313 key=test${test_count}.${name}
314 notmuch config set --database ${key} ${value}
315 notmuch config set ${key} shadow${value}
316 output=$(notmuch --config='' config get ${key})
317 notmuch config set --database ${key}
318 output2=$(notmuch --config='' config get ${key})
319 notmuch config set ${key}
320 test_expect_equal "${output}+${output2}" "${value}+"