Skip to content

Commit e579aaa

Browse files
committed
t4200: parameterize "rerere gc" custom expiry test
The test creates a rerere database entry that is two days old, and tries to expire with three different custom expiry configuration (keep ones less than 5 days old, keep ones used less than 5 days ago, and expire everything right now). We'll be introducing a different way to spell the same "5 days" and "right now" parameter in a later step; parameterize the test to make it easier to test the new spelling when it happens. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1ad8b47 commit e579aaa

File tree

1 file changed

+33
-25
lines changed

1 file changed

+33
-25
lines changed

t/t4200-rerere.sh

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -239,32 +239,40 @@ test_expect_success 'old records rest in peace' '
239239
! test -f $rr2/preimage
240240
'
241241

242-
test_expect_success 'rerere gc with custom expiry' '
243-
rm -fr .git/rr-cache &&
244-
rr=.git/rr-cache/$_z40 &&
245-
mkdir -p "$rr" &&
246-
>"$rr/preimage" &&
247-
>"$rr/postimage" &&
248-
249-
two_days_ago=$((-2*86400)) &&
250-
test-chmtime =$two_days_ago "$rr/preimage" &&
251-
test-chmtime =$two_days_ago "$rr/postimage" &&
252-
253-
find .git/rr-cache -type f | sort >original &&
254-
255-
git -c gc.rerereresolved=5 -c gc.rerereunresolved=5 rerere gc &&
256-
find .git/rr-cache -type f | sort >actual &&
257-
test_cmp original actual &&
258-
259-
git -c gc.rerereresolved=5 -c gc.rerereunresolved=0 rerere gc &&
260-
find .git/rr-cache -type f | sort >actual &&
261-
test_cmp original actual &&
242+
rerere_gc_custom_expiry_test () {
243+
five_days="$1" right_now="$2"
244+
test_expect_success "rerere gc with custom expiry ($five_days, $right_now)" '
245+
rm -fr .git/rr-cache &&
246+
rr=.git/rr-cache/$_z40 &&
247+
mkdir -p "$rr" &&
248+
>"$rr/preimage" &&
249+
>"$rr/postimage" &&
250+
251+
two_days_ago=$((-2*86400)) &&
252+
test-chmtime =$two_days_ago "$rr/preimage" &&
253+
test-chmtime =$two_days_ago "$rr/postimage" &&
254+
255+
find .git/rr-cache -type f | sort >original &&
256+
257+
git -c "gc.rerereresolved=$five_days" \
258+
-c "gc.rerereunresolved=$five_days" rerere gc &&
259+
find .git/rr-cache -type f | sort >actual &&
260+
test_cmp original actual &&
261+
262+
git -c "gc.rerereresolved=$five_days" \
263+
-c "gc.rerereunresolved=$right_now" rerere gc &&
264+
find .git/rr-cache -type f | sort >actual &&
265+
test_cmp original actual &&
266+
267+
git -c "gc.rerereresolved=$right_now" \
268+
-c "gc.rerereunresolved=$right_now" rerere gc &&
269+
find .git/rr-cache -type f | sort >actual &&
270+
>expect &&
271+
test_cmp expect actual
272+
'
273+
}
262274

263-
git -c gc.rerereresolved=0 -c gc.rerereunresolved=0 rerere gc &&
264-
find .git/rr-cache -type f | sort >actual &&
265-
>expect &&
266-
test_cmp expect actual
267-
'
275+
rerere_gc_custom_expiry_test 5 0
268276

269277
test_expect_success 'setup: file2 added differently in two branches' '
270278
git reset --hard &&

0 commit comments

Comments
 (0)