Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 2AAB6431FB6 for ; Wed, 7 Mar 2012 11:50:02 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9o19+ACpI0p3 for ; Wed, 7 Mar 2012 11:50:01 -0800 (PST) Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 36CE1431FAE for ; Wed, 7 Mar 2012 11:50:01 -0800 (PST) Received: by wico1 with SMTP id o1so3651639wic.26 for ; Wed, 07 Mar 2012 11:49:59 -0800 (PST) Received: by 10.180.24.66 with SMTP id s2mr6535472wif.7.1331149799876; Wed, 07 Mar 2012 11:49:59 -0800 (PST) Received: from localhost ([109.131.36.23]) by mx.google.com with ESMTPS id w14sm25260363wiv.11.2012.03.07.11.49.57 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 07 Mar 2012 11:49:58 -0800 (PST) From: Pieter Praet To: Notmuch Mail Subject: [PATCH v4] test: emacs: new test "notmuch-search: change tags of all matching messages" Date: Wed, 7 Mar 2012 20:49:52 +0100 Message-Id: <1331149792-17192-1-git-send-email-pieter@praet.org> X-Mailer: git-send-email 1.7.8.1 In-Reply-To: <1329936867-923-1-git-send-email-pieter@praet.org> References: <1329936867-923-1-git-send-email-pieter@praet.org> X-Gm-Message-State: ALoCoQkFbtqP3CmQBa+G1G5DLiEht/C+Q95mv+jWWAMM04L6JaRATLRZsPeKq1KAh6PB6YA1inY4 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Mar 2012 19:50:02 -0000 * test/emacs-search: - New subtest "notmuch-search: change tags of all matching messages": `notmuch-search-tag-all' (bound to "*") adds and removes tags to/from all messages which match the query used to populate the current search buffer. --- Moved to a separate file to prevent a merge conflict when applied in conjunction with the patches listed @ id:"877gz4dnl2.fsf@praet.org". test/emacs-search | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ test/notmuch-test | 1 + 2 files changed, 49 insertions(+), 0 deletions(-) create mode 100755 test/emacs-search diff --git a/test/emacs-search b/test/emacs-search new file mode 100755 index 0000000..1cd8a89 --- /dev/null +++ b/test/emacs-search @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +test_description="Emacs notmuch-search-mode" +. test-lib.sh + +EXPECTED=$TEST_DIRECTORY/emacs-show.expected-output + +add_email_corpus + + +test_begin_subtest "notmuch-search: change tags of all matching messages" +old_tag="inbox" +new_tag="xobni" +filter="AND from:cworth" + +# Get initial tag counts and prevent false positives/negatives +old_tag_count_1=$(notmuch count tag:"${old_tag}" "${filter}") +new_tag_count_1=$(notmuch count tag:"${new_tag}" "${filter}") +test "${old_tag_count_1}" = "0" && old_tag_count_1="Need >0 matches!" +test "${new_tag_count_1}" = "0" || new_tag_count_1="Need 0 matches!" + +# Change tags of all matching messages and get tag counts +test_emacs "(notmuch-search \"tag:${old_tag} ${filter}\") + (notmuch-test-wait) + (notmuch-search-tag-all \"-${old_tag}\" \"+${new_tag}\")" +old_tag_count_2=$(notmuch count tag:"${old_tag}" "${filter}") +new_tag_count_2=$(notmuch count tag:"${new_tag}" "${filter}") + +# Revert tag changes and get tag counts +test_emacs "(notmuch-search \"tag:${new_tag} ${filter}\") + (notmuch-test-wait) + (notmuch-search-tag-all \"+${old_tag}\" \"-${new_tag}\")" +old_tag_count_3=$(notmuch count tag:"${old_tag}" "${filter}") +new_tag_count_3=$(notmuch count tag:"${new_tag}" "${filter}") + +# ... and verify the results +output=" +before: old:${old_tag_count_1} new:${new_tag_count_1} +after: old:${old_tag_count_2} new:${new_tag_count_2} +restored: old:${old_tag_count_3} new:${new_tag_count_3}" +expected=" +before: old:${old_tag_count_1} new:0 +after: old:0 new:${old_tag_count_1} +restored: old:${old_tag_count_1} new:0" +test_expect_equal "$output" "$expected" + + +test_done diff --git a/test/notmuch-test b/test/notmuch-test index e14d34e..81d0d7f 100755 --- a/test/notmuch-test +++ b/test/notmuch-test @@ -54,6 +54,7 @@ TESTS=" argument-parsing emacs-test-functions emacs-address-cleaning + emacs-search emacs-show " TESTS=${NOTMUCH_TESTS:=$TESTS} -- 1.7.8.1