unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob 9565f296457adec6a3e47bda596910736293ce5d 3925 bytes (raw)
name: test/T260-thread-order.sh 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
 
#!/usr/bin/env bash
test_description="threading when messages received out of order"
. $(dirname "$0")/test-lib.sh || exit 1

# Generate all single-root four message thread structures.  We'll use
# this for multiple tests below.
THREADS=$($NOTMUCH_PYTHON ${NOTMUCH_SRCDIR}/test/gen-threads.py 4)
nthreads=$(wc -l <<< "$THREADS")

test_begin_subtest "Messages with one parent get linked in all delivery orders"
# In the first variant, this delivers messages that reference only
# their immediate parent.  Hence, we should only expect threads to be
# fully joined at the end.
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 --sort=newest-first '*' | notmuch_search_sanitize)
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_begin_subtest "Messages with all parents get linked in all delivery orders"
# Here we do the same thing as the previous test, but each message
# references all of its parents.  Since every message references the
# root of the thread, each thread should always be fully joined.  This
# is currently broken because of the bug detailed in
# id:8738h7kv2q.fsf@qmul.ac.uk.
rm ${MAIL_DIR}/*
notmuch new > /dev/null
output=""
expected=""
for ((n = 0; n < 4; n++)); do
    # Deliver the n'th message of every thread
    thread=0
    while read -a parents; do
        references=""
        parent=${parents[$n]}
        while [[ ${parent:-None} != None ]]; do
            references="<m$parent@t$thread> $references"
            pp=$parent
            parent=${parents[$parent]}
            # Avoid looping over broken input (if ever)
            parents[$pp]="None"
        done

        generate_message \
            [id]=m$n@t$thread [references]="'$references'" \
            [subject]=p$thread [from]=m$n
        thread=$((thread + 1))
    done <<< "$THREADS"
    notmuch new > /dev/null

    output="$output
$(notmuch search --sort=newest-first '*' | notmuch_search_sanitize)"

    # Construct expected output
    template="thread:XXX   2001-01-05 [$((n+1))/$((n+1))]"
    for ((m = n; m > 0; m--)); do
        template="$template m$m,"
    done
    expected="$expected
$(for ((i = 0; i < $nthreads; i++)); do
        echo "$template m0; p$i (inbox unread)"
    done)"
done
test_expect_equal "$output" "$expected"

add_email_corpus threading

test_begin_subtest "reply to ghost"
notmuch show --entire-thread=true id:000-real-root@example.org | grep ^Subject: | head -1  > OUTPUT
cat <<EOF > EXPECTED
Subject: root message
EOF
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "reply to ghost (tree view)"
test_subtest_known_broken
test_emacs '(notmuch-tree "tag:inbox")
	    (notmuch-test-wait)
	    (test-output)
	    (delete-other-windows)'
cat <<EOF > EXPECTED
  2016-06-17  Alice                 ┬►root message                                        (inbox unread)
  2016-06-18  Alice                 ╰┬►child message                                      (inbox unread)
  2016-06-18  Alice                  ├┬►grand-child message                               (inbox unread)
  2016-06-18  Alice                  │╰─►great grand-child message                        (inbox unread)
  2016-06-18  Daniel                 ├─►grand-child message 2                             (inbox unread)
  2016-06-17  Mallory                ╰─►fake root message                                 (inbox unread)
End of search results.
EOF
test_expect_equal_file EXPECTED OUTPUT

test_done

debug log:

solving 9565f296 ...
found 9565f296 in https://yhetil.org/notmuch/20180720233746.2844-7-david@tethera.net/
found ce8636b9 in https://yhetil.org/notmuch/20180720233746.2844-4-david@tethera.net/
found fea61275 in https://yhetil.org/notmuch.git/
preparing index
index prepared:
100755 fea612757c41c4675dd3a95deaea6da7e2ef16a0	test/T260-thread-order.sh

applying [1/2] https://yhetil.org/notmuch/20180720233746.2844-4-david@tethera.net/
diff --git a/test/T260-thread-order.sh b/test/T260-thread-order.sh
index fea61275..ce8636b9 100755


applying [2/2] https://yhetil.org/notmuch/20180720233746.2844-7-david@tethera.net/
diff --git a/test/T260-thread-order.sh b/test/T260-thread-order.sh
index ce8636b9..9565f296 100755

Checking patch test/T260-thread-order.sh...
Applied patch test/T260-thread-order.sh cleanly.
Checking patch test/T260-thread-order.sh...
Applied patch test/T260-thread-order.sh cleanly.

index at:
100755 9565f296457adec6a3e47bda596910736293ce5d	test/T260-thread-order.sh

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

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).