From 565a794a30944ed297768dd583de5a97239b256b Mon Sep 17 00:00:00 2001 From: Dmitry Kurochkin Date: Thu, 2 Feb 2012 03:25:40 +0400 Subject: [PATCH] Re: [PATCH v4] test: emacs: add test for `notmuch-search-operate-all' --- 08/487f0a5d1f4dc83c76ee290f93ba9f4eda3463 | 310 ++++++++++++++++++++++ 1 file changed, 310 insertions(+) create mode 100644 08/487f0a5d1f4dc83c76ee290f93ba9f4eda3463 diff --git a/08/487f0a5d1f4dc83c76ee290f93ba9f4eda3463 b/08/487f0a5d1f4dc83c76ee290f93ba9f4eda3463 new file mode 100644 index 000000000..fd3bdf853 --- /dev/null +++ b/08/487f0a5d1f4dc83c76ee290f93ba9f4eda3463 @@ -0,0 +1,310 @@ +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 07ADF431FAF + for ; Wed, 1 Feb 2012 15:26:59 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.799 +X-Spam-Level: +X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_FROM=0.001, 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 67WbPh9gcmx1 for ; + Wed, 1 Feb 2012 15:26:58 -0800 (PST) +Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com + [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 995EA431FAE + for ; Wed, 1 Feb 2012 15:26:57 -0800 (PST) +Received: by bke11 with SMTP id 11so1713715bke.26 + for ; Wed, 01 Feb 2012 15:26:56 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; + h=from:to:cc:subject:in-reply-to:references:user-agent:date + :message-id:mime-version:content-type; + bh=uP67WGWVrYqQgk2NUEOVjtoflXMIGB+w+zdhX1TK4Lo=; + b=AwVl80YCzalsc9mBL+aJ8XFc+XXi0bWN5pAJdPFhnfVG6B5uA+kAR2kYshSABSR/Af + Sgpvxn2BIy14qDkX3aufyrp2Fyf8KlR9H67JXgbBs0q59AamlAYQRhrLxBZ/pmWGo6bS + ujieHVBxSVE3cJr/4ghdt3AzxBrR432nKMucQ= +Received: by 10.204.156.5 with SMTP id u5mr244510bkw.84.1328138814858; + Wed, 01 Feb 2012 15:26:54 -0800 (PST) +Received: from localhost ([91.144.186.21]) + by mx.google.com with ESMTPS id 20sm1383152bkr.0.2012.02.01.15.26.53 + (version=TLSv1/SSLv3 cipher=OTHER); + Wed, 01 Feb 2012 15:26:53 -0800 (PST) +From: Dmitry Kurochkin +To: Pieter Praet +Subject: Re: [PATCH v4] test: emacs: add test for `notmuch-search-operate-all' +In-Reply-To: <87liomb8gv.fsf@praet.org> +References: <1327599289-16865-1-git-send-email-dmitry.kurochkin@gmail.com> + <1327909550-6788-1-git-send-email-pieter@praet.org> + <87y5spober.fsf@gmail.com> <877h067jn3.fsf@praet.org> + <87hazamywi.fsf@gmail.com> <87liomb8gv.fsf@praet.org> +User-Agent: Notmuch/0.11+139~gd9b7cab (http://notmuchmail.org) Emacs/23.3.1 + (x86_64-pc-linux-gnu) +Date: Thu, 02 Feb 2012 03:25:40 +0400 +Message-ID: <8762fqm8zv.fsf@gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Cc: Notmuch Mail +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, 01 Feb 2012 23:26:59 -0000 + +Hi Pieter. + +On Wed, 01 Feb 2012 21:32:32 +0100, Pieter Praet wrote: +> On Wed, 01 Feb 2012 18:06:05 +0400, Dmitry Kurochkin wrote: +> > On Wed, 01 Feb 2012 14:44:48 +0100, Pieter Praet wrote: +> > > On Mon, 30 Jan 2012 12:13:48 +0400, Dmitry Kurochkin wrote: +> > > > Hi Pieter. +> > > > +> > > > On Mon, 30 Jan 2012 08:45:50 +0100, Pieter Praet wrote: +> > > > > `notmuch-search-operate-all' (bound to "*") adds and removes tags +> > > > > to/from all messages which match the query used to populate the +> > > > > current search buffer. +> > > > > +> > > > > --- +> > > > > +> > > > > Rebased to current master. +> > > > > +> > > > > Previous versions (chronologically): +> > > > > - id:"1309450108-2793-1-git-send-email-pieter@praet.org" +> > > > > - id:"1309762318-4530-5-git-send-email-pieter@praet.org" +> > > > > - id:"1310313335-4159-5-git-send-email-pieter@praet.org" +> > > > > +> > > > +> > > > This looks like a useful patch series. We definitely need more tests +> > > > for tagging operations in the Emacs UI. Do you plan to revive it? +> > > > +> > > +> > > Absolutely. In fact, it's still alive and kicking on a local branch :) +> > > +> > > +> > > > Note that not so long ago I posted a bunch of tagging-related patches +> > > > [1] that would conflict with this patch at least because of +> > > > `notmuch-search-operate-all' being renamed to `notmuch-search-tag-all'. +> > > > +> > > +> > > Nice series! Will probably be pushed in the next few days, +> > > so I'll hold off on resubmitting the tests until then. +> > > +> > > +> > > > > +> > > > > test/emacs | 19 +++++++++++++++++++ +> > > > > 1 files changed, 19 insertions(+), 0 deletions(-) +> > > > > +> > > > > diff --git a/test/emacs b/test/emacs +> > > > > index 8ca4c8a..e94ad94 100755 +> > > > > --- a/test/emacs +> > > > > +++ b/test/emacs +> > > > > @@ -124,6 +124,25 @@ test_emacs "(notmuch-show \"$os_x_darwin_thread\") +> > > > > output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize) +> > > > > 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)" +> > > > > +> > > > > +test_begin_subtest "Add/remove tags to/from all matching messages." +> > > > > +test_emacs '(notmuch-search "tag:inbox AND tags") +> > > > > + (notmuch-test-wait) +> > > > > + (notmuch-search-operate-all "+matching" "-inbox") +> > > > > + (notmuch-search "tag:matching AND NOT tag:inbox") +> > > > > + (notmuch-test-wait) +> > > > > + (test-output)' +> > > > > +cat <EXPECTED +> > > > > + 2009-11-18 [3/3] Adrian Perez de Castro, Keith Packard, Carl Worth [notmuch] Introducing myself (matching signed unread) +> > > > > + 2009-11-18 [1/3] Carl Worth, Israel Herraiz, Keith Packard [notmuch] New to the list (inbox matching unread) +> > > > > + 2009-11-18 [2/2] Keith Packard, Carl Worth [notmuch] [PATCH] Make notmuch-show 'X' (and 'x') commands remove inbox (and unread) tags (matching unread) +> > > > > + 2009-11-18 [1/2] Keith Packard, Alexander Botero-Lowry [notmuch] [PATCH] Create a default notmuch-show-hook that highlights URLs and uses word-wrap (inbox matching unread) +> > > > > + 2009-11-18 [1/1] Jan Janak [notmuch] [PATCH] notmuch new: Support for conversion of spool subdirectories into tags (matching unread) +> > > > > + 2009-11-18 [1/1] Stewart Smith [notmuch] [PATCH] Fix linking with gcc to use g++ to link in C++ libs. (matching unread) +> > > > > + 2009-11-17 [1/2] Ingmar Vanhassel, Carl Worth [notmuch] [PATCH] Typsos (inbox matching unread) +> > > > > +End of search results. +> > > > > +EOF +> > > > > +test_expect_equal_file OUTPUT EXPECTED +> > > > +> > > > I am worried that this test would break because of changes in other +> > > > tests. E.g. if a new test adds a new message which matches "tag:inbox +> > > > AND tags", this test would have to be updated. I think we should avoid +> > > > this. I see the following options here: +> > > > +> > > > * Search for messages which are less likely to change, e.g. "from:carl". +> > > > +> > > > * Rework the test to avoid using any fixed expected results, e.g.: +> > > > +> > > > - count all messages with tag:inbox +> > > > +> > > > - remove inbox tag, add some other distinct tag for all messages with +> > > > tag:inbox +> > > > +> > > > - count all messages with tag:inbox again, check that it is 0 +> > > > +> > > > - add the inbox tag back, remove the previously added tag, check the +> > > > message count +> > > > +> > > > I like the latter approach because it does not compare Emacs UI output +> > > > and hence would not break when that output changes. What do you think? +> > > > +> > > > Also, we should leave notmuch db in the same state as it was before the +> > > > test if possible. +> > > > +> > > +> > > Good point(s)! +> > > +> > > How about this: +> > > +> > > #+begin_src sh +> > > test_begin_subtest "Add/remove tags to/from all matching messages." +> > > expected=$(notmuch count from:cworth AND tag:inbox) +> > > test "${expected}" == "0" && expected="Need more matches!" # prevent false positives +> > > test_emacs "(notmuch-search \"from:cworth AND tag:inbox\") +> > > (notmuch-test-wait) +> > > (notmuch-search-operate-all \"+matching\" \"-inbox\")" +> > > output=$(notmuch count from:cworth AND tag:matching AND NOT tag:inbox) +> > > notmuch tag -matching +inbox -- from:cworth AND tag:matching AND NOT tag:inbox # restore db state! +> > > test_expect_equal "$output" "$expected" +> > > #+end_src +> > > +> > +> > I think "from:cworth" is not needed here. In my previous email I meant +> > this as an alternative option to testing using counts. +> > +> +> I know, but I decided to include it anyway, on the basis that it +> increases the probability of the search buffer containing threads with +> matched *as well as* unmatched messages, thus providing more insurance +> wrt `notmuch-search-operate-all' doing The Right Thing (TM). +> +> +> > Probably we should add more counts in the test? E.g.: +> > +> > * before tagging +> > - count tag:matching, it must be zero +> > +> > * after -inbox +matching +> > - count tag:matching, it must be equal to $expected +> > - count tag:inbox, it must be zero +> > +> > * after +inbox -matching +> > - count tag:matching, it must be zero +> > - count tag:inbox, it must be equal to $expected +> > +> > We can compare it in a single test_expect_equal call. Actual and +> > expected results may be smth like: +> > +> > initial tag:matching count: n1 +> > tag:inbox count after tagging: n2 +> > tag:matching count after tagging: n3 +> > tag:inbox count after restoring: n4 +> > tag:matching count after restoring: n5 +> > +> > In case of failure, we should get a nice diff. +> > +> +> OK, how about this?: +> + +Looks good. Minor comments below. + +> #+begin_src sh +> test_begin_subtest "Add/remove tags to/from all matching messages." + +We should add notmuch-search here, because similar functionality would +be available in notmuch-show soon. Also, I suggest replacing +"add/remove tags to/from" with "change tags". Consider: + + Change tags for all matching threads in notmuch-search. + +> old="inbox" ; new="xobni" ; filter="AND from:cworth" + +I would prefer this to be on separate lines. + +> o1=$(notmuch count tag:"${old}" "${filter}") ; n1=$(notmuch count tag:"${new}" "${filter}") + +I would definately prefer this to be on separate lines. + +Also, please consider s/o1/old_count_1, s/n1/new_count_1/ and so on. + +> test "${o1}" == "0" && o1="Need more matches!" # prevent false positives +> test_emacs "(notmuch-search \"tag:${old} ${filter}\") +> (notmuch-test-wait) +> (notmuch-search-operate-all \"+${new}\" \"-${old}\")" +> o2=$(notmuch count tag:"${old}" "${filter}") ; n2=$(notmuch count tag:"${new}" "${filter}") + +Same comment about separate lines. + +> notmuch tag -"${new}" +"${old}" -- tag:"${new}" "${filter}" AND NOT tag:"${old}"} # restore db state! + +Why "AND NOT tag:$old" is needed here? + +Since the line is too long, please move the comment to a separate line +above. + +Since we are testing Emacs UI, should we restore db though Emacs as +well? + +> o3=$(notmuch count tag:"${old}" "${filter}") ; n3=$(notmuch count tag:"${new}" "${filter}") + +Same comment about separate lines. + +> output=" +> before: ${old}=$o1 ${new}=$n1 +> after: ${old}=$o2 ${new}=$n2 +> restored: ${old}=$o3 ${new}=$n3" +> expected=" +> before: ${old}=$o1 ${new}=0 +> after: ${old}=0 ${new}=$o1 +> restored: ${old}=$o1 ${new}=0" + +I would change "=" to ":". + +Regards, + Dmitry + +> test_expect_equal "$output" "$expected" +> #+end_src +> +> +> > Regards, +> > Dmitry +> > +> > > +> > > > Regards, +> > > > Dmitry +> > > > +> > > > [1] id:"1327901644-15799-1-git-send-email-dmitry.kurochkin@gmail.com" +> > > > +> > > > > + +> > > > > test_begin_subtest "Message with .. in Message-Id:" +> > > > > add_message [id]=123..456@example '[subject]="Message with .. in Message-Id"' +> > > > > test_emacs '(notmuch-search "id:\"123..456@example\"") +> > > > > -- +> > > > > 1.7.8.1 +> > > > > +> > > > _______________________________________________ +> > > > notmuch mailing list +> > > > notmuch@notmuchmail.org +> > > > http://notmuchmail.org/mailman/listinfo/notmuch +> > > +> > > +> > > Peace +> > > +> > > -- +> > > Pieter +> +> +> Peace +> +> -- +> Pieter -- 2.26.2