unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Jameson Graef Rollins <jrollins@finestructure.net>
To: Mike Kelly <pioto@pioto.org>, notmuch@notmuchmail.org
Subject: Re: [PATCH v2 7/9] test/count: fix numeric comparision tests on FreeBSD
Date: Wed, 30 May 2012 13:28:37 -0700	[thread overview]
Message-ID: <877gvtxvka.fsf@servo.finestructure.net> (raw)
In-Reply-To: <1338361324-57289-8-git-send-email-pioto@pioto.org>

[-- Attachment #1: Type: text/plain, Size: 1654 bytes --]

On Wed, May 30 2012, Mike Kelly <pioto@pioto.org> 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.

> +# Like test_expect_equal, but does a numeric comparision instead of a
> +# string comparision
> +test_expect_equal_num () {
> +	exec 1>&6 2>&7		# Restore stdout and stderr
> +	inside_subtest=
> +	test "$#" = 3 && { prereq=$1; shift; } || prereq=
> +	test "$#" = 2 ||
> +	error "bug in the test script: not 2 or 3 parameters to test_expect_equal"
> +
> +	output="$1"
> +	expected="$2"
> +	if ! test_skip "$test_subtest_name"
> +	then
> +		if test "$output" -eq "$expected"
> +		then
> +			test_ok_ "$test_subtest_name"
> +		else
> +			test_failure_ "$test_subtest_name" "$output != $expected"
> +		fi
> +	fi
> +}

Also, the new function is missing the diff output, which is important
for debugging, and the syntax is different from the standard we've been
using:

  if ...; then

We try to maintain syntax consistency across the code base.  Thanks.

jamie.

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

  reply	other threads:[~2012-05-30 20:28 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-30  7:01 [PATCH v2 0/9] FreeBSD Support Patches Mike Kelly
2012-05-30  7:01 ` [PATCH v2 1/9] configure: Add support for FreeBSD Mike Kelly
2012-05-30  7:01 ` [PATCH v2 2/9] test/Makefile.local: Use $(XAPIAN_LDFLAGS) for symbol-test Mike Kelly
2012-05-30  7:01 ` [PATCH v2 3/9] Makefile.local: define _GNU_SOURCE Mike Kelly
2012-05-31  8:14   ` Jani Nikula
2012-05-30  7:01 ` [PATCH v2 4/9] test/smtp-dummy.c: fix compilation on FreeBSD Mike Kelly
2012-05-30  7:02 ` [PATCH v2 5/9] tests: Test against source man pages Mike Kelly
2012-05-30  7:02 ` [PATCH v2 6/9] test/basic: use portable args for find Mike Kelly
2012-05-30  7:02 ` [PATCH v2 7/9] test/count: fix numeric comparision tests on FreeBSD Mike Kelly
2012-05-30 20:28   ` Jameson Graef Rollins [this message]
2012-05-30 21:00     ` Tomi Ollila
2012-05-31  8:28       ` Jani Nikula
2012-05-30  7:02 ` [PATCH v2 8/9] test/atomicity: use a more portable 'cp' form Mike Kelly
2012-05-30  7:02 ` [PATCH v2 9/9] tests: bsd sed doesn't allow replacing '\n' Mike Kelly
2012-05-30 10:35 ` [PATCH v2 0/9] FreeBSD Support Patches Tomi Ollila
2012-09-02  2:41 ` David Bremner
2012-09-04 22:45   ` Mike Kelly

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877gvtxvka.fsf@servo.finestructure.net \
    --to=jrollins@finestructure.net \
    --cc=notmuch@notmuchmail.org \
    --cc=pioto@pioto.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).