#!/usr/bin/env bash # # Copyright (c) 2016 Daniel Kahn Gillmor # test_description='thread breakage by reindexing (currently broken)' . ./test-lib.sh || exit 1 message_a() { mkdir -p ${MAIL_DIR}/cur cat > ${MAIL_DIR}/cur/a < From: Alice To: Bob Date: Thu, 31 Mar 2016 20:10:00 -0400 This is the first message in the thread. EOF } message_b() { mkdir -p ${MAIL_DIR}/cur cat > ${MAIL_DIR}/cur/b < In-Reply-To: References: From: Bob To: Alice Date: Thu, 31 Mar 2016 20:15:00 -0400 This is the second message in the thread. EOF } test_thread_count() { notmuch new >/dev/null test_begin_subtest "${2:-Expecting $1 thread(s)}" count=$(notmuch count --output=threads) test_expect_equal "$count" "$1" } test_thread_count 0 'There should be no threads initially' message_a test_thread_count 1 'One message in: one thread' message_b test_thread_count 1 'Second message in the same thread: one thread' rm -f ${MAIL_DIR}/cur/a test_thread_count 1 'First message removed: still only one thread' message_a # this is known to fail (it shows 2 threads) because no "ghost # message" was created for message A when it was removed from the # index, despite message B still pointing to it. test_begin_subtest 'First message reappears: should return to the same thread' test_subtest_known_broken notmuch new >/dev/null count=$(notmuch count --output=threads) test_expect_equal "$count" "1" test_done