Re: [PATCH v2 7/9] test/count: fix numeric comparision tests on FreeBSD
authorJameson Graef Rollins <jrollins@finestructure.net>
Wed, 30 May 2012 20:28:37 +0000 (13:28 +1700)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:47:31 +0000 (09:47 -0800)
8c/c11535ce704c9ac6be47418874fe724cd2136b [new file with mode: 0644]

diff --git a/8c/c11535ce704c9ac6be47418874fe724cd2136b b/8c/c11535ce704c9ac6be47418874fe724cd2136b
new file mode 100644 (file)
index 0000000..8e7e3ed
--- /dev/null
@@ -0,0 +1,127 @@
+Return-Path: <jrollins@finestructure.net>\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 EAADB431FB6\r
+       for <notmuch@notmuchmail.org>; Wed, 30 May 2012 13:28:43 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.29\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.29 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_MED=-2.3, T_MIME_NO_TEXT=0.01] 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 GJep2InkF3P9 for <notmuch@notmuchmail.org>;\r
+       Wed, 30 May 2012 13:28:43 -0700 (PDT)\r
+Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu\r
+       [131.215.239.19])\r
+       by olra.theworths.org (Postfix) with ESMTP id 54468431FAF\r
+       for <notmuch@notmuchmail.org>; Wed, 30 May 2012 13:28:43 -0700 (PDT)\r
+Received: from earth-doxen.imss.caltech.edu (localhost [127.0.0.1])\r
+       by earth-doxen-postvirus (Postfix) with ESMTP id DB12466E012C;\r
+       Wed, 30 May 2012 13:28:42 -0700 (PDT)\r
+X-Spam-Scanned: at Caltech-IMSS on earth-doxen by amavisd-new\r
+Received: from finestructure.net (m70.ligo.caltech.edu [131.215.115.170])\r
+       (Authenticated sender: jrollins)\r
+       by earth-doxen-submit (Postfix) with ESMTP id EE36B66E01A4;\r
+       Wed, 30 May 2012 13:28:39 -0700 (PDT)\r
+Received: by finestructure.net (Postfix, from userid 1000)\r
+       id CF9221D3; Wed, 30 May 2012 13:28:39 -0700 (PDT)\r
+From: Jameson Graef Rollins <jrollins@finestructure.net>\r
+To: 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: <1338361324-57289-8-git-send-email-pioto@pioto.org>\r
+References: <1338361324-57289-1-git-send-email-pioto@pioto.org>\r
+       <1338361324-57289-8-git-send-email-pioto@pioto.org>\r
+User-Agent: Notmuch/0.13+24~g16915cd (http://notmuchmail.org) Emacs/23.4.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Wed, 30 May 2012 13:28:37 -0700\r
+Message-ID: <877gvtxvka.fsf@servo.finestructure.net>\r
+MIME-Version: 1.0\r
+Content-Type: multipart/signed; boundary="=-=-=";\r
+       micalg=pgp-sha256; protocol="application/pgp-signature"\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 20:28:44 -0000\r
+\r
+--=-=-=\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
+> +# Like test_expect_equal, but does a numeric comparision instead of a\r
+> +# string comparision\r
+> +test_expect_equal_num () {\r
+> +    exec 1>&6 2>&7          # Restore stdout and stderr\r
+> +    inside_subtest=\r
+> +    test "$#" = 3 && { prereq=$1; shift; } || prereq=\r
+> +    test "$#" = 2 ||\r
+> +    error "bug in the test script: not 2 or 3 parameters to test_expect_equal"\r
+> +\r
+> +    output="$1"\r
+> +    expected="$2"\r
+> +    if ! test_skip "$test_subtest_name"\r
+> +    then\r
+> +            if test "$output" -eq "$expected"\r
+> +            then\r
+> +                    test_ok_ "$test_subtest_name"\r
+> +            else\r
+> +                    test_failure_ "$test_subtest_name" "$output != $expected"\r
+> +            fi\r
+> +    fi\r
+> +}\r
+\r
+Also, the new function is missing the diff output, which is important\r
+for debugging, and the syntax is different from the standard we've been\r
+using:\r
+\r
+  if ...; then\r
+\r
+We try to maintain syntax consistency across the code base.  Thanks.\r
+\r
+jamie.\r
+\r
+--=-=-=\r
+Content-Type: application/pgp-signature\r
+\r
+-----BEGIN PGP SIGNATURE-----\r
+Version: GnuPG v1.4.12 (GNU/Linux)\r
+\r
+iQIcBAEBCAAGBQJPxoL1AAoJEO00zqvie6q8y04P/Av7haRAPhHgXVkRR1kJVnom\r
+CIoEpbKq6yHz8M9dYyNpZ/zz8vFvjvZm6JghKkiHKPz1FXjY25GBjM2jeyxXVZ46\r
+xQ8IYT6K8GYfiRLKGMUZJLc6OXETKcHxsGRIzGP+rSsAOHWss3lKJxlJutrfz5rI\r
+pZuo4m2fKiYm9Qiiu1V2/s2xWtD0ZGftf3zi/SetkYTHNhSNN/gi57SxGfb0I7bs\r
+/ed0uDYLNPpbm+dRP/DnsLOFGbeCDRz5tMGa1zeKgfg3oAvzPwGrjYwn+HKVkloh\r
+Xsk1sgswZSE0z08xi0w5i6l0aDjXE9Z11hT15T3mwzLmjkpNJOGCl8Mi3D45+PJa\r
+XIPr6bTmEspPQq22ZANcKTT324597ER0SZR5tCCTOpaPDU6GmahxwocUonNZQWq+\r
+D0Oamy9qInDQJJ+eDHX2xjSr6/6X6yi2gT9bz2z71hO2xN0dtTgyNs9DdUZwBjeR\r
+bJ5MR56o85xZzo2Eml30aZa9ujgbW28HVCvrjh3jEdoqb/blevCGqOXs63brwTLX\r
+xqCpDMCYPKbMe1tU3i5qiPAHCd3VJftuYAVTo3QhPRWS/5cmOD/eAgyGsW/G7NNo\r
+YzgmNMz/NCqGm/Hn1aLhGLdKdnAzUZNF5PlYatzwTvo/wS9ZU4XWs6LnlUXTkaBI\r
+gvYA2B7ojIgiDLzgUK73\r
+=dKfi\r
+-----END PGP SIGNATURE-----\r
+--=-=-=--\r