diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-08-19 09:47:59 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-08-19 18:36:23 +0200 |
commit | 759b453f9f21c5cda483a38f6693dfcbcb680290 (patch) | |
tree | b53d23471cf2a62eb278319e8a92eb40ac534499 /t/t7900-maintenance.sh | |
parent | run-command: fix detaching when running auto maintenance (diff) | |
download | git-759b453f9f21c5cda483a38f6693dfcbcb680290.tar.xz git-759b453f9f21c5cda483a38f6693dfcbcb680290.zip |
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 <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7900-maintenance.sh')
-rwxr-xr-x | t/t7900-maintenance.sh | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh index 06ab43cfb5..074eadcd1c 100755 --- a/t/t7900-maintenance.sh +++ b/t/t7900-maintenance.sh @@ -967,8 +967,13 @@ test_expect_success '--detach causes maintenance to run in background' ' git config set maintenance.loose-objects.auto 1 && git config set maintenance.incremental-repack.enabled true && - git maintenance run --detach >out 2>&1 && - test_must_be_empty out + # The extra file descriptor gets inherited to the child + # process, and by reading stdout we thus essentially wait for + # that descriptor to get closed, which indicates that the child + # is done, too. + output=$(git maintenance run --detach 2>&1 9>&1) && + printf "%s" "$output" >output && + test_must_be_empty output ) ' |