t2401: update path checks using test_path helpers
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Solly committed
Oct 15, 2025 at 15:03 UTC
0c4f1346ca57814a988be0846f9ec1560dea87dc
1 file changed
+17
-17
t/t2401-worktree-prune.sh
+17
-17
@@ -24,8 +24,8 @@ test_expect_success 'prune files inside $GIT_DIR/worktrees' '
24
Removing worktrees/abc: not a valid directory
25
EOF
26
test_cmp expect actual &&
27
- ! test -f .git/worktrees/abc &&
28
- ! test -d .git/worktrees
27
+ test_path_is_missing .git/worktrees/abc &&
28
+ test_path_is_missing .git/worktrees
29
'
30
31
test_expect_success 'prune directories without gitdir' '
@@ -36,8 +36,8 @@ Removing worktrees/def: gitdir file does not exist
36
EOF
37
git worktree prune --verbose 2>actual &&
38
test_cmp expect actual &&
39
- ! test -d .git/worktrees/def &&
40
- ! test -d .git/worktrees
39
+ test_path_is_missing .git/worktrees/def &&
40
+ test_path_is_missing .git/worktrees
41
'
42
43
test_expect_success SANITY 'prune directories with unreadable gitdir' '
@@ -47,8 +47,8 @@ test_expect_success SANITY 'prune directories with unreadable gitdir' '
47
chmod u-r .git/worktrees/def/gitdir &&
48
git worktree prune --verbose 2>actual &&
49
test_grep "Removing worktrees/def: unable to read gitdir file" actual &&
50
- ! test -d .git/worktrees/def &&
51
- ! test -d .git/worktrees
50
+ test_path_is_missing .git/worktrees/def &&
51
+ test_path_is_missing .git/worktrees
52
'
53
54
test_expect_success 'prune directories with invalid gitdir' '
@@ -57,8 +57,8 @@ test_expect_success 'prune directories with invalid gitdir' '
57
: >.git/worktrees/def/gitdir &&
58
git worktree prune --verbose 2>actual &&
59
test_grep "Removing worktrees/def: invalid gitdir file" actual &&
60
- ! test -d .git/worktrees/def &&
61
- ! test -d .git/worktrees
60
+ test_path_is_missing .git/worktrees/def &&
61
+ test_path_is_missing .git/worktrees
62
'
63
64
test_expect_success 'prune directories with gitdir pointing to nowhere' '
@@ -67,8 +67,8 @@ test_expect_success 'prune directories with gitdir pointing to nowhere' '
67
echo "$(pwd)"/nowhere >.git/worktrees/def/gitdir &&
68
git worktree prune --verbose 2>actual &&
69
test_grep "Removing worktrees/def: gitdir file points to non-existent location" actual &&
70
- ! test -d .git/worktrees/def &&
71
- ! test -d .git/worktrees
70
+ test_path_is_missing .git/worktrees/def &&
71
+ test_path_is_missing .git/worktrees
72
'
73
74
test_expect_success 'not prune locked checkout' '
@@ -76,23 +76,23 @@ test_expect_success 'not prune locked checkout' '
76
mkdir -p .git/worktrees/ghi &&
77
: >.git/worktrees/ghi/locked &&
78
git worktree prune &&
79
- test -d .git/worktrees/ghi
79
+ test_path_is_dir .git/worktrees/ghi
80
'
81
82
test_expect_success 'not prune recent checkouts' '
83
test_when_finished rm -r .git/worktrees &&
84
git worktree add jlm HEAD &&
85
- test -d .git/worktrees/jlm &&
85
+ test_path_is_dir .git/worktrees/jlm &&
86
rm -rf jlm &&
87
git worktree prune --verbose --expire=2.days.ago &&
88
- test -d .git/worktrees/jlm
88
+ test_path_is_dir .git/worktrees/jlm
89
'
90
91
test_expect_success 'not prune proper checkouts' '
92
test_when_finished rm -r .git/worktrees &&
93
git worktree add --detach "$PWD/nop" main &&
94
git worktree prune &&
95
- test -d .git/worktrees/nop
95
+ test_path_is_dir .git/worktrees/nop
96
'
97
98
test_expect_success 'prune duplicate (linked/linked)' '
@@ -103,8 +103,8 @@ test_expect_success 'prune duplicate (linked/linked)' '
103
mv .git/worktrees/w2/gitdir.new .git/worktrees/w2/gitdir &&
104
git worktree prune --verbose 2>actual &&
105
test_grep "duplicate entry" actual &&
106
- test -d .git/worktrees/w1 &&
107
- ! test -d .git/worktrees/w2
106
+ test_path_is_dir .git/worktrees/w1 &&
107
+ test_path_is_missing .git/worktrees/w2
108
'
109
110
test_expect_success 'prune duplicate (main/linked)' '
@@ -116,7 +116,7 @@ test_expect_success 'prune duplicate (main/linked)' '
116
mv repo wt &&
117
git -C wt worktree prune --verbose 2>actual &&
118
test_grep "duplicate entry" actual &&
119
- ! test -d .git/worktrees/wt
119
+ test_path_is_missing .git/worktrees/wt
120
'
121
122
test_expect_success 'not prune proper worktrees inside linked worktree with relative paths' '