Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / d0 / 7be56b8e0d7094b39722e86c3b8ea92323105d
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 DDEAE431FBD;\r
6         Sun, 10 Jan 2010 09:54:26 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 Received: from olra.theworths.org ([127.0.0.1])\r
9         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
10         with ESMTP id MjdpMhD3VDeF; Sun, 10 Jan 2010 09:54:26 -0800 (PST)\r
11 Received: from yoom.home.cworth.org (localhost [127.0.0.1])\r
12         by olra.theworths.org (Postfix) with ESMTP id CB572431FAE;\r
13         Sun, 10 Jan 2010 09:54:25 -0800 (PST)\r
14 Received: by yoom.home.cworth.org (Postfix, from userid 1000)\r
15         id 841B625400A; Sun, 10 Jan 2010 09:54:25 -0800 (PST)\r
16 From: Carl Worth <cworth@cworth.org>\r
17 To: "Jeffrey C. Ollie" <jeff@ocjtech.us>, Not Much Mail\r
18         <notmuch@notmuchmail.org>\r
19 In-Reply-To: <1259424123-26285-1-git-send-email-jeff@ocjtech.us>\r
20 References: <1259424123-26285-1-git-send-email-jeff@ocjtech.us>\r
21 Date: Sun, 10 Jan 2010 09:54:25 -0800\r
22 Message-ID: <87my0llub2.fsf@yoom.home.cworth.org>\r
23 MIME-Version: 1.0\r
24 Content-Type: multipart/mixed; boundary="=-=-="\r
25 Subject: Re: [notmuch] [PATCH] Add the beginnings of a test suite.\r
26 X-BeenThere: notmuch@notmuchmail.org\r
27 X-Mailman-Version: 2.1.13\r
28 Precedence: list\r
29 List-Id: "Use and development of the notmuch mail system."\r
30         <notmuch.notmuchmail.org>\r
31 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
32         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
33 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
34 List-Post: <mailto:notmuch@notmuchmail.org>\r
35 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
36 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
37         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
38 X-List-Received-Date: Sun, 10 Jan 2010 17:54:27 -0000\r
39 \r
40 --=-=-=\r
41 Content-Type: multipart/signed; boundary="==-=-=";\r
42         micalg=pgp-sha1; protocol="application/pgp-signature"\r
43 \r
44 --==-=-=\r
45 \r
46 On Sat, 28 Nov 2009 10:02:03 -0600, "Jeffrey C. Ollie" <jeff@ocjtech.us> wrote:\r
47 > This is the beginning of a test suite.  It uses the Check[1] unit\r
48 > testing framework to handle the testing.  There's one basic test of\r
49 > the SHA1 routines, obviously many more will need to be added.\r
50 \r
51 Hi Jeffrey,\r
52 \r
53 Thanks very much for this contribution. I'm always highly in favor of\r
54 improving our testing infrastructure. And a good test suite was on of\r
55 the first items I put on the notmuch/TODO list.\r
56 \r
57 However, it's not clear to me that this kind of C-based unit testing\r
58 will be able to easily support much of what I want from testing for\r
59 notmuch. It seems that most of the bugs I encounter, or features that I\r
60 want to test, require a lot of state to be setup that would be really\r
61 painful to do in C code.\r
62 \r
63 For example, a recent bug I hit was:\r
64 \r
65         After moving an (old) existing file into the mail store,\r
66         "notmuch new" won't pick it up.\r
67 \r
68 And I don't see an easy way to test something like that from a typical\r
69 "check" test. Meanwhile, I can't see a lot of use from the kinds of\r
70 things that *could* be checked from a check test. We could easily check\r
71 little things like that after calling notmuch_message_add_tag that\r
72 notmuch_message_get_tags has the same tag in its list. But if we have to\r
73 do higher-level testing anyway, (for cases like the bug above), then\r
74 it's easy to cover fine-grained stuff like this there as well.\r
75 \r
76 For the recent rename-support work I did I wrote the attached\r
77 notmuch-test script. It does the kind of high-level state setup I\r
78 described above, (and actually contains a test for precisely the bug I\r
79 described above).\r
80 \r
81 I haven't added this to the repository yet since it needs a bunch of\r
82 work before being usable. Here are some things it needs:\r
83 \r
84   * Automated verification that tests are working, (currently I'm just\r
85     manually verifying that the results are as expected---obviously\r
86     that's not practical in the long term).\r
87 \r
88   * Modularization so that each test can be maintained as a small,\r
89     independent snippet.\r
90 \r
91   * The ability to run an individual test in isolation without running\r
92     the whole suite.\r
93 \r
94   * A fix in notmuch to get rid of the stupid sleep calls that are\r
95     slowing down the current notmuch-test. (One approach would be to\r
96     stop using mtime altogether. That might slow things down\r
97     unacceptably in general use, but might be just fine for the test\r
98     suite where the mail store can generally be quite tiny. Another\r
99     approach would be to use a filesystem like ext4 with sub-second\r
100     mtime support).\r
101 \r
102 Anyway, just wanted to share some thoughts and some preliminary code for\r
103 a notmuch test suite.\r
104 \r
105 -Carl\r
106 \r
107 \r
108 --==-=-=\r
109 Content-Type: application/pgp-signature\r
110 \r
111 -----BEGIN PGP SIGNATURE-----\r
112 Version: GnuPG v1.4.10 (GNU/Linux)\r
113 \r
114 iD8DBQFLShRR6JDdNq8qSWgRAsb/AJ98eYj50/tLpFvEeusQp64uPRws+wCfThoc\r
115 4IUXgxTd86itranVdy3iazU=\r
116 =O/dO\r
117 -----END PGP SIGNATURE-----\r
118 --==-=-=--\r
119 \r
120 --=-=-=\r
121 Content-Disposition: inline; filename=notmuch-test\r
122 Content-Description: Lame prototype of a notmuch test suite\r
123 \r
124 #!/bin/sh\r
125 set -e\r
126 \r
127 find_notmuch_binary ()\r
128 {\r
129     dir=$1\r
130 \r
131     while [ -n "$dir" ]; do\r
132         bin=$dir/notmuch\r
133         if [ -x $bin ]; then\r
134             echo $bin\r
135             return\r
136         fi\r
137         dir=$(dirname $dir)\r
138         if [ "$dir" = "/" ]; then\r
139             break\r
140         fi\r
141     done\r
142 \r
143     echo notmuch\r
144 }\r
145 \r
146 # Generate a new message in the mail directory, with\r
147 # a unique message ID and subject.\r
148 #\r
149 # The filename of the message generated is available as\r
150 # $gen_msg_filename\r
151 gen_msg_cnt=0\r
152 gen_msg_filename=""\r
153 generate_message ()\r
154 {\r
155     gen_msg_cnt=$((gen_msg_cnt + 1))\r
156     gen_msg_name=msg-$(printf "%03d" $gen_msg_cnt)\r
157 \r
158     if [ "$#" = "0" ]; then\r
159         gen_msg_filename="${MAIL_DIR}/$gen_msg_name"\r
160     else\r
161         gen_msg_filename="${MAIL_DIR}/$1/$gen_msg_name"\r
162         mkdir -p $(dirname $gen_msg_filename)\r
163     fi\r
164 \r
165 cat <<EOF >$gen_msg_filename\r
166 From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
167 To: Notmuch Test Suite <test_suite@notmuchmail.org>\r
168 Message-Id: <msg-${gen_msg_cnt}@notmuch-test-suite>\r
169 Subject: Test message ${gen_msg_filename}\r
170 Date: Tue, 05 Jan 2010 15:43:57 -0800\r
171 \r
172 This is just a test message at ${gen_msg_filename}\r
173 EOF\r
174 }\r
175 \r
176 do_sleep ()\r
177 {\r
178     sleep 1\r
179 }\r
180 \r
181 TEST_DIR=$(pwd)/test.$$\r
182 MAIL_DIR=${TEST_DIR}/mail\r
183 export NOTMUCH_CONFIG=${TEST_DIR}/notmuch-config\r
184 NOTMUCH=$(find_notmuch_binary $(pwd))\r
185 \r
186 rm -rf ${TEST_DIR}\r
187 mkdir ${TEST_DIR}\r
188 cd ${TEST_DIR}\r
189 \r
190 mkdir ${MAIL_DIR}\r
191 \r
192 cat <<EOF > ${NOTMUCH_CONFIG}\r
193 [database]\r
194 path=${MAIL_DIR}\r
195 \r
196 [user]\r
197 name=Notmuch Test Suite\r
198 primary_email=test_suite@notmuchmail.org\r
199 EOF\r
200 \r
201 echo "### Testing \"notmuch new\" with no messages"\r
202 $NOTMUCH new\r
203 \r
204 echo "### Testing \"notmuch new\" with 1 new message"\r
205 do_sleep\r
206 generate_message\r
207 $NOTMUCH new\r
208 \r
209 echo "### Testing \"notmuch new\" with 2 new messages"\r
210 do_sleep\r
211 generate_message\r
212 generate_message\r
213 $NOTMUCH new\r
214 \r
215 echo "### Testing \"notmuch new\" with no new messages (and a non-empty database)"\r
216 \r
217 $NOTMUCH new\r
218 \r
219 echo "### Testing \"notmuch new\" with two new directories (one mail)"\r
220 rm -rf ${MAIL_DIR}/* ${MAIL_DIR}/.notmuch\r
221 mkdir ${MAIL_DIR}/def\r
222 mkdir ${MAIL_DIR}/ghi\r
223 generate_message def\r
224 \r
225 $NOTMUCH new\r
226 \r
227 echo "### Testing \"notmuch new\" with two new directories (one mail)---opposite inode order"\r
228 \r
229 rm -rf ${MAIL_DIR}/.notmuch\r
230 mv ${MAIL_DIR}/ghi ${MAIL_DIR}/abc\r
231 rm ${MAIL_DIR}/def/*\r
232 generate_message abc\r
233 \r
234 $NOTMUCH new\r
235 \r
236 echo "### Testing \"notmuch new\" with 1 old message moved into the mail store"\r
237 rm -rf ${MAIL_DIR}/* ${MAIL_DIR}/.notmuch\r
238 generate_message\r
239 tmp_msg_filename=tmp/$gen_msg_filename\r
240 mkdir -p $(dirname $tmp_msg_filename)\r
241 mv $gen_msg_filename $tmp_msg_filename\r
242 do_sleep\r
243 $NOTMUCH new > /dev/null\r
244 do_sleep\r
245 mv $tmp_msg_filename $gen_msg_filename\r
246 $NOTMUCH new\r
247 \r
248 echo "### Testing \"notmuch new\" with 1 renamed message"\r
249 \r
250 do_sleep\r
251 generate_message\r
252 $NOTMUCH new > /dev/null\r
253 do_sleep\r
254 mv $gen_msg_filename ${gen_msg_filename}-renamed\r
255 $NOTMUCH new\r
256 \r
257 echo "### Testing \"notmuch new\" with 1 deleted message"\r
258 \r
259 do_sleep\r
260 rm ${gen_msg_filename}-renamed\r
261 $NOTMUCH new\r
262 \r
263 echo "### Testing \"notmuch new\" with a new directory with 3 messages"\r
264 \r
265 do_sleep\r
266 generate_message dir\r
267 generate_message dir\r
268 generate_message dir\r
269 \r
270 $NOTMUCH new\r
271 \r
272 echo "### Testing \"notmuch new\" with a renamed directory of 3 messages"\r
273 \r
274 do_sleep\r
275 mv ${MAIL_DIR}/dir ${MAIL_DIR}/dir-renamed\r
276 \r
277 $NOTMUCH new\r
278 \r
279 echo "### Testing \"notmuch new\" with a deleted directory of 3 messages"\r
280 \r
281 do_sleep\r
282 rm -rf ${MAIL_DIR}/dir-renamed\r
283 \r
284 $NOTMUCH new\r
285 \r
286 echo "### Testing \"notmuch new\" with a new directory with 3 messages (tail of list)"\r
287 \r
288 do_sleep\r
289 generate_message zzz\r
290 generate_message zzz\r
291 generate_message zzz\r
292 \r
293 $NOTMUCH new\r
294 \r
295 echo "### Testing \"notmuch new\" with a deleted directory of 3 messages (tail of list)"\r
296 \r
297 do_sleep\r
298 rm -rf ${MAIL_DIR}/zzz\r
299 \r
300 $NOTMUCH new\r
301 \r
302 echo "### Testing \"notmuch new\" with a symlink to an external directory of 1 message"\r
303 \r
304 rm -rf ${MAIL_DIR}/.notmuch\r
305 mv ${MAIL_DIR} ${TEST_DIR}/actual_maildir\r
306 \r
307 mkdir ${MAIL_DIR}\r
308 ln -s ${TEST_DIR}/actual_maildir ${MAIL_DIR}/symlink\r
309 \r
310 $NOTMUCH new\r
311 \r
312 echo "### Testing \"notmuch new\" with a symlink to an external file"\r
313 do_sleep\r
314 generate_message\r
315 external_msg_filename=${TEST_DIR}/external/$(basename $gen_msg_filename)\r
316 mkdir -p $(dirname $external_msg_filename)\r
317 mv $gen_msg_filename $external_msg_filename\r
318 ln -s $external_msg_filename $gen_msg_filename\r
319 \r
320 $NOTMUCH new\r
321 \r
322 echo "### Testing \"notmuch new\" with a two-level directory with 3 files"\r
323 \r
324 do_sleep\r
325 generate_message two/levels\r
326 generate_message two/levels\r
327 generate_message two/levels\r
328 \r
329 $NOTMUCH new\r
330 \r
331 echo "### Testing \"notmuch new\" with deletion of two-level directory (3 files)"\r
332 \r
333 do_sleep\r
334 rm -rf ${MAIL_DIR}/two\r
335 \r
336 $NOTMUCH new\r
337 \r
338 cat <<EOF\r
339 Notmuch test suite complete.\r
340 \r
341 Intermediate state can be examined in:\r
342         ${TEST_DIR}\r
343 EOF\r
344 \r
345 --=-=-=--\r