[PATCH v2 4/4] test: emacs: new test "notmuch-search: change tags of all matching messages"

Pieter Praet pieter at praet.org
Wed Feb 22 10:53:55 PST 2012


On Mon, 20 Feb 2012 16:25:05 +0400, Dmitry Kurochkin <dmitry.kurochkin at gmail.com> wrote:
> On Sun, 19 Feb 2012 21:38:28 +0100, Pieter Praet <pieter at praet.org> wrote:
> > `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.
> 
> LGTM.  But since you will need to send a new version to address Tomi's
> comments anyway, below are few minor comments.
> 
> Regards,
>   Dmitry
> 
> > ---
> >  test/emacs |   32 ++++++++++++++++++++++++++++++++
> >  1 files changed, 32 insertions(+), 0 deletions(-)
> > 
> > diff --git a/test/emacs b/test/emacs
> > index b0fb760..1db8540 100755
> > --- a/test/emacs
> > +++ b/test/emacs
> > @@ -124,6 +124,38 @@ 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 "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 1+ matches!"
> 
> Consider s/1+/>0/.
> 
> > +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"
> > +
> 
> I would add a newline before every commented block.
>

Agreed, on all accounts.


> Regards,
>   Dmitry
> 
> >  test_begin_subtest "Message with .. in Message-Id:"
> >  add_message [id]=123..456 at example '[subject]="Message with .. in Message-Id"'
> >  test_emacs '(notmuch-search "id:\"123..456 at example\"")
> > -- 
> > 1.7.8.1
> > 


Peace

-- 
Pieter


More information about the notmuch mailing list