Re: [PATCH 1/3] test: fix count test
authorJani Nikula <jani@nikula.org>
Wed, 5 Dec 2012 08:05:00 +0000 (09:05 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:51:30 +0000 (09:51 -0800)
5a/a0ddb85c294c681c675393485c98a5c3a3e4a3 [new file with mode: 0644]

diff --git a/5a/a0ddb85c294c681c675393485c98a5c3a3e4a3 b/5a/a0ddb85c294c681c675393485c98a5c3a3e4a3
new file mode 100644 (file)
index 0000000..1dd7b4c
--- /dev/null
@@ -0,0 +1,189 @@
+Return-Path: <jani@nikula.org>\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 DE9AF431FB6\r
+       for <notmuch@notmuchmail.org>; Wed,  5 Dec 2012 00:05:13 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[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 Cu2zubNyPTDE for <notmuch@notmuchmail.org>;\r
+       Wed,  5 Dec 2012 00:05:09 -0800 (PST)\r
+Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com\r
+       [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 7FD2C431FAE\r
+       for <notmuch@notmuchmail.org>; Wed,  5 Dec 2012 00:05:09 -0800 (PST)\r
+Received: by mail-bk0-f53.google.com with SMTP id j5so2483076bkw.26\r
+       for <notmuch@notmuchmail.org>; Wed, 05 Dec 2012 00:05:06 -0800 (PST)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=google.com; s=20120113;\r
+       h=from:to:subject:in-reply-to:references:user-agent:date:message-id\r
+       :mime-version:content-type:content-transfer-encoding\r
+       :x-gm-message-state;\r
+       bh=9OMgv09kG5TCAVbaJL40xkKo8m/w1VEr8rsEfsSvNL0=;\r
+       b=h+sgLGqxTUKFdYWLw9yIyjZs4Zs1lzr4QnE+DOt4GSVJSy3BQIhui9ZfTNoo5bUCNX\r
+       M18c1Vhr/G7GAyv7uz2iFqU+0m5mSvKJ6wA2pIQeuaFObUTK8JRag7RDpbqpvd+MX8Xw\r
+       RhSFWfJ1L8fbCvCFBGzVjCB2ZCCg30IqmVGjXVDhkZS450MzPbnqCRIwJEmAIeDB/X5r\r
+       yubAdTQ94RXRqCF6Vq2JH8iiAXME3NfVzA3GnXiuUjcj+AcJ9em3qVGCtVDDQzgn1nza\r
+       7aCEuzlxYqTimhRAbeQ+aql/ZXD/cV0XlQuPanc8u/CLL/BLZzFpn9kmYxUn/8LUMaP8\r
+       YFQw==\r
+Received: by 10.204.157.26 with SMTP id z26mr4970992bkw.101.1354694706683;\r
+       Wed, 05 Dec 2012 00:05:06 -0800 (PST)\r
+Received: from localhost ([2001:4b98:dc0:43:216:3eff:fe1b:25f3])\r
+       by mx.google.com with ESMTPS id f24sm2804896bkv.7.2012.12.05.00.05.04\r
+       (version=SSLv3 cipher=OTHER); Wed, 05 Dec 2012 00:05:05 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: Michal Nazarewicz <mina86@mina86.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 1/3] test: fix count test\r
+In-Reply-To: <xa1tfw3l2zd7.fsf@mina86.com>\r
+References: <cover.1354656085.git.jani@nikula.org>\r
+       <0ca075ab5fb0d886d0235c1f0549db8b0b14c9b5.1354656085.git.jani@nikula.org>\r
+       <xa1tfw3l2zd7.fsf@mina86.com>\r
+User-Agent: Notmuch/0.14+137~gda2ee8b (http://notmuchmail.org) Emacs/23.2.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Wed, 05 Dec 2012 09:05:00 +0100\r
+Message-ID: <877gowudoz.fsf@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Transfer-Encoding: quoted-printable\r
+X-Gm-Message-State:\r
+ ALoCoQk4193NvaBs+nQcFJj69Fwh98YPfN+UEONtcv1x2qR34yraTB9egxI+1L8ijOJX0nVTS21f\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: Wed, 05 Dec 2012 08:05:14 -0000\r
+\r
+On Wed, 05 Dec 2012, Michal Nazarewicz <mina86@mina86.com> wrote:\r
+> On Tue, Dec 04 2012, Jani Nikula wrote:\r
+>> The quoting for ${SEARCH} is broken when it's supposed to be '*', and\r
+>\r
+> Why is it broken?  It does not appear to be broken to me and in fact the\r
+> test passes.\r
+\r
+This is exactly why nobody noticed before. It looks all right and the\r
+test passes...\r
+\r
+>> it seems tricky to get it right. Just drop the variable and use '*'\r
+>> directly. Before this, none of the messages ever matched, and the test\r
+>> was comparing zeros.\r
+\r
+...but the query does not find anything, and the test compares zero\r
+results to zero results. Please try this patch, which should pass if\r
+everything were all right:\r
+\r
+diff --git a/test/count b/test/count\r
+index 300b171..ecae40e 100755\r
+--- a/test/count\r
++++ b/test/count\r
+@@ -6,6 +6,11 @@ add_email_corpus\r
+=20\r
+ SEARCH=3D"\"*\""\r
+=20\r
++test_begin_subtest "check the query"\r
++test_expect_equal \\r
++    "`notmuch count ${SEARCH}`" \\r
++    "`notmuch count '*'`"\r
++\r
+ test_begin_subtest "message count is the default for notmuch count"\r
+ test_expect_equal \\r
+     "`notmuch search --output=3Dmessages ${SEARCH} | wc -l`" \\r
+\r
+--=20\r
+\r
+At least for me this produces:\r
+\r
+ FAIL   check the query\r
+ --- count.1.expected   2012-12-05 08:01:09.004751327 +0000\r
+ +++ count.1.output     2012-12-05 08:01:09.004751327 +0000\r
+ @@ -1 +1 @@\r
+ -52\r
+ +0\r
+\r
+And because it seems to be really hard to get the quoting right, and\r
+keep it that way, I think it's more robust just to s/${SEARCH}/'*'/.\r
+\r
+\r
+BR,\r
+Jani.\r
+\r
+\r
+>> ---\r
+>>  test/count |   23 ++++++++++-------------\r
+>>  1 file changed, 10 insertions(+), 13 deletions(-)\r
+>>\r
+>> diff --git a/test/count b/test/count\r
+>> index 300b171..8e587ff 100755\r
+>> --- a/test/count\r
+>> +++ b/test/count\r
+>> @@ -4,37 +4,34 @@ test_description=3D'"notmuch count" for messages and t=\r
+hreads'\r
+>>=20=20\r
+>>  add_email_corpus\r
+>>=20=20\r
+>> -SEARCH=3D"\"*\""\r
+>> -\r
+>>  test_begin_subtest "message count is the default for notmuch count"\r
+>>  test_expect_equal \\r
+>> -    "`notmuch search --output=3Dmessages ${SEARCH} | wc -l`" \\r
+>> -    "`notmuch count ${SEARCH}`"\r
+>> +    "`notmuch search --output=3Dmessages '*' | wc -l`" \\r
+>> +    "`notmuch count '*'`"\r
+>>=20=20\r
+>>  test_begin_subtest "message count with --output=3Dmessages"\r
+>>  test_expect_equal \\r
+>> -    "`notmuch search --output=3Dmessages ${SEARCH} | wc -l`" \\r
+>> -    "`notmuch count --output=3Dmessages ${SEARCH}`"\r
+>> +    "`notmuch search --output=3Dmessages '*' | wc -l`" \\r
+>> +    "`notmuch count --output=3Dmessages '*'`"\r
+>>=20=20\r
+>>  test_begin_subtest "thread count with --output=3Dthreads"\r
+>>  test_expect_equal \\r
+>> -    "`notmuch search --output=3Dthreads ${SEARCH} | wc -l`" \\r
+>> -    "`notmuch count --output=3Dthreads ${SEARCH}`"\r
+>> +    "`notmuch search --output=3Dthreads '*' | wc -l`" \\r
+>> +    "`notmuch count --output=3Dthreads '*'`"\r
+>>=20=20\r
+>>  test_begin_subtest "thread count is the default for notmuch search"\r
+>>  test_expect_equal \\r
+>> -    "`notmuch search ${SEARCH} | wc -l`" \\r
+>> -    "`notmuch count --output=3Dthreads ${SEARCH}`"\r
+>> +    "`notmuch search '*' | wc -l`" \\r
+>> +    "`notmuch count --output=3Dthreads '*'`"\r
+>>=20=20\r
+>> -SEARCH=3D"from:cworth and not from:cworth"\r
+>>  test_begin_subtest "count with no matching messages"\r
+>>  test_expect_equal \\r
+>>      "0" \\r
+>> -    "`notmuch count --output=3Dmessages ${SEARCH}`"\r
+>> +    "`notmuch count --output=3Dmessages from:cworth and not from:cworth=\r
+`"\r
+>>=20=20\r
+>>  test_begin_subtest "count with no matching threads"\r
+>>  test_expect_equal \\r
+>>      "0" \\r
+>> -    "`notmuch count --output=3Dthreads ${SEARCH}`"\r
+>> +    "`notmuch count --output=3Dthreads from:cworth and not from:cworth`"\r
+>>=20=20\r
+>>  test_done\r
+>\r
+> --=20\r
+> Best regards,                                         _     _\r
+> .o. | Liege of Serenely Enlightened Majesty of      o' \,=3D./ `o\r
+> ..o | Computer Science,  Micha=C5=82 =E2=80=9Cmina86=E2=80=9D Nazarewicz =\r
+   (o o)\r
+> ooo +----<email/xmpp: mpn@google.com>--------------ooO--(_)--Ooo--\r