Re: [PATCH v2 7/9] test/count: fix numeric comparision tests on FreeBSD
authorTomi Ollila <tomi.ollila@iki.fi>
Wed, 30 May 2012 21:00:50 +0000 (00:00 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:31 +0000 (09:47 -0800)
bd/16e2493bb836f919027f7d60e7609f1042f933 [new file with mode: 0644]

diff --git a/bd/16e2493bb836f919027f7d60e7609f1042f933 b/bd/16e2493bb836f919027f7d60e7609f1042f933
new file mode 100644 (file)
index 0000000..a3794f5
--- /dev/null
@@ -0,0 +1,91 @@
+Return-Path: <tomi.ollila@iki.fi>\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 55361431FB6\r
+       for <notmuch@notmuchmail.org>; Wed, 30 May 2012 14:00:41 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       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 533eKh9XvcsH for <notmuch@notmuchmail.org>;\r
+       Wed, 30 May 2012 14:00:40 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+       by olra.theworths.org (Postfix) with ESMTP id 5A4BB431FAF\r
+       for <notmuch@notmuchmail.org>; Wed, 30 May 2012 14:00:40 -0700 (PDT)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+       id 15343100642; Thu, 31 May 2012 00:00:50 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Jameson Graef Rollins <jrollins@finestructure.net>,\r
+       Mike Kelly <pioto@pioto.org>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v2 7/9] test/count: fix numeric comparision tests on\r
+       FreeBSD\r
+In-Reply-To: <877gvtxvka.fsf@servo.finestructure.net>\r
+References: <1338361324-57289-1-git-send-email-pioto@pioto.org>\r
+       <1338361324-57289-8-git-send-email-pioto@pioto.org>\r
+       <877gvtxvka.fsf@servo.finestructure.net>\r
+User-Agent: Notmuch/0.13+29~g3c353b7 (http://notmuchmail.org) Emacs/23.1.1\r
+       (x86_64-redhat-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+       $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+       !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Thu, 31 May 2012 00:00:50 +0300\r
+Message-ID: <m2fwahxu2l.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\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, 30 May 2012 21:00:41 -0000\r
+\r
+On Wed, May 30 2012, Jameson Graef Rollins <jrollins@finestructure.net> wrote:\r
+\r
+> On Wed, May 30 2012, Mike Kelly <pioto@pioto.org> wrote:\r
+>> FreeBSD's `wc -l` includes some white space in front of the number.\r
+>> Instead, we add a test_expect_equal_num() to test-lib.sh, which ensures\r
+>> we do a proper numeric comparision, and in a portable way.\r
+>\r
+> Is there a way we can avoid adding another new test function here?  This\r
+> new function is almost completely identical with the old one, except\r
+> that it uses "test .. -eq" instead of "[ .. =".  If the problem is just\r
+> that the arguments occasionally contain superfluous spaces, I would\r
+> rather see the existing function just strip the spaces.  Of maybe add an\r
+> option to the test to ask for arithmetic rather than string comparison.\r
+> That would be preferable to introducing an new function that is\r
+> confusingly similar to an existing one.\r
+\r
+I liked Mike's suggestion as I also thought the options; stripping in\r
+test_expect_equal cannot be done as there might be whitespace differences\r
+which mean failure arguments to test_expect_equal cannot be given without\r
+quotes as variable might be split into multiple args. if test_expect_equal\r
+were changed to take comparison argument (like '-eq' or '=')  then all\r
+calls would need to be changes (and function name could be changed to\r
+something more generic...) None of these sounded as good options...\r
+\r
+But, there is at least one option more:\r
+\r
+test_expect_equal \\r
+-    "`notmuch search --output=messages ${SEARCH} | wc -l`" \\r
++    "$((`notmuch search --output=messages ${SEARCH} | wc -l`))" \\r
+    "`notmuch count --output=messages ${SEARCH}`"\r
+\r
+this makes arithmetic evaluation -- no operation to be done but\r
+the spaces around the value are dropped.\r
+\r
+>\r
+> jamie.\r
+\r
+Tomi\r