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

[PATCH v2 1/1] t2401: update path checks using test_path helpers

From
Solly <solobarine@gmail.com>
Date
Oct 15, 2025, 14:03 UTC
Message-ID
<20251015140329.13691-2-solobarine@gmail.com>
In-Reply-To
<20251015140329.13691-1-solobarine@gmail.com>

Update old-style shell path checks to use the modern test helpers 'test_path_is_file' and 'test_path_is_dir' for improved runtime diagnosis.

Signed-off-by: Solly <solobarine@gmail.com>
---
 t/t2401-worktree-prune.sh | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/t/t2401-worktree-prune.sh b/t/t2401-worktree-prune.sh
index fe671d4197..f8f28c76ee 100755
--- a/t/t2401-worktree-prune.sh
+++ b/t/t2401-worktree-prune.sh
@@ -24,8 +24,8 @@ test_expect_success 'prune files inside $GIT_DIR/worktrees' '
 Removing worktrees/abc: not a valid directory
 EOF
 	test_cmp expect actual &&
-	! test -f .git/worktrees/abc &&
-	! test -d .git/worktrees
+	test_path_is_missing .git/worktrees/abc &&
+	test_path_is_missing .git/worktrees
 '
 
 test_expect_success 'prune directories without gitdir' '
@@ -36,8 +36,8 @@ Removing worktrees/def: gitdir file does not exist
 EOF
 	git worktree prune --verbose 2>actual &&
 	test_cmp expect actual &&
-	! test -d .git/worktrees/def &&
-	! test -d .git/worktrees
+	test_path_is_missing .git/worktrees/def &&
+	test_path_is_missing .git/worktrees
 '
 
 test_expect_success SANITY 'prune directories with unreadable gitdir' '
@@ -47,8 +47,8 @@ test_expect_success SANITY 'prune directories with unreadable gitdir' '
 	chmod u-r .git/worktrees/def/gitdir &&
 	git worktree prune --verbose 2>actual &&
 	test_grep "Removing worktrees/def: unable to read gitdir file" actual &&
-	! test -d .git/worktrees/def &&
-	! test -d .git/worktrees
+	test_path_is_missing .git/worktrees/def &&
+	test_path_is_missing .git/worktrees
 '
 
 test_expect_success 'prune directories with invalid gitdir' '
@@ -57,8 +57,8 @@ test_expect_success 'prune directories with invalid gitdir' '
 	: >.git/worktrees/def/gitdir &&
 	git worktree prune --verbose 2>actual &&
 	test_grep "Removing worktrees/def: invalid gitdir file" actual &&
-	! test -d .git/worktrees/def &&
-	! test -d .git/worktrees
+	test_path_is_missing .git/worktrees/def &&
+	test_path_is_missing .git/worktrees
 '
 
 test_expect_success 'prune directories with gitdir pointing to nowhere' '
@@ -67,8 +67,8 @@ test_expect_success 'prune directories with gitdir pointing to nowhere' '
 	echo "$(pwd)"/nowhere >.git/worktrees/def/gitdir &&
 	git worktree prune --verbose 2>actual &&
 	test_grep "Removing worktrees/def: gitdir file points to non-existent location" actual &&
-	! test -d .git/worktrees/def &&
-	! test -d .git/worktrees
+	test_path_is_missing .git/worktrees/def &&
+	test_path_is_missing .git/worktrees
 '
 
 test_expect_success 'not prune locked checkout' '
@@ -76,23 +76,23 @@ test_expect_success 'not prune locked checkout' '
 	mkdir -p .git/worktrees/ghi &&
 	: >.git/worktrees/ghi/locked &&
 	git worktree prune &&
-	test -d .git/worktrees/ghi
+	test_path_is_dir .git/worktrees/ghi
 '
 
 test_expect_success 'not prune recent checkouts' '
 	test_when_finished rm -r .git/worktrees &&
 	git worktree add jlm HEAD &&
-	test -d .git/worktrees/jlm &&
+	test_path_is_dir .git/worktrees/jlm &&
 	rm -rf jlm &&
 	git worktree prune --verbose --expire=2.days.ago &&
-	test -d .git/worktrees/jlm
+	test_path_is_dir .git/worktrees/jlm
 '
 
 test_expect_success 'not prune proper checkouts' '
 	test_when_finished rm -r .git/worktrees &&
 	git worktree add --detach "$PWD/nop" main &&
 	git worktree prune &&
-	test -d .git/worktrees/nop
+	test_path_is_dir .git/worktrees/nop
 '
 
 test_expect_success 'prune duplicate (linked/linked)' '
@@ -103,8 +103,8 @@ test_expect_success 'prune duplicate (linked/linked)' '
 	mv .git/worktrees/w2/gitdir.new .git/worktrees/w2/gitdir &&
 	git worktree prune --verbose 2>actual &&
 	test_grep "duplicate entry" actual &&
-	test -d .git/worktrees/w1 &&
-	! test -d .git/worktrees/w2
+	test_path_is_dir .git/worktrees/w1 &&
+	test_path_is_missing .git/worktrees/w2
 '
 
 test_expect_success 'prune duplicate (main/linked)' '
@@ -116,7 +116,7 @@ test_expect_success 'prune duplicate (main/linked)' '
 	mv repo wt &&
 	git -C wt worktree prune --verbose 2>actual &&
 	test_grep "duplicate entry" actual &&
-	! test -d .git/worktrees/wt
+	test_path_is_missing .git/worktrees/wt
 '
 
 test_expect_success 'not prune proper worktrees inside linked worktree with relative paths' '
-- 
2.34.1
Previous: SollyNext: Junio C Hamano
Message 6 of 7 in “t: update path checks using test_path helpers”
  1. 1/1 t: update path checks using test_path helpersSolly, Oct 14, 2025
  2. Junio C HamanoOct 14, 2025
  3. Usman AkinyemiOct 14, 2025
  4. Eric SunshineOct 14, 2025
  5. 0/1 *** t2401: update path checks using test_path helpers ***Solly, Oct 15, 2025
  6. 1/1 t2401: update path checks using test_path helpersSolly, Oct 15, 2025
  7. Junio C HamanoOct 15, 2025

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.