[PATCH] test: add some exclude tests
authorMark Walters <markwalters1009@gmail.com>
Sun, 18 Mar 2012 17:23:01 +0000 (17:23 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:45:37 +0000 (09:45 -0800)
91/99fd750af3f715c4c52471b3fa75ff7a452b25 [new file with mode: 0644]

diff --git a/91/99fd750af3f715c4c52471b3fa75ff7a452b25 b/91/99fd750af3f715c4c52471b3fa75ff7a452b25
new file mode 100644 (file)
index 0000000..2a48aee
--- /dev/null
@@ -0,0 +1,263 @@
+Return-Path: <markwalters1009@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 8C8F0431FB6\r
+       for <notmuch@notmuchmail.org>; Sun, 18 Mar 2012 10:23:08 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+       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 hfMv+QflixxX for <notmuch@notmuchmail.org>;\r
+       Sun, 18 Mar 2012 10:23:07 -0700 (PDT)\r
+Received: from mail-we0-f181.google.com (mail-we0-f181.google.com\r
+       [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 286DA431FAF\r
+       for <notmuch@notmuchmail.org>; Sun, 18 Mar 2012 10:23:07 -0700 (PDT)\r
+Received: by werm13 with SMTP id m13so6039192wer.26\r
+       for <notmuch@notmuchmail.org>; Sun, 18 Mar 2012 10:23:04 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+       bh=mwnElj3aj0E3OAL7/9S79Dkzml/fQGY9nS75gBM7DFg=;\r
+       b=dUrQhslfUtVnhhFX/2W4frfcWs7YDlG88rMei26Ie5MW/vwxeUu+Q0HhhrAucjLzZk\r
+       l35H3vCLngHoZacjT72FEIflGJwMKmO4v1VxWykJ4gOqZVRvlVeEVQj4B19kmxnq5XsM\r
+       YL1vOvlzUzmlsf+44i0/cTHJ1U32bBQVDrFLZqNPvlBkhkuhgej6brGSeA6YFGjzaLBk\r
+       gZ7cn1cfdy3l3bo5bhhg4MA8padJy1+yhktOd5PEkczdwiRSYe6V7gRFxv2kyq7zD5XZ\r
+       HSyqrdCDwkLg7D9LIjZGsUVxdv8Cu2ZrHR3PWdxQM/7+iuay/D/ezj3zAwmRgM2ngalC\r
+       KsPw==\r
+Received: by 10.180.80.104 with SMTP id q8mr13538470wix.14.1332091384369;\r
+       Sun, 18 Mar 2012 10:23:04 -0700 (PDT)\r
+Received: from localhost (94-192-233-223.zone6.bethere.co.uk.\r
+ [94.192.233.223])     by mx.google.com with ESMTPS id\r
+ df3sm18397976wib.1.2012.03.18.10.23.02        (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Sun, 18 Mar 2012 10:23:03 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] test: add some exclude tests\r
+Date: Sun, 18 Mar 2012 17:23:01 +0000\r
+Message-Id: <1332091381-16797-1-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <20120317155023.GH2670@mit.edu>\r
+References: <20120317155023.GH2670@mit.edu>\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: Sun, 18 Mar 2012 17:23:08 -0000\r
+\r
+Here are some tests for search exclude working in a systematic fashion\r
+as suggested by Austin.\r
+\r
+In principle I think something like the generate_thread function could\r
+go in to test-lib.sh, but it would need to be written by someone much\r
+familiar with bash quoting than I am.\r
+\r
+At the moment I have left the current exclude tests in the "search"\r
+test: should they be moved here?\r
+\r
+Best wishes \r
+\r
+Mark\r
+\r
+---\r
+ test/notmuch-test    |    1 +\r
+ test/search-excludes |  160 ++++++++++++++++++++++++++++++++++++++++++++++++++\r
+ 2 files changed, 161 insertions(+), 0 deletions(-)\r
+ create mode 100755 test/search-excludes\r
+\r
+diff --git a/test/notmuch-test b/test/notmuch-test\r
+index f03b594..4dcd8c6 100755\r
+--- a/test/notmuch-test\r
++++ b/test/notmuch-test\r
+@@ -27,6 +27,7 @@ TESTS="\r
+   search-position-overlap-bug\r
+   search-insufficient-from-quoting\r
+   search-limiting\r
++  search-excludes\r
+   tagging\r
+   json\r
+   multipart\r
+diff --git a/test/search-excludes b/test/search-excludes\r
+new file mode 100755\r
+index 0000000..81c284e\r
+--- /dev/null\r
++++ b/test/search-excludes\r
+@@ -0,0 +1,160 @@\r
++#!/usr/bin/env bash\r
++test_description='"notmuch search" with excludes in several variations'\r
++. ./test-lib.sh\r
++\r
++# Generates a thread of 'length' messages. The subject of the nth\r
++# message in the thread is 'subject: message n'\r
++generate_thread ()\r
++{\r
++    local subject="$1"\r
++    local length="$2"\r
++    generate_message '[subject]="'"${subject}: message 1"'"'\r
++    parent_id=$gen_msg_id\r
++    for i in `seq 2 $length`\r
++    do\r
++      generate_message '[subject]="'"${subject}: message $i"'"' \\r
++                       "[in-reply-to]=\<$parent_id\>"\r
++      parent_id=$gen_msg_id\r
++    done\r
++    notmuch new > /dev/null\r
++}\r
++\r
++# We construct some threads for the tests. We use the tag "test" to\r
++# indicate which messages we will search for.\r
++\r
++# A thread of deleted messages; test matches one of them.\r
++generate_thread "All messages excluded: single match" 5\r
++notmuch tag +deleted subject:"All messages excluded: single match*"\r
++notmuch tag +test 'subject:All messages excluded: single match: message 2'\r
++\r
++# A thread of deleted messages; test matches two of them.\r
++generate_thread "All messages excluded: double match" 5\r
++notmuch tag +deleted subject:"All messages excluded: double match*"\r
++notmuch tag +test 'subject:All messages excluded: double match: message 2'\r
++notmuch tag +test 'subject:All messages excluded: double match: message 4'\r
++\r
++# A thread some messages deleted; test only matches a deleted message.\r
++generate_thread "Some messages excluded: single excluded match" 5\r
++notmuch tag +deleted +test 'subject:Some messages excluded: single excluded match: message 3'\r
++\r
++# A thread some messages deleted; test only matches a non-deleted message.\r
++generate_thread "Some messages excluded: single non-excluded match" 5\r
++notmuch tag +deleted 'subject:Some messages excluded: single non-excluded match: message 2'\r
++notmuch tag +test 'subject:Some messages excluded: single non-excluded match: message 4'\r
++\r
++# A thread no messages deleted; test matches a message.\r
++generate_thread "No messages excluded: single match" 5\r
++notmuch tag +test 'subject:No messages excluded: single match: message 3'\r
++\r
++# Set up excludes\r
++notmuch config set search.exclude_tags deleted\r
++\r
++test_begin_subtest "Default exclusion (thread summary)"\r
++output=$(notmuch search tag:test | notmuch_search_sanitize)\r
++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)\r
++thread:XXX   2001-01-05 [1/5] Notmuch Test Suite; No messages excluded: single match: message 3 (inbox test unread)"\r
++\r
++test_begin_subtest "Default exclusion (messages)"\r
++output=$(notmuch search --output=messages tag:test | notmuch_search_sanitize)\r
++test_expect_equal "$output" "id:msg-019@notmuch-test-suite\r
++id:msg-023@notmuch-test-suite"\r
++\r
++test_begin_subtest "exclude=true (thread summary)"\r
++output=$(notmuch search --exclude=true tag:test | notmuch_search_sanitize)\r
++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)\r
++thread:XXX   2001-01-05 [1/5] Notmuch Test Suite; No messages excluded: single match: message 3 (inbox test unread)"\r
++\r
++test_begin_subtest "exclude=true (messages)"\r
++output=$(notmuch search --exclude=true --output=messages tag:test | notmuch_search_sanitize)\r
++test_expect_equal "$output" "id:msg-019@notmuch-test-suite\r
++id:msg-023@notmuch-test-suite"\r
++\r
++test_begin_subtest "exclude=false (thread summary)"\r
++output=$(notmuch search --exclude=false tag:test | notmuch_search_sanitize)\r
++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)\r
++thread:XXX   2001-01-05 [2/5] Notmuch Test Suite; All messages excluded: double match: message 2 (deleted inbox test unread)\r
++thread:XXX   2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single excluded match: message 3 (deleted inbox test unread)\r
++thread:XXX   2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single non-excluded match: message 4 (deleted inbox test unread)\r
++thread:XXX   2001-01-05 [1/5] Notmuch Test Suite; No messages excluded: single match: message 3 (inbox test unread)"\r
++\r
++test_begin_subtest "exclude=false (messages)"\r
++output=$(notmuch search --exclude=false --output=messages tag:test | notmuch_search_sanitize)\r
++test_expect_equal "$output" "id:msg-002@notmuch-test-suite\r
++id:msg-007@notmuch-test-suite\r
++id:msg-009@notmuch-test-suite\r
++id:msg-013@notmuch-test-suite\r
++id:msg-019@notmuch-test-suite\r
++id:msg-023@notmuch-test-suite"\r
++\r
++test_begin_subtest "exclude=flag (thread summary)"\r
++output=$(notmuch search --exclude=flag tag:test | notmuch_search_sanitize)\r
++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)\r
++thread:XXX   2001-01-05 [0/5] Notmuch Test Suite; All messages excluded: double match: message 4 (deleted inbox test unread)\r
++thread:XXX   2001-01-05 [0/5] Notmuch Test Suite; Some messages excluded: single excluded match: message 3 (deleted inbox test unread)\r
++thread:XXX   2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single non-excluded match: message 4 (deleted inbox test unread)\r
++thread:XXX   2001-01-05 [1/5] Notmuch Test Suite; No messages excluded: single match: message 3 (inbox test unread)"\r
++\r
++test_begin_subtest "exclude=flag (messages)"\r
++output=$(notmuch search --exclude=flag --output=messages tag:test | notmuch_search_sanitize)\r
++test_expect_equal "$output" "id:msg-002@notmuch-test-suite\r
++id:msg-007@notmuch-test-suite\r
++id:msg-009@notmuch-test-suite\r
++id:msg-013@notmuch-test-suite\r
++id:msg-019@notmuch-test-suite\r
++id:msg-023@notmuch-test-suite"\r
++\r
++test_begin_subtest "Default exclusion: tag in query (thread summary)"\r
++output=$(notmuch search tag:test and tag:deleted | notmuch_search_sanitize)\r
++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)\r
++thread:XXX   2001-01-05 [2/5] Notmuch Test Suite; All messages excluded: double match: message 2 (deleted inbox test unread)\r
++thread:XXX   2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single excluded match: message 3 (deleted inbox test unread)"\r
++\r
++test_begin_subtest "Default exclusion: tag in query (messages)"\r
++output=$(notmuch search --output=messages tag:test and tag:deleted | notmuch_search_sanitize)\r
++test_expect_equal "$output" "id:msg-002@notmuch-test-suite\r
++id:msg-007@notmuch-test-suite\r
++id:msg-009@notmuch-test-suite\r
++id:msg-013@notmuch-test-suite"\r
++\r
++test_begin_subtest "exclude=true: tag in query (thread summary)"\r
++output=$(notmuch search --exclude=true tag:test and tag:deleted | notmuch_search_sanitize)\r
++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)\r
++thread:XXX   2001-01-05 [2/5] Notmuch Test Suite; All messages excluded: double match: message 2 (deleted inbox test unread)\r
++thread:XXX   2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single excluded match: message 3 (deleted inbox test unread)"\r
++\r
++test_begin_subtest "exclude=true: tag in query (messages)"\r
++output=$(notmuch search --exclude=true --output=messages tag:test and tag:deleted | notmuch_search_sanitize)\r
++test_expect_equal "$output" "id:msg-002@notmuch-test-suite\r
++id:msg-007@notmuch-test-suite\r
++id:msg-009@notmuch-test-suite\r
++id:msg-013@notmuch-test-suite"\r
++\r
++test_begin_subtest "exclude=false: tag in query (thread summary)"\r
++output=$(notmuch search --exclude=false tag:test and tag:deleted | notmuch_search_sanitize)\r
++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)\r
++thread:XXX   2001-01-05 [2/5] Notmuch Test Suite; All messages excluded: double match: message 2 (deleted inbox test unread)\r
++thread:XXX   2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single excluded match: message 3 (deleted inbox test unread)"\r
++\r
++test_begin_subtest "exclude=false: tag in query (messages)"\r
++output=$(notmuch search --exclude=false --output=messages tag:test and tag:deleted | notmuch_search_sanitize)\r
++test_expect_equal "$output" "id:msg-002@notmuch-test-suite\r
++id:msg-007@notmuch-test-suite\r
++id:msg-009@notmuch-test-suite\r
++id:msg-013@notmuch-test-suite"\r
++\r
++test_begin_subtest "exclude=flag: tag in query (thread summary)"\r
++output=$(notmuch search --exclude=flag tag:test and tag:deleted | notmuch_search_sanitize)\r
++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)\r
++thread:XXX   2001-01-05 [2/5] Notmuch Test Suite; All messages excluded: double match: message 2 (deleted inbox test unread)\r
++thread:XXX   2001-01-05 [1/5] Notmuch Test Suite; Some messages excluded: single excluded match: message 3 (deleted inbox test unread)"\r
++\r
++test_begin_subtest "exclude=flag: tag in query (messages)"\r
++output=$(notmuch search --exclude=flag --output=messages tag:test and tag:deleted | notmuch_search_sanitize)\r
++test_expect_equal "$output" "id:msg-002@notmuch-test-suite\r
++id:msg-007@notmuch-test-suite\r
++id:msg-009@notmuch-test-suite\r
++id:msg-013@notmuch-test-suite"\r
++\r
++\r
++\r
++test_done\r
+-- \r
+1.7.9.1\r
+\r