--- /dev/null
+Return-Path: <amthrax@awakening.csail.mit.edu>\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 EE690429E27\r
+ for <notmuch@notmuchmail.org>; Mon, 7 Nov 2011 19:54:41 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[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 e-xwV5qHVo68 for <notmuch@notmuchmail.org>;\r
+ Mon, 7 Nov 2011 19:54:41 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-7.mit.edu (DMZ-MAILSEC-SCANNER-7.MIT.EDU\r
+ [18.7.68.36])\r
+ by olra.theworths.org (Postfix) with ESMTP id 67B34431FB6\r
+ for <notmuch@notmuchmail.org>; Mon, 7 Nov 2011 19:54:41 -0800 (PST)\r
+X-AuditID: 12074424-b7ef76d0000008dc-1c-4eb8a80041bf\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+ by dmz-mailsec-scanner-7.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 74.DC.02268.008A8BE4; Mon, 7 Nov 2011 22:54:40 -0500 (EST)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+ by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id pA83seC4030566; \r
+ Mon, 7 Nov 2011 22:54:40 -0500\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+ (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id pA83sd8X007121\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Mon, 7 Nov 2011 22:54:39 -0500 (EST)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
+ (envelope-from <amthrax@awakening.csail.mit.edu>)\r
+ id 1RNcoG-0006A6-1P; Mon, 07 Nov 2011 22:57:16 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] test: Add a test script for "notmuch tag"\r
+Date: Mon, 7 Nov 2011 22:57:11 -0500\r
+Message-Id: <1320724631-23643-1-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.7.1\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFprJIsWRmVeSWpSXmKPExsUixG6nrsuwYoefwfYLVhbXb85kdmD0eLbq\r
+ FnMAYxSXTUpqTmZZapG+XQJXxsWjF1gLZgpXrN2/l62B8Rt/FyMnh4SAicTcfc2sELaYxIV7\r
+ 69m6GLk4hAT2MUpM2r6cBcJZzyjxYc5SVgjnBJPE2sfrmUBahAQ2M0p83GoCYrMJaEhs27+c\r
+ EcQWEZCW2Hl3NlADBwezgJrEny4VkLCwgJXE7XNXWUBsFgFViQtnT7KD2LwCDhITzxxjBCmX\r
+ EFCQWLajegIj7wJGhlWMsim5Vbq5iZk5xanJusXJiXl5qUW65nq5mSV6qSmlmxjBIeCisoOx\r
+ +ZDSIUYBDkYlHt6Zojv8hFgTy4orcw8xSnIwKYnyxi8FCvEl5adUZiQWZ8QXleakFh9ilOBg\r
+ VhLhVWoCyvGmJFZWpRblw6SkOViUxHltdjr4CQmkJ5akZqemFqQWwWRlODiUJHiPLANqFCxK\r
+ TU+tSMvMKUFIM3FwggznARp+EqSGt7ggMbc4Mx0if4pRUUqcV245UEIAJJFRmgfXC4vRV4zi\r
+ QK8I8/4GaecBxjdc9yugwUxAg9t1t4EMLklESEk1MFY4lEXK7lLMqdp85asVY/5bDv9TDzpv\r
+ KXfrTa1S3Grz7/RMlT3bRdiab/PuqVr2YbXebZ2DZ867W1iVVHsp29kdkVojxcWztajXhDsx\r
+ XZTh0JyFlw/NdvqzzNWdpzP19L+1Vzc2nVz14Z+d2sx35vzPpq/0W3Jhf2v9P43njjFND36Z\r
+ MctHJymxFGckGmoxFxUnAgAAl3IGrAIAAA==\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: Tue, 08 Nov 2011 03:54:42 -0000\r
+\r
+---\r
+This is, in principle, unrelated to the notmuch tag optimization I\r
+just sent out, though it does test some things that would be weird\r
+(though valid) to test if it weren't for that optimization.\r
+\r
+ test/notmuch-test | 1 +\r
+ test/tagging | 41 +++++++++++++++++++++++++++++++++++++++++\r
+ 2 files changed, 42 insertions(+), 0 deletions(-)\r
+ create mode 100755 test/tagging\r
+\r
+diff --git a/test/notmuch-test b/test/notmuch-test\r
+index 738f8f6..bbabf28 100755\r
+--- a/test/notmuch-test\r
++++ b/test/notmuch-test\r
+@@ -24,6 +24,7 @@ TESTS="\r
+ search-by-folder\r
+ search-position-overlap-bug\r
+ search-insufficient-from-quoting\r
++ tagging\r
+ json\r
+ multipart\r
+ thread-naming\r
+diff --git a/test/tagging b/test/tagging\r
+new file mode 100755\r
+index 0000000..77202bf\r
+--- /dev/null\r
++++ b/test/tagging\r
+@@ -0,0 +1,41 @@\r
++#!/usr/bin/env bash\r
++test_description='"notmuch tag"'\r
++. ./test-lib.sh\r
++\r
++add_message '[subject]=One'\r
++add_message '[subject]=Two'\r
++\r
++test_begin_subtest "Adding tags"\r
++notmuch tag +tag1 +tag2 +tag3 \*\r
++output=$(notmuch search \* | notmuch_search_sanitize)\r
++test_expect_equal "$output" "\\r
++thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; One (inbox tag1 tag2 tag3 unread)\r
++thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 tag2 tag3 unread)"\r
++\r
++test_begin_subtest "Removing tags"\r
++notmuch tag -tag1 -tag2 \*\r
++output=$(notmuch search \* | notmuch_search_sanitize)\r
++test_expect_equal "$output" "\\r
++thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; One (inbox tag3 unread)\r
++thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag3 unread)"\r
++\r
++test_expect_code 1 "No tag operations" 'notmuch tag One'\r
++test_expect_code 1 "No query" 'notmuch tag +tag2'\r
++\r
++test_begin_subtest "Redundant tagging"\r
++notmuch tag +tag1 -tag3 One\r
++notmuch tag +tag1 -tag3 \*\r
++output=$(notmuch search \* | notmuch_search_sanitize)\r
++test_expect_equal "$output" "\\r
++thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; One (inbox tag1 unread)\r
++thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 unread)"\r
++\r
++test_begin_subtest "Special characters in tags"\r
++notmuch tag +':" ' \*\r
++notmuch tag -':" ' Two\r
++output=$(notmuch search \* | notmuch_search_sanitize)\r
++test_expect_equal "$output" "\\r
++thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; One (:\" inbox tag1 unread)\r
++thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 unread)"\r
++\r
++test_done\r
+-- \r
+1.7.7.1\r
+\r