[PATCH] test:Folder tags shouldn't match after removal of file in given folder
authorMark Anderson <ma.skies@gmail.com>
Mon, 27 Jun 2011 17:12:24 +0000 (11:12 +1800)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:38:43 +0000 (09:38 -0800)
2d/b3ab379cf15c22685b0b8fd349fd100f59e534 [new file with mode: 0644]

diff --git a/2d/b3ab379cf15c22685b0b8fd349fd100f59e534 b/2d/b3ab379cf15c22685b0b8fd349fd100f59e534
new file mode 100644 (file)
index 0000000..bd962f5
--- /dev/null
@@ -0,0 +1,161 @@
+Return-Path: <ma.skies@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 0CC52431FD0\r
+       for <notmuch@notmuchmail.org>; Mon, 27 Jun 2011 10:12:28 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id isbJvWrSBj4a for <notmuch@notmuchmail.org>;\r
+       Mon, 27 Jun 2011 10:12:27 -0700 (PDT)\r
+Received: from mail-iw0-f181.google.com (mail-iw0-f181.google.com\r
+       [209.85.214.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 6289E431FB6\r
+       for <notmuch@notmuchmail.org>; Mon, 27 Jun 2011 10:12:27 -0700 (PDT)\r
+Received: by iwn37 with SMTP id 37so5064013iwn.26\r
+       for <notmuch@notmuchmail.org>; Mon, 27 Jun 2011 10:12:27 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+       h=domainkey-signature:from:to:subject:user-agent:date:message-id\r
+       :mime-version:content-type;\r
+       bh=IoF+uM1TyyoxE40SfXomxa3VEKR9LusiUE+VHr7NaKk=;\r
+       b=Ps+P6p/lu64DhNKClkjvNzk+5GaWeLtvqPlX2B3Owy8mBkLrmjmA/i3iCJUtKDP7Ru\r
+       jUsD6vkto8LsGXoGzZLpgwgPyI3/lzVH63uBC0M/N94zgaM0IsYQXkxgBvQUsV2k1xS5\r
+       jkSy7f7zfbYz+dmXqvMn2zHjI4SGZX0fX9Rvw=\r
+DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;\r
+       h=from:to:subject:user-agent:date:message-id:mime-version\r
+       :content-type;\r
+       b=FCH0eVFn6h+8WbYDafOo6oie/aWMF3X7fJ83CQQb/yfDM08IYW20XWWcFCdqo728XG\r
+       lObrjyYcjonO7mRvHrIKuMs0miwsqy1s8rnnWsONvvWDQZH0eMsQAUiaGf/N7dPNNzek\r
+       2hpv413k343I+lIVCiUXxr6OoE6ffqfT302JM=\r
+Received: by 10.42.133.67 with SMTP id g3mr7729196ict.51.1309194746748;\r
+       Mon, 27 Jun 2011 10:12:26 -0700 (PDT)\r
+Received: from localhost ([74.205.145.146])\r
+       by mx.google.com with ESMTPS id a9sm5531558icy.18.2011.06.27.10.12.25\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Mon, 27 Jun 2011 10:12:26 -0700 (PDT)\r
+From: Mark Anderson <ma.skies@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] test:Folder tags shouldn't match after removal of file in\r
+       given folder\r
+User-Agent: Notmuch/0.5-283-gb744eac (http://notmuchmail.org) Emacs/23.2.1\r
+       (i686-pc-linux-gnu)\r
+Date: Mon, 27 Jun 2011 11:12:24 -0600\r
+Message-ID: <87sjqvw64n.fsf@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\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: Mon, 27 Jun 2011 17:12:28 -0000\r
+\r
+\r
+Test for bug.  Current stemming support for notmuch adds extra terms\r
+to the DB which aren't removed when the file renames are detected.\r
+\r
+When folder tags are added to a message, Xapian terms for both XFOLDER\r
+and ZXFOLDER are generated.  When one of the filenames are\r
+renamed/removed, only the XFOLDER tags are removed, leaving it possible\r
+for a match on a folder: tag that was previously but is no longer a\r
+match in the maildir.\r
+---\r
+\r
+I found this bug last week.  Essentially when the folder:spam tag is\r
+added and puts the XFOLDERspam, it also inserts the ZXFOLDERspam.  Then\r
+if the mail is removed from the folder, it neglects to remove\r
+ZXFOLDERspam.\r
+\r
+This was detected with my offlineimap usage with gmail, still haven't\r
+polished my personal folder/label transition.  As I was looking into it,\r
+I saw some unusual things flagged as spam, and investigated.\r
+\r
+ test/notmuch-test            |    1 +\r
+ test/search-folder-coherence |   48 ++++++++++++++++++++++++++++++++++++++++++\r
+ 2 files changed, 49 insertions(+), 0 deletions(-)\r
+ create mode 100755 test/search-folder-coherence\r
+\r
+diff --git a/test/notmuch-test b/test/notmuch-test\r
+index fe85c6a..79e6267 100755\r
+--- a/test/notmuch-test\r
++++ b/test/notmuch-test\r
+@@ -41,6 +41,7 @@ TESTS="\r
+   maildir-sync\r
+   crypto\r
+   symbol-hiding\r
++  search-folder-coherence\r
+ "\r
+ TESTS=${NOTMUCH_TESTS:=$TESTS}\r
\r
+diff --git a/test/search-folder-coherence b/test/search-folder-coherence\r
+new file mode 100755\r
+index 0000000..cf3ba40\r
+--- /dev/null\r
++++ b/test/search-folder-coherence\r
+@@ -0,0 +1,48 @@\r
++#!/usr/bin/env bash\r
++test_description='folder tags removed and added through file renames remain consistent'\r
++. ./test-lib.sh\r
++\r
++test_begin_subtest "No new messages"\r
++output=$(NOTMUCH_NEW)\r
++test_expect_equal "$output" "No new mail."\r
++\r
++\r
++test_begin_subtest "Single new message"\r
++generate_message\r
++file_x=$gen_msg_filename\r
++id_x=$gen_msg_id\r
++output=$(NOTMUCH_NEW)\r
++test_expect_equal "$output" "Added 1 new message to the database."\r
++\r
++test_begin_subtest "Add second folder for same message"\r
++dir=$(dirname $file_x)\r
++mkdir $dir/spam\r
++cp $file_x $dir/spam\r
++output=$(NOTMUCH_NEW)\r
++test_expect_equal "$output" "No new mail."\r
++\r
++\r
++test_begin_subtest "Multiple files for same message"\r
++cat <<EOF >EXPECTED\r
++MAIL_DIR/msg-001\r
++MAIL_DIR/spam/msg-001\r
++EOF\r
++notmuch search --output=files id:$id_x | sed -e "s,$MAIL_DIR,MAIL_DIR," >OUTPUT\r
++test_expect_equal_file OUTPUT EXPECTED\r
++\r
++test_begin_subtest "Test matches folder:spam"\r
++output=$(notmuch search folder:spam)\r
++test_expect_equal "$output" "thread:0000000000000001   2001-01-05 [1/1] Notmuch Test Suite; Test message #1 (inbox unread)"\r
++\r
++sleep 1;\r
++\r
++test_begin_subtest "Remove folder:spam copy of email"\r
++rm $dir/spam/$(basename $file_x)\r
++output=$(NOTMUCH_NEW)\r
++test_expect_equal "$output" "No new mail. Detected 1 file rename."\r
++\r
++test_begin_subtest "No mails match the folder:spam search"\r
++output=$(notmuch search folder:spam)\r
++test_expect_equal "$output" ""\r
++\r
++test_done\r
+-- \r
+1.7.4.1\r
+\r