test: add tests wrt ignoring user-specified files and directories
authorTomi Ollila <tomi.ollila@iki.fi>
Wed, 15 Feb 2012 09:17:30 +0000 (11:17 +0200)
committerDavid Bremner <bremner@debian.org>
Fri, 17 Feb 2012 12:04:23 +0000 (08:04 -0400)
Files and directories which are specified in 'new.ignore' in the
config file shouldn't be indexed nor reported by `notmuch new'.

This is basically Pieter's work with Austin's comments addressed.

test/new

index 49f390d61b4a71bf81470f212983ef985f2bdc31..e4536845902afb035a2cb328df76927b11629993 100755 (executable)
--- a/test/new
+++ b/test/new
@@ -153,4 +153,26 @@ rm -rf "${MAIL_DIR}"/two
 output=$(NOTMUCH_NEW)
 test_expect_equal "$output" "No new mail. Removed 3 messages."
 
+# This test requires that notmuch new has been run at least once.
+test_begin_subtest "Skip and report non-mail files"
+generate_message
+mkdir -p "${MAIL_DIR}"/.git && touch "${MAIL_DIR}"/.git/config
+touch "${MAIL_DIR}"/ignored_file
+touch "${MAIL_DIR}"/.ignored_hidden_file
+output=$(NOTMUCH_NEW 2>&1)
+test_expect_equal "$output" \
+"Note: Ignoring non-mail file: ${MAIL_DIR}/.git/config
+Note: Ignoring non-mail file: ${MAIL_DIR}/.ignored_hidden_file
+Note: Ignoring non-mail file: ${MAIL_DIR}/ignored_file
+Added 1 new message to the database."
+
+test_begin_subtest "Ignore files and directories specified in new.ignore"
+test_subtest_known_broken
+generate_message
+notmuch config set new.ignore .git ignored_file .ignored_hidden_file
+touch "${MAIL_DIR}"/.git # change .git's mtime for notmuch new to rescan.
+output=$(NOTMUCH_NEW 2>&1)
+test_expect_equal "$output" "Added 1 new message to the database."
+
+
 test_done