[PATCH] test: add sanity tests for threading
[notmuch-archives.git] / e6 / 3757cc5e50d40aee713490d4b3e955b824444e
diff --git a/e6/3757cc5e50d40aee713490d4b3e955b824444e b/e6/3757cc5e50d40aee713490d4b3e955b824444e
new file mode 100644 (file)
index 0000000..2775fe1
--- /dev/null
@@ -0,0 +1,112 @@
+Return-Path: <bremner@tethera.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 8C5CA6DE00CB\r
+ for <notmuch@notmuchmail.org>; Sat, 19 Sep 2015 09:30:32 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.113\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.113 tagged_above=-999 required=5 tests=[AWL=0.113]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id gitF3RI1j43o for <notmuch@notmuchmail.org>;\r
+ Sat, 19 Sep 2015 09:30:31 -0700 (PDT)\r
+X-Greylist: delayed 2620 seconds by postgrey-1.35 at arlo;\r
+ Sat, 19 Sep 2015 09:30:30 PDT\r
+Received: from gitolite.debian.net (gitolite.debian.net [87.98.215.224])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id CB6DA6DE009A\r
+ for <notmuch@notmuchmail.org>; Sat, 19 Sep 2015 09:30:30 -0700 (PDT)\r
+Received: from remotemail by gitolite.debian.net with local (Exim 4.80)\r
+ (envelope-from <bremner@tethera.net>)\r
+ id 1ZdKL1-0002fw-EB; Sat, 19 Sep 2015 15:46:07 +0000\r
+Received: (nullmailer pid 25920 invoked by uid 1000); Sat, 19 Sep 2015\r
+ 15:45:48 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] test: add sanity tests for threading\r
+Date: Sat, 19 Sep 2015 12:45:42 -0300\r
+Message-Id: <1442677542-25879-1-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.5.1\r
+In-Reply-To:\r
+ <CAJhTkNh7_hXDLsAGyD7nwkXV4ca6ymkLtFG945USvfqK4ZJEdQ@mail.gmail.com>\r
+References:\r
+ <CAJhTkNh7_hXDLsAGyD7nwkXV4ca6ymkLtFG945USvfqK4ZJEdQ@mail.gmail.com>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 19 Sep 2015 16:30:32 -0000\r
+\r
+These tests are inspired by a problem report\r
+\r
+      id:CAJhTkNh7_hXDLsAGyD7nwkXV4ca6ymkLtFG945USvfqK4ZJEdQ@mail.gmail.com\r
+\r
+Of course I can't duplicate the mentioned problem, it probably depends\r
+on specific message data.\r
+---\r
+ test/T580-thread-search.sh | 42 ++++++++++++++++++++++++++++++++++++++++++\r
+ 1 file changed, 42 insertions(+)\r
+ create mode 100755 test/T580-thread-search.sh\r
+\r
+diff --git a/test/T580-thread-search.sh b/test/T580-thread-search.sh\r
+new file mode 100755\r
+index 0000000..6f7106d\r
+--- /dev/null\r
++++ b/test/T580-thread-search.sh\r
+@@ -0,0 +1,42 @@\r
++#!/usr/bin/env bash\r
++#\r
++# Copyright (c) 2015 David Bremner\r
++#\r
++\r
++test_description='test of searching by thread-id'\r
++\r
++. ./test-lib.sh || exit 1\r
++\r
++add_email_corpus\r
++\r
++test_begin_subtest "Every message is found in exactly one thread"\r
++\r
++count=0\r
++success=0\r
++for id in $(notmuch search --output=messages '*'); do\r
++    count=$((count +1))\r
++    matches=$(notmuch search --output=threads "$id" | wc -l)\r
++    if [ "$matches" = 1 ]; then\r
++      success=$((success + 1))\r
++    fi\r
++done\r
++\r
++test_expect_equal "$count" "$success"\r
++\r
++test_begin_subtest "roundtripping message-ids via thread-ids"\r
++\r
++count=0\r
++success=0\r
++for id in $(notmuch search --output=messages '*'); do\r
++    count=$((count +1))\r
++    thread=$(notmuch search --output=threads "$id")\r
++    matched=$(notmuch search --output=messages "$thread" | grep "$id")\r
++    if [ "$matched" = "$id" ]; then\r
++      success=$((success + 1))\r
++    fi\r
++done\r
++\r
++test_expect_equal "$count" "$success"\r
++\r
++\r
++test_done\r
+-- \r
+2.5.1\r
+\r