Skip to content

Commit 442136f

Browse files
committed
Merge branch 'dt/gc-ignore-old-gc-logs'
* dt/gc-ignore-old-gc-logs: t6500: wait for detached auto gc at the end of the test script
2 parents 2f9dfb8 + ef09036 commit 442136f

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

t/t6500-gc.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ test_expect_success 'auto gc with too many loose objects does not attempt to cre
6767
test_line_count = 2 new # There is one new pack and its .idx
6868
'
6969

70+
run_and_wait_for_auto_gc () {
71+
# We read stdout from gc for the side effect of waiting until the
72+
# background gc process exits, closing its fd 9. Furthermore, the
73+
# variable assignment from a command substitution preserves the
74+
# exit status of the main gc process.
75+
# Note: this fd trickery doesn't work on Windows, but there is no
76+
# need to, because on Win the auto gc always runs in the foreground.
77+
doesnt_matter=$(git gc --auto 9>&1)
78+
}
79+
7080
test_expect_success 'background auto gc does not run if gc.log is present and recent but does if it is old' '
7181
test_commit foo &&
7282
test_commit bar &&
@@ -80,7 +90,13 @@ test_expect_success 'background auto gc does not run if gc.log is present and re
8090
test-chmtime =-345600 .git/gc.log &&
8191
test_must_fail git gc --auto &&
8292
test_config gc.logexpiry 2.days &&
83-
git gc --auto
93+
run_and_wait_for_auto_gc &&
94+
ls .git/objects/pack/pack-*.pack >packs &&
95+
test_line_count = 1 packs
8496
'
8597

98+
# DO NOT leave a detached auto gc process running near the end of the
99+
# test script: it can run long enough in the background to racily
100+
# interfere with the cleanup in 'test_done'.
101+
86102
test_done

0 commit comments

Comments
 (0)