public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] t4200: replace test -f and test -d with test_path_exists
@ 2026-03-10  8:43 PRASHANT S BISHT
  0 siblings, 0 replies; 3+ messages in thread
From: PRASHANT S BISHT @ 2026-03-10  8:43 UTC (permalink / raw)
  To: git; +Cc: sunshine, gitster, PRASHANT S BISHT

Replace old-style path existence checks with the modern test_path_exists
helper function that provides clearer diagnostic messages on failure.

This conversion focuses on test assertions within test_expect_success
blocks where a missing path genuinely indicates a test failure,
rather than on control-flow checks (such as those in test_lazy_prereq
blocks) where missing paths are expected in certain environments.

Signed-off-by: PRASHANT S BISHT <prashantjee2025@gmail.com>
---
 t/t4200-rerere.sh | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh
index 204325f4d5..71a49bee56 100755
--- a/t/t4200-rerere.sh
+++ b/t/t4200-rerere.sh
@@ -72,7 +72,7 @@ test_expect_success 'nothing recorded without rerere' '
 	rm -rf .git/rr-cache &&
 	git config rerere.enabled false &&
 	test_must_fail git merge first &&
-	! test -d .git/rr-cache
+	! test_path_exists .git/rr-cache
 '
 
 test_expect_success 'activate rerere, old style (conflicting merge)' '
@@ -84,8 +84,8 @@ test_expect_success 'activate rerere, old style (conflicting merge)' '
 	sha1=$(sed "s/	.*//" .git/MERGE_RR) &&
 	rr=.git/rr-cache/$sha1 &&
 	grep "^=======\$" $rr/preimage &&
-	! test -f $rr/postimage &&
-	! test -f $rr/thisimage
+	! test_path_exists $rr/postimage &&
+	! test_path_exists $rr/thisimage
 '
 
 test_expect_success 'rerere.enabled works, too' '
@@ -110,8 +110,8 @@ test_expect_success 'set up rr-cache' '
 
 test_expect_success 'rr-cache looks sane' '
 	# no postimage or thisimage yet
-	! test -f $rr/postimage &&
-	! test -f $rr/thisimage &&
+	! test_path_exists $rr/postimage &&
+	! test_path_exists $rr/thisimage &&
 
 	# preimage has right number of lines
 	cnt=$(sed -ne "/^<<<<<<</,/^>>>>>>>/p" $rr/preimage | wc -l) &&
@@ -167,7 +167,7 @@ test_expect_success 'first postimage wins' '
 	git show first:a1 | sed "s/To die: t/To die! T/" >expect &&
 
 	git commit -q -a -m "prefer first over second" &&
-	test -f $rr/postimage &&
+	test_path_exists $rr/postimage &&
 
 	oldmtimepost=$(test-tool chmtime --get -60 $rr/postimage) &&
 
@@ -190,14 +190,14 @@ test_expect_success 'rerere clear' '
 	mv $rr/postimage .git/post-saved &&
 	echo "$sha1	a1" | tr "\012" "\000" >.git/MERGE_RR &&
 	git rerere clear &&
-	! test -d $rr
+	! test_path_exists $rr
 '
 
 test_expect_success 'leftover directory' '
 	git reset --hard &&
 	mkdir -p $rr &&
 	test_must_fail git merge first &&
-	test -f $rr/preimage
+	test_path_exists $rr/preimage
 '
 
 test_expect_success 'missing preimage' '
@@ -205,7 +205,7 @@ test_expect_success 'missing preimage' '
 	mkdir -p $rr &&
 	cp .git/post-saved $rr/postimage &&
 	test_must_fail git merge first &&
-	test -f $rr/preimage
+	test_path_exists $rr/preimage
 '
 
 test_expect_success 'set up for garbage collection tests' '
@@ -230,16 +230,16 @@ test_expect_success 'set up for garbage collection tests' '
 
 test_expect_success 'gc preserves young or recently used records' '
 	git rerere gc &&
-	test -f $rr/preimage &&
-	test -f $rr2/preimage
+	test_path_exists $rr/preimage &&
+	test_path_exists $rr2/preimage
 '
 
 test_expect_success 'old records rest in peace' '
 	test-tool chmtime =$just_over_60_days_ago $rr/postimage &&
 	test-tool chmtime =$just_over_15_days_ago $rr2/preimage &&
 	git rerere gc &&
-	! test -f $rr/preimage &&
-	! test -f $rr2/preimage
+	! test_path_exists $rr/preimage &&
+	! test_path_exists $rr2/preimage
 '
 
 rerere_gc_custom_expiry_test () {
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v2] t4200: replace test -f and test -d with test_path_exists
@ 2026-03-16  4:22 PRASHANT S BISHT
  2026-03-16  6:37 ` Eric Sunshine
  0 siblings, 1 reply; 3+ messages in thread
From: PRASHANT S BISHT @ 2026-03-16  4:22 UTC (permalink / raw)
  To: git; +Cc: PRASHANT S BISHT

Replace old-style path existence checks with the modern test_path_exists
helper function that provides clearer diagnostic messages on failure.

This conversion focuses on test assertions within test_expect_success
blocks where a missing path genuinely indicates a test failure,
rather than on control-flow checks (such as those in test_lazy_prereq
blocks) where missing paths are expected in certain environments.

Signed-off-by: PRASHANT S BISHT <prashantjee2025@gmail.com>
---
 t/t4200-rerere.sh | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh
index 204325f4d5..71a49bee56 100755
--- a/t/t4200-rerere.sh
+++ b/t/t4200-rerere.sh
@@ -72,7 +72,7 @@ test_expect_success 'nothing recorded without rerere' '
 	rm -rf .git/rr-cache &&
 	git config rerere.enabled false &&
 	test_must_fail git merge first &&
-	! test -d .git/rr-cache
+	! test_path_exists .git/rr-cache
 '
 
 test_expect_success 'activate rerere, old style (conflicting merge)' '
@@ -84,8 +84,8 @@ test_expect_success 'activate rerere, old style (conflicting merge)' '
 	sha1=$(sed "s/	.*//" .git/MERGE_RR) &&
 	rr=.git/rr-cache/$sha1 &&
 	grep "^=======\$" $rr/preimage &&
-	! test -f $rr/postimage &&
-	! test -f $rr/thisimage
+	! test_path_exists $rr/postimage &&
+	! test_path_exists $rr/thisimage
 '
 
 test_expect_success 'rerere.enabled works, too' '
@@ -110,8 +110,8 @@ test_expect_success 'set up rr-cache' '
 
 test_expect_success 'rr-cache looks sane' '
 	# no postimage or thisimage yet
-	! test -f $rr/postimage &&
-	! test -f $rr/thisimage &&
+	! test_path_exists $rr/postimage &&
+	! test_path_exists $rr/thisimage &&
 
 	# preimage has right number of lines
 	cnt=$(sed -ne "/^<<<<<<</,/^>>>>>>>/p" $rr/preimage | wc -l) &&
@@ -167,7 +167,7 @@ test_expect_success 'first postimage wins' '
 	git show first:a1 | sed "s/To die: t/To die! T/" >expect &&
 
 	git commit -q -a -m "prefer first over second" &&
-	test -f $rr/postimage &&
+	test_path_exists $rr/postimage &&
 
 	oldmtimepost=$(test-tool chmtime --get -60 $rr/postimage) &&
 
@@ -190,14 +190,14 @@ test_expect_success 'rerere clear' '
 	mv $rr/postimage .git/post-saved &&
 	echo "$sha1	a1" | tr "\012" "\000" >.git/MERGE_RR &&
 	git rerere clear &&
-	! test -d $rr
+	! test_path_exists $rr
 '
 
 test_expect_success 'leftover directory' '
 	git reset --hard &&
 	mkdir -p $rr &&
 	test_must_fail git merge first &&
-	test -f $rr/preimage
+	test_path_exists $rr/preimage
 '
 
 test_expect_success 'missing preimage' '
@@ -205,7 +205,7 @@ test_expect_success 'missing preimage' '
 	mkdir -p $rr &&
 	cp .git/post-saved $rr/postimage &&
 	test_must_fail git merge first &&
-	test -f $rr/preimage
+	test_path_exists $rr/preimage
 '
 
 test_expect_success 'set up for garbage collection tests' '
@@ -230,16 +230,16 @@ test_expect_success 'set up for garbage collection tests' '
 
 test_expect_success 'gc preserves young or recently used records' '
 	git rerere gc &&
-	test -f $rr/preimage &&
-	test -f $rr2/preimage
+	test_path_exists $rr/preimage &&
+	test_path_exists $rr2/preimage
 '
 
 test_expect_success 'old records rest in peace' '
 	test-tool chmtime =$just_over_60_days_ago $rr/postimage &&
 	test-tool chmtime =$just_over_15_days_ago $rr2/preimage &&
 	git rerere gc &&
-	! test -f $rr/preimage &&
-	! test -f $rr2/preimage
+	! test_path_exists $rr/preimage &&
+	! test_path_exists $rr2/preimage
 '
 
 rerere_gc_custom_expiry_test () {
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] t4200: replace test -f and test -d with test_path_exists
  2026-03-16  4:22 [PATCH v2] t4200: replace test -f and test -d with test_path_exists PRASHANT S BISHT
@ 2026-03-16  6:37 ` Eric Sunshine
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Sunshine @ 2026-03-16  6:37 UTC (permalink / raw)
  To: PRASHANT S BISHT; +Cc: git

On Mon, Mar 16, 2026 at 12:23 AM PRASHANT S BISHT
<prashantjee2025@gmail.com> wrote:
> Replace old-style path existence checks with the modern test_path_exists
> helper function that provides clearer diagnostic messages on failure.
>
> This conversion focuses on test assertions within test_expect_success
> blocks where a missing path genuinely indicates a test failure,
> rather than on control-flow checks (such as those in test_lazy_prereq
> blocks) where missing paths are expected in certain environments.
>
> Signed-off-by: PRASHANT S BISHT <prashantjee2025@gmail.com>
> ---
> diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh
> @@ -72,7 +72,7 @@ test_expect_success 'nothing recorded without rerere' '
>         test_must_fail git merge first &&
> -       ! test -d .git/rr-cache
> +       ! test_path_exists .git/rr-cache

Unfortunately, this conversion and all of the others involving `!` are
incorrect. Take a look at the implementations of `test_path_exists`
and other `test_path_*` functions in t/test-lib/functions.sh to see if
you can figure out why and what the proper change should be. (Hint: We
want test failures to be noisy and explanatory, while successes should
be silent.)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-16  6:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-16  4:22 [PATCH v2] t4200: replace test -f and test -d with test_path_exists PRASHANT S BISHT
2026-03-16  6:37 ` Eric Sunshine
  -- strict thread matches above, loose matches on Subject: below --
2026-03-10  8:43 PRASHANT S BISHT

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox