Re: [PATCH v2 3/5] t0041: use test_line_count_cmd to check std{out,err}
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 16, 2021, 03:06 UTC
- Message-ID
- <xmqqlf7ase3d.fsf@gitster.g>
- In-Reply-To
- <20210615172038.28917-4-congdanhqx@gmail.com>
Đoàn Trần Công Danh <congdanhqx@gmail.com> writes:
Show 6 quoted lines
> 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.
Show 5 quoted lines
> 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 ...
Show 6 quoted lines
> 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.