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

[GSOC PATCH] t2003: modernize test path helpers

From
Burak Kaan Karaçay <bkkaracay@gmail.com>
Date
Feb 8, 2026, 20:28 UTC
Message-ID
<20260208202809.270523-1-bkkaracay@gmail.com>

The old style 'test -f' and 'test -d' checks are silent on failure, which makes debugging difficult.

Replace them with the 'test_path_is_*' helpers which provide verbose error messages when a test fails.

Signed-off-by: Burak Kaan Karaçay <bkkaracay@gmail.com>
---
 t/t2003-checkout-cache-mkdir.sh | 49 ++++++++++++++++-----------------
 1 file changed, 24 insertions(+), 25 deletions(-)
diff --git a/t/t2003-checkout-cache-mkdir.sh b/t/t2003-checkout-cache-mkdir.sh
index ff163cf675..5844389c88 100755
--- a/t/t2003-checkout-cache-mkdir.sh
+++ b/t/t2003-checkout-cache-mkdir.sh
@@ -24,27 +24,27 @@ test_expect_success SYMLINKS 'have symlink in place where dir is expected.' '
 	mkdir path2 &&
 	ln -s path2 path1 &&
 	git checkout-index -f -a &&
-	test ! -h path1 && test -d path1 &&
-	test -f path1/file1 && test ! -f path2/file1
+	test_path_is_dir_not_symlink path1 &&
+	test_path_is_file path1/file1 && test_path_is_missing path2/file1
 '
 
 test_expect_success 'use --prefix=path2/' '
 	rm -fr path0 path1 path2 &&
 	mkdir path2 &&
 	git checkout-index --prefix=path2/ -f -a &&
-	test -f path2/path0 &&
-	test -f path2/path1/file1 &&
-	test ! -f path0 &&
-	test ! -f path1/file1
+	test_path_is_file path2/path0 &&
+	test_path_is_file path2/path1/file1 &&
+	test_path_is_missing path0 &&
+	test_path_is_missing path1/file1
 '
 
 test_expect_success 'use --prefix=tmp-' '
 	rm -fr path0 path1 path2 tmp* &&
 	git checkout-index --prefix=tmp- -f -a &&
-	test -f tmp-path0 &&
-	test -f tmp-path1/file1 &&
-	test ! -f path0 &&
-	test ! -f path1/file1
+	test_path_is_file tmp-path0 &&
+	test_path_is_file tmp-path1/file1 &&
+	test_path_is_missing path0 &&
+	test_path_is_missing path1/file1
 '
 
 test_expect_success 'use --prefix=tmp- but with a conflicting file and dir' '
@@ -52,10 +52,10 @@ test_expect_success 'use --prefix=tmp- but with a conflicting file and dir' '
 	echo nitfol >tmp-path1 &&
 	mkdir tmp-path0 &&
 	git checkout-index --prefix=tmp- -f -a &&
-	test -f tmp-path0 &&
-	test -f tmp-path1/file1 &&
-	test ! -f path0 &&
-	test ! -f path1/file1
+	test_path_is_file tmp-path0 &&
+	test_path_is_file tmp-path1/file1 &&
+	test_path_is_missing path0 &&
+	test_path_is_missing path1/file1
 '
 
 test_expect_success SYMLINKS 'use --prefix=tmp/orary/ where tmp is a symlink' '
@@ -63,10 +63,10 @@ test_expect_success SYMLINKS 'use --prefix=tmp/orary/ where tmp is a symlink' '
 	mkdir tmp1 tmp1/orary &&
 	ln -s tmp1 tmp &&
 	git checkout-index --prefix=tmp/orary/ -f -a &&
-	test -d tmp1/orary &&
-	test -f tmp1/orary/path0 &&
-	test -f tmp1/orary/path1/file1 &&
-	test -h tmp
+	test_path_is_dir tmp1/orary &&
+	test_path_is_file tmp1/orary/path0 &&
+	test_path_is_file tmp1/orary/path1/file1 &&
+	test_path_is_symlink tmp
 '
 
 test_expect_success SYMLINKS 'use --prefix=tmp/orary- where tmp is a symlink' '
@@ -74,9 +74,9 @@ test_expect_success SYMLINKS 'use --prefix=tmp/orary- where tmp is a symlink' '
 	mkdir tmp1 &&
 	ln -s tmp1 tmp &&
 	git checkout-index --prefix=tmp/orary- -f -a &&
-	test -f tmp1/orary-path0 &&
-	test -f tmp1/orary-path1/file1 &&
-	test -h tmp
+	test_path_is_file tmp1/orary-path0 &&
+	test_path_is_file tmp1/orary-path1/file1 &&
+	test_path_is_symlink tmp
 '
 
 test_expect_success SYMLINKS 'use --prefix=tmp- where tmp-path1 is a symlink' '
@@ -84,10 +84,9 @@ test_expect_success SYMLINKS 'use --prefix=tmp- where tmp-path1 is a symlink' '
 	mkdir tmp1 &&
 	ln -s tmp1 tmp-path1 &&
 	git checkout-index --prefix=tmp- -f -a &&
-	test -f tmp-path0 &&
-	test ! -h tmp-path1 &&
-	test -d tmp-path1 &&
-	test -f tmp-path1/file1
+	test_path_is_file tmp-path0 &&
+	test_path_is_dir_not_symlink tmp-path1 &&
+	test_path_is_file tmp-path1/file1
 '
 
 test_expect_success 'apply filter from working tree .gitattributes with --prefix' '
-- 
2.52.0
Next: Junio C Hamano
Message 1 of 2 in “t2003: modernize test path helpers”
  1. t2003: modernize test path helpersBurak Kaan Karaçay, Feb 8, 2026
  2. Junio C HamanoFeb 9, 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.