unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] test:Folder tags shouldn't match after removal of file in given folder
@ 2011-06-27 17:12 Mark Anderson
  2011-06-27 20:58 ` Austin Clements
  2011-06-28  6:43 ` Pieter Praet
  0 siblings, 2 replies; 6+ messages in thread
From: Mark Anderson @ 2011-06-27 17:12 UTC (permalink / raw)
  To: notmuch


Test for bug.  Current stemming support for notmuch adds extra terms
to the DB which aren't removed when the file renames are detected.

When folder tags are added to a message, Xapian terms for both XFOLDER
and ZXFOLDER are generated.  When one of the filenames are
renamed/removed, only the XFOLDER tags are removed, leaving it possible
for a match on a folder: tag that was previously but is no longer a
match in the maildir.
---

I found this bug last week.  Essentially when the folder:spam tag is
added and puts the XFOLDERspam, it also inserts the ZXFOLDERspam.  Then
if the mail is removed from the folder, it neglects to remove
ZXFOLDERspam.

This was detected with my offlineimap usage with gmail, still haven't
polished my personal folder/label transition.  As I was looking into it,
I saw some unusual things flagged as spam, and investigated.

 test/notmuch-test            |    1 +
 test/search-folder-coherence |   48 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 0 deletions(-)
 create mode 100755 test/search-folder-coherence

diff --git a/test/notmuch-test b/test/notmuch-test
index fe85c6a..79e6267 100755
--- a/test/notmuch-test
+++ b/test/notmuch-test
@@ -41,6 +41,7 @@ TESTS="
   maildir-sync
   crypto
   symbol-hiding
+  search-folder-coherence
 "
 TESTS=${NOTMUCH_TESTS:=$TESTS}
 
diff --git a/test/search-folder-coherence b/test/search-folder-coherence
new file mode 100755
index 0000000..cf3ba40
--- /dev/null
+++ b/test/search-folder-coherence
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+test_description='folder tags removed and added through file renames remain consistent'
+. ./test-lib.sh
+
+test_begin_subtest "No new messages"
+output=$(NOTMUCH_NEW)
+test_expect_equal "$output" "No new mail."
+
+
+test_begin_subtest "Single new message"
+generate_message
+file_x=$gen_msg_filename
+id_x=$gen_msg_id
+output=$(NOTMUCH_NEW)
+test_expect_equal "$output" "Added 1 new message to the database."
+
+test_begin_subtest "Add second folder for same message"
+dir=$(dirname $file_x)
+mkdir $dir/spam
+cp $file_x $dir/spam
+output=$(NOTMUCH_NEW)
+test_expect_equal "$output" "No new mail."
+
+
+test_begin_subtest "Multiple files for same message"
+cat <<EOF >EXPECTED
+MAIL_DIR/msg-001
+MAIL_DIR/spam/msg-001
+EOF
+notmuch search --output=files id:$id_x | sed -e "s,$MAIL_DIR,MAIL_DIR," >OUTPUT
+test_expect_equal_file OUTPUT EXPECTED
+
+test_begin_subtest "Test matches folder:spam"
+output=$(notmuch search folder:spam)
+test_expect_equal "$output" "thread:0000000000000001   2001-01-05 [1/1] Notmuch Test Suite; Test message #1 (inbox unread)"
+
+sleep 1;
+
+test_begin_subtest "Remove folder:spam copy of email"
+rm $dir/spam/$(basename $file_x)
+output=$(NOTMUCH_NEW)
+test_expect_equal "$output" "No new mail. Detected 1 file rename."
+
+test_begin_subtest "No mails match the folder:spam search"
+output=$(notmuch search folder:spam)
+test_expect_equal "$output" ""
+
+test_done
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-06-29 21:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-27 17:12 [PATCH] test:Folder tags shouldn't match after removal of file in given folder Mark Anderson
2011-06-27 20:58 ` Austin Clements
2011-06-27 22:57   ` Mark Anderson
2011-06-28  6:43 ` Pieter Praet
2011-06-29 20:04   ` [PATCH] Fix folder: coherence issue Mark Anderson
2011-06-29 21:16     ` Carl Worth

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