2 test_description="threading when messages received out of order"
5 # Generate all single-root four message thread structures. We'll use
6 # this for multiple tests below.
7 THREADS=$(python ${TEST_DIRECTORY}/gen-threads.py 4)
8 nthreads=$(wc -l <<< "$THREADS")
10 test_begin_subtest "Messages with one parent get linked in all delivery orders"
11 # In the first variant, this delivers messages that reference only
12 # their immediate parent. Hence, we should only expect threads to be
13 # fully joined at the end.
14 for ((n = 0; n < 4; n++)); do
15 # Deliver the n'th message of every thread
17 while read -a parents; do
20 [id]=m$n@t$thread [in-reply-to]="\<m$parent@t$thread\>" \
21 [subject]=p$thread [from]=m$n
22 thread=$((thread + 1))
24 notmuch new > /dev/null
26 output=$(notmuch search --sort=newest-first '*' | notmuch_search_sanitize)
27 expected=$(for ((i = 0; i < $nthreads; i++)); do
28 echo "thread:XXX 2001-01-05 [4/4] m3, m2, m1, m0; p$i (inbox unread)"
30 test_expect_equal "$output" "$expected"
32 test_begin_subtest "Messages with all parents get linked in all delivery orders"
33 test_subtest_known_broken
34 # Here we do the same thing as the previous test, but each message
35 # references all of its parents. Since every message references the
36 # root of the thread, each thread should always be fully joined. This
37 # is currently broken because of the bug detailed in
38 # id:8738h7kv2q.fsf@qmul.ac.uk.
40 notmuch new > /dev/null
43 for ((n = 0; n < 4; n++)); do
44 # Deliver the n'th message of every thread
46 while read -a parents; do
49 while [[ $parent != None ]]; do
50 references="<m$parent@t$thread> $references"
51 parent=${parents[$parent]}
55 [id]=m$n@t$thread [references]="'$references'" \
56 [subject]=p$thread [from]=m$n
57 thread=$((thread + 1))
59 notmuch new > /dev/null
62 $(notmuch search --sort=newest-first '*' | notmuch_search_sanitize)"
64 # Construct expected output
65 template="thread:XXX 2001-01-05 [$((n+1))/$((n+1))]"
66 for ((m = n; m > 0; m--)); do
67 template="$template m$m,"
70 $(for ((i = 0; i < $nthreads; i++)); do
71 echo "$template m0; p$i (inbox unread)"
74 test_expect_equal "$output" "$expected"