t2400: replace 'test -[efd]' with 'test_path_is_*'

'test_path_is_file', 'test_path_is_dir' and 'test_file_is_missing' are test helpers used in Git's development, that emit useful diagnostic information when they detect a failing condition, while test -[efd] does not. Replace the basic shell commands 'test -f', 'test -d' and 'test -e', with these test helpers. Co-authored-by: Isabella Caselli <icaselli@usp.br> Signed-off-by: Isabella Caselli <icaselli@usp.br> Signed-off-by: Rodrigo Michelassi <rodmichelassi@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Rodrigo Michelassi committed Jun 16, 2025 at 21:29 UTC 855cfc65aeca5b2458a6bc100eb1280a119fdb87
1 file changed +10 -10
t/t2400-worktree-add.sh
+10 -10
@@ -42,8 +42,8 @@ test_expect_success '"add" using - shorthand' '
42
43 test_expect_success '"add" refuses to checkout locked branch' '
44 test_must_fail git worktree add zere main &&
45 - ! test -d zere &&
46 - ! test -d .git/worktrees/zere
45 + test_path_is_missing zere &&
46 + test_path_is_missing .git/worktrees/zere
47 '
48
49 test_expect_success 'checking out paths not complaining about linked checkouts' '
@@ -70,14 +70,14 @@ test_expect_success '"add" worktree' '
70 test_expect_success '"add" worktree with lock' '
71 git worktree add --detach --lock here-with-lock main &&
72 test_when_finished "git worktree unlock here-with-lock || :" &&
73 - test -f .git/worktrees/here-with-lock/locked
73 + test_path_is_file .git/worktrees/here-with-lock/locked
74 '
75
76 test_expect_success '"add" worktree with lock and reason' '
77 lock_reason="why not" &&
78 git worktree add --detach --lock --reason "$lock_reason" here-with-lock-reason main &&
79 test_when_finished "git worktree unlock here-with-lock-reason || :" &&
80 - test -f .git/worktrees/here-with-lock-reason/locked &&
80 + test_path_is_file .git/worktrees/here-with-lock-reason/locked &&
81 echo "$lock_reason" >expect &&
82 test_cmp expect .git/worktrees/here-with-lock-reason/locked
83 '
@@ -412,14 +412,14 @@ test_expect_success '"add --orphan" with empty repository' '
412 test_expect_success '"add" worktree with orphan branch and lock' '
413 git worktree add --lock --orphan -b orphanbr orphan-with-lock &&
414 test_when_finished "git worktree unlock orphan-with-lock || :" &&
415 - test -f .git/worktrees/orphan-with-lock/locked
415 + test_path_is_file .git/worktrees/orphan-with-lock/locked
416 '
417
418 test_expect_success '"add" worktree with orphan branch, lock, and reason' '
419 lock_reason="why not" &&
420 git worktree add --detach --lock --reason "$lock_reason" orphan-with-lock-reason main &&
421 test_when_finished "git worktree unlock orphan-with-lock-reason || :" &&
422 - test -f .git/worktrees/orphan-with-lock-reason/locked &&
422 + test_path_is_file .git/worktrees/orphan-with-lock-reason/locked &&
423 echo "$lock_reason" >expect &&
424 test_cmp expect .git/worktrees/orphan-with-lock-reason/locked
425 '
@@ -474,7 +474,7 @@ test_expect_success 'local clone --shared from linked checkout' '
474
475 test_expect_success '"add" worktree with --no-checkout' '
476 git worktree add --no-checkout -b swamp swamp &&
477 - ! test -e swamp/init.t &&
477 + test_path_is_missing swamp/init.t &&
478 git -C swamp reset --hard &&
479 test_cmp init.t swamp/init.t
480 '
@@ -497,7 +497,7 @@ test_expect_success 'put a worktree under rebase' '
497
498 test_expect_success 'add a worktree, checking out a rebased branch' '
499 test_must_fail git worktree add new-rebase under-rebase &&
500 - ! test -d new-rebase
500 + test_path_is_missing new-rebase
501 '
502
503 test_expect_success 'checking out a rebased branch from another worktree' '
@@ -535,7 +535,7 @@ test_expect_success 'checkout a branch under bisect' '
535 git worktree list >actual &&
536 grep "under-bisect.*detached HEAD" actual &&
537 test_must_fail git worktree add new-bisect under-bisect &&
538 - ! test -d new-bisect
538 + test_path_is_missing new-bisect
539 )
540 '
541
@@ -1165,7 +1165,7 @@ test_expect_success '"add" not tripped up by magic worktree matching"' '
1165
1166 test_expect_success FUNNYNAMES 'sanitize generated worktree name' '
1167 git worktree add --detach ". weird*..?.lock.lock" &&
1168 - test -d .git/worktrees/---weird-.-
1168 + test_path_is_dir .git/worktrees/---weird-.-
1169 '
1170
1171 test_expect_success '"add" should not fail because of another bad worktree' '