Subject: Re: [GSoC PATCH] t1420-lost-found.sh: use test_path_is_file for error logging

From: Junio C Hamano <[email-masked]>
Date: Mon, 05 Jan 2026 12:24:17 +0900

Andrew Chitester <[email-masked]> writes:

> This test will fail silently without giving any error message. Use
> test_path_is_file in place of test -f to ensure this test errors with a
> message.
>
> Signed-off-by: Andrew Chitester <[email-masked]>
> ---
>  t/t1420-lost-found.sh | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/t/t1420-lost-found.sh b/t/t1420-lost-found.sh
> index 2fb2f44f02..5fbb1d10ed 100755
> --- a/t/t1420-lost-found.sh
> +++ b/t/t1420-lost-found.sh
> @@ -29,8 +29,8 @@ test_expect_success 'lost and found something' '
>  	git reset --hard HEAD^ &&
>  	git fsck --lost-found &&
>  	test 2 = $(ls .git/lost-found/*/* | wc -l) &&
> -	test -f .git/lost-found/commit/$(cat lost-commit) &&
> -	test -f .git/lost-found/other/$(cat lost-other)
> +	test_path_is_file .git/lost-found/commit/$(cat lost-commit) &&
> +	test_path_is_file .git/lost-found/other/$(cat lost-other)
>  '

Looks correct, but given that what these tests want to ensure is
that underneath .git/lost-found there are only these two expected
files, I have to wonder if the output of "ls" here is expected to be
very stable.  I.e. if we rewrote the whole thing to something like
...

	ls .git/lost-found/*/* >actual &&
	cat >expect <<-EOF &&
	.git/lost-found/commit/$(cat lost-commit)
	.git/lost-found/other/$(cat lost-other)
	EOF
	test_cmp expect actual

... would it be a more direct way to say that and is easier to
understand to our readers.