t2003: modernize path existence checks using test helpers
The old style 'test -f' and 'test -d' checks are silent on failure, which makes debugging difficult. Replace them with the 'test_path_is_*' helpers which provide verbose error messages when a test fails. Signed-off-by: Burak Kaan Karaçay <bkkaracay@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Burak Kaan Karaçay committed
Feb 9, 2026 at 14:24 UTC
168d575719d944759964e004d17a3282b0f883d5
1 file changed
+25
-25
t/t2003-checkout-cache-mkdir.sh
+25
-25
@@ -24,27 +24,28 @@ test_expect_success SYMLINKS 'have symlink in place where dir is expected.' '
24
mkdir path2 &&
25
ln -s path2 path1 &&
26
git checkout-index -f -a &&
27
- test ! -h path1 && test -d path1 &&
28
- test -f path1/file1 && test ! -f path2/file1
27
+ test_path_is_dir_not_symlink path1 &&
28
+ test_path_is_file path1/file1 &&
29
+ test_path_is_missing path2/file1
30
'
31
32
test_expect_success 'use --prefix=path2/' '
33
rm -fr path0 path1 path2 &&
34
mkdir path2 &&
35
git checkout-index --prefix=path2/ -f -a &&
35
- test -f path2/path0 &&
36
- test -f path2/path1/file1 &&
37
- test ! -f path0 &&
38
- test ! -f path1/file1
36
+ test_path_is_file path2/path0 &&
37
+ test_path_is_file path2/path1/file1 &&
38
+ test_path_is_missing path0 &&
39
+ test_path_is_missing path1/file1
40
'
41
42
test_expect_success 'use --prefix=tmp-' '
43
rm -fr path0 path1 path2 tmp* &&
44
git checkout-index --prefix=tmp- -f -a &&
44
- test -f tmp-path0 &&
45
- test -f tmp-path1/file1 &&
46
- test ! -f path0 &&
47
- test ! -f path1/file1
45
+ test_path_is_file tmp-path0 &&
46
+ test_path_is_file tmp-path1/file1 &&
47
+ test_path_is_missing path0 &&
48
+ test_path_is_missing path1/file1
49
'
50
51
test_expect_success 'use --prefix=tmp- but with a conflicting file and dir' '
@@ -52,10 +53,10 @@ test_expect_success 'use --prefix=tmp- but with a conflicting file and dir' '
53
echo nitfol >tmp-path1 &&
54
mkdir tmp-path0 &&
55
git checkout-index --prefix=tmp- -f -a &&
55
- test -f tmp-path0 &&
56
- test -f tmp-path1/file1 &&
57
- test ! -f path0 &&
58
- test ! -f path1/file1
56
+ test_path_is_file tmp-path0 &&
57
+ test_path_is_file tmp-path1/file1 &&
58
+ test_path_is_missing path0 &&
59
+ test_path_is_missing path1/file1
60
'
61
62
test_expect_success SYMLINKS 'use --prefix=tmp/orary/ where tmp is a symlink' '
@@ -63,10 +64,10 @@ test_expect_success SYMLINKS 'use --prefix=tmp/orary/ where tmp is a symlink' '
64
mkdir tmp1 tmp1/orary &&
65
ln -s tmp1 tmp &&
66
git checkout-index --prefix=tmp/orary/ -f -a &&
66
- test -d tmp1/orary &&
67
- test -f tmp1/orary/path0 &&
68
- test -f tmp1/orary/path1/file1 &&
69
- test -h tmp
67
+ test_path_is_dir tmp1/orary &&
68
+ test_path_is_file tmp1/orary/path0 &&
69
+ test_path_is_file tmp1/orary/path1/file1 &&
70
+ test_path_is_symlink tmp
71
'
72
73
test_expect_success SYMLINKS 'use --prefix=tmp/orary- where tmp is a symlink' '
@@ -74,9 +75,9 @@ test_expect_success SYMLINKS 'use --prefix=tmp/orary- where tmp is a symlink' '
75
mkdir tmp1 &&
76
ln -s tmp1 tmp &&
77
git checkout-index --prefix=tmp/orary- -f -a &&
77
- test -f tmp1/orary-path0 &&
78
- test -f tmp1/orary-path1/file1 &&
79
- test -h tmp
78
+ test_path_is_file tmp1/orary-path0 &&
79
+ test_path_is_file tmp1/orary-path1/file1 &&
80
+ test_path_is_symlink tmp
81
'
82
83
test_expect_success SYMLINKS 'use --prefix=tmp- where tmp-path1 is a symlink' '
@@ -84,10 +85,9 @@ test_expect_success SYMLINKS 'use --prefix=tmp- where tmp-path1 is a symlink' '
85
mkdir tmp1 &&
86
ln -s tmp1 tmp-path1 &&
87
git checkout-index --prefix=tmp- -f -a &&
87
- test -f tmp-path0 &&
88
- test ! -h tmp-path1 &&
89
- test -d tmp-path1 &&
90
- test -f tmp-path1/file1
88
+ test_path_is_file tmp-path0 &&
89
+ test_path_is_dir_not_symlink tmp-path1 &&
90
+ test_path_is_file tmp-path1/file1
91
'
92
93
test_expect_success 'apply filter from working tree .gitattributes with --prefix' '