From: Mark Walters <markwalters1009@gmail.com>
To: notmuch@notmuchmail.org
Subject: [PATCH] test: add some exclude tests
Date: Sun, 18 Mar 2012 17:23:01 +0000 [thread overview]
Message-ID: <1332091381-16797-1-git-send-email-markwalters1009@gmail.com> (raw)
In-Reply-To: <20120317155023.GH2670@mit.edu>
Here are some tests for search exclude working in a systematic fashion
as suggested by Austin.
In principle I think something like the generate_thread function could
go in to test-lib.sh, but it would need to be written by someone much
familiar with bash quoting than I am.
At the moment I have left the current exclude tests in the "search"
test: should they be moved here?
Best wishes
Mark
---
test/notmuch-test | 1 +
test/search-excludes | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 161 insertions(+), 0 deletions(-)
create mode 100755 test/search-excludes
diff --git a/test/notmuch-test b/test/notmuch-test
index f03b594..4dcd8c6 100755
--- a/test/notmuch-test
+++ b/test/notmuch-test
@@ -27,6 +27,7 @@ TESTS="
search-position-overlap-bug
search-insufficient-from-quoting
search-limiting
+ search-excludes
tagging
json
multipart
diff --git a/test/search-excludes b/test/search-excludes
new file mode 100755
index 0000000..81c284e
--- /dev/null
+++ b/test/search-excludes
@@ -0,0 +1,160 @@
+#!/usr/bin/env bash
+test_description='"notmuch search" with excludes in several variations'
+. ./test-lib.sh
+
+# Generates a thread of 'length' messages. The subject of the nth
+# message in the thread is 'subject: message n'
+generate_thread ()
+{
+ local subject="$1"
+ local length="$2"
+ generate_message '[subject]="'"${subject}: message 1"'"'
+ parent_id=$gen_msg_id
+ for i in `seq 2 $length`
+ do
+ generate_message '[subject]="'"${subject}: message $i"'"' \
+ "[in-reply-to]=\<$parent_id\>"
+ parent_id=$gen_msg_id
+ done
+ notmuch new > /dev/null
+}
+
+# We construct some threads for the tests. We use the tag "test" to
+# indicate which messages we will search for.
+
+# A thread of deleted messages; test matches one of them.
+generate_thread "All messages excluded: single match" 5
+notmuch tag +deleted subject:"All messages excluded: single match*"
+notmuch tag +test 'subject:All messages excluded: single match: message 2'
+
+# A thread of deleted messages; test matches two of them.
+generate_thread "All messages excluded: double match" 5
+notmuch tag +deleted subject:"All messages excluded: double match*"
+notmuch tag +test 'subject:All messages excluded: double match: message 2'
+notmuch tag +test 'subject:All messages excluded: double match: message 4'
+
+# A thread some messages deleted; test only matches a deleted message.
+generate_thread "Some messages excluded: single excluded match" 5
+notmuch tag +deleted +test 'subject:Some messages excluded: single excluded match: message 3'
+
+# A thread some messages deleted; test only matches a non-deleted message.
+generate_thread "Some messages excluded: single non-excluded match" 5
+notmuch tag +deleted 'subject:Some messages excluded: single non-excluded match: message 2'
+notmuch tag +test 'subject:Some messages excluded: single non-excluded match: message 4'
+
+# A thread no messages deleted; test matches a message.
+generate_thread "No messages excluded: single match" 5
+notmuch tag +test 'subject:No messages excluded: single match: message 3'
+
+# Set up excludes
+notmuch config set search.exclude_tags deleted
+
+test_begin_subtest "Default exclusion (thread summary)"
+output=$(notmuch search tag:test | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single non-excluded match: message 4 (deleted inbox test unread)
+thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; No messages excluded: single match: message 3 (inbox test unread)"
+
+test_begin_subtest "Default exclusion (messages)"
+output=$(notmuch search --output=messages tag:test | notmuch_search_sanitize)
+test_expect_equal "$output" "id:msg-019@notmuch-test-suite
+id:msg-023@notmuch-test-suite"
+
+test_begin_subtest "exclude=true (thread summary)"
+output=$(notmuch search --exclude=true tag:test | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single non-excluded match: message 4 (deleted inbox test unread)
+thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; No messages excluded: single match: message 3 (inbox test unread)"
+
+test_begin_subtest "exclude=true (messages)"
+output=$(notmuch search --exclude=true --output=messages tag:test | notmuch_search_sanitize)
+test_expect_equal "$output" "id:msg-019@notmuch-test-suite
+id:msg-023@notmuch-test-suite"
+
+test_begin_subtest "exclude=false (thread summary)"
+output=$(notmuch search --exclude=false tag:test | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; All messages excluded: single match: message 2 (deleted inbox test unread)
+thread:XXX 2001-01-05 [2/5] Notmuch Test Suite; All messages excluded: double match: message 2 (deleted inbox test unread)
+thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single excluded match: message 3 (deleted inbox test unread)
+thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single non-excluded match: message 4 (deleted inbox test unread)
+thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; No messages excluded: single match: message 3 (inbox test unread)"
+
+test_begin_subtest "exclude=false (messages)"
+output=$(notmuch search --exclude=false --output=messages tag:test | notmuch_search_sanitize)
+test_expect_equal "$output" "id:msg-002@notmuch-test-suite
+id:msg-007@notmuch-test-suite
+id:msg-009@notmuch-test-suite
+id:msg-013@notmuch-test-suite
+id:msg-019@notmuch-test-suite
+id:msg-023@notmuch-test-suite"
+
+test_begin_subtest "exclude=flag (thread summary)"
+output=$(notmuch search --exclude=flag tag:test | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX 2001-01-05 [0/5] Notmuch Test Suite; All messages excluded: single match: message 2 (deleted inbox test unread)
+thread:XXX 2001-01-05 [0/5] Notmuch Test Suite; All messages excluded: double match: message 4 (deleted inbox test unread)
+thread:XXX 2001-01-05 [0/5] Notmuch Test Suite; Some messages excluded: single excluded match: message 3 (deleted inbox test unread)
+thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single non-excluded match: message 4 (deleted inbox test unread)
+thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; No messages excluded: single match: message 3 (inbox test unread)"
+
+test_begin_subtest "exclude=flag (messages)"
+output=$(notmuch search --exclude=flag --output=messages tag:test | notmuch_search_sanitize)
+test_expect_equal "$output" "id:msg-002@notmuch-test-suite
+id:msg-007@notmuch-test-suite
+id:msg-009@notmuch-test-suite
+id:msg-013@notmuch-test-suite
+id:msg-019@notmuch-test-suite
+id:msg-023@notmuch-test-suite"
+
+test_begin_subtest "Default exclusion: tag in query (thread summary)"
+output=$(notmuch search tag:test and tag:deleted | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; All messages excluded: single match: message 2 (deleted inbox test unread)
+thread:XXX 2001-01-05 [2/5] Notmuch Test Suite; All messages excluded: double match: message 2 (deleted inbox test unread)
+thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single excluded match: message 3 (deleted inbox test unread)"
+
+test_begin_subtest "Default exclusion: tag in query (messages)"
+output=$(notmuch search --output=messages tag:test and tag:deleted | notmuch_search_sanitize)
+test_expect_equal "$output" "id:msg-002@notmuch-test-suite
+id:msg-007@notmuch-test-suite
+id:msg-009@notmuch-test-suite
+id:msg-013@notmuch-test-suite"
+
+test_begin_subtest "exclude=true: tag in query (thread summary)"
+output=$(notmuch search --exclude=true tag:test and tag:deleted | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; All messages excluded: single match: message 2 (deleted inbox test unread)
+thread:XXX 2001-01-05 [2/5] Notmuch Test Suite; All messages excluded: double match: message 2 (deleted inbox test unread)
+thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single excluded match: message 3 (deleted inbox test unread)"
+
+test_begin_subtest "exclude=true: tag in query (messages)"
+output=$(notmuch search --exclude=true --output=messages tag:test and tag:deleted | notmuch_search_sanitize)
+test_expect_equal "$output" "id:msg-002@notmuch-test-suite
+id:msg-007@notmuch-test-suite
+id:msg-009@notmuch-test-suite
+id:msg-013@notmuch-test-suite"
+
+test_begin_subtest "exclude=false: tag in query (thread summary)"
+output=$(notmuch search --exclude=false tag:test and tag:deleted | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; All messages excluded: single match: message 2 (deleted inbox test unread)
+thread:XXX 2001-01-05 [2/5] Notmuch Test Suite; All messages excluded: double match: message 2 (deleted inbox test unread)
+thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single excluded match: message 3 (deleted inbox test unread)"
+
+test_begin_subtest "exclude=false: tag in query (messages)"
+output=$(notmuch search --exclude=false --output=messages tag:test and tag:deleted | notmuch_search_sanitize)
+test_expect_equal "$output" "id:msg-002@notmuch-test-suite
+id:msg-007@notmuch-test-suite
+id:msg-009@notmuch-test-suite
+id:msg-013@notmuch-test-suite"
+
+test_begin_subtest "exclude=flag: tag in query (thread summary)"
+output=$(notmuch search --exclude=flag tag:test and tag:deleted | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; All messages excluded: single match: message 2 (deleted inbox test unread)
+thread:XXX 2001-01-05 [2/5] Notmuch Test Suite; All messages excluded: double match: message 2 (deleted inbox test unread)
+thread:XXX 2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single excluded match: message 3 (deleted inbox test unread)"
+
+test_begin_subtest "exclude=flag: tag in query (messages)"
+output=$(notmuch search --exclude=flag --output=messages tag:test and tag:deleted | notmuch_search_sanitize)
+test_expect_equal "$output" "id:msg-002@notmuch-test-suite
+id:msg-007@notmuch-test-suite
+id:msg-009@notmuch-test-suite
+id:msg-013@notmuch-test-suite"
+
+
+
+test_done
--
1.7.9.1
next prev parent reply other threads:[~2012-03-18 17:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-15 18:42 [PATCH 0/5] Move --no-exclude to --exclude=(true|false|flag) Mark Walters
2012-03-15 18:42 ` [PATCH 1/5] lib: change default for notmuch_query_set_omit_excluded Mark Walters
2012-03-15 18:42 ` [PATCH 2/5] cli: move count to the new --exclude=(true|false|flag) naming scheme Mark Walters
2012-03-15 18:42 ` [PATCH 3/5] cli: move search to the new --exclude= " Mark Walters
2012-03-17 15:50 ` Austin Clements
2012-03-17 19:49 ` Jameson Graef Rollins
2012-03-18 17:23 ` Mark Walters [this message]
2012-03-18 18:08 ` [PATCH] test: add some exclude tests Jameson Graef Rollins
2012-03-15 18:42 ` [PATCH 4/5] cli: move show to the new --exclude= option naming scheme Mark Walters
2012-03-17 16:51 ` Austin Clements
2012-03-18 17:30 ` Mark Walters
2012-03-15 18:42 ` [PATCH 5/5] emacs: make show set --exclude=flag Mark Walters
2012-03-17 16:52 ` Austin Clements
2012-03-17 6:02 ` [PATCH 0/5] Move --no-exclude to --exclude=(true|false|flag) Jameson Graef Rollins
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1332091381-16797-1-git-send-email-markwalters1009@gmail.com \
--to=markwalters1009@gmail.com \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).