Skip to content

Commit c277344

Browse files
committed
t4200: make "rerere gc" test more robust
The test blindly trusted that there may be _some_ entries left in the rerere database, and used them by updating their timestamps to see if the gc threshold variables are honoured correctly. This won't work if there is no entry in the database when the test begins. Instead, clear the rerere database, and populate it with a few known entries (which are bogus, but for the purpose of testing "garbage collection", it does not matter---we want to make sure we collect old cruft, even if the files are corrupt rerere database entries), and use them for the expiry test. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 780fbeb commit c277344

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

t/t4200-rerere.sh

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -420,19 +420,28 @@ count_pre_post () {
420420
}
421421

422422
test_expect_success 'rerere gc' '
423-
find .git/rr-cache -type f >original &&
424-
xargs test-chmtime -172800 <original &&
423+
rm -fr .git/rr-cache &&
424+
rr=.git/rr-cache/$_z40 &&
425+
mkdir -p "$rr" &&
426+
>"$rr/preimage" &&
427+
>"$rr/postimage" &&
428+
429+
two_days_ago=$((-2*86400)) &&
430+
test-chmtime =$two_days_ago "$rr/preimage" &&
431+
test-chmtime =$two_days_ago "$rr/postimage" &&
432+
433+
find .git/rr-cache -type f | sort >original &&
425434
426435
git -c gc.rerereresolved=5 -c gc.rerereunresolved=5 rerere gc &&
427-
find .git/rr-cache -type f >actual &&
436+
find .git/rr-cache -type f | sort >actual &&
428437
test_cmp original actual &&
429438
430439
git -c gc.rerereresolved=5 -c gc.rerereunresolved=0 rerere gc &&
431-
find .git/rr-cache -type f >actual &&
440+
find .git/rr-cache -type f | sort >actual &&
432441
test_cmp original actual &&
433442
434443
git -c gc.rerereresolved=0 -c gc.rerereunresolved=0 rerere gc &&
435-
find .git/rr-cache -type f >actual &&
444+
find .git/rr-cache -type f | sort >actual &&
436445
>expect &&
437446
test_cmp expect actual
438447
'

0 commit comments

Comments
 (0)