From: "Burak Kaan Karaçay" <bkkaracay@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, christian.couder@gmail.com,
"Burak Kaan Karaçay" <bkkaracay@gmail.com>
Subject: [GSOC PATCH v2] t2003: modernize path existence checks using test helpers
Date: Mon, 9 Feb 2026 14:24:44 +0300 [thread overview]
Message-ID: <20260209112444.1268765-1-bkkaracay@gmail.com> (raw)
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>
---
Thank you for the review.
Changes since v1:
- Fixed subject line.
- Split the command chain.
t/t2003-checkout-cache-mkdir.sh | 50 ++++++++++++++++-----------------
1 file changed, 25 insertions(+), 25 deletions(-)
diff --git a/t/t2003-checkout-cache-mkdir.sh b/t/t2003-checkout-cache-mkdir.sh
index ff163cf675..19166adf0f 100755
--- a/t/t2003-checkout-cache-mkdir.sh
+++ b/t/t2003-checkout-cache-mkdir.sh
@@ -24,27 +24,28 @@ 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 +53,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 +64,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 +75,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 +85,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
reply other threads:[~2026-02-09 11:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260209112444.1268765-1-bkkaracay@gmail.com \
--to=bkkaracay@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox