t4200: convert test -[df] checks to test_path_* helpers
Replace old-style path existence checks in t4200-rerere.sh with the appropriate test_path_* helper functions. These helpers provide clearer diagnostic messages on failure than the raw shell test builtin. Signed-off-by: Prashant S Bisht <prashantjee2025@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
PRASHANT S BISHT committed
Mar 16, 2026 at 22:54 UTC
d893f3e7cc0a49ac62ff0ec16d7fdbf606399333
1 file changed
+13
-13
t/t4200-rerere.sh
+13
-13
@@ -72,7 +72,7 @@ test_expect_success 'nothing recorded without rerere' '
72
rm -rf .git/rr-cache &&
73
git config rerere.enabled false &&
74
test_must_fail git merge first &&
75
- ! test -d .git/rr-cache
75
+ test_path_is_missing .git/rr-cache
76
'
77
78
test_expect_success 'activate rerere, old style (conflicting merge)' '
@@ -84,8 +84,8 @@ test_expect_success 'activate rerere, old style (conflicting merge)' '
84
sha1=$(sed "s/ .*//" .git/MERGE_RR) &&
85
rr=.git/rr-cache/$sha1 &&
86
grep "^=======\$" $rr/preimage &&
87
- ! test -f $rr/postimage &&
88
- ! test -f $rr/thisimage
87
+ test_path_is_missing $rr/postimage &&
88
+ test_path_is_missing $rr/thisimage
89
'
90
91
test_expect_success 'rerere.enabled works, too' '
@@ -110,8 +110,8 @@ test_expect_success 'set up rr-cache' '
110
111
test_expect_success 'rr-cache looks sane' '
112
# no postimage or thisimage yet
113
- ! test -f $rr/postimage &&
114
- ! test -f $rr/thisimage &&
113
+ test_path_is_missing $rr/postimage &&
114
+ test_path_is_missing $rr/thisimage &&
115
116
# preimage has right number of lines
117
cnt=$(sed -ne "/^<<<<<<</,/^>>>>>>>/p" $rr/preimage | wc -l) &&
@@ -167,7 +167,7 @@ test_expect_success 'first postimage wins' '
167
git show first:a1 | sed "s/To die: t/To die! T/" >expect &&
168
169
git commit -q -a -m "prefer first over second" &&
170
- test -f $rr/postimage &&
170
+ test_path_is_file $rr/postimage &&
171
172
oldmtimepost=$(test-tool chmtime --get -60 $rr/postimage) &&
173
@@ -190,14 +190,14 @@ test_expect_success 'rerere clear' '
190
mv $rr/postimage .git/post-saved &&
191
echo "$sha1 a1" | tr "\012" "\000" >.git/MERGE_RR &&
192
git rerere clear &&
193
- ! test -d $rr
193
+ test_path_is_missing $rr
194
'
195
196
test_expect_success 'leftover directory' '
197
git reset --hard &&
198
mkdir -p $rr &&
199
test_must_fail git merge first &&
200
- test -f $rr/preimage
200
+ test_path_is_file $rr/preimage
201
'
202
203
test_expect_success 'missing preimage' '
@@ -205,7 +205,7 @@ test_expect_success 'missing preimage' '
205
mkdir -p $rr &&
206
cp .git/post-saved $rr/postimage &&
207
test_must_fail git merge first &&
208
- test -f $rr/preimage
208
+ test_path_is_file $rr/preimage
209
'
210
211
test_expect_success 'set up for garbage collection tests' '
@@ -230,16 +230,16 @@ test_expect_success 'set up for garbage collection tests' '
230
231
test_expect_success 'gc preserves young or recently used records' '
232
git rerere gc &&
233
- test -f $rr/preimage &&
234
- test -f $rr2/preimage
233
+ test_path_is_file $rr/preimage &&
234
+ test_path_is_file $rr2/preimage
235
'
236
237
test_expect_success 'old records rest in peace' '
238
test-tool chmtime =$just_over_60_days_ago $rr/postimage &&
239
test-tool chmtime =$just_over_15_days_ago $rr2/preimage &&
240
git rerere gc &&
241
- ! test -f $rr/preimage &&
242
- ! test -f $rr2/preimage
241
+ test_path_is_missing $rr/preimage &&
242
+ test_path_is_missing $rr2/preimage
243
'
244
245
rerere_gc_custom_expiry_test () {