From 78f4ef4c1488c02e01cf053dd8fa33ffba440674 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Wed, 5 Dec 2012 09:05:00 +0100 Subject: [PATCH] Re: [PATCH 1/3] test: fix count test --- 5a/a0ddb85c294c681c675393485c98a5c3a3e4a3 | 189 ++++++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 5a/a0ddb85c294c681c675393485c98a5c3a3e4a3 diff --git a/5a/a0ddb85c294c681c675393485c98a5c3a3e4a3 b/5a/a0ddb85c294c681c675393485c98a5c3a3e4a3 new file mode 100644 index 000000000..1dd7b4c53 --- /dev/null +++ b/5a/a0ddb85c294c681c675393485c98a5c3a3e4a3 @@ -0,0 +1,189 @@ +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 DE9AF431FB6 + for ; Wed, 5 Dec 2012 00:05:13 -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 Cu2zubNyPTDE for ; + Wed, 5 Dec 2012 00:05:09 -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 7FD2C431FAE + for ; Wed, 5 Dec 2012 00:05:09 -0800 (PST) +Received: by mail-bk0-f53.google.com with SMTP id j5so2483076bkw.26 + for ; Wed, 05 Dec 2012 00:05:06 -0800 (PST) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=google.com; s=20120113; + h=from:to:subject:in-reply-to:references:user-agent:date:message-id + :mime-version:content-type:content-transfer-encoding + :x-gm-message-state; + bh=9OMgv09kG5TCAVbaJL40xkKo8m/w1VEr8rsEfsSvNL0=; + b=h+sgLGqxTUKFdYWLw9yIyjZs4Zs1lzr4QnE+DOt4GSVJSy3BQIhui9ZfTNoo5bUCNX + M18c1Vhr/G7GAyv7uz2iFqU+0m5mSvKJ6wA2pIQeuaFObUTK8JRag7RDpbqpvd+MX8Xw + RhSFWfJ1L8fbCvCFBGzVjCB2ZCCg30IqmVGjXVDhkZS450MzPbnqCRIwJEmAIeDB/X5r + yubAdTQ94RXRqCF6Vq2JH8iiAXME3NfVzA3GnXiuUjcj+AcJ9em3qVGCtVDDQzgn1nza + 7aCEuzlxYqTimhRAbeQ+aql/ZXD/cV0XlQuPanc8u/CLL/BLZzFpn9kmYxUn/8LUMaP8 + YFQw== +Received: by 10.204.157.26 with SMTP id z26mr4970992bkw.101.1354694706683; + Wed, 05 Dec 2012 00:05:06 -0800 (PST) +Received: from localhost ([2001:4b98:dc0:43:216:3eff:fe1b:25f3]) + by mx.google.com with ESMTPS id f24sm2804896bkv.7.2012.12.05.00.05.04 + (version=SSLv3 cipher=OTHER); Wed, 05 Dec 2012 00:05:05 -0800 (PST) +From: Jani Nikula +To: Michal Nazarewicz , notmuch@notmuchmail.org +Subject: Re: [PATCH 1/3] test: fix count test +In-Reply-To: +References: + <0ca075ab5fb0d886d0235c1f0549db8b0b14c9b5.1354656085.git.jani@nikula.org> + +User-Agent: Notmuch/0.14+137~gda2ee8b (http://notmuchmail.org) Emacs/23.2.1 + (x86_64-pc-linux-gnu) +Date: Wed, 05 Dec 2012 09:05:00 +0100 +Message-ID: <877gowudoz.fsf@nikula.org> +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Transfer-Encoding: quoted-printable +X-Gm-Message-State: + ALoCoQk4193NvaBs+nQcFJj69Fwh98YPfN+UEONtcv1x2qR34yraTB9egxI+1L8ijOJX0nVTS21f +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, 05 Dec 2012 08:05:14 -0000 + +On Wed, 05 Dec 2012, Michal Nazarewicz 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 +=20 + SEARCH=3D"\"*\"" +=20 ++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=3Dmessages ${SEARCH} | wc -l`" \ + +--=20 + +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=3D'"notmuch count" for messages and t= +hreads' +>>=20=20 +>> add_email_corpus +>>=20=20 +>> -SEARCH=3D"\"*\"" +>> - +>> test_begin_subtest "message count is the default for notmuch count" +>> test_expect_equal \ +>> - "`notmuch search --output=3Dmessages ${SEARCH} | wc -l`" \ +>> - "`notmuch count ${SEARCH}`" +>> + "`notmuch search --output=3Dmessages '*' | wc -l`" \ +>> + "`notmuch count '*'`" +>>=20=20 +>> test_begin_subtest "message count with --output=3Dmessages" +>> test_expect_equal \ +>> - "`notmuch search --output=3Dmessages ${SEARCH} | wc -l`" \ +>> - "`notmuch count --output=3Dmessages ${SEARCH}`" +>> + "`notmuch search --output=3Dmessages '*' | wc -l`" \ +>> + "`notmuch count --output=3Dmessages '*'`" +>>=20=20 +>> test_begin_subtest "thread count with --output=3Dthreads" +>> test_expect_equal \ +>> - "`notmuch search --output=3Dthreads ${SEARCH} | wc -l`" \ +>> - "`notmuch count --output=3Dthreads ${SEARCH}`" +>> + "`notmuch search --output=3Dthreads '*' | wc -l`" \ +>> + "`notmuch count --output=3Dthreads '*'`" +>>=20=20 +>> test_begin_subtest "thread count is the default for notmuch search" +>> test_expect_equal \ +>> - "`notmuch search ${SEARCH} | wc -l`" \ +>> - "`notmuch count --output=3Dthreads ${SEARCH}`" +>> + "`notmuch search '*' | wc -l`" \ +>> + "`notmuch count --output=3Dthreads '*'`" +>>=20=20 +>> -SEARCH=3D"from:cworth and not from:cworth" +>> test_begin_subtest "count with no matching messages" +>> test_expect_equal \ +>> "0" \ +>> - "`notmuch count --output=3Dmessages ${SEARCH}`" +>> + "`notmuch count --output=3Dmessages from:cworth and not from:cworth= +`" +>>=20=20 +>> test_begin_subtest "count with no matching threads" +>> test_expect_equal \ +>> "0" \ +>> - "`notmuch count --output=3Dthreads ${SEARCH}`" +>> + "`notmuch count --output=3Dthreads from:cworth and not from:cworth`" +>>=20=20 +>> test_done +> +> --=20 +> Best regards, _ _ +> .o. | Liege of Serenely Enlightened Majesty of o' \,=3D./ `o +> ..o | Computer Science, Micha=C5=82 =E2=80=9Cmina86=E2=80=9D Nazarewicz = + (o o) +> ooo +------------------ooO--(_)--Ooo-- -- 2.26.2