Re: [PATCH] Fix typo in Message.maildir_flags_to_tags
[notmuch-archives.git] / af / cd41b06cdcacf47fe5f75d9253e8b4e009def9
1 Return-Path: <cworth@cworth.org>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 4B05E40DAE3\r
6         for <notmuch@notmuchmail.org>; Tue,  9 Nov 2010 12:39:01 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -2.89\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.89 tagged_above=-999 required=5\r
12         tests=[ALL_TRUSTED=-1, BAYES_00=-1.9, T_MIME_NO_TEXT=0.01]\r
13         autolearn=ham\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id YbZdbEn8mz4o; Tue,  9 Nov 2010 12:38:50 -0800 (PST)\r
17 Received: from yoom.home.cworth.org (localhost [127.0.0.1])\r
18         by olra.theworths.org (Postfix) with ESMTP id DE76740DAD3;\r
19         Tue,  9 Nov 2010 12:38:49 -0800 (PST)\r
20 Received: by yoom.home.cworth.org (Postfix, from userid 1000)\r
21         id 8A26A25412B; Tue,  9 Nov 2010 12:38:49 -0800 (PST)\r
22 From: Carl Worth <cworth@cworth.org>\r
23 To: Michal Sojka <sojkam1@fel.cvut.cz>, notmuch@notmuchmail.org\r
24 Subject: Re: [PATCH v4 0/4] Maildir synchronization\r
25 In-Reply-To: <87iq066cbd.fsf@steelpick.2x.cz>\r
26 References: <87tyk3vpxd.fsf@wsheee.2x.cz>\r
27         <1288560558-18915-1-git-send-email-sojkam1@fel.cvut.cz>\r
28         <877hgsrjau.fsf@yoom.home.cworth.org> <87d3qhq527.fsf@resox.2x.cz>\r
29         <874obrmww9.fsf@yoom.home.cworth.org>\r
30         <87iq066cbd.fsf@steelpick.2x.cz>\r
31 User-Agent: Notmuch/0.4 (http://notmuchmail.org) Emacs/23.2.1\r
32         (i486-pc-linux-gnu)\r
33 Date: Tue, 09 Nov 2010 12:38:49 -0800\r
34 Message-ID: <87oc9ykzae.fsf@yoom.home.cworth.org>\r
35 MIME-Version: 1.0\r
36 Content-Type: multipart/mixed; boundary="=-=-="\r
37 X-BeenThere: notmuch@notmuchmail.org\r
38 X-Mailman-Version: 2.1.13\r
39 Precedence: list\r
40 List-Id: "Use and development of the notmuch mail system."\r
41         <notmuch.notmuchmail.org>\r
42 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
43         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
44 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
45 List-Post: <mailto:notmuch@notmuchmail.org>\r
46 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
47 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
49 X-List-Received-Date: Tue, 09 Nov 2010 20:39:01 -0000\r
50 \r
51 --=-=-=\r
52 Content-Type: multipart/signed; boundary="==-=-=";\r
53         micalg=pgp-sha1; protocol="application/pgp-signature"\r
54 \r
55 --==-=-=\r
56 Content-Transfer-Encoding: quoted-printable\r
57 \r
58 On Tue, 09 Nov 2010 11:06:30 +0100, Michal Sojka <sojkam1@fel.cvut.cz> wrot=\r
59 e:\r
60 > This sounds good. Still it will be neccessary to synchronize with all\r
61 > files, not only the first one.\r
62 \r
63 OK. I'll add that to the list of things I'll fix up.\r
64 \r
65 > > I'd like to get things merged today, so I plan to take your patches and\r
66 > > then add new commits on top to implement the functions I described\r
67 > > above.\r
68 >=20\r
69 > Great! Seems that it is still not finished and I do not want to do\r
70 > duplicite work, so let me know what is the current status and whether\r
71 > you need some help from me (e.g. tests for multiple messages with same\r
72 > ID). I should be on IRC today.\r
73 \r
74 Yesterday ended up being very busy, but I'm working on this stuff\r
75 now. My plan is to merge it and then release notmuch 0.5. (And yes, if I\r
76 had a more strict release manager then 0.5 would have been released\r
77 yesterday as-is---but it turns out my release manager had an equally\r
78 busy day yesterday).\r
79 \r
80 If you wanted to write some more tests, then that would be very useful.\r
81 \r
82 I've been changing the way the tests are written, so you might want to\r
83 look at the attached file to see what I'm doing and match it. Notable\r
84 differences:\r
85 \r
86         * Using test_begin_subtest and test_expect_equal rather than the\r
87           list-of-commands to test_expect_success.\r
88 \r
89         * Not emitting separate line-item results for things that are\r
90           already tested in other scripts, (like "add message" and\r
91           "search for message", etc.)\r
92 \r
93 The updating I've done here only goes as far as just before "Add a\r
94 message to new/ without info". And it looks like one change I made\r
95 inadvertently broke a later test, so it's expected that "Check that\r
96 removing info did not change tags" currently fails. [And this failure\r
97 shows what I don't like about test_expect_success---if we were using\r
98 test_expect_equal it would be trivial to see what problem I made here.]\r
99 \r
100 Finally, when going through these tests I saw:\r
101 \r
102         "Removing of unread tag should fail without cur/"\r
103 \r
104 And that's behavior I do not want. Adding and removing tags should be\r
105 reliable whether or not the maildir synchronization can succeed. In this\r
106 specific case, the right answer is probably to say that a directory\r
107 without "new" and "cur" is not a maildir so no synchronization should be\r
108 done.\r
109 \r
110 Notmuch does need to be able to support things like mh format still. Do\r
111 the current patches break that by doing maildir-style renaming in\r
112 non-maildir directories? If so, we'll need to fix that as well. And that\r
113 might require an "is_maildir" term to be stored for directory documents\r
114 in the database.\r
115 \r
116 Again, that's something I can help with.\r
117 \r
118 Thanks again,\r
119 \r
120 =2DCarl\r
121 \r
122 \r
123 --==-=-=\r
124 Content-Type: application/pgp-signature\r
125 \r
126 -----BEGIN PGP SIGNATURE-----\r
127 Version: GnuPG v1.4.10 (GNU/Linux)\r
128 \r
129 iD8DBQFM2bFZ6JDdNq8qSWgRAoc0AKCSOhpUcAj9zi97HqEv11RvrXTyrACfffC7\r
130 5wx1KHaiPBWaTrD8v9LglZ8=\r
131 =t4Ei\r
132 -----END PGP SIGNATURE-----\r
133 --==-=-=--\r
134 \r
135 --=-=-=\r
136 Content-Disposition: inline; filename=maildir-sync\r
137 \r
138 #!/bin/bash\r
139 \r
140 test_description="maildir synchronization"\r
141 \r
142 . ./test-lib.sh\r
143 \r
144 # Much easier to examine differences if the "notmuch show\r
145 # --format=json" output includes some newlines. Also, need to avoid\r
146 # including the local value of MAIL_DIR in the result.\r
147 filter_show_json() {\r
148     sed -e 's/, /,\n/g'  | sed -e "s|${MAIL_DIR}/|MAIL_DIR/|"\r
149     echo\r
150 }\r
151 \r
152 cat >> "$NOTMUCH_CONFIG" <<EOF\r
153 [maildir]\r
154 synchronize_flags=true\r
155 EOF\r
156 \r
157 test_begin_subtest "Adding 'S' flag to existing file removes 'unread' tag"\r
158 add_message [subject]='"test message"' [date]='"Sat, 01 Jan 2000 12:00:00 -0000"' [filename]='"msg-001:2,"'\r
159 NOTMUCH_NEW > /dev/null\r
160 output=$(notmuch search tag:inbox | notmuch_search_sanitize)\r
161 output+="\r
162 "\r
163 mv "${gen_msg_filename}" "${gen_msg_filename}S"\r
164 increment_mtime "$(dirname "${gen_msg_filename}")"\r
165 output+=$(NOTMUCH_NEW)\r
166 output+="\r
167 "\r
168 output+=$(notmuch search tag:inbox | notmuch_search_sanitize)\r
169 test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; test message (inbox unread)\r
170 No new mail. Detected 1 file rename.\r
171 thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; test message (inbox)"\r
172 \r
173 test_begin_subtest "Adding message with 'S' flag prevents 'unread' tag"\r
174 add_message [subject]='"test message 2"' [date]='"Sat, 01 Jan 2000 12:00:00 -0000"' [filename]='"msg-002:2,S"' &&\r
175 output=$(notmuch search tag:inbox | notmuch_search_sanitize)\r
176 test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; test message (inbox)\r
177 thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; test message 2 (inbox)"\r
178 \r
179 test_begin_subtest "Adding 'replied' flag adds 'R' tag to filename"\r
180 notmuch tag +replied tag:inbox\r
181 output=$(ls -1 "${MAIL_DIR}")\r
182 test_expect_equal "$output" "msg-001:2,RS\r
183 msg-002:2,RS"\r
184 \r
185 test_begin_subtest "notmuch show works with renamed file (without notmuch new)"\r
186 output=$(notmuch show --format=json id:msg-001@notmuch-test-suite | filter_show_json)\r
187 test_expect_equal "$output" '[[[{"id": "msg-001@notmuch-test-suite",\r
188 "match": true,\r
189 "filename": "MAIL_DIR/msg-001:2,RS",\r
190 "timestamp": 946728000,\r
191 "date_relative": "2000-01-01",\r
192 "tags": ["inbox","replied"],\r
193 "headers": {"Subject": "test message",\r
194 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
195 "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
196 "Cc": "",\r
197 "Bcc": "",\r
198 "Date": "Sat,\r
199 01 Jan 2000 12:00:00 -0000"},\r
200 "body": [{"id": 1,\r
201 "content-type": "text/plain",\r
202 "content": "This is just a test message (#1)\n"}]},\r
203 []]]]'\r
204 \r
205 test_expect_success 'notmuch reply works with renamed file (without notmuch new)' 'notmuch reply id:msg-001@notmuch-test-suite'\r
206 \r
207 test_begin_subtest "notmuch new detects no file rename after tag->flag synchronization"\r
208 increment_mtime "$(dirname ${gen_msg_filename})"\r
209 output=$(NOTMUCH_NEW)\r
210 test_expect_equal "$output" "No new mail."\r
211 \r
212 test_expect_success "Add a message to new/ without info" '\r
213 generate_message [subject]="\"test message 3\"" [date]="\"Sat, 01 Jan 2000 12:00:00 -0000\"" [dir]=new &&\r
214 NOTMUCH_NEW > actual &&\r
215 test_cmp - actual <<EOF\r
216 Added 1 new message to the database.\r
217 EOF\r
218 '\r
219 test_expect_success "Check that the message has inbox and unread tags" '\r
220 notmuch search tag:inbox and tag:unread | notmuch_search_sanitize > actual &&\r
221 test_cmp - actual <<EOF\r
222 thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; test message 3 (inbox unread)\r
223 EOF\r
224 '\r
225 test_expect_success "Tag the message with 'tmp' tag" '\r
226 notmuch tag +tmp tag:inbox and tag:unread'\r
227 \r
228 test_expect_success "Check that the message was not moved from new/ to cur/" '\r
229 echo filename:$gen_msg_filename > expected &&\r
230 notmuch show id:$gen_msg_id|grep -o "filename:.*$" > actual &&\r
231 test_cmp expected actual &&\r
232 test -f "$gen_msg_filename"\r
233 '\r
234 test_expect_success "Check that the message was not renamed" '\r
235 ls "${MAIL_DIR}/new" > actual &&\r
236 test_cmp - actual <<EOF\r
237 msg-003\r
238 EOF\r
239 '\r
240 test_expect_success 'Removing of unread tag should fail without cur/' '\r
241 test_must_fail notmuch tag -unread tag:inbox and tag:unread\r
242 '\r
243 test_expect_success "Check that the tags were not changed" '\r
244 notmuch search tag:inbox and tag:unread | notmuch_search_sanitize > actual &&\r
245 test_cmp - actual <<EOF\r
246 thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; test message 3 (inbox tmp unread)\r
247 EOF\r
248 '\r
249 \r
250 # notmuch new is not necessary here, but we run it in order to check\r
251 # for 'no rename' later (*).\r
252 test_expect_success 'Create cur/ and let notmuch know about it' '\r
253 mkdir "$MAIL_DIR/cur" &&\r
254 notmuch new\r
255 '\r
256 test_expect_success 'Removing of unread tag should pass with cur/' '\r
257 notmuch tag -unread tag:inbox and tag:unread\r
258 '\r
259 test_expect_success 'Check that the message was moved to cur/' '\\r
260 ls "$MAIL_DIR/cur" > actual &&\r
261 test_cmp - actual <<EOF\r
262 msg-003:2,S\r
263 EOF\r
264 '\r
265 test_expect_success 'No rename should be detected by notmuch new' '\r
266 increment_mtime "$MAIL_DIR/cur" &&\r
267 notmuch new > actual &&\r
268 test_cmp - actual <<EOF\r
269 No new mail.\r
270 EOF\r
271 '\r
272 # (*) If notmuch new was not run we've got "Processed 1 file in almost\r
273 # no time" here. The reason is that removing unread tag in a previous\r
274 # test created directory document in the database but this document\r
275 # was not linked as subdirectory of $MAIL_DIR. Therefore notmuch new\r
276 # could not reach the cur/ directory and its files in it during\r
277 # recurive traversal.\r
278 test_expect_success 'Remove info from file name' '\r
279 mv "$MAIL_DIR/cur/msg-003:2,S" "$MAIL_DIR/cur/msg-003" &&\r
280 increment_mtime "$MAIL_DIR/cur" &&\r
281 NOTMUCH_NEW > actual\r
282 test_cmp - actual <<EOF\r
283 No new mail. Detected 1 file rename.\r
284 EOF\r
285 '\r
286 test_expect_success "Check that removing info did not change tags" '\r
287 notmuch search tag:inbox | notmuch_search_sanitize > actual &&\r
288 test_cmp - actual <<EOF\r
289 thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; test message 3 (inbox tmp)\r
290 EOF\r
291 '\r
292 test_expect_success "Add a message to fakenew/ without info" '\r
293 generate_message [subject]="\"test message 4\"" [date]="\"Sat, 01 Jan 2000 12:00:00 -0000\"" [dir]=fakenew &&\r
294 NOTMUCH_NEW > actual &&\r
295 test_cmp - actual <<EOF\r
296 Added 1 new message to the database.\r
297 EOF\r
298 '\r
299 test_expect_success "Check that the message has inbox and unread tags" '\r
300 notmuch search tag:inbox and tag:unread | notmuch_search_sanitize > actual &&\r
301 test_cmp - actual <<EOF\r
302 thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; test message 4 (inbox unread)\r
303 EOF\r
304 '\r
305 test_expect_success 'Removing of unread tag should leave the message in fakenew/' '\r
306 notmuch tag -unread tag:inbox and tag:unread &&\r
307 ls "$MAIL_DIR/fakenew" > actual &&\r
308 test_cmp - actual <<EOF\r
309 msg-004:2,S\r
310 EOF\r
311 '\r
312 \r
313 test_expect_success 'Make maildir flags out of sync with the database' '\r
314 ls $MAIL_DIR > expected &&\r
315 mv $MAIL_DIR/msg-001:2,RS $MAIL_DIR/msg-001:2, &&\r
316 mv $MAIL_DIR/msg-002:2,RS $MAIL_DIR/msg-002:2, &&\r
317 increment_mtime $MAIL_DIR\r
318 '\r
319 \r
320 test_expect_success 'Test whether dump/new/restore synchronizes the maildir flags with the database' '\r
321 notmuch dump dump.txt &&\r
322 notmuch new &&\r
323 notmuch restore dump.txt &&\r
324 ls $MAIL_DIR > actual &&\r
325 test_cmp expected actual\r
326 '\r
327 \r
328 test_done\r
329 \r
330 --=-=-=\r
331 \r
332 \r
333 -- \r
334 carl.d.worth@intel.com\r
335 \r
336 --=-=-=--\r