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 <gitster@pobox.com>
Junio C Hamano committed
Aug 22, 2017 at 14:25 UTC
e579aaa64d8a24013de6cdd3fb3028e25d9a0917
1 file changed
+33
-25
t/t4200-rerere.sh
+33
-25
@@ -239,32 +239,40 @@ test_expect_success 'old records rest in peace' '
239
! test -f $rr2/preimage
240
'
241
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
+}
274
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
276
277
test_expect_success 'setup: file2 added differently in two branches' '
278
git reset --hard &&