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

Re: [GSoC PATCH v3] t9200: replace test -f/-d with modern path helpers

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 11, 2026, 17:52 UTC
Message-ID
<xmqqwlzip82b.fsf@gitster.g>
In-Reply-To
<20260309230134.758107-1-pabloosabaterr@gmail.com>
Pablo Sabater <pabloosabaterr@gmail.com> writes:
> Replace old style 'test -f' and 'test -d' with helpers
> 'test_path_is_file' and 'test_path_is_dir' respectively,
> which make debugging a failing test easier by loudly
> reporting what expectation was not met.
Well explained.
> The instances were found with:
>
> 	git grep "test -[efd]" t/

People seem to add the above to their test-path helper patches, but unless the coverage of the work is fairly thorough and you want to say "all the similar issues should be found with this command and I addressed all of them", I do not see much point saying how you found one of them and addressed it.

You could have used "git grep -e <pattern> -- t/\*.sh", or you could have been working to fix something in t9200 and noticed these while you were doing something else to the file.

I do not see it as too huge a deal and it is probably not a cause to send in another iteration once it is already written, though.

Show 18 quoted lines
> Signed-off-by: Pablo Sabater <pabloosabaterr@gmail.com>
> ---
>  t/t9200-git-cvsexportcommit.sh | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/t/t9200-git-cvsexportcommit.sh b/t/t9200-git-cvsexportcommit.sh
> index a44eabf0d8..4507e8e6db 100755
> --- a/t/t9200-git-cvsexportcommit.sh
> +++ b/t/t9200-git-cvsexportcommit.sh
> @@ -31,7 +31,7 @@ export CVSROOT CVSWORK GIT_DIR
>  rm -rf "$CVSROOT" "$CVSWORK"
>  
>  cvs init &&
> -test -d "$CVSROOT" &&
> +test_path_is_dir "$CVSROOT" &&
>  cvs -Q co -d "$CVSWORK" . &&
>  echo >empty &&
>  git add empty &&

Our test-path helpers should work even outside test_expect_* functions, so this is not wrong per-se, but it somehow looks a bit unusual. A related clean-up would be to wrap the CVS initialization part inside another "do we even have a working CVS installation to make it worth our time testing 'git cvsexportcommit' command?" check, i.e.,

	if ! cvs init || ! test -d "$CVSROOT" || ! cvs -Q co -d "$CVSWORK" .
        then
		skip_all="cvs repository set-up fails"
		test_done
	fi
and then move the git initialization part to its own test, e.g.,
	test_expect_success 'git setup' '
		echo >empty &&
		git add empty &&
		git commit -q -a -m Initial
	'
Show 7 quoted lines
> @@ -303,7 +303,7 @@ test_expect_success 're-commit a removed filename which remains in CVS attic' '
>  	git commit -m "Added attic_gremlin" &&
>  	git cvsexportcommit -w "$CVSWORK" -c HEAD &&
>  	(cd "$CVSWORK" && cvs -Q update -d) &&
> -	test -f "$CVSWORK/attic_gremlin"
> +	test_path_is_file "$CVSWORK/attic_gremlin"
>  '
OK.
>  
>  # the state of the CVS sandbox may be indeterminate for ' space'
Previous: PabloNext: Pablo
Message 10 of 16 in “t9200: use helpers to replace test -f <path> and test -d <path>”
  1. t9200: use helpers to replace test -f <path> and test -d <path>Pablo Sabater, Mar 9, 2026
  2. Junio C HamanoMar 9, 2026
  3. PabloMar 9, 2026
  4. t9200: replace test -f/-d with modern path helpersPablo Sabater, Mar 9, 2026
  5. Junio C HamanoMar 9, 2026
  6. PabloMar 9, 2026
  7. t9200: replace test -f/-d with modern path helpersPablo Sabater, Mar 9, 2026
  8. Junio C HamanoMar 9, 2026
  9. PabloMar 11, 2026
  10. Junio C HamanoMar 11, 2026
  11. PabloMar 11, 2026
  12. Junio C HamanoMar 11, 2026
  13. PabloMar 11, 2026
  14. Junio C HamanoMar 11, 2026
  15. t9200: replace test -f with modern path helperPablo Sabater, Mar 12, 2026
  16. Junio C HamanoMar 12, 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.