Re: A systematic way of handling Xapian lock errors?
[notmuch-archives.git] / 50 / 3f3bd1ae2710c0803ba9b780a58b189d001c78
1 Return-Path: <m.walters@qmul.ac.uk>\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 68E41431FAF\r
6         for <notmuch@notmuchmail.org>; Sun, 25 Nov 2012 08:23:17 -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: -1.098\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
12         tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
13         NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\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 ekTaWAYFtEAn for <notmuch@notmuchmail.org>;\r
17         Sun, 25 Nov 2012 08:23:16 -0800 (PST)\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 743D4431FAE\r
22         for <notmuch@notmuchmail.org>; Sun, 25 Nov 2012 08:23:16 -0800 (PST)\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
24         by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
25         (envelope-from <m.walters@qmul.ac.uk>)\r
26         id 1TcezC-0007X7-Ty; Sun, 25 Nov 2012 16:23:15 +0000\r
27 Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost)\r
28         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
29         (envelope-from <m.walters@qmul.ac.uk>)\r
30         id 1TcezC-0001cU-G7; Sun, 25 Nov 2012 16:23:14 +0000\r
31 From: Mark Walters <markwalters1009@gmail.com>\r
32 To: Peter Wang <novalazy@gmail.com>, notmuch@notmuchmail.org\r
33 Subject: Re: [PATCH v2 18/20] test: add tests for insert\r
34 In-Reply-To: <1353806206-29133-19-git-send-email-novalazy@gmail.com>\r
35 References: <1353806206-29133-1-git-send-email-novalazy@gmail.com>\r
36         <1353806206-29133-19-git-send-email-novalazy@gmail.com>\r
37 User-Agent: Notmuch/0.14+81~g9730584 (http://notmuchmail.org) Emacs/23.4.1\r
38         (x86_64-pc-linux-gnu)\r
39 Date: Sun, 25 Nov 2012 16:23:17 +0000\r
40 Message-ID: <87zk25ird6.fsf@qmul.ac.uk>\r
41 MIME-Version: 1.0\r
42 Content-Type: text/plain; charset=us-ascii\r
43 X-Sender-Host-Address: 93.97.24.31\r
44 X-QM-SPAM-Info: Sender has good ham record.  :)\r
45 X-QM-Body-MD5: b6bd8c379cb97ab08c491760b11ceac9 (of first 20000 bytes)\r
46 X-SpamAssassin-Score: -1.8\r
47 X-SpamAssassin-SpamBar: -\r
48 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
49         determine if it is\r
50         spam. We require at least 5.0 points to mark a message as spam.\r
51         This message scored -1.8 points.\r
52         Summary of the scoring: \r
53         * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
54         *      medium trust\r
55         *      [138.37.6.40 listed in list.dnswl.org]\r
56         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
57         provider *      (markwalters1009[at]gmail.com)\r
58         *  0.5 AWL AWL: From: address is in the auto white-list\r
59 X-QM-Scan-Virus: ClamAV says the message is clean\r
60 X-BeenThere: notmuch@notmuchmail.org\r
61 X-Mailman-Version: 2.1.13\r
62 Precedence: list\r
63 List-Id: "Use and development of the notmuch mail system."\r
64         <notmuch.notmuchmail.org>\r
65 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
66         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
67 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
68 List-Post: <mailto:notmuch@notmuchmail.org>\r
69 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
70 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
72 X-List-Received-Date: Sun, 25 Nov 2012 16:23:17 -0000\r
73 \r
74 On Sun, 25 Nov 2012, Peter Wang <novalazy@gmail.com> wrote:\r
75 > Add tests for new 'insert' command.\r
76 > ---\r
77 >  test/insert       | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++\r
78 >  test/notmuch-test |  1 +\r
79 >  2 files changed, 94 insertions(+)\r
80 >  create mode 100755 test/insert\r
81 >\r
82 > diff --git a/test/insert b/test/insert\r
83 > new file mode 100755\r
84 > index 0000000..d821a41\r
85 > --- /dev/null\r
86 > +++ b/test/insert\r
87 > @@ -0,0 +1,93 @@\r
88 > +#!/usr/bin/env bash\r
89 > +test_description='"notmuch insert"'\r
90 > +. ./test-lib.sh\r
91 > +\r
92 > +# Create directories and database before inserting.\r
93 > +mkdir -p "$MAIL_DIR"/{cur,new,tmp}\r
94 > +mkdir -p "$MAIL_DIR"/Drafts/{cur,new,tmp}\r
95 > +notmuch new > /dev/null\r
96 > +\r
97 > +# We use generate_message to create the temporary message file.\r
98 > +# It happens to be in the mail directory already but that is okay.\r
99 \r
100 Perhaps add "since we do not call notmuch new".\r
101 \r
102 > +\r
103 > +test_begin_subtest "Insert message, default"\r
104 > +generate_message \\r
105 > +    "[subject]=\"insert-subject\"" \\r
106 > +    "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \\r
107 > +    "[body]=\"insert-message\""\r
108 > +notmuch insert < "$gen_msg_filename"\r
109 > +test_expect_equal "`notmuch count subject:insert-subject tag:unread`" "1"\r
110 \r
111 I would much prefer to test that we have the proper full message here\r
112 with something like notmuch show  or something. I would like\r
113 something that tests that the full message has actually been written to\r
114 disk.\r
115 \r
116 > +test_begin_subtest "Insert message, add tag"\r
117 > +generate_message \\r
118 > +    "[subject]=\"insert-subject-addtag\"" \\r
119 > +    "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \\r
120 > +    "[body]=\"insert-message-addtag\""\r
121 > +notmuch insert +custom < "$gen_msg_filename"\r
122 > +test_expect_equal "`notmuch count tag:custom`" "1"\r
123 > +\r
124 > +test_begin_subtest "Insert message, add/remove tag"\r
125 > +generate_message \\r
126 > +    "[subject]=\"insert-subject-addrmtag\"" \\r
127 > +    "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \\r
128 > +    "[body]=\"insert-message-addrmtag\""\r
129 > +notmuch insert +custom -unread < "$gen_msg_filename"\r
130 > +test_expect_equal "`notmuch count tag:custom NOT tag:unread`" "1"\r
131 > +\r
132 > +test_begin_subtest "Insert message, folder"\r
133 > +generate_message \\r
134 > +    "[subject]=\"insert-subject-draft\"" \\r
135 > +    "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \\r
136 > +    "[body]=\"insert-message-draft\""\r
137 > +notmuch insert --folder=Drafts < "$gen_msg_filename"\r
138 > +test_expect_equal "`notmuch count folder:Drafts`" "1"\r
139 > +\r
140 > +test_begin_subtest "Insert message, folder and tags"\r
141 > +generate_message \\r
142 > +    "[subject]=\"insert-subject-draft\"" \\r
143 > +    "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \\r
144 > +    "[body]=\"insert-message-draft\""\r
145 > +notmuch insert --folder=Drafts +draft -unread < "$gen_msg_filename"\r
146 > +test_expect_equal "`notmuch count folder:Drafts tag:draft NOT tag:unread`" "1"\r
147 > +\r
148 > +test_begin_subtest "Insert message, non-existent folder"\r
149 > +generate_message \\r
150 > +    "[subject]=\"insert-subject-nonexistfolder\"" \\r
151 > +    "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \\r
152 > +    "[body]=\"insert-message-nonexistfolder\""\r
153 > +notmuch insert --folder=nonesuch < "$gen_msg_filename"\r
154 > +test_expect_equal "$?" "1"\r
155 \r
156 Here and for other error cases you could check that the correct error\r
157 message is being returned.\r
158 \r
159 Best wishes\r
160 \r
161 Mark\r
162 > +\r
163 > +test_begin_subtest "Insert message, create folder"\r
164 > +generate_message \\r
165 > +    "[subject]=\"insert-subject-createfolder\"" \\r
166 > +    "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \\r
167 > +    "[body]=\"insert-message-createfolder\""\r
168 > +notmuch insert --folder=F --create-folder +folder < "$gen_msg_filename"\r
169 > +test_expect_equal "`notmuch count folder:F tag:folder`" "1"\r
170 > +\r
171 > +test_begin_subtest "Insert message, create subfolder"\r
172 > +generate_message \\r
173 > +    "[subject]=\"insert-subject-createfolder\"" \\r
174 > +    "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \\r
175 > +    "[body]=\"insert-message-createfolder\""\r
176 > +notmuch insert --folder=F/G/H/I/J --create-folder +folder < "$gen_msg_filename"\r
177 > +test_expect_equal "`notmuch count folder:F/G/H/I/J tag:folder`" "1"\r
178 > +\r
179 > +test_begin_subtest "Insert message, create existing subfolder"\r
180 > +generate_message \\r
181 > +    "[subject]=\"insert-subject-createfolder\"" \\r
182 > +    "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \\r
183 > +    "[body]=\"insert-message-createfolder\""\r
184 > +notmuch insert --folder=F/G/H/I/J --create-folder +folder < "$gen_msg_filename"\r
185 > +test_expect_equal "`notmuch count folder:F/G/H/I/J tag:folder`" "2"\r
186 > +\r
187 > +test_begin_subtest "Insert message, create invalid subfolder"\r
188 > +generate_message \\r
189 > +    "[subject]=\"insert-subject-createinvalidfolder\"" \\r
190 > +    "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" \\r
191 > +    "[body]=\"insert-message-createinvalidfolder\""\r
192 > +notmuch insert --folder=../G --create-folder < "$gen_msg_filename"\r
193 > +test_expect_equal "$?" "1"\r
194 > +\r
195 > +test_done\r
196 > diff --git a/test/notmuch-test b/test/notmuch-test\r
197 > index 9a1b375..09be44c 100755\r
198 > --- a/test/notmuch-test\r
199 > +++ b/test/notmuch-test\r
200 > @@ -22,6 +22,7 @@ TESTS="\r
201 >    config\r
202 >    new\r
203 >    count\r
204 > +  insert\r
205 >    search\r
206 >    search-output\r
207 >    search-by-folder\r
208 > -- \r
209 > 1.7.12.1\r
210 >\r
211 > _______________________________________________\r
212 > notmuch mailing list\r
213 > notmuch@notmuchmail.org\r
214 > http://notmuchmail.org/mailman/listinfo/notmuch\r