Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / a2 / a0dfed375b2d4a1b3d14703183c31994a59c48
1 Return-Path: <sojkam1@fel.cvut.cz>\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 33D58409DE6\r
6         for <notmuch@notmuchmail.org>; Tue, 11 May 2010 05:15:16 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.9\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5\r
12         tests=[BAYES_00=-1.9] autolearn=ham\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id uh08dxlZQ6-d for <notmuch@notmuchmail.org>;\r
16         Tue, 11 May 2010 05:15:01 -0700 (PDT)\r
17 Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36])\r
18         by olra.theworths.org (Postfix) with ESMTP id 4F782418C25\r
19         for <notmuch@notmuchmail.org>; Tue, 11 May 2010 05:14:38 -0700 (PDT)\r
20 Received: from localhost (unknown [192.168.200.4])\r
21         by max.feld.cvut.cz (Postfix) with ESMTP id A2CC819F33F8;\r
22         Tue, 11 May 2010 14:14:37 +0200 (CEST)\r
23 X-Virus-Scanned: IMAP AMAVIS\r
24 Received: from max.feld.cvut.cz ([192.168.200.1])\r
25         by localhost (styx.feld.cvut.cz [192.168.200.4]) (amavisd-new,\r
26         port 10044)\r
27         with ESMTP id auSlytIHSLgM; Tue, 11 May 2010 14:14:33 +0200 (CEST)\r
28 Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34])\r
29         by max.feld.cvut.cz (Postfix) with ESMTP id F28B719F33FB;\r
30         Tue, 11 May 2010 14:14:31 +0200 (CEST)\r
31 Received: from steelpick.2x.cz (k335-30.felk.cvut.cz [147.32.86.30])\r
32         (Authenticated sender: sojkam1)\r
33         by imap.feld.cvut.cz (Postfix) with ESMTPSA id C22C3FA004;\r
34         Tue, 11 May 2010 14:14:31 +0200 (CEST)\r
35 Received: from wsh by steelpick.2x.cz with local (Exim 4.71)\r
36         (envelope-from <sojkam1@fel.cvut.cz>)\r
37         id 1OBoM3-0005t2-K3; Tue, 11 May 2010 14:14:31 +0200\r
38 From: Michal Sojka <sojkam1@fel.cvut.cz>\r
39 To: notmuch@notmuchmail.org\r
40 Subject: [PATCH 4/4] Tests for maildir synchronization\r
41 Date: Tue, 11 May 2010 14:14:21 +0200\r
42 Message-Id: <1273580061-22580-5-git-send-email-sojkam1@fel.cvut.cz>\r
43 X-Mailer: git-send-email 1.7.1\r
44 In-Reply-To: <1273580061-22580-1-git-send-email-sojkam1@fel.cvut.cz>\r
45 References: <1273580061-22580-1-git-send-email-sojkam1@fel.cvut.cz>\r
46 X-BeenThere: notmuch@notmuchmail.org\r
47 X-Mailman-Version: 2.1.13\r
48 Precedence: list\r
49 List-Id: "Use and development of the notmuch mail system."\r
50         <notmuch.notmuchmail.org>\r
51 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
53 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
54 List-Post: <mailto:notmuch@notmuchmail.org>\r
55 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
56 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
58 X-List-Received-Date: Tue, 11 May 2010 12:15:16 -0000\r
59 \r
60 Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>\r
61 ---\r
62  test/t0011-maildir-sync.sh |  216 ++++++++++++++++++++++++++++++++++++++++++++\r
63  test/test-lib.sh           |   11 ++-\r
64  2 files changed, 223 insertions(+), 4 deletions(-)\r
65  create mode 100755 test/t0011-maildir-sync.sh\r
66 \r
67 diff --git a/test/t0011-maildir-sync.sh b/test/t0011-maildir-sync.sh\r
68 new file mode 100755\r
69 index 0000000..6bdee2d\r
70 --- /dev/null\r
71 +++ b/test/t0011-maildir-sync.sh\r
72 @@ -0,0 +1,216 @@\r
73 +#!/bin/bash\r
74 +\r
75 +test_description="Test maildir synchronization"\r
76 +\r
77 +. ./test-lib.sh\r
78 +\r
79 +filter_show() {\r
80 +    sed -e 's/, /,\n/g'|sed -e "s|${MAIL_DIR}/||" -e '/^"tags"/d'\r
81 +    echo\r
82 +}\r
83 +\r
84 +cat >> "$NOTMUCH_CONFIG" <<EOF\r
85 +[maildir]\r
86 +sync_level=4\r
87 +EOF\r
88 +\r
89 +test_expect_success "No new mail" '\r
90 +output=$(NOTMUCH_NEW) &&\r
91 +pass_if_equal "$output" "No new mail."\r
92 +'\r
93 +cat > expected <<EOF\r
94 +Added 1 new message to the database.\r
95 +EOF\r
96 +test_expect_success "Add a message, no flags" '\r
97 +generate_message [subject]="\"test message\"" [date]="\"Sat, 01 Jan 2000 12:00:00 -0000\"" [filename]="\"msg-001:2,\"" &&\r
98 +NOTMUCH_NEW > actual &&\r
99 +test_cmp expected actual\r
100 +#emacs --eval "(gdb \"gdb --annotate=3 --args $(which notmuch) new\")"\r
101 +'\r
102 +cat > expected <<EOF\r
103 +thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; test message (inbox unread)\r
104 +EOF\r
105 +test_expect_success 'Search for the message' '\r
106 +notmuch search tag:inbox and tag:unread | notmuch_search_sanitize > actual &&\r
107 +test_cmp expected actual\r
108 +'\r
109 +cat > expected <<EOF\r
110 +No new mail. Detected 1 file rename.\r
111 +EOF\r
112 +test_expect_success 'Add seen flag' '\r
113 +mv "${gen_msg_filename}" "${gen_msg_filename}S" &&\r
114 +increment_mtime "$(dirname "${gen_msg_filename}")" &&\r
115 +NOTMUCH_NEW > actual &&\r
116 +test_cmp expected actual\r
117 +'\r
118 +cat > expected <<EOF\r
119 +thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; test message (inbox)\r
120 +EOF\r
121 +test_expect_success 'Check that tags were updated' '\r
122 +notmuch search tag:inbox and not tag:unread | notmuch_search_sanitize > actual &&\r
123 +test_cmp expected actual\r
124 +'\r
125 +cat > expected <<EOF\r
126 +Added 1 new message to the database.\r
127 +EOF\r
128 +test_expect_success "Add a seen message" '\r
129 +generate_message [subject]="\"test message 2\"" [date]="\"Sat, 01 Jan 2000 12:00:00 -0000\"" [filename]="\"msg-002:2,S\"" &&\r
130 +NOTMUCH_NEW > actual &&\r
131 +test_cmp expected actual\r
132 +'\r
133 +cat > expected <<EOF\r
134 +thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; test message (inbox)\r
135 +thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; test message 2 (inbox)\r
136 +EOF\r
137 +test_expect_success 'Check that the seen message is not tagged unread' '\r
138 +notmuch search tag:inbox and not tag:unread | notmuch_search_sanitize > actual &&\r
139 +test_cmp expected actual\r
140 +'\r
141 +test_expect_success 'Tag the seen messages as replied' '\r
142 +notmuch tag +replied -inbox tag:inbox and not tag:unread\r
143 +'\r
144 +\r
145 +cat > expected <<EOF\r
146 +msg-001:2,RS\r
147 +msg-002:2,RS\r
148 +EOF\r
149 +test_expect_success 'Check that R flag was added' '\r
150 +ls -1 "${MAIL_DIR}" > actual &&\r
151 +test_cmp expected actual\r
152 +'\r
153 +cat <<EOF > show-expected\r
154 +[[[{"id": "msg-001@notmuch-test-suite",\r
155 +"match": true,\r
156 +"filename": "msg-001:2,RS",\r
157 +"timestamp": 946728000,\r
158 +"date_relative": "2000-01-01",\r
159 +"headers": {"Subject": "test message",\r
160 +"From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
161 +"To": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
162 +"Cc": "",\r
163 +"Bcc": "",\r
164 +"Date": "Sat,\r
165 +01 Jan 2000 12:00:00 -0000"},\r
166 +"body": [{"id": 1,\r
167 +"content-type": "text/plain",\r
168 +"content": "This is just a test message (#1)\n"}]},\r
169 +[]]]]\r
170 +EOF\r
171 +\r
172 +test_expect_success 'Renamed message can be shown without running notmuch new' '\r
173 +notmuch show --format=json id:msg-001@notmuch-test-suite | filter_show > show-actual &&\r
174 +test_cmp show-expected show-actual\r
175 +'\r
176 +\r
177 +test_expect_success 'Test that we can reply to the renamed message' '\r
178 +notmuch reply id:msg-001@notmuch-test-suite\r
179 +'\r
180 +\r
181 +echo "No new mail." > expected\r
182 +test_expect_success 'No rename should be detected by notmuch new' '\r
183 +increment_mtime "$(dirname "${gen_msg_filename}")" &&\r
184 +notmuch new > actual &&\r
185 +test_cmp expected actual\r
186 +'\r
187 +test_expect_success "Add a message to new/ without info" '\r
188 +generate_message [subject]="\"test message 3\"" [date]="\"Sat, 01 Jan 2000 12:00:00 -0000\"" [dir]=new &&\r
189 +NOTMUCH_NEW > actual &&\r
190 +test_cmp - actual <<EOF\r
191 +Added 1 new message to the database.\r
192 +EOF\r
193 +'\r
194 +test_expect_success "Check that the message has inbox and unread tags" '\r
195 +notmuch search tag:inbox and tag:unread | notmuch_search_sanitize > actual &&\r
196 +test_cmp - actual <<EOF\r
197 +thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; test message 3 (inbox unread)\r
198 +EOF\r
199 +'\r
200 +test_expect_success "Tag the message with 'tmp' tag" '\r
201 +notmuch tag +tmp tag:inbox and tag:unread'\r
202 +\r
203 +test_expect_success "Check that the message was not moved from new/ to cur/" '\r
204 +echo filename:$gen_msg_filename > expected &&\r
205 +notmuch show id:$gen_msg_id|grep -o "filename:.*$" > actual &&\r
206 +test_cmp expected actual &&\r
207 +test -f "$gen_msg_filename"\r
208 +'\r
209 +test_expect_success "Check that the message was not renamed" '\r
210 +ls "${MAIL_DIR}/new" > actual &&\r
211 +test_cmp - actual <<EOF\r
212 +msg-003\r
213 +EOF\r
214 +'\r
215 +test_expect_success 'Removing of unread tag should fail without cur/' '\r
216 +test_must_fail notmuch tag -unread tag:inbox and tag:unread\r
217 +'\r
218 +test_expect_success "Check that the tags were not changed" '\r
219 +notmuch search tag:inbox and tag:unread | notmuch_search_sanitize > actual &&\r
220 +test_cmp - actual <<EOF\r
221 +thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; test message 3 (inbox tmp unread)\r
222 +EOF\r
223 +'\r
224 +\r
225 +# notmuch new is not necessary here, but we run it in order to check\r
226 +# for 'no rename' later (*).\r
227 +test_expect_success 'Create cur/ and let notmuch know about it' '\r
228 +mkdir "$MAIL_DIR/cur" &&\r
229 +notmuch new\r
230 +'\r
231 +test_expect_success 'Removing of unread tag should pass with cur/' '\r
232 +notmuch tag -unread tag:inbox and tag:unread\r
233 +'\r
234 +test_expect_success 'Check that the message was moved to cur/' '\\r
235 +ls "$MAIL_DIR/cur" > actual &&\r
236 +test_cmp - actual <<EOF\r
237 +msg-003:2,S\r
238 +EOF\r
239 +'\r
240 +test_expect_success 'No rename should be detected by notmuch new' '\r
241 +increment_mtime "$MAIL_DIR/cur" &&\r
242 +notmuch new > actual &&\r
243 +test_cmp - actual <<EOF\r
244 +No new mail.\r
245 +EOF\r
246 +'\r
247 +# (*) If notmuch new was not run we've got "Processed 1 file in almost\r
248 +# no time" here. The reason is that removing unread tag in a previous\r
249 +# test created directory document in the database but this document\r
250 +# was not linked as subdirectory of $MAIL_DIR. Therefore notmuch new\r
251 +# could not reach the cur/ directory and its files in it during\r
252 +# recurive traversal.\r
253 +test_expect_success 'Remove info from file name' '\r
254 +mv "$MAIL_DIR/cur/msg-003:2,S" "$MAIL_DIR/cur/msg-003" &&\r
255 +increment_mtime "$MAIL_DIR/cur" &&\r
256 +NOTMUCH_NEW > actual\r
257 +test_cmp - actual <<EOF\r
258 +No new mail. Detected 1 file rename.\r
259 +EOF\r
260 +'\r
261 +test_expect_success "Check that removing info did not change tags" '\r
262 +notmuch search tag:inbox | notmuch_search_sanitize > actual &&\r
263 +test_cmp - actual <<EOF\r
264 +thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; test message 3 (inbox tmp)\r
265 +EOF\r
266 +'\r
267 +test_expect_success "Add a message to fakenew/ without info" '\r
268 +generate_message [subject]="\"test message 4\"" [date]="\"Sat, 01 Jan 2000 12:00:00 -0000\"" [dir]=fakenew &&\r
269 +NOTMUCH_NEW > actual &&\r
270 +test_cmp - actual <<EOF\r
271 +Added 1 new message to the database.\r
272 +EOF\r
273 +'\r
274 +test_expect_success "Check that the message has inbox and unread tags" '\r
275 +notmuch search tag:inbox and tag:unread | notmuch_search_sanitize > actual &&\r
276 +test_cmp - actual <<EOF\r
277 +thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; test message 4 (inbox unread)\r
278 +EOF\r
279 +'\r
280 +test_expect_success 'Removing of unread tag should leave the message in fakenew/' '\r
281 +notmuch tag -unread tag:inbox and tag:unread &&\r
282 +ls "$MAIL_DIR/fakenew" > actual &&\r
283 +test_cmp - actual <<EOF\r
284 +msg-004:2,S\r
285 +EOF\r
286 +'\r
287 +\r
288 +test_done\r
289 diff --git a/test/test-lib.sh b/test/test-lib.sh\r
290 index 06559cd..3c288a5 100755\r
291 --- a/test/test-lib.sh\r
292 +++ b/test/test-lib.sh\r
293 @@ -276,12 +276,15 @@ generate_message ()\r
294      local -A template="($@)"\r
295      local additional_headers\r
296  \r
297 +    gen_msg_cnt=$((gen_msg_cnt + 1))\r
298 +    if [ -z "${template[filename]}" ]; then\r
299 +       template[filename]="msg-$(printf "%03d" $gen_msg_cnt)"\r
300 +    fi\r
301 +    gen_msg_name=${template[filename]}\r
302 +\r
303      if [ -z "${template[id]}" ]; then\r
304 -       gen_msg_cnt=$((gen_msg_cnt + 1))\r
305 -       gen_msg_name=msg-$(printf "%03d" $gen_msg_cnt)\r
306 -       gen_msg_id="${gen_msg_name}@notmuch-test-suite"\r
307 +       gen_msg_id="${gen_msg_name%:2,*}@notmuch-test-suite"\r
308      else\r
309 -       gen_msg_name="msg-${template[id]}"\r
310         gen_msg_id="${template[id]}"\r
311      fi\r
312  \r
313 -- \r
314 1.7.1\r
315 \r