From: PRASHANT S BISHT <prashantjee2025@gmail.com>
To: git@vger.kernel.org
Cc: PRASHANT S BISHT <prashantjee2025@gmail.com>
Subject: [PATCH] t0004: replace test -e with test_path_exists
Date: Mon, 9 Mar 2026 23:06:35 +0530 [thread overview]
Message-ID: <20260309173635.29683-1-prashantjee2025@gmail.com> (raw)
Replace old-style path existence checks with the modern test_path_exists
helper function that provides clearer diagnostic messages on failure.
When test -e fails, the output gives no indication of what went wrong.
These instances were found using:
git grep "test -[efd]" t/ | grep -v "if test"
as suggested in the microproject ideas.
---
t/t0004-unwritable.sh | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/t/t0004-unwritable.sh b/t/t0004-unwritable.sh
index 3bdafbae0f..2a9fc781b6 100755
--- a/t/t0004-unwritable.sh
+++ b/t/t0004-unwritable.sh
@@ -21,7 +21,7 @@ test_expect_success POSIXPERM,SANITY 'write-tree should notice unwritable reposi
test_must_fail git write-tree 2>out.write-tree
'
-test_lazy_prereq WRITE_TREE_OUT 'test -e "$TRASH_DIRECTORY"/out.write-tree'
+test_lazy_prereq WRITE_TREE_OUT 'test_path_exists "$TRASH_DIRECTORY/out.write-tree"'
test_expect_success WRITE_TREE_OUT 'write-tree output on unwritable repository' '
cat >expect <<-\EOF &&
error: insufficient permission for adding an object to repository database .git/objects
@@ -36,7 +36,7 @@ test_expect_success POSIXPERM,SANITY 'commit should notice unwritable repository
test_must_fail git commit -m second 2>out.commit
'
-test_lazy_prereq COMMIT_OUT 'test -e "$TRASH_DIRECTORY"/out.commit'
+test_lazy_prereq COMMIT_OUT 'test_path_exists "$TRASH_DIRECTORY/out.commit"'
test_expect_success COMMIT_OUT 'commit output on unwritable repository' '
cat >expect <<-\EOF &&
error: insufficient permission for adding an object to repository database .git/objects
@@ -52,7 +52,7 @@ test_expect_success POSIXPERM,SANITY 'update-index should notice unwritable repo
test_must_fail git update-index file 2>out.update-index
'
-test_lazy_prereq UPDATE_INDEX_OUT 'test -e "$TRASH_DIRECTORY"/out.update-index'
+test_lazy_prereq UPDATE_INDEX_OUT 'test_path_exists "$TRASH_DIRECTORY/out.update-index"'
test_expect_success UPDATE_INDEX_OUT 'update-index output on unwritable repository' '
cat >expect <<-\EOF &&
error: insufficient permission for adding an object to repository database .git/objects
@@ -69,7 +69,7 @@ test_expect_success POSIXPERM,SANITY 'add should notice unwritable repository' '
test_must_fail git add file 2>out.add
'
-test_lazy_prereq ADD_OUT 'test -e "$TRASH_DIRECTORY"/out.add'
+test_lazy_prereq ADD_OUT 'test_path_exists "$TRASH_DIRECTORY/out.add"'
test_expect_success ADD_OUT 'add output on unwritable repository' '
cat >expect <<-\EOF &&
error: insufficient permission for adding an object to repository database .git/objects
--
2.50.1 (Apple Git-155)
next reply other threads:[~2026-03-09 17:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-09 17:36 PRASHANT S BISHT [this message]
2026-03-09 21:14 ` [PATCH] t0004: replace test -e with test_path_exists Junio C Hamano
2026-03-09 22:47 ` Jeff King
2026-03-09 23:12 ` Junio C Hamano
2026-03-16 17:24 ` [PATCH v2] t4200: convert test -[df] checks to test_path_* helpers PRASHANT S BISHT
-- strict thread matches above, loose matches on Subject: below --
2026-03-09 17:56 [PATCH] t0004: replace test -e with test_path_exists PRASHANT S BISHT
2026-03-09 19:30 ` Eric Sunshine
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=20260309173635.29683-1-prashantjee2025@gmail.com \
--to=prashantjee2025@gmail.com \
--cc=git@vger.kernel.org \
/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