unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Jani Nikula <jani@nikula.org>
To: Michal Nazarewicz <mina86@mina86.com>, notmuch@notmuchmail.org
Subject: Re: [PATCH 1/3] test: fix count test
Date: Wed, 05 Dec 2012 09:05:00 +0100	[thread overview]
Message-ID: <877gowudoz.fsf@nikula.org> (raw)
In-Reply-To: <xa1tfw3l2zd7.fsf@mina86.com>

On Wed, 05 Dec 2012, Michal Nazarewicz <mina86@mina86.com> wrote:
> On Tue, Dec 04 2012, Jani Nikula wrote:
>> The quoting for ${SEARCH} is broken when it's supposed to be '*', and
>
> Why is it broken?  It does not appear to be broken to me and in fact the
> test passes.

This is exactly why nobody noticed before. It looks all right and the
test passes...

>> it seems tricky to get it right. Just drop the variable and use '*'
>> directly. Before this, none of the messages ever matched, and the test
>> was comparing zeros.

...but the query does not find anything, and the test compares zero
results to zero results. Please try this patch, which should pass if
everything were all right:

diff --git a/test/count b/test/count
index 300b171..ecae40e 100755
--- a/test/count
+++ b/test/count
@@ -6,6 +6,11 @@ add_email_corpus
 
 SEARCH="\"*\""
 
+test_begin_subtest "check the query"
+test_expect_equal \
+    "`notmuch count ${SEARCH}`" \
+    "`notmuch count '*'`"
+
 test_begin_subtest "message count is the default for notmuch count"
 test_expect_equal \
     "`notmuch search --output=messages ${SEARCH} | wc -l`" \

-- 

At least for me this produces:

 FAIL   check the query
 --- count.1.expected   2012-12-05 08:01:09.004751327 +0000
 +++ count.1.output     2012-12-05 08:01:09.004751327 +0000
 @@ -1 +1 @@
 -52
 +0

And because it seems to be really hard to get the quoting right, and
keep it that way, I think it's more robust just to s/${SEARCH}/'*'/.


BR,
Jani.


>> ---
>>  test/count |   23 ++++++++++-------------
>>  1 file changed, 10 insertions(+), 13 deletions(-)
>>
>> diff --git a/test/count b/test/count
>> index 300b171..8e587ff 100755
>> --- a/test/count
>> +++ b/test/count
>> @@ -4,37 +4,34 @@ test_description='"notmuch count" for messages and threads'
>>  
>>  add_email_corpus
>>  
>> -SEARCH="\"*\""
>> -
>>  test_begin_subtest "message count is the default for notmuch count"
>>  test_expect_equal \
>> -    "`notmuch search --output=messages ${SEARCH} | wc -l`" \
>> -    "`notmuch count ${SEARCH}`"
>> +    "`notmuch search --output=messages '*' | wc -l`" \
>> +    "`notmuch count '*'`"
>>  
>>  test_begin_subtest "message count with --output=messages"
>>  test_expect_equal \
>> -    "`notmuch search --output=messages ${SEARCH} | wc -l`" \
>> -    "`notmuch count --output=messages ${SEARCH}`"
>> +    "`notmuch search --output=messages '*' | wc -l`" \
>> +    "`notmuch count --output=messages '*'`"
>>  
>>  test_begin_subtest "thread count with --output=threads"
>>  test_expect_equal \
>> -    "`notmuch search --output=threads ${SEARCH} | wc -l`" \
>> -    "`notmuch count --output=threads ${SEARCH}`"
>> +    "`notmuch search --output=threads '*' | wc -l`" \
>> +    "`notmuch count --output=threads '*'`"
>>  
>>  test_begin_subtest "thread count is the default for notmuch search"
>>  test_expect_equal \
>> -    "`notmuch search ${SEARCH} | wc -l`" \
>> -    "`notmuch count --output=threads ${SEARCH}`"
>> +    "`notmuch search '*' | wc -l`" \
>> +    "`notmuch count --output=threads '*'`"
>>  
>> -SEARCH="from:cworth and not from:cworth"
>>  test_begin_subtest "count with no matching messages"
>>  test_expect_equal \
>>      "0" \
>> -    "`notmuch count --output=messages ${SEARCH}`"
>> +    "`notmuch count --output=messages from:cworth and not from:cworth`"
>>  
>>  test_begin_subtest "count with no matching threads"
>>  test_expect_equal \
>>      "0" \
>> -    "`notmuch count --output=threads ${SEARCH}`"
>> +    "`notmuch count --output=threads from:cworth and not from:cworth`"
>>  
>>  test_done
>
> -- 
> Best regards,                                         _     _
> .o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
> ..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
> ooo +----<email/xmpp: mpn@google.com>--------------ooO--(_)--Ooo--

  reply	other threads:[~2012-12-05  8:05 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-04 21:26 [PATCH 0/3] test fixes, portability Jani Nikula
2012-12-04 21:26 ` [PATCH 1/3] test: fix count test Jani Nikula
2012-12-04 23:04   ` Michal Nazarewicz
2012-12-05  8:05     ` Jani Nikula [this message]
2012-12-05 20:13       ` Michal Nazarewicz
2012-12-05 21:23         ` Jani Nikula
2012-12-06 13:45       ` Michal Nazarewicz
2012-12-04 21:26 ` [PATCH 2/3] test: wrap 'wc -l' results in arithmetic evaluation to strip whitespace Jani Nikula
2012-12-04 21:26 ` [PATCH 3/3] test: use perl instead of sed -r for portability Jani Nikula
2012-12-04 23:01   ` Michal Nazarewicz
2012-12-05  8:13     ` Jani Nikula
2012-12-04 22:55 ` [PATCH 0/3] test fixes, portability Tomi Ollila
2012-12-08 13:35 ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877gowudoz.fsf@nikula.org \
    --to=jani@nikula.org \
    --cc=mina86@mina86.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).