Skip to content

Commit 71c3e02

Browse files
committed
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>
1 parent 67ad421 commit 71c3e02

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

t/t2004-checkout-cache-temp.sh

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ test_expect_success 'checkout one stage 0 to temporary file' '
4242
test_line_count = 1 actual &&
4343
test $(cut "-d " -f2 actual) = path1 &&
4444
p=$(cut "-d " -f1 actual) &&
45-
test -f $p &&
45+
test_path_is_file $p &&
4646
test $(cat $p) = tree1path1
4747
'
4848

@@ -55,7 +55,7 @@ test_expect_success 'checkout all stage 0 to temporary files' '
5555
do
5656
test $(grep $f actual | cut "-d " -f2) = $f &&
5757
p=$(grep $f actual | cut "-d " -f1) &&
58-
test -f $p &&
58+
test_path_is_file $p &&
5959
test $(cat $p) = tree1$f || return 1
6060
done
6161
'
@@ -71,7 +71,7 @@ test_expect_success 'checkout one stage 2 to temporary file' '
7171
test_line_count = 1 actual &&
7272
test $(cut "-d " -f2 actual) = path1 &&
7373
p=$(cut "-d " -f1 actual) &&
74-
test -f $p &&
74+
test_path_is_file $p &&
7575
test $(cat $p) = tree2path1
7676
'
7777

@@ -83,7 +83,7 @@ test_expect_success 'checkout all stage 2 to temporary files' '
8383
do
8484
test $(grep $f actual | cut "-d " -f2) = $f &&
8585
p=$(grep $f actual | cut "-d " -f1) &&
86-
test -f $p &&
86+
test_path_is_file $p &&
8787
test $(cat $p) = tree2$f || return 1
8888
done
8989
'
@@ -108,9 +108,9 @@ test_expect_success 'checkout all stages/one file to temporary files' '
108108
test_line_count = 1 actual &&
109109
test $(cut "-d " -f2 actual) = path1 &&
110110
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 &&
114114
test $(cat $s1) = tree1path1 &&
115115
test $(cat $s2) = tree2path1 &&
116116
test $(cat $s3) = tree3path1)
@@ -143,8 +143,8 @@ test_expect_success 'checkout some stages/one file to temporary files' '
143143
test $(cut "-d " -f2 actual) = path2 &&
144144
cut "-d " -f1 actual | (read s1 s2 s3 &&
145145
test $s1 = . &&
146-
test -f $s2 &&
147-
test -f $s3 &&
146+
test_path_is_file $s2 &&
147+
test_path_is_file $s3 &&
148148
test $(cat $s2) = tree2path2 &&
149149
test $(cat $s3) = tree3path2)
150150
'
@@ -162,9 +162,9 @@ test_expect_success '-- path0: no entry' '
162162
test_expect_success '-- path1: all 3 stages' '
163163
test $(grep path1 actual | cut "-d " -f2) = path1 &&
164164
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 &&
168168
test $(cat $s1) = tree1path1 &&
169169
test $(cat $s2) = tree2path1 &&
170170
test $(cat $s3) = tree3path1)
@@ -174,27 +174,27 @@ test_expect_success '-- path2: no stage 1, have stage 2 and 3' '
174174
test $(grep path2 actual | cut "-d " -f2) = path2 &&
175175
grep path2 actual | cut "-d " -f1 | (read s1 s2 s3 &&
176176
test $s1 = . &&
177-
test -f $s2 &&
178-
test -f $s3 &&
177+
test_path_is_file $s2 &&
178+
test_path_is_file $s3 &&
179179
test $(cat $s2) = tree2path2 &&
180180
test $(cat $s3) = tree3path2)
181181
'
182182

183183
test_expect_success '-- path3: no stage 2, have stage 1 and 3' '
184184
test $(grep path3 actual | cut "-d " -f2) = path3 &&
185185
grep path3 actual | cut "-d " -f1 | (read s1 s2 s3 &&
186-
test -f $s1 &&
186+
test_path_is_file $s1 &&
187187
test $s2 = . &&
188-
test -f $s3 &&
188+
test_path_is_file $s3 &&
189189
test $(cat $s1) = tree1path3 &&
190190
test $(cat $s3) = tree3path3)
191191
'
192192

193193
test_expect_success '-- path4: no stage 3, have stage 1 and 3' '
194194
test $(grep path4 actual | cut "-d " -f2) = path4 &&
195195
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 &&
198198
test $s3 = . &&
199199
test $(cat $s1) = tree1path4 &&
200200
test $(cat $s2) = tree2path4)
@@ -203,7 +203,7 @@ test_expect_success '-- path4: no stage 3, have stage 1 and 3' '
203203
test_expect_success '-- asubdir/path5: no stage 2 and 3 have stage 1' '
204204
test $(grep asubdir/path5 actual | cut "-d " -f2) = asubdir/path5 &&
205205
grep asubdir/path5 actual | cut "-d " -f1 | (read s1 s2 s3 &&
206-
test -f $s1 &&
206+
test_path_is_file $s1 &&
207207
test $s2 = . &&
208208
test $s3 = . &&
209209
test $(cat $s1) = tree1asubdir/path5)
@@ -216,7 +216,7 @@ test_expect_success 'checkout --temp within subdir' '
216216
test_line_count = 1 actual &&
217217
test $(grep path5 actual | cut "-d " -f2) = path5 &&
218218
grep path5 actual | cut "-d " -f1 | (read s1 s2 s3 &&
219-
test -f ../$s1 &&
219+
test_path_is_file ../$s1 &&
220220
test $s2 = . &&
221221
test $s3 = . &&
222222
test $(cat ../$s1) = tree1asubdir/path5)
@@ -230,7 +230,7 @@ test_expect_success 'checkout --temp symlink' '
230230
test_line_count = 1 actual &&
231231
test $(cut "-d " -f2 actual) = path6 &&
232232
p=$(cut "-d " -f1 actual) &&
233-
test -f $p &&
233+
test_path_is_file $p &&
234234
test $(cat $p) = path7
235235
'
236236

0 commit comments

Comments
 (0)