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"
20 cp notmuch-config-backup.${test_name} ${NOTMUCH_CONFIG}
26 dir="$TMP_DIRECTORY/database.$test_count"
29 notmuch config set database.path $dir
30 notmuch config set database.mail_root $MAIL_DIR
32 XAPIAN_PATH="$dir/xapian"
38 dir="$TMP_DIRECTORY/link.$test_count"
40 notmuch config set database.path $dir
41 notmuch config set database.mail_root $MAIL_DIR
42 XAPIAN_PATH="$MAIL_DIR/.notmuch/xapian"
52 notmuch config set database.path
53 notmuch config set database.mail_root
54 XAPIAN_PATH="$MAIL_DIR/.notmuch/xapian"
60 local profile=${1:-default}
62 if [[ $profile != default ]]; then
63 export NOTMUCH_PROFILE=$profile
67 DATABASE_PATH="${HOME}/.local/share/notmuch/${profile}"
69 mkdir -p $DATABASE_PATH
71 config_dir="${HOME}/.config/notmuch/${profile}"
72 mkdir -p ${config_dir}
73 CONFIG_PATH=$config_dir/config
74 mv ${NOTMUCH_CONFIG} $CONFIG_PATH
77 XAPIAN_PATH="${DATABASE_PATH}/xapian"
78 notmuch --config=${CONFIG_PATH} config set database.mail_root ${TMP_DIRECTORY}/mail
79 notmuch --config=${CONFIG_PATH} config set database.path
82 for config in traditional split XDG XDG+profile symlink home_mail; do
83 #start each set of tests with an known set of messages
89 XAPIAN_PATH="$MAIL_DIR/.notmuch/xapian"
93 mv mail/.notmuch/xapian $DATABASE_PATH
97 mv mail/.notmuch/xapian $DATABASE_PATH
101 mv mail/.notmuch/xapian $DATABASE_PATH
111 test_begin_subtest "count ($config)"
112 output=$(notmuch count '*')
113 test_expect_equal "$output" '52'
115 test_begin_subtest "count+tag ($config)"
117 notmuch tag +$tag '*'
118 output=$(notmuch count tag:$tag)
119 notmuch tag -$tag '*'
120 test_expect_equal "$output" '52'
122 test_begin_subtest "address ($config)"
123 notmuch address --deduplicate=no --sort=newest-first --output=sender --output=recipients path:foo >OUTPUT
125 Carl Worth <cworth@cworth.org>
126 notmuch@notmuchmail.org
128 test_expect_equal_file EXPECTED OUTPUT
130 test_begin_subtest "dump ($config)"
131 notmuch dump is:attachment and is:signed | sort > OUTPUT
133 #notmuch-dump batch-tag:3 config,properties,tags
134 +attachment +inbox +signed +unread -- id:20091118005829.GB25380@dottiness.seas.harvard.edu
135 +attachment +inbox +signed +unread -- id:20091118010116.GC25380@dottiness.seas.harvard.edu
137 test_expect_equal_file EXPECTED OUTPUT
139 test_begin_subtest "dump + tag + restore ($config)"
140 notmuch dump '*' > EXPECTED
141 notmuch tag -inbox '*'
142 notmuch restore < EXPECTED
143 notmuch dump > OUTPUT
144 test_expect_equal_file EXPECTED OUTPUT
146 test_begin_subtest "reindex ($config)"
147 notmuch search --output=messages '*' > EXPECTED
149 notmuch search --output=messages '*' > OUTPUT
150 test_expect_equal_file EXPECTED OUTPUT
152 test_begin_subtest "use existing database ($config)"
153 output=$(notmuch new)
154 test_expect_equal "$output" 'No new mail.'
156 test_begin_subtest "create database ($config)"
157 rm -rf $DATABASE_PATH/{.notmuch,}/xapian
159 output=$(notmuch count '*')
160 test_expect_equal "$output" '52'
162 test_begin_subtest "detect new files ($config)"
166 output=$(notmuch count '*')
167 test_expect_equal "$output" '54'
169 test_begin_subtest "Show a raw message ($config)"
171 notmuch show --format=raw id:$gen_msg_id > OUTPUT
172 test_expect_equal_file $gen_msg_filename OUTPUT
173 rm -f $gen_msg_filename
175 test_begin_subtest "reply ($config)"
176 add_message '[from]="Sender <sender@example.com>"' \
177 [to]=test_suite@notmuchmail.org \
178 [subject]=notmuch-reply-test \
179 '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
180 '[body]="basic reply test"'
181 notmuch reply id:${gen_msg_id} 2>&1 > OUTPUT
183 From: Notmuch Test Suite <test_suite@notmuchmail.org>
184 Subject: Re: notmuch-reply-test
185 To: Sender <sender@example.com>
186 In-Reply-To: <${gen_msg_id}>
187 References: <${gen_msg_id}>
189 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
192 test_expect_equal_file EXPECTED OUTPUT
193 test_begin_subtest "insert+search ($config)"
195 "[subject]=\"insert-subject\"" \
196 "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \
197 "[body]=\"insert-message\""
198 mkdir -p "$MAIL_DIR"/{cur,new,tmp}
199 notmuch insert < "$gen_msg_filename"
200 cur_msg_filename=$(notmuch search --output=files "subject:insert-subject")
201 test_expect_equal_file "$cur_msg_filename" "$gen_msg_filename"
204 test_begin_subtest "compact+search ($config)"
205 notmuch search --output=messages '*' | sort > EXPECTED
207 notmuch search --output=messages '*' | sort > OUTPUT
208 test_expect_equal_file EXPECTED OUTPUT
210 test_begin_subtest "upgrade backup ($config)"
211 features=$(xapian-metadata get $XAPIAN_PATH features | grep -v "^relative directory paths")
212 xapian-metadata set $XAPIAN_PATH features "$features"
213 output=$(notmuch new | grep Welcome)
216 "Welcome to a new version of notmuch! Your database will now be upgraded."
218 test_begin_subtest "notmuch +config -database suggests notmuch new ($config)"
219 mv "$XAPIAN_PATH" "${XAPIAN_PATH}.bak"
222 Notmuch is configured, but no database was found.
223 You probably want to run "notmuch new" now to create a database.
225 Note that the first run of "notmuch new" can take a very long time
226 and that the resulting database will use roughly the same amount of
227 storage space as the email being indexed.
230 mv "${XAPIAN_PATH}.bak" "$XAPIAN_PATH"
232 test_expect_equal_file EXPECTED OUTPUT
234 test_begin_subtest "Set config value ($config)"
237 notmuch config set test${test_count}.${name} ${value}
238 output=$(notmuch config get test${test_count}.${name})
239 notmuch config set test${test_count}.${name}
240 output2=$(notmuch config get test${test_count}.${name})
241 test_expect_equal "${output}+${output2}" "${value}+"
243 test_begin_subtest "Set config value in database ($config)"
246 notmuch config set --database test${test_count}.${name} ${value}
247 output=$(notmuch config get test${test_count}.${name})
248 notmuch config set --database test${test_count}.${name}
249 output2=$(notmuch config get test${test_count}.${name})
250 test_expect_equal "${output}+${output2}" "${value}+"
252 test_begin_subtest "Config list ($config)"
253 notmuch config list | notmuch_dir_sanitize | sed -e "s/^database.backup_dir=.*$/database.backup_dir/" \
254 -e "s/^database.hook_dir=.*$/database.hook_dir/" \
255 -e "s/^database.path=.*$/database.path/" \
256 -e "s,^database.mail_root=CWD/home/mail,database.mail_root=MAIL_DIR," \
259 built_with.compact=true
260 built_with.field_processor=true
261 built_with.retry_lock=true
264 database.mail_root=MAIL_DIR
266 maildir.synchronize_flags=true
268 new.tags=unread;inbox
270 user.name=Notmuch Test Suite
271 user.other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org
272 user.primary_email=test_suite@notmuchmail.org
274 test_expect_equal_file EXPECTED OUTPUT
278 test_begin_subtest "Set shadowed config value in database ($config)"
281 key=test${test_count}.${name}
282 notmuch config set --database ${key} ${value}
283 notmuch config set ${key} shadow${value}
284 output=$(notmuch --config='' config get ${key})
285 notmuch config set --database ${key}
286 output2=$(notmuch --config='' config get ${key})
287 notmuch config set ${key}
288 test_expect_equal "${output}+${output2}" "${value}+"