File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,16 @@ test_expect_success 'auto gc with too many loose objects does not attempt to cre
67
67
test_line_count = 2 new # There is one new pack and its .idx
68
68
'
69
69
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
+
70
80
test_expect_success ' background auto gc does not run if gc.log is present and recent but does if it is old' '
71
81
test_commit foo &&
72
82
test_commit bar &&
@@ -80,7 +90,13 @@ test_expect_success 'background auto gc does not run if gc.log is present and re
80
90
test-chmtime =-345600 .git/gc.log &&
81
91
test_must_fail git gc --auto &&
82
92
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
84
96
'
85
97
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
+
86
102
test_done
You can’t perform that action at this time.
0 commit comments