t2004: use test_path_is_file instead of test -f
Replace 'test -f' with the helper function 'test_path_is_file' to provide better error messages upon failure. Signed-off-by: Lambert Duclos-de Guise <lambertddg@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Lambert Duclos-de Guise committed
Feb 21, 2026 at 17:28 UTC
a4b61a71c4060748e4d6e8d970e52989c04f1f88
1 file changed
+21
-21
t/t2004-checkout-cache-temp.sh
+21
-21
@@ -42,7 +42,7 @@ test_expect_success 'checkout one stage 0 to temporary file' '
42
test_line_count = 1 actual &&
43
test $(cut "-d " -f2 actual) = path1 &&
44
p=$(cut "-d " -f1 actual) &&
45
- test -f $p &&
45
+ test_path_is_file $p &&
46
test $(cat $p) = tree1path1
47
'
48
@@ -55,7 +55,7 @@ test_expect_success 'checkout all stage 0 to temporary files' '
55
do
56
test $(grep $f actual | cut "-d " -f2) = $f &&
57
p=$(grep $f actual | cut "-d " -f1) &&
58
- test -f $p &&
58
+ test_path_is_file $p &&
59
test $(cat $p) = tree1$f || return 1
60
done
61
'
@@ -71,7 +71,7 @@ test_expect_success 'checkout one stage 2 to temporary file' '
71
test_line_count = 1 actual &&
72
test $(cut "-d " -f2 actual) = path1 &&
73
p=$(cut "-d " -f1 actual) &&
74
- test -f $p &&
74
+ test_path_is_file $p &&
75
test $(cat $p) = tree2path1
76
'
77
@@ -83,7 +83,7 @@ test_expect_success 'checkout all stage 2 to temporary files' '
83
do
84
test $(grep $f actual | cut "-d " -f2) = $f &&
85
p=$(grep $f actual | cut "-d " -f1) &&
86
- test -f $p &&
86
+ test_path_is_file $p &&
87
test $(cat $p) = tree2$f || return 1
88
done
89
'
@@ -108,9 +108,9 @@ test_expect_success 'checkout all stages/one file to temporary files' '
108
test_line_count = 1 actual &&
109
test $(cut "-d " -f2 actual) = path1 &&
110
cut "-d " -f1 actual | (read s1 s2 s3 &&
111
- test -f $s1 &&
112
- test -f $s2 &&
113
- test -f $s3 &&
111
+ test_path_is_file $s1 &&
112
+ test_path_is_file $s2 &&
113
+ test_path_is_file $s3 &&
114
test $(cat $s1) = tree1path1 &&
115
test $(cat $s2) = tree2path1 &&
116
test $(cat $s3) = tree3path1)
@@ -143,8 +143,8 @@ test_expect_success 'checkout some stages/one file to temporary files' '
143
test $(cut "-d " -f2 actual) = path2 &&
144
cut "-d " -f1 actual | (read s1 s2 s3 &&
145
test $s1 = . &&
146
- test -f $s2 &&
147
- test -f $s3 &&
146
+ test_path_is_file $s2 &&
147
+ test_path_is_file $s3 &&
148
test $(cat $s2) = tree2path2 &&
149
test $(cat $s3) = tree3path2)
150
'
@@ -162,9 +162,9 @@ test_expect_success '-- path0: no entry' '
162
test_expect_success '-- path1: all 3 stages' '
163
test $(grep path1 actual | cut "-d " -f2) = path1 &&
164
grep path1 actual | cut "-d " -f1 | (read s1 s2 s3 &&
165
- test -f $s1 &&
166
- test -f $s2 &&
167
- test -f $s3 &&
165
+ test_path_is_file $s1 &&
166
+ test_path_is_file $s2 &&
167
+ test_path_is_file $s3 &&
168
test $(cat $s1) = tree1path1 &&
169
test $(cat $s2) = tree2path1 &&
170
test $(cat $s3) = tree3path1)
@@ -174,8 +174,8 @@ test_expect_success '-- path2: no stage 1, have stage 2 and 3' '
174
test $(grep path2 actual | cut "-d " -f2) = path2 &&
175
grep path2 actual | cut "-d " -f1 | (read s1 s2 s3 &&
176
test $s1 = . &&
177
- test -f $s2 &&
178
- test -f $s3 &&
177
+ test_path_is_file $s2 &&
178
+ test_path_is_file $s3 &&
179
test $(cat $s2) = tree2path2 &&
180
test $(cat $s3) = tree3path2)
181
'
@@ -183,9 +183,9 @@ test_expect_success '-- path2: no stage 1, have stage 2 and 3' '
183
test_expect_success '-- path3: no stage 2, have stage 1 and 3' '
184
test $(grep path3 actual | cut "-d " -f2) = path3 &&
185
grep path3 actual | cut "-d " -f1 | (read s1 s2 s3 &&
186
- test -f $s1 &&
186
+ test_path_is_file $s1 &&
187
test $s2 = . &&
188
- test -f $s3 &&
188
+ test_path_is_file $s3 &&
189
test $(cat $s1) = tree1path3 &&
190
test $(cat $s3) = tree3path3)
191
'
@@ -193,8 +193,8 @@ test_expect_success '-- path3: no stage 2, have stage 1 and 3' '
193
test_expect_success '-- path4: no stage 3, have stage 1 and 3' '
194
test $(grep path4 actual | cut "-d " -f2) = path4 &&
195
grep path4 actual | cut "-d " -f1 | (read s1 s2 s3 &&
196
- test -f $s1 &&
197
- test -f $s2 &&
196
+ test_path_is_file $s1 &&
197
+ test_path_is_file $s2 &&
198
test $s3 = . &&
199
test $(cat $s1) = tree1path4 &&
200
test $(cat $s2) = tree2path4)
@@ -203,7 +203,7 @@ test_expect_success '-- path4: no stage 3, have stage 1 and 3' '
203
test_expect_success '-- asubdir/path5: no stage 2 and 3 have stage 1' '
204
test $(grep asubdir/path5 actual | cut "-d " -f2) = asubdir/path5 &&
205
grep asubdir/path5 actual | cut "-d " -f1 | (read s1 s2 s3 &&
206
- test -f $s1 &&
206
+ test_path_is_file $s1 &&
207
test $s2 = . &&
208
test $s3 = . &&
209
test $(cat $s1) = tree1asubdir/path5)
@@ -216,7 +216,7 @@ test_expect_success 'checkout --temp within subdir' '
216
test_line_count = 1 actual &&
217
test $(grep path5 actual | cut "-d " -f2) = path5 &&
218
grep path5 actual | cut "-d " -f1 | (read s1 s2 s3 &&
219
- test -f ../$s1 &&
219
+ test_path_is_file ../$s1 &&
220
test $s2 = . &&
221
test $s3 = . &&
222
test $(cat ../$s1) = tree1asubdir/path5)
@@ -230,7 +230,7 @@ test_expect_success 'checkout --temp symlink' '
230
test_line_count = 1 actual &&
231
test $(cut "-d " -f2 actual) = path6 &&
232
p=$(cut "-d " -f1 actual) &&
233
- test -f $p &&
233
+ test_path_is_file $p &&
234
test $(cat $p) = path7
235
'
236