Subject: [PATCH v2] [GSoC Patch v2]Modernize Test Path Checking: test -(e|f|d)

From: "Sampriyo Guin via GitGitGadget" <[email-masked]>
Date: Wed, 19 Mar 2025 06:03:57 +0000

From: Sampriyo Guin <[email-masked]>

test -f changed to test_path_is_file
test -f does not provide a proper error message so test_path_is_file used
Changed for t/t2003-checkout-cache-mkdir.sh

Signed-off-by: Sampriyo Guin <[email-masked]>
---
    [GSoC Patch v2] Modernize Test Path Checking in Git’s Test Suite
    
    test -(e|f|d) does not provide a proper error message when hit test
    failures. So test_path_exists, test_path_is_dir, test_path_is_file used.
    
    Added changes for files from t/t0007-git-var.sh to
    t/t1700-split-index.sh.
    
    Signed-off-by: Sampriyo Guin <[email-masked]>

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1923%2FRimoGuin%2Fmaster-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1923/RimoGuin/master-v2
Pull-Request: https://github.com/git/git/pull/1923

Range-diff vs v1:

 1:  432dbe6fb82 < -:  ----------- [GSoC Patch] Modernize Test Path Checking in Git’s Test Suite
 -:  ----------- > 1:  0f74a82d681 [GSoC Patch v2]Modernize Test Path Checking: test -(e|f|d)

 t/t2003-checkout-cache-mkdir.sh | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/t/t2003-checkout-cache-mkdir.sh b/t/t2003-checkout-cache-mkdir.sh
index ff163cf6750..9d2f59e0d78 100755
--- a/t/t2003-checkout-cache-mkdir.sh
+++ b/t/t2003-checkout-cache-mkdir.sh
@@ -24,16 +24,16 @@ 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 ! -h path1 && test_path_is_dir path1 &&
+	test_path_is_file path1/file1 && test ! -f 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_path_is_file path2/path0 &&
+	test_path_is_file path2/path1/file1 &&
 	test ! -f path0 &&
 	test ! -f path1/file1
 '
@@ -41,8 +41,8 @@ test_expect_success 'use --prefix=path2/' '
 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_path_is_file tmp-path0 &&
+	test_path_is_file tmp-path1/file1 &&
 	test ! -f path0 &&
 	test ! -f path1/file1
 '
@@ -52,8 +52,8 @@ 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_path_is_file tmp-path0 &&
+	test_path_is_file tmp-path1/file1 &&
 	test ! -f path0 &&
 	test ! -f path1/file1
 '
@@ -63,9 +63,9 @@ 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_path_is_dir tmp1/orary &&
+	test_path_is_file tmp1/orary/path0 &&
+	test_path_is_file tmp1/orary/path1/file1 &&
 	test -h tmp
 '
 
@@ -74,8 +74,8 @@ 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_path_is_file tmp1/orary-path0 &&
+	test_path_is_file tmp1/orary-path1/file1 &&
 	test -h tmp
 '
 
@@ -84,10 +84,10 @@ 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_path_is_file tmp-path0 &&
 	test ! -h tmp-path1 &&
-	test -d tmp-path1 &&
-	test -f tmp-path1/file1
+	test_path_is_dir tmp-path1 &&
+	test_path_is_file tmp-path1/file1
 '
 
 test_expect_success 'apply filter from working tree .gitattributes with --prefix' '

base-commit: 683c54c999c301c2cd6f715c411407c413b1d84e
-- 
gitgitgadget