Skip to content

Commit 759b453

Browse files
pks-tgitster
authored andcommitted
t7900: fix flaky test due to leaking background job
One of the recently-added tests in t7900 exercises git-maintanance(1) with the `--detach` flag, which causes it to perform maintenance in the background. We do not wait for the backgrounded process to exit though, which causes the process to leak outside of the test, leading to racy behaviour. Fix this by synchronizing with the process via a separate file descriptor. This is the same workaround as we use in t6500, see the function `run_and_wait_for_auto_gc ()`. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 98077d0 commit 759b453

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

t/t7900-maintenance.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -967,8 +967,13 @@ test_expect_success '--detach causes maintenance to run in background' '
967967
git config set maintenance.loose-objects.auto 1 &&
968968
git config set maintenance.incremental-repack.enabled true &&
969969
970-
git maintenance run --detach >out 2>&1 &&
971-
test_must_be_empty out
970+
# The extra file descriptor gets inherited to the child
971+
# process, and by reading stdout we thus essentially wait for
972+
# that descriptor to get closed, which indicates that the child
973+
# is done, too.
974+
output=$(git maintenance run --detach 2>&1 9>&1) &&
975+
printf "%s" "$output" >output &&
976+
test_must_be_empty output
972977
)
973978
'
974979

0 commit comments

Comments
 (0)