From: Junio C Hamano <gitster@pobox.com>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: Johannes Sixt <j.sixt@viscovery.net>,
Brian Gernhardt <brian@gernhardtsoftware.com>,
Git List <git@vger.kernel.org>
Subject: Re: [PATCH] t6022: Use -eq not = to test output of wc -l
Date: Tue, 16 Nov 2010 11:10:40 -0800 [thread overview]
Message-ID: <7vtyjhgk3z.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20101116171031.GB13398@burratino> (Jonathan Nieder's message of "Tue\, 16 Nov 2010 11\:10\:32 -0600")
Jonathan Nieder <jrnieder@gmail.com> writes:
> Johannes Sixt wrote:
>
>> - It doesn't save any messages or fix-ups during review: instead of "do
>> not quote!" we have to say "use test_line_count!".
>
> I was nervous about introducing test_line_count for that reason.
>
> Another consideration won out: not syntax but output format. See
> cae3aa79 (t6022 (renaming merge): chain test commands with &&,
> 2010-10-31). Kind of analogous to test_cmp, which is a similar
> headache to get used over less portable or less pleasant alternatives.
>
> If a piped variant is needed, I would prefer it to work something
> like this. Usage:
>
> {
> command_producing_five_lines |
> test_line_count = 5 -
> }
>
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
> ---
> diff --git a/t/test-lib.sh b/t/test-lib.sh
> index 1ea0116..35a5634 100644
> --- a/t/test-lib.sh
> +++ b/t/test-lib.sh
> @@ -660,15 +660,24 @@ test_path_is_missing () {
> # output through when the number of lines is wrong.
>
> test_line_count () {
> + line_count_tmp=
> if test $# != 3
> then
> error "bug in the test script: not 3 parameters to test_line_count"
> - elif ! test $(wc -l <"$3") "$1" "$2"
> + fi
> + if test "$3" = -
> + then
> + line_count_tmp=test_line_count.output
> + cat >"$line_count_tmp"
> + set -- "$1" "$2" "$line_count_tmp"
> + fi
> + if ! test $(wc -l <"$3") "$1" "$2"
> then
> echo "test_line_count: line count for $3 !$1 $2"
> cat "$3"
> return 1
You forgot to clean the temporary file here.
Also if the file is huge, do we really want to cat the whole thing?
> fi
> + rm -f "$line_count_tmp"
> }
>
> # This is not among top-level (test_expect_success | test_expect_failure)
next prev parent reply other threads:[~2010-11-16 19:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-08 21:29 [PATCH] t6022: Use -eq not = to test output of wc -l Brian Gernhardt
2010-11-08 21:35 ` Ævar Arnfjörð Bjarmason
2010-11-08 21:38 ` Jonathan Nieder
2010-11-15 22:21 ` Junio C Hamano
2010-11-16 6:46 ` Bert Wesarg
2010-11-16 7:12 ` Johannes Sixt
2010-11-16 17:10 ` Jonathan Nieder
2010-11-16 19:10 ` Junio C Hamano [this message]
2010-11-16 19:23 ` Jonathan Nieder
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vtyjhgk3z.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=brian@gernhardtsoftware.com \
--cc=git@vger.kernel.org \
--cc=j.sixt@viscovery.net \
--cc=jrnieder@gmail.com \
/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.
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 NNTP newsgroup(s).