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
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
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
41 Content-Type: multipart/signed; boundary="==-=-=";
\r
42 micalg=pgp-sha1; protocol="application/pgp-signature"
\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
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
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
63 For example, a recent bug I hit was:
\r
65 After moving an (old) existing file into the mail store,
\r
66 "notmuch new" won't pick it up.
\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
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
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
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
88 * Modularization so that each test can be maintained as a small,
\r
89 independent snippet.
\r
91 * The ability to run an individual test in isolation without running
\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
102 Anyway, just wanted to share some thoughts and some preliminary code for
\r
103 a notmuch test suite.
\r
109 Content-Type: application/pgp-signature
\r
111 -----BEGIN PGP SIGNATURE-----
\r
112 Version: GnuPG v1.4.10 (GNU/Linux)
\r
114 iD8DBQFLShRR6JDdNq8qSWgRAsb/AJ98eYj50/tLpFvEeusQp64uPRws+wCfThoc
\r
115 4IUXgxTd86itranVdy3iazU=
\r
117 -----END PGP SIGNATURE-----
\r
121 Content-Disposition: inline; filename=notmuch-test
\r
122 Content-Description: Lame prototype of a notmuch test suite
\r
127 find_notmuch_binary ()
\r
131 while [ -n "$dir" ]; do
\r
133 if [ -x $bin ]; then
\r
137 dir=$(dirname $dir)
\r
138 if [ "$dir" = "/" ]; then
\r
146 # Generate a new message in the mail directory, with
\r
147 # a unique message ID and subject.
\r
149 # The filename of the message generated is available as
\r
150 # $gen_msg_filename
\r
152 gen_msg_filename=""
\r
153 generate_message ()
\r
155 gen_msg_cnt=$((gen_msg_cnt + 1))
\r
156 gen_msg_name=msg-$(printf "%03d" $gen_msg_cnt)
\r
158 if [ "$#" = "0" ]; then
\r
159 gen_msg_filename="${MAIL_DIR}/$gen_msg_name"
\r
161 gen_msg_filename="${MAIL_DIR}/$1/$gen_msg_name"
\r
162 mkdir -p $(dirname $gen_msg_filename)
\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
172 This is just a test message at ${gen_msg_filename}
\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
192 cat <<EOF > ${NOTMUCH_CONFIG}
\r
197 name=Notmuch Test Suite
\r
198 primary_email=test_suite@notmuchmail.org
\r
201 echo "### Testing \"notmuch new\" with no messages"
\r
204 echo "### Testing \"notmuch new\" with 1 new message"
\r
209 echo "### Testing \"notmuch new\" with 2 new messages"
\r
215 echo "### Testing \"notmuch new\" with no new messages (and a non-empty database)"
\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
227 echo "### Testing \"notmuch new\" with two new directories (one mail)---opposite inode order"
\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
236 echo "### Testing \"notmuch new\" with 1 old message moved into the mail store"
\r
237 rm -rf ${MAIL_DIR}/* ${MAIL_DIR}/.notmuch
\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
243 $NOTMUCH new > /dev/null
\r
245 mv $tmp_msg_filename $gen_msg_filename
\r
248 echo "### Testing \"notmuch new\" with 1 renamed message"
\r
252 $NOTMUCH new > /dev/null
\r
254 mv $gen_msg_filename ${gen_msg_filename}-renamed
\r
257 echo "### Testing \"notmuch new\" with 1 deleted message"
\r
260 rm ${gen_msg_filename}-renamed
\r
263 echo "### Testing \"notmuch new\" with a new directory with 3 messages"
\r
266 generate_message dir
\r
267 generate_message dir
\r
268 generate_message dir
\r
272 echo "### Testing \"notmuch new\" with a renamed directory of 3 messages"
\r
275 mv ${MAIL_DIR}/dir ${MAIL_DIR}/dir-renamed
\r
279 echo "### Testing \"notmuch new\" with a deleted directory of 3 messages"
\r
282 rm -rf ${MAIL_DIR}/dir-renamed
\r
286 echo "### Testing \"notmuch new\" with a new directory with 3 messages (tail of list)"
\r
289 generate_message zzz
\r
290 generate_message zzz
\r
291 generate_message zzz
\r
295 echo "### Testing \"notmuch new\" with a deleted directory of 3 messages (tail of list)"
\r
298 rm -rf ${MAIL_DIR}/zzz
\r
302 echo "### Testing \"notmuch new\" with a symlink to an external directory of 1 message"
\r
304 rm -rf ${MAIL_DIR}/.notmuch
\r
305 mv ${MAIL_DIR} ${TEST_DIR}/actual_maildir
\r
308 ln -s ${TEST_DIR}/actual_maildir ${MAIL_DIR}/symlink
\r
312 echo "### Testing \"notmuch new\" with a symlink to an external file"
\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
322 echo "### Testing \"notmuch new\" with a two-level directory with 3 files"
\r
325 generate_message two/levels
\r
326 generate_message two/levels
\r
327 generate_message two/levels
\r
331 echo "### Testing \"notmuch new\" with deletion of two-level directory (3 files)"
\r
334 rm -rf ${MAIL_DIR}/two
\r
339 Notmuch test suite complete.
\r
341 Intermediate state can be examined in:
\r