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"
19 cp notmuch-config-backup.${test_name} ${NOTMUCH_CONFIG}
25 dir="$TMP_DIRECTORY/database.$test_count"
28 notmuch config set database.path $dir
29 notmuch config set database.mail_root $MAIL_DIR
31 XAPIAN_PATH="$dir/xapian"
37 dir="$TMP_DIRECTORY/link.$test_count"
39 notmuch config set database.path $dir
40 notmuch config set database.mail_root $MAIL_DIR
41 XAPIAN_PATH="$MAIL_DIR/.notmuch/xapian"
47 local profile=${1:-default}
49 if [[ $profile != default ]]; then
50 export NOTMUCH_PROFILE=$profile
54 DATABASE_PATH="${HOME}/.local/share/notmuch/${profile}"
56 mkdir -p $DATABASE_PATH
58 config_dir="${HOME}/.config/notmuch/${profile}"
59 mkdir -p ${config_dir}
60 CONFIG_PATH=$config_dir/config
61 mv ${NOTMUCH_CONFIG} $CONFIG_PATH
64 XAPIAN_PATH="${DATABASE_PATH}/xapian"
65 notmuch --config=${CONFIG_PATH} config set database.mail_root ${TMP_DIRECTORY}/mail
66 notmuch --config=${CONFIG_PATH} config set database.path
69 for config in traditional split XDG XDG+profile symlink; do
70 #start each set of tests with an known set of messages
76 XAPIAN_PATH="$MAIL_DIR/.notmuch/xapian"
80 mv mail/.notmuch/xapian $DATABASE_PATH
84 mv mail/.notmuch/xapian $DATABASE_PATH
88 mv mail/.notmuch/xapian $DATABASE_PATH
95 test_begin_subtest "count ($config)"
96 output=$(notmuch count '*')
97 test_expect_equal "$output" '52'
99 test_begin_subtest "count+tag ($config)"
101 notmuch tag +$tag '*'
102 output=$(notmuch count tag:$tag)
103 notmuch tag -$tag '*'
104 test_expect_equal "$output" '52'
106 test_begin_subtest "address ($config)"
107 notmuch address --deduplicate=no --sort=newest-first --output=sender --output=recipients path:foo >OUTPUT
109 Carl Worth <cworth@cworth.org>
110 notmuch@notmuchmail.org
112 test_expect_equal_file EXPECTED OUTPUT
114 test_begin_subtest "dump ($config)"
115 notmuch dump is:attachment and is:signed | sort > OUTPUT
117 #notmuch-dump batch-tag:3 config,properties,tags
118 +attachment +inbox +signed +unread -- id:20091118005829.GB25380@dottiness.seas.harvard.edu
119 +attachment +inbox +signed +unread -- id:20091118010116.GC25380@dottiness.seas.harvard.edu
121 test_expect_equal_file EXPECTED OUTPUT
123 test_begin_subtest "dump + tag + restore ($config)"
124 notmuch dump '*' > EXPECTED
125 notmuch tag -inbox '*'
126 notmuch restore < EXPECTED
127 notmuch dump > OUTPUT
128 test_expect_equal_file EXPECTED OUTPUT
130 test_begin_subtest "reindex ($config)"
131 notmuch search --output=messages '*' > EXPECTED
133 notmuch search --output=messages '*' > OUTPUT
134 test_expect_equal_file EXPECTED OUTPUT
136 test_begin_subtest "use existing database ($config)"
137 output=$(notmuch new)
138 test_expect_equal "$output" 'No new mail.'
140 test_begin_subtest "create database ($config)"
141 rm -rf $DATABASE_PATH/{.notmuch,}/xapian
143 output=$(notmuch count '*')
144 test_expect_equal "$output" '52'
146 test_begin_subtest "detect new files ($config)"
150 output=$(notmuch count '*')
151 test_expect_equal "$output" '54'
153 test_begin_subtest "Show a raw message ($config)"
155 notmuch show --format=raw id:$gen_msg_id > OUTPUT
156 test_expect_equal_file $gen_msg_filename OUTPUT
157 rm -f $gen_msg_filename
159 test_begin_subtest "reply ($config)"
160 add_message '[from]="Sender <sender@example.com>"' \
161 [to]=test_suite@notmuchmail.org \
162 [subject]=notmuch-reply-test \
163 '[date]="Tue, 05 Jan 2010 15:43:56 -0000"' \
164 '[body]="basic reply test"'
165 notmuch reply id:${gen_msg_id} 2>&1 > OUTPUT
167 From: Notmuch Test Suite <test_suite@notmuchmail.org>
168 Subject: Re: notmuch-reply-test
169 To: Sender <sender@example.com>
170 In-Reply-To: <${gen_msg_id}>
171 References: <${gen_msg_id}>
173 On Tue, 05 Jan 2010 15:43:56 -0000, Sender <sender@example.com> wrote:
176 test_expect_equal_file EXPECTED OUTPUT
177 test_begin_subtest "insert+search ($config)"
179 "[subject]=\"insert-subject\"" \
180 "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \
181 "[body]=\"insert-message\""
182 mkdir -p "$MAIL_DIR"/{cur,new,tmp}
183 notmuch insert < "$gen_msg_filename"
184 cur_msg_filename=$(notmuch search --output=files "subject:insert-subject")
185 test_expect_equal_file "$cur_msg_filename" "$gen_msg_filename"
188 test_begin_subtest "compact+search ($config)"
189 notmuch search --output=messages '*' | sort > EXPECTED
191 notmuch search --output=messages '*' | sort > OUTPUT
192 test_expect_equal_file EXPECTED OUTPUT
194 test_begin_subtest "upgrade backup ($config)"
195 features=$(xapian-metadata get $XAPIAN_PATH features | grep -v "^relative directory paths")
196 xapian-metadata set $XAPIAN_PATH features "$features"
197 output=$(notmuch new | grep Welcome)
200 "Welcome to a new version of notmuch! Your database will now be upgraded."
202 test_begin_subtest "notmuch +config -database suggests notmuch new ($config)"
203 mv "$XAPIAN_PATH" "${XAPIAN_PATH}.bak"
206 Notmuch is configured, but no database was found.
207 You probably want to run "notmuch new" now to create a database.
209 Note that the first run of "notmuch new" can take a very long time
210 and that the resulting database will use roughly the same amount of
211 storage space as the email being indexed.
214 mv "${XAPIAN_PATH}.bak" "$XAPIAN_PATH"
216 test_expect_equal_file EXPECTED OUTPUT
218 test_begin_subtest "Set config value ($config)"
221 notmuch config set test${test_count}.${name} ${value}
222 output=$(notmuch config get test${test_count}.${name})
223 notmuch config set test${test_count}.${name}
224 output2=$(notmuch config get test${test_count}.${name})
225 test_expect_equal "${output}+${output2}" "${value}+"
227 test_begin_subtest "Set config value in database ($config)"
230 notmuch config set --database test${test_count}.${name} ${value}
231 output=$(notmuch config get test${test_count}.${name})
232 notmuch config set --database test${test_count}.${name}
233 output2=$(notmuch config get test${test_count}.${name})
234 test_expect_equal "${output}+${output2}" "${value}+"
236 test_begin_subtest "Config list ($config)"
237 notmuch config list | notmuch_dir_sanitize | sed -e "s/^database.backup_dir=.*$/database.backup_dir/" \
238 -e "s/^database.hook_dir=.*$/database.hook_dir/" \
239 -e "s/^database.path=.*$/database.path/" > OUTPUT
241 built_with.compact=true
242 built_with.field_processor=true
243 built_with.retry_lock=true
246 database.mail_root=MAIL_DIR
248 maildir.synchronize_flags=true
250 new.tags=unread;inbox
252 user.name=Notmuch Test Suite
253 user.other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org
254 user.primary_email=test_suite@notmuchmail.org
256 test_expect_equal_file EXPECTED OUTPUT
260 test_begin_subtest "Set shadowed config value in database ($config)"
263 key=test${test_count}.${name}
264 notmuch config set --database ${key} ${value}
265 notmuch config set ${key} shadow${value}
266 output=$(notmuch --config='' config get ${key})
267 notmuch config set --database ${key}
268 output2=$(notmuch --config='' config get ${key})
269 notmuch config set ${key}
270 test_expect_equal "${output}+${output2}" "${value}+"