Subject: Re: [PATCH v2 3/5] t0041: use test_line_count_cmd to check std{out,err}

From: Junio C Hamano <[email-masked]>
Date: Wed, 16 Jun 2021 12:06:14 +0900

Đoàn Trần Công Danh  <[email-masked]> writes:

>  test_expect_success 'tag --contains <existent_tag>' '
> -	git tag --contains "v1.0" >actual 2>actual.err &&
> -	grep "v1.0" actual &&
> -	test_line_count = 0 actual.err
> +	test_line_count_cmd --err = 0 git tag --contains v1.0 >actual &&
> +	grep "v1.0" actual

Sorry, but I am not impressed if this is a typical/prime example of
how the new helper helps in writing our tests.

Notice that so many tests that you touched only care about 0 lines?

Instead of this new helper, I think it would be a more useful
improvement if we check the emptyness in a more direct way, i.e.

>  test_expect_success 'tag --contains <existent_tag>' '
> 	git tag --contains "v1.0" >actual 2>actual.err &&
> 	grep "v1.0" actual &&
> -	test_line_count = 0 actual.err
> +	test_must_be_empty actual.err

I think this helper may be misnamed and test_file_is_empty would sit
better with test_dir_is_empty and test_file_not_empty that already
exist, though.

By the way, my opinion would be quite different if example like this
one ...

>  test_expect_success 'tag --no-contains <existent_tag>' '
> -	git tag --no-contains "v1.0" >actual 2>actual.err  &&
> -	test_line_count = 0 actual &&
> -	test_line_count = 0 actual.err
> +	test_line_count_cmd --out = 0 --err = 0 git tag --no-contains v1.0
>  '

... were the majority, but I do not think that is the case.  Most
tests that employ the new test_line_count_cmd in this patch still
create either actual or actual.err in the working tree anyway, so I
do not see much point in adding this new helper---it is hard to
explain to new test writers when to use it.