2 test_description='reindexing messages'
3 . $(dirname "$0")/test-lib.sh || exit 1
8 if [ $NOTMUCH_HAVE_SFSEXP -eq 1 ]; then
10 count=$(notmuch count --lastmod '*' | cut -f 3)
11 for query in '()' '(not)' '(and)' '(or ())' '(or (not))' '(or (and))' \
12 '(or (and) (or) (not (and)))'; do
13 test_begin_subtest "reindex all messages: $query"
14 notmuch reindex --query=sexp "$query"
15 output=$(notmuch count --lastmod '*' | cut -f 3)
17 test_expect_equal "$output" "$count"
22 notmuch tag +usertag1 '*'
24 notmuch search '*' 2>1 | notmuch_search_sanitize > initial-threads
25 notmuch search --output=messages '*' 2>/dev/null > initial-message-ids
26 notmuch dump > initial-dump
28 test_begin_subtest 'reindex preserves threads'
30 notmuch search '*' | notmuch_search_sanitize > OUTPUT
31 test_expect_equal_file initial-threads OUTPUT
33 test_begin_subtest 'reindex after removing duplicate file preserves threads'
35 sed 's,3/3(4),3/3,' < initial-threads > EXPECTED
36 mv $MAIL_DIR/bar/18:2, duplicate-msg-1.eml
38 notmuch search '*' | notmuch_search_sanitize > OUTPUT
39 test_expect_equal_file EXPECTED OUTPUT
41 test_begin_subtest 'reindex preserves message-ids'
43 notmuch search --output=messages '*' > OUTPUT
44 test_expect_equal_file initial-message-ids OUTPUT
46 test_begin_subtest 'reindex preserves tags'
49 test_expect_equal_file initial-dump OUTPUT
51 test_begin_subtest 'reindex preserves tags with special prefixes'
52 notmuch tag +attachment2 +encrypted2 +signed2 '*'
53 notmuch dump > EXPECTED
56 notmuch tag -attachment2 -encrypted2 -signed2 '*'
57 test_expect_equal_file EXPECTED OUTPUT
60 test_begin_subtest 'reindex moves a message between threads'
61 notmuch search --output=threads id:87iqd9rn3l.fsf@vertex.dottedmag > EXPECTED
63 sed -i 's/1258471718-6781-1-git-send-email-dottedmag@dottedmag.net/87iqd9rn3l.fsf@vertex.dottedmag/' $MAIL_DIR/02:2,*
64 notmuch reindex id:1258471718-6781-2-git-send-email-dottedmag@dottedmag.net
65 notmuch search --output=threads id:1258471718-6781-2-git-send-email-dottedmag@dottedmag.net > OUTPUT
66 test_expect_equal_file EXPECTED OUTPUT
70 test_begin_subtest 'reindex detects removal of all files'
71 notmuch search --output=messages not id:20091117232137.GA7669@griffis1.net> EXPECTED
73 mv $MAIL_DIR/cur/51:2,* duplicate-message-2.eml
74 notmuch reindex id:20091117232137.GA7669@griffis1.net
75 notmuch search --output=messages '*' > OUTPUT
76 test_expect_equal_file EXPECTED OUTPUT
80 test_begin_subtest 'reindex detects removal of all files'
81 notmuch search --output=messages not id:20091117232137.GA7669@griffis1.net> EXPECTED
83 mv $MAIL_DIR/cur/51:2,* duplicate-message-2.eml
84 notmuch reindex id:20091117232137.GA7669@griffis1.net
85 notmuch search --output=messages '*' > OUTPUT
86 test_expect_equal_file EXPECTED OUTPUT
89 test_begin_subtest "reindex preserves properties"
91 #= 1258471718-6781-1-git-send-email-dottedmag@dottedmag.net userprop=userval
92 #= 1258471718-6781-2-git-send-email-dottedmag@dottedmag.net userprop=userval
93 #= 1258491078-29658-1-git-send-email-dottedmag@dottedmag.net userprop=userval1
94 #= 20091117190054.GU3165@dottiness.seas.harvard.edu userprop=userval
95 #= 20091117203301.GV3165@dottiness.seas.harvard.edu userprop=userval3
96 #= 87fx8can9z.fsf@vertex.dottedmag userprop=userval2
97 #= 87iqd9rn3l.fsf@vertex.dottedmag userprop=userval
98 #= 87lji4lx9v.fsf@yoom.home.cworth.org userprop=userval3
99 #= 87lji5cbwo.fsf@yoom.home.cworth.org userprop=userval
100 #= cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com userprop=userval
102 notmuch restore < prop-dump
104 notmuch dump | grep '^#=' | sort > OUTPUT
105 test_expect_equal_file prop-dump OUTPUT
107 add_email_corpus lkml
109 test_begin_subtest "reindex of lkml corpus preserves threads"
110 notmuch search '*' | notmuch_search_sanitize > EXPECTED
112 notmuch search '*' | notmuch_search_sanitize > OUTPUT
113 test_expect_equal_file EXPECTED OUTPUT
116 test_begin_subtest "reindex after removing corpus"
117 tar cf backup.tar mail/cur
118 find mail/cur -type f -delete
119 test_expect_success "notmuch reindex '*'"