Re: Flat search and threaded views
[notmuch-archives.git] / 35 / f7310bc3f822dc0240046fdbf214fc4231c16d
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 12E4A431FBF\r
6         for <notmuch@notmuchmail.org>; Tue, 22 Apr 2014 14:31:37 -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.502\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.502 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_LOW=-0.7] 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 lHBFgiZAz2me for <notmuch@notmuchmail.org>;\r
17         Tue, 22 Apr 2014 14:31:29 -0700 (PDT)\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 D816C431FBD\r
22         for <notmuch@notmuchmail.org>; Tue, 22 Apr 2014 14:31:28 -0700 (PDT)\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 1WciHf-0004dP-5D; Tue, 22 Apr 2014 22:31:23 +0100\r
27 Received: from 5751dfa2.skybroadband.com ([87.81.223.162] helo=localhost)\r
28         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)\r
29         (envelope-from <m.walters@qmul.ac.uk>)\r
30         id 1WciHe-000071-LC; Tue, 22 Apr 2014 22:31:18 +0100\r
31 From: Mark Walters <markwalters1009@gmail.com>\r
32 To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
33 Subject: Re: [PATCH v2] test: Test thread linking in all possible delivery\r
34         orders\r
35 In-Reply-To: <1398110291-15832-1-git-send-email-amdragon@mit.edu>\r
36 References: <87y4zhfmrn.fsf@maritornes.cs.unb.ca>\r
37         <1398110291-15832-1-git-send-email-amdragon@mit.edu>\r
38 User-Agent: Notmuch/0.15.2+615~g78e3a93 (http://notmuchmail.org) Emacs/23.4.1\r
39         (x86_64-pc-linux-gnu)\r
40 Date: Tue, 22 Apr 2014 22:31:10 +0100\r
41 Message-ID: <87wqehaw69.fsf@qmul.ac.uk>\r
42 MIME-Version: 1.0\r
43 Content-Type: text/plain; charset=us-ascii\r
44 X-Sender-Host-Address: 87.81.223.162\r
45 X-QM-Geographic: According to ripencc,\r
46         this message was delivered by a machine in Britain (UK) (GB).\r
47 X-QM-SPAM-Info: Sender has good ham record.  :)\r
48 X-QM-Body-MD5: 5eb0dfbe17deb5b67783cb2efcf93ff8 (of first 20000 bytes)\r
49 X-SpamAssassin-Score: -0.1\r
50 X-SpamAssassin-SpamBar: /\r
51 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
52         determine if it is\r
53         spam. We require at least 5.0 points to mark a message as spam.\r
54         This message scored -0.1 points.\r
55         Summary of the scoring: \r
56         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
57         provider *      (markwalters1009[at]gmail.com)\r
58         * -0.1 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: Tue, 22 Apr 2014 21:31:37 -0000\r
73 \r
74 \r
75 Hi\r
76 \r
77 Broadly this looks good but I am somewhat confused by the python\r
78 part. Is it intended to produce the same tree multiple times? It does\r
79 seem to produce all the possible trees (*) so it doesn't matter but\r
80 might be worth a comment.\r
81 \r
82 Best wishes\r
83 \r
84 Mark\r
85 \r
86 (*) I think there should be 64 rooted trees (16 trees and 4 possible\r
87 roots) and the python generates 144 lines. Piping the output to sort and\r
88 uniq gives 64 lines.\r
89 \r
90 \r
91  \r
92 On Mon, 21 Apr 2014, Austin Clements <amdragon@MIT.EDU> wrote:\r
93 > These tests deliver all possible (single-root) four-message threads in\r
94 > all possible orders and check that notmuch successfully links them\r
95 > into threads.\r
96 >\r
97 > There are two variants of the test: one delivers messages that\r
98 > reference only their immediate parent and the other delivers messages\r
99 > that reference all of their parents.  The latter test is currently\r
100 > known-broken.\r
101 >\r
102 > This is introduced as a new test (rather than just adding it to\r
103 > T050-new) because it's much easier for this to start with an empty\r
104 > database.\r
105 > ---\r
106 >\r
107 > This version hopefully addresses David's comments in\r
108 > id:87y4zhfmrn.fsf@maritornes.cs.unb.ca and adds a second test that\r
109 > demonstrates the bug Mark in figured out in\r
110 > id:8738h7kv2q.fsf@qmul.ac.uk.\r
111 >\r
112 > test/T051-new-linking.sh | 91 ++++++++++++++++++++++++++++++++++++++++++++++++\r
113 >  1 file changed, 91 insertions(+)\r
114 >  create mode 100755 test/T051-new-linking.sh\r
115 >\r
116 > diff --git a/test/T051-new-linking.sh b/test/T051-new-linking.sh\r
117 > new file mode 100755\r
118 > index 0000000..9ccbc52\r
119 > --- /dev/null\r
120 > +++ b/test/T051-new-linking.sh\r
121 > @@ -0,0 +1,91 @@\r
122 > +#!/usr/bin/env bash\r
123 > +test_description='"notmuch new" thread linking'\r
124 > +\r
125 > +. ./test-lib.sh\r
126 > +\r
127 > +# Generate all possible single-root four message thread structures.\r
128 > +# Each line in THREADS is a thread structure, where the n'th field is\r
129 > +# the parent of message n.  We'll use this for multiple tests below.\r
130 > +THREADS=$(python -c '\r
131 > +def mkTrees(free, tree={}):\r
132 > +    if free == set():\r
133 > +        print(" ".join(map(str, [msg[1] for msg in sorted(tree.items())])))\r
134 > +        return\r
135 > +    # Attach each free message to each message in the tree (if there is\r
136 > +    # no tree, make the free message the root), backtracking after each\r
137 > +    for msg in sorted(free):\r
138 > +        parents = sorted(tree.keys()) if tree else ["none"]\r
139 > +        for parent in parents:\r
140 > +            ntree = tree.copy()\r
141 > +            ntree[msg] = parent\r
142 > +            mkTrees(free - set([msg]), ntree)\r
143 > +mkTrees(set(range(4)))')\r
144 > +nthreads=$(wc -l <<< "$THREADS")\r
145 > +\r
146 > +test_begin_subtest "All four-message threads get linked in all delivery orders (one parent)"\r
147 > +# In the first variant, this delivers messages that reference only\r
148 > +# their immediate parent.  Hence, we should only expect threads to be\r
149 > +# fully joined at the end.\r
150 > +for ((n = 0; n < 4; n++)); do\r
151 > +    # Deliver the n'th message of every thread\r
152 > +    thread=0\r
153 > +    while read -a parents; do\r
154 > +        parent=${parents[$n]}\r
155 > +        generate_message \\r
156 > +            [id]=m$n@t$thread [in-reply-to]="\<m$parent@t$thread\>" \\r
157 > +            [subject]=p$thread [from]=m$n\r
158 > +        thread=$((thread + 1))\r
159 > +    done <<< "$THREADS"\r
160 > +    notmuch new > /dev/null\r
161 > +done\r
162 > +output=$(notmuch search --sort=newest-first '*' | notmuch_search_sanitize)\r
163 > +expected=$(for ((i = 0; i < $nthreads; i++)); do\r
164 > +        echo "thread:XXX   2001-01-05 [4/4] m3, m2, m1, m0; p$i (inbox unread)"\r
165 > +    done)\r
166 > +test_expect_equal "$output" "$expected"\r
167 > +\r
168 > +test_begin_subtest "The same (full parent linkage)"\r
169 > +test_subtest_known_broken\r
170 > +# Here we do the same thing as the previous test, but each message\r
171 > +# references all of its parents.  Since every message references the\r
172 > +# root of the thread, each thread should always be fully joined.  This\r
173 > +# is currently broken because of the bug detailed in\r
174 > +# id:8738h7kv2q.fsf@qmul.ac.uk.\r
175 > +rm ${MAIL_DIR}/*\r
176 > +notmuch new\r
177 > +output=""\r
178 > +expected=""\r
179 > +for ((n = 0; n < 4; n++)); do\r
180 > +    # Deliver the n'th message of every thread\r
181 > +    thread=0\r
182 > +    while read -a parents; do\r
183 > +        references=""\r
184 > +        parent=${parents[$n]}\r
185 > +        while [[ $parent != none ]]; do\r
186 > +            references="<m$parent@t$thread> $references"\r
187 > +            parent=${parents[$parent]}\r
188 > +        done\r
189 > +\r
190 > +        generate_message \\r
191 > +            [id]=m$n@t$thread [references]="'$references'" \\r
192 > +            [subject]=p$thread [from]=m$n\r
193 > +        thread=$((thread + 1))\r
194 > +    done <<< "$THREADS"\r
195 > +    notmuch new > /dev/null\r
196 > +\r
197 > +    output="$output\r
198 > +$(notmuch search --sort=newest-first '*' | notmuch_search_sanitize)"\r
199 > +\r
200 > +    # Construct expected output\r
201 > +    template="thread:XXX   2001-01-05 [$((n+1))/$((n+1))]"\r
202 > +    for ((m = n; m > 0; m--)); do\r
203 > +        template="$template m$m,"\r
204 > +    done\r
205 > +    expected="$expected\r
206 > +$(for ((i = 0; i < $nthreads; i++)); do\r
207 > +        echo "$template m0; p$i (inbox unread)"\r
208 > +    done)"\r
209 > +done\r
210 > +test_expect_equal "$output" "$expected"\r
211 > +\r
212 > +test_done\r
213 > -- \r
214 > 1.9.1\r