unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] test: Test thread linking in all possible delivery orders
@ 2014-03-23 21:00 Austin Clements
  2014-04-07 10:37 ` David Bremner
  0 siblings, 1 reply; 8+ messages in thread
From: Austin Clements @ 2014-03-23 21:00 UTC (permalink / raw)
  To: notmuch

This test delivers all possible (single-root) four-message threads in
all possible orders and checks that notmuch successfully links them
into threads in every case.

This is introduced as a new test (rather than just adding it to
T050-new) because it's much easier for this to start with an empty
database.
---

I thought I saw a bug in the thread linking code.  It turned out to be
okay, but I wrote this test to convince myself.

As far as I can tell, we don't have any tests specifically for thread
linking.  We certainly don't have any that are this systematic.

 test/T051-new-linking.sh | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100755 test/T051-new-linking.sh

diff --git a/test/T051-new-linking.sh b/test/T051-new-linking.sh
new file mode 100755
index 0000000..b6d778a
--- /dev/null
+++ b/test/T051-new-linking.sh
@@ -0,0 +1,43 @@
+#!/usr/bin/env bash
+test_description='"notmuch new" thread linking'
+
+. ./test-lib.sh
+
+test_begin_subtest "All four-message threads get linked in all delivery orders"
+# Generate all possible single-root four message thread structures.
+# Each line in THREADS is a thread structure, where the n'th field is
+# the parent of message n.
+THREADS=$(python -c '
+def mkTrees(free, tree={}):
+    if not free:
+        print(" ".join(map(str, [msg[1] for msg in sorted(tree.items())])))
+        return
+    # Attach each free message to each message in the tree (if there is
+    # no tree, make the free message the root)
+    for msg in sorted(free):
+        parents = sorted(tree.keys()) if tree else ["none"]
+        for parent in parents:
+            ntree = tree.copy()
+            ntree[msg] = parent
+            mkTrees(free - set([msg]), ntree)
+mkTrees(set(range(4)))')
+for ((n = 0; n < 4; n++)); do
+    # Deliver the n'th message of every thread
+    thread=0
+    while read -a parents; do
+        parent=${parents[$n]}
+        generate_message \
+            [id]=m$n@t$thread [in-reply-to]="\<m$parent@t$thread\>" \
+            [subject]=p$thread [from]=m$n
+        thread=$((thread + 1))
+    done <<< "$THREADS"
+    notmuch new > /dev/null
+done
+output=$(notmuch search '*' | notmuch_search_sanitize)
+nthreads=$(wc -l <<< "$THREADS")
+expected=$(for ((i = 0; i < $nthreads; i++)); do
+        echo "thread:XXX   2001-01-05 [4/4] m3, m2, m1, m0; p$i (inbox unread)"
+    done)
+test_expect_equal "$output" "$expected"
+
+test_done
-- 
1.8.4.rc3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-07-16 22:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-23 21:00 [PATCH] test: Test thread linking in all possible delivery orders Austin Clements
2014-04-07 10:37 ` David Bremner
2014-04-21 19:58   ` [PATCH v2] " Austin Clements
2014-04-22 21:31     ` Mark Walters
2014-04-22 22:11       ` Austin Clements
2014-07-09 21:15       ` [PATCH v3] " Austin Clements
2014-07-16 10:31         ` David Bremner
2014-07-16 22:35         ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).