]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t/test-lib: silence EBUSY errors on Windows during test cleanup
authorPatrick Steinhardt <ps@pks.im>
Wed, 3 Jun 2026 05:39:45 +0000 (07:39 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 3 Jun 2026 07:38:04 +0000 (16:38 +0900)
When tests have finished we clean up the trash directory via `rm -rf`.
On Windows this can fail with EBUSY in cases where a process still holds
some of the files open, for example when we have spawned a daemonized
process that wasn't properly terminated. We thus retry several times,
but every failure will result in error messages being printed, and that
in turn breaks the TAP output format.

One such case where this is causing issues is in t921x, which contains
tests related to Scalar. Some tests spawn the fsmonitor daemon, and we
never properly terminate it.

The obvious fix would be to ensure that we never leak any processes, but
that gets ugly fast. Instead, let's work around the issue by silencing
error messages printed by the `rm -rf` calls. We already know to print
an error when the retry loop fails, so we don't loose much.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/test-lib.sh

index 4a7357b547e77e39ad84b47760249e6998a2337f..d1d24c4124fd1d08df53652ae53d4f1a73663ef3 100644 (file)
@@ -1299,10 +1299,10 @@ test_done () {
                        error "Tests passed but trash directory already removed before test cleanup; aborting"
 
                        cd "$TRASH_DIRECTORY/.." &&
-                       rm -fr "$TRASH_DIRECTORY" || {
+                       rm -fr "$TRASH_DIRECTORY" 2>/dev/null || {
                                # try again in a bit
                                sleep 5;
-                               rm -fr "$TRASH_DIRECTORY"
+                               rm -fr "$TRASH_DIRECTORY" 2>/dev/null
                        } ||
                        error "Tests passed but test cleanup failed; aborting"
                fi