git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 5, 2026, 03:24 UTC
Message-ID
<xmqq4ip0n3mm.fsf@gitster.g>
In-Reply-To
<20260104161536.45384-1-andchi@fastmail.com>
Andrew Chitester <andchi@fastmail.com> writes:
Show 22 quoted lines
> 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 <andchi@fastmail.com>
> ---
>  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.

Previous: Andrew ChitesterNext: Andrew Chitester
Message 2 of 4 in “t1420-lost-found.sh: use test_path_is_file for error logging”
  1. t1420-lost-found.sh: use test_path_is_file for error loggingAndrew Chitester, Jan 4, 2026
  2. Junio C HamanoJan 5, 2026
  3. Andrew ChitesterJan 8, 2026
  4. 1/1 t1420: modernize the lost-found testAndrew Chitester, Jan 6, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.