--- /dev/null
+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 3E568431FBF\r
+ for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 05:21:17 -0800 (PST)\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 8JGCiFCqG6Uu for <notmuch@notmuchmail.org>;\r
+ Sat, 24 Nov 2012 05:21:16 -0800 (PST)\r
+Received: from mail-wg0-f41.google.com (mail-wg0-f41.google.com\r
+ [74.125.82.41]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client\r
+ certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
+ 3F765431FBD for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 05:21:14 -0800\r
+ (PST)\r
+Received: by mail-wg0-f41.google.com with SMTP id ds1so1423804wgb.2\r
+ for <notmuch@notmuchmail.org>; Sat, 24 Nov 2012 05:21:13 -0800 (PST)\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=DmByQYtBM/JPv38+UjDIlnFxQuxknzHgZK3zJg8dlhg=;\r
+ b=cbQP8cbLAst2wQh8ZoMH3fFHSGmBr6lJggyFZrNEhKXb5r3NEbNHABupe7/KMXQ+nA\r
+ /4cCXxqaMatGTPYLmz22w9gIFd68MoTl1dk0Azv4ScBGimtxo0OVnumqyZQOIwkXt7cg\r
+ KqQuG1MFmwU9JJAyAGV49AFxk9G7IPNjeXNpWXk1IuNTfDvvYAcPyU1pKG+XRG1+x2Hd\r
+ vchYBs3bwBMPuBbxjyFWi0BDHCQMPnxRr+fWIILGG6oocHSIaVDH7/GByXnohjjiZhJt\r
+ Qj9AfA/e9D1ejotyE20sBZjv83BdTeAHXnWn6NFe67jU5wFnczNGRDVsQqbS2L95bEIb\r
+ 7iNA==\r
+Received: by 10.180.92.103 with SMTP id cl7mr10225246wib.16.1353763272995;\r
+ Sat, 24 Nov 2012 05:21:12 -0800 (PST)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+ by mx.google.com with ESMTPS id b1sm14246026wix.11.2012.11.24.05.21.11\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Sat, 24 Nov 2012 05:21:12 -0800 (PST)\r
+From: markwalters1009 <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 5/7] test: test for race when tagging from emacs search\r
+Date: Sat, 24 Nov 2012 13:20:54 +0000\r
+Message-Id: <1353763256-32336-6-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1353763256-32336-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1353763256-32336-1-git-send-email-markwalters1009@gmail.com>\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: Sat, 24 Nov 2012 13:21:17 -0000\r
+\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+\r
+When tagging from search view in emacs there is a race condition: it\r
+tags all messages in the thread even ones which arrived after the\r
+search was made. This can cause dataloss (if, for example, a thread is\r
+archived it could archive messages the user has never seen).\r
+\r
+Mark this test known broken.\r
+---\r
+ test/emacs | 23 +++++++++++++++++++++++\r
+ 1 files changed, 23 insertions(+), 0 deletions(-)\r
+\r
+diff --git a/test/emacs b/test/emacs\r
+index 77265b0..3788439 100755\r
+--- a/test/emacs\r
++++ b/test/emacs\r
+@@ -122,6 +122,29 @@ test_emacs "(notmuch-search \"$os_x_darwin_thread\")\r
+ output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)\r
+ test_expect_equal "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox unread)"\r
+ \r
++test_begin_subtest "Tag all matching messages from search view"\r
++test_subtest_known_broken\r
++notmuch tag +test-tag-race from:cworth\r
++test_emacs "(notmuch-search \"tag:test-tag-race\")\r
++ (notmuch-test-wait)"\r
++notmuch tag +test-tag-race "id:1258471718-6781-2-git-send-email-dottedmag@dottedmag.net"\r
++test_emacs "(execute-kbd-macro \"*+test-tag-race-2\")"\r
++output=$(notmuch count tag:test-tag-race-2)\r
++test_expect_equal "$output" "12"\r
++notmuch tag -test-tag-race '*'\r
++notmuch tag -test-tag-race-2 '*'\r
++\r
++test_begin_subtest "Change tags from search view: another message arriving after thread lookup"\r
++test_subtest_known_broken\r
++typsos_id="878we4qdqf.fsf@yoom.home.cworth.org"\r
++typsos_thread=$(notmuch search --output=threads id:$typsos_id)\r
++test_emacs "(notmuch-search \"$typsos_thread\")\r
++ (notmuch-test-wait)"\r
++add_message "[subject]=\"new-thread-message\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"new-thread-message\"" "[in-reply-to]=\"<$typsos_id>\""\r
++test_emacs "(execute-kbd-macro \"+tag-from-search-view -unread\")"\r
++output=$(notmuch search tag:tag-from-search-view | notmuch_search_sanitize)\r
++test_expect_equal "$output" "thread:XXX 2009-11-18 [2/3] Ingmar Vanhassel, Carl Worth| Notmuch Test Suite; [notmuch] [PATCH] Typsos (inbox tag-from-search-view unread)"\r
++\r
+ test_begin_subtest "Add tag from notmuch-show view"\r
+ test_emacs "(notmuch-show \"$os_x_darwin_thread\")\r
+ (execute-kbd-macro \"+tag-from-show-view\")"\r
+-- \r
+1.7.9.1\r
+\r