Re: [PATCH 9/9] add has: query prefix to search for specific properties
[notmuch-archives.git] / 42 / 009ed64c3708bed51d59298334426113c7c94c
1 Return-Path: <amdragon@mit.edu>\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 16FC2431FBF\r
6         for <notmuch@notmuchmail.org>; Tue, 22 Apr 2014 15:11:28 -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: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\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 aNtJlpsaqTVU for <notmuch@notmuchmail.org>;\r
16         Tue, 22 Apr 2014 15:11:20 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-7.mit.edu (dmz-mailsec-scanner-7.mit.edu\r
18         [18.7.68.36])\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 7BAF5431FBD\r
22         for <notmuch@notmuchmail.org>; Tue, 22 Apr 2014 15:11:20 -0700 (PDT)\r
23 X-AuditID: 12074424-f79e26d000000c70-85-5356e90777b0\r
24 Received: from mailhub-auth-3.mit.edu ( [18.9.21.43])\r
25         (using TLS with cipher AES256-SHA (256/256 bits))\r
26         (Client did not present a certificate)\r
27         by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP\r
28         id E7.DA.03184.709E6535; Tue, 22 Apr 2014 18:11:19 -0400 (EDT)\r
29 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
30         by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id s3MMBHKP024357; \r
31         Tue, 22 Apr 2014 18:11:18 -0400\r
32 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
33         (authenticated bits=0)\r
34         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
35         by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s3MMBFnZ001951\r
36         (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
37         Tue, 22 Apr 2014 18:11:16 -0400\r
38 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
39         (envelope-from <amdragon@mit.edu>)\r
40         id 1WciuJ-0003bH-9t; Tue, 22 Apr 2014 18:11:15 -0400\r
41 Date: Tue, 22 Apr 2014 18:11:15 -0400\r
42 From: Austin Clements <amdragon@MIT.EDU>\r
43 To: Mark Walters <markwalters1009@gmail.com>\r
44 Subject: Re: [PATCH v2] test: Test thread linking in all possible delivery\r
45         orders\r
46 Message-ID: <20140422221115.GH25817@mit.edu>\r
47 References: <87y4zhfmrn.fsf@maritornes.cs.unb.ca>\r
48         <1398110291-15832-1-git-send-email-amdragon@mit.edu>\r
49         <87wqehaw69.fsf@qmul.ac.uk>\r
50 MIME-Version: 1.0\r
51 Content-Type: text/plain; charset=us-ascii\r
52 Content-Disposition: inline\r
53 In-Reply-To: <87wqehaw69.fsf@qmul.ac.uk>\r
54 User-Agent: Mutt/1.5.21 (2010-09-15)\r
55 X-Brightmail-Tracker:\r
56  H4sIAAAAAAAAA+NgFupmleLIzCtJLcpLzFFi42IR4hTV1mV/GRZs8HKxmsWN1m5Gi9VzeSyu\r
57         35zJ7MDssXPWXXaPZ6tuMXtsOfSeOYA5issmJTUnsyy1SN8ugSvj5+L0grk6FW+PXmBrYJyl\r
58         2MXIySEhYCLx4tJdRghbTOLCvfVsXYxcHEICs5kkNh7/zArhbGSUOPX7ATuEc5pJYt2OLVDO\r
59         EkaJlRd2AfVwcLAIqEqcehUOMopNQENi2/7lYGNFBHQkbh9awA5iMwvoSbTPesYEUi4sECwx\r
60         54kUSJgXqOTp7UaoZW2MEn09PYwQCUGJkzOfsED0aknc+PcSrJdZQFpi+T8OkDAn0Kp9n9Yw\r
61         g9iiAioSU05uY5vAKDQLSfcsJN2zELoXMDKvYpRNya3SzU3MzClOTdYtTk7My0st0jXXy80s\r
62         0UtNKd3ECApzdheVHYzNh5QOMQpwMCrx8BauDAsWYk0sK67MPcQoycGkJMrr+wAoxJeUn1KZ\r
63         kVicEV9UmpNafIhRgoNZSYRXejVQjjclsbIqtSgfJiXNwaIkzvvW2ipYSCA9sSQ1OzW1ILUI\r
64         JivDwaEkwZv6AqhRsCg1PbUiLTOnBCHNxMEJMpwHaLg2SA1vcUFibnFmOkT+FKOilDhvNUhC\r
65         ACSRUZoH1wtLQ68YxYFeEeZNBqniAaYwuO5XQIOZgAY/2RICMrgkESEl1cCYENp+aP4nzTvr\r
66         vBmFqxlNztxeFioU03Fr29qt0y8w/ct4EmLufmq3kF365IDr702jFbLrMlK3Bmop/ur/l+HA\r
67         emrfzjUlW1QnHXdckvTnQttNsWnLTq68bGb6R/xzzyGnT2nn/3ZFFDPeFMpSmhJ/Ja9Cd+YV\r
68         +fCuz3dPf3BtDbpR+GjCtcR+JZbijERDLeai4kQAIAMk8B4DAAA=\r
69 Cc: notmuch@notmuchmail.org\r
70 X-BeenThere: notmuch@notmuchmail.org\r
71 X-Mailman-Version: 2.1.13\r
72 Precedence: list\r
73 List-Id: "Use and development of the notmuch mail system."\r
74         <notmuch.notmuchmail.org>\r
75 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
76         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
77 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
78 List-Post: <mailto:notmuch@notmuchmail.org>\r
79 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
80 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
81         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
82 X-List-Received-Date: Tue, 22 Apr 2014 22:11:28 -0000\r
83 \r
84 The intent was to produce distinct trees, but obviously combinatorics\r
85 is not my strong suit.  Any ideas how to fix/rewrite the algorithm,\r
86 other than just uniq'ing the output?\r
87 \r
88 Quoth Mark Walters on Apr 22 at 10:31 pm:\r
89\r
90 > Hi\r
91\r
92 > Broadly this looks good but I am somewhat confused by the python\r
93 > part. Is it intended to produce the same tree multiple times? It does\r
94 > seem to produce all the possible trees (*) so it doesn't matter but\r
95 > might be worth a comment.\r
96\r
97 > Best wishes\r
98\r
99 > Mark\r
100\r
101 > (*) I think there should be 64 rooted trees (16 trees and 4 possible\r
102 > roots) and the python generates 144 lines. Piping the output to sort and\r
103 > uniq gives 64 lines.\r
104\r
105\r
106 >  \r
107 > On Mon, 21 Apr 2014, Austin Clements <amdragon@MIT.EDU> wrote:\r
108 > > These tests deliver all possible (single-root) four-message threads in\r
109 > > all possible orders and check that notmuch successfully links them\r
110 > > into threads.\r
111 > >\r
112 > > There are two variants of the test: one delivers messages that\r
113 > > reference only their immediate parent and the other delivers messages\r
114 > > that reference all of their parents.  The latter test is currently\r
115 > > known-broken.\r
116 > >\r
117 > > This is introduced as a new test (rather than just adding it to\r
118 > > T050-new) because it's much easier for this to start with an empty\r
119 > > database.\r
120 > > ---\r
121 > >\r
122 > > This version hopefully addresses David's comments in\r
123 > > id:87y4zhfmrn.fsf@maritornes.cs.unb.ca and adds a second test that\r
124 > > demonstrates the bug Mark in figured out in\r
125 > > id:8738h7kv2q.fsf@qmul.ac.uk.\r
126 > >\r
127 > > test/T051-new-linking.sh | 91 ++++++++++++++++++++++++++++++++++++++++++++++++\r
128 > >  1 file changed, 91 insertions(+)\r
129 > >  create mode 100755 test/T051-new-linking.sh\r
130 > >\r
131 > > diff --git a/test/T051-new-linking.sh b/test/T051-new-linking.sh\r
132 > > new file mode 100755\r
133 > > index 0000000..9ccbc52\r
134 > > --- /dev/null\r
135 > > +++ b/test/T051-new-linking.sh\r
136 > > @@ -0,0 +1,91 @@\r
137 > > +#!/usr/bin/env bash\r
138 > > +test_description='"notmuch new" thread linking'\r
139 > > +\r
140 > > +. ./test-lib.sh\r
141 > > +\r
142 > > +# Generate all possible single-root four message thread structures.\r
143 > > +# Each line in THREADS is a thread structure, where the n'th field is\r
144 > > +# the parent of message n.  We'll use this for multiple tests below.\r
145 > > +THREADS=$(python -c '\r
146 > > +def mkTrees(free, tree={}):\r
147 > > +    if free == set():\r
148 > > +        print(" ".join(map(str, [msg[1] for msg in sorted(tree.items())])))\r
149 > > +        return\r
150 > > +    # Attach each free message to each message in the tree (if there is\r
151 > > +    # no tree, make the free message the root), backtracking after each\r
152 > > +    for msg in sorted(free):\r
153 > > +        parents = sorted(tree.keys()) if tree else ["none"]\r
154 > > +        for parent in parents:\r
155 > > +            ntree = tree.copy()\r
156 > > +            ntree[msg] = parent\r
157 > > +            mkTrees(free - set([msg]), ntree)\r
158 > > +mkTrees(set(range(4)))')\r
159 > > +nthreads=$(wc -l <<< "$THREADS")\r
160 > > +\r
161 > > +test_begin_subtest "All four-message threads get linked in all delivery orders (one parent)"\r
162 > > +# In the first variant, this delivers messages that reference only\r
163 > > +# their immediate parent.  Hence, we should only expect threads to be\r
164 > > +# fully joined at the end.\r
165 > > +for ((n = 0; n < 4; n++)); do\r
166 > > +    # Deliver the n'th message of every thread\r
167 > > +    thread=0\r
168 > > +    while read -a parents; do\r
169 > > +        parent=${parents[$n]}\r
170 > > +        generate_message \\r
171 > > +            [id]=m$n@t$thread [in-reply-to]="\<m$parent@t$thread\>" \\r
172 > > +            [subject]=p$thread [from]=m$n\r
173 > > +        thread=$((thread + 1))\r
174 > > +    done <<< "$THREADS"\r
175 > > +    notmuch new > /dev/null\r
176 > > +done\r
177 > > +output=$(notmuch search --sort=newest-first '*' | notmuch_search_sanitize)\r
178 > > +expected=$(for ((i = 0; i < $nthreads; i++)); do\r
179 > > +        echo "thread:XXX   2001-01-05 [4/4] m3, m2, m1, m0; p$i (inbox unread)"\r
180 > > +    done)\r
181 > > +test_expect_equal "$output" "$expected"\r
182 > > +\r
183 > > +test_begin_subtest "The same (full parent linkage)"\r
184 > > +test_subtest_known_broken\r
185 > > +# Here we do the same thing as the previous test, but each message\r
186 > > +# references all of its parents.  Since every message references the\r
187 > > +# root of the thread, each thread should always be fully joined.  This\r
188 > > +# is currently broken because of the bug detailed in\r
189 > > +# id:8738h7kv2q.fsf@qmul.ac.uk.\r
190 > > +rm ${MAIL_DIR}/*\r
191 > > +notmuch new\r
192 > > +output=""\r
193 > > +expected=""\r
194 > > +for ((n = 0; n < 4; n++)); do\r
195 > > +    # Deliver the n'th message of every thread\r
196 > > +    thread=0\r
197 > > +    while read -a parents; do\r
198 > > +        references=""\r
199 > > +        parent=${parents[$n]}\r
200 > > +        while [[ $parent != none ]]; do\r
201 > > +            references="<m$parent@t$thread> $references"\r
202 > > +            parent=${parents[$parent]}\r
203 > > +        done\r
204 > > +\r
205 > > +        generate_message \\r
206 > > +            [id]=m$n@t$thread [references]="'$references'" \\r
207 > > +            [subject]=p$thread [from]=m$n\r
208 > > +        thread=$((thread + 1))\r
209 > > +    done <<< "$THREADS"\r
210 > > +    notmuch new > /dev/null\r
211 > > +\r
212 > > +    output="$output\r
213 > > +$(notmuch search --sort=newest-first '*' | notmuch_search_sanitize)"\r
214 > > +\r
215 > > +    # Construct expected output\r
216 > > +    template="thread:XXX   2001-01-05 [$((n+1))/$((n+1))]"\r
217 > > +    for ((m = n; m > 0; m--)); do\r
218 > > +        template="$template m$m,"\r
219 > > +    done\r
220 > > +    expected="$expected\r
221 > > +$(for ((i = 0; i < $nthreads; i++)); do\r
222 > > +        echo "$template m0; p$i (inbox unread)"\r
223 > > +    done)"\r
224 > > +done\r
225 > > +test_expect_equal "$output" "$expected"\r
226 > > +\r
227 > > +test_done\r