From d3560bccb7ddf4df55a7e5061dd5d4a356a9ea7e Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Thu, 31 May 2012 08:28:24 +0000 Subject: [PATCH] Re: [PATCH v2 7/9] test/count: fix numeric comparision tests on FreeBSD --- 22/b82a04e87662c8e47556f871aed454b6ee7d9d | 122 ++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 22/b82a04e87662c8e47556f871aed454b6ee7d9d diff --git a/22/b82a04e87662c8e47556f871aed454b6ee7d9d b/22/b82a04e87662c8e47556f871aed454b6ee7d9d new file mode 100644 index 000000000..aa23b6c89 --- /dev/null +++ b/22/b82a04e87662c8e47556f871aed454b6ee7d9d @@ -0,0 +1,122 @@ +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 394EE431FB6 + for ; Thu, 31 May 2012 01:28:31 -0700 (PDT) +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 mXTPFzHpc6de for ; + Thu, 31 May 2012 01:28:30 -0700 (PDT) +Received: from mail-vb0-f53.google.com (mail-vb0-f53.google.com + [209.85.212.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 65241431FAF + for ; Thu, 31 May 2012 01:28:30 -0700 (PDT) +Received: by vbbfc26 with SMTP id fc26so641586vbb.26 + for ; Thu, 31 May 2012 01:28:29 -0700 (PDT) +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:x-gm-message-state; + bh=jC/d4Xg4c5RkXjuWnQezPJITZ3Hgigtwerv96FwW5j4=; + b=lGsG57Tme5TiBuKjgKM26MnRV4KgrsRUfdAyJbPBd/Q9FX3XCPEewIZhNQN7otLndf + iaFzCuIVtX/aZJ9BhkSLHT+SPAtcVeHkDlxxRDr/YB30VRhkCKURIdV3EE81qcLClAZ+ + pgAfUxBzsOUNf6C+bDqSpHnGD1tSuq91/NuRMD2F88kBtyketQLyUEs7mI5qkYYRFjTt + 8iNioSLSY0qCD7NB9nAJGHtlrW8TdcX7A8b9tjg9trRezUL84rV/cmgLG07VFpI+bgla + F6hiqYsuux3S3stmLkiWijZUejzJnGvHiIFQ+dHYMHP9TNXvX0t8NszePTqwR7sjvL1i + vdsQ== +Received: by 10.220.241.130 with SMTP id le2mr7243345vcb.38.1338452909690; + Thu, 31 May 2012 01:28:29 -0700 (PDT) +Received: from localhost (nikula.org. [92.243.24.172]) + by mx.google.com with ESMTPS id i19sm3750912vdt.18.2012.05.31.01.28.27 + (version=SSLv3 cipher=OTHER); Thu, 31 May 2012 01:28:28 -0700 (PDT) +From: Jani Nikula +To: Tomi Ollila , + Jameson Graef Rollins , + Mike Kelly , notmuch@notmuchmail.org +Subject: Re: [PATCH v2 7/9] test/count: fix numeric comparision tests on + FreeBSD +In-Reply-To: +References: <1338361324-57289-1-git-send-email-pioto@pioto.org> + <1338361324-57289-8-git-send-email-pioto@pioto.org> + <877gvtxvka.fsf@servo.finestructure.net> + +User-Agent: Notmuch/0.13+9~ga1668d0 (http://notmuchmail.org) Emacs/23.1.1 + (i686-pc-linux-gnu) +Date: Thu, 31 May 2012 08:28:24 +0000 +Message-ID: <874nqw4uvr.fsf@nikula.org> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Gm-Message-State: + ALoCoQkrNFDNddCV3PnikfuzAydYQxHNP2KVhylomc2a+5Xaor8lvnOEwaIPdqCrTvfhH2OkIRBz +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: Thu, 31 May 2012 08:28:31 -0000 + +On Wed, 30 May 2012, Tomi Ollila wrote: +> On Wed, May 30 2012, Jameson Graef Rollins wrote: +> +>> On Wed, May 30 2012, Mike Kelly wrote: +>>> FreeBSD's `wc -l` includes some white space in front of the number. +>>> Instead, we add a test_expect_equal_num() to test-lib.sh, which ensures +>>> we do a proper numeric comparision, and in a portable way. +>> +>> Is there a way we can avoid adding another new test function here? This +>> new function is almost completely identical with the old one, except +>> that it uses "test .. -eq" instead of "[ .. =". If the problem is just +>> that the arguments occasionally contain superfluous spaces, I would +>> rather see the existing function just strip the spaces. Of maybe add an +>> option to the test to ask for arithmetic rather than string comparison. +>> That would be preferable to introducing an new function that is +>> confusingly similar to an existing one. +> +> I liked Mike's suggestion as I also thought the options; stripping in +> test_expect_equal cannot be done as there might be whitespace differences +> which mean failure arguments to test_expect_equal cannot be given without +> quotes as variable might be split into multiple args. if test_expect_equal +> were changed to take comparison argument (like '-eq' or '=') then all +> calls would need to be changes (and function name could be changed to +> something more generic...) None of these sounded as good options... +> +> But, there is at least one option more: +> +> test_expect_equal \ +> - "`notmuch search --output=messages ${SEARCH} | wc -l`" \ +> + "$((`notmuch search --output=messages ${SEARCH} | wc -l`))" \ +> "`notmuch count --output=messages ${SEARCH}`" +> +> this makes arithmetic evaluation -- no operation to be done but +> the spaces around the value are dropped. + +But it's non-obvious. How about just adding '| tr -d " "' to the end and +be done with it? + +J. + + +> +>> +>> jamie. +> +> Tomi +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2