From 4c2b1df36ef5e2ef6828f753e1a3f3d9fa7db4e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Di=C3=B3genes=20Fernandes?= Date: Thu, 28 Aug 2025 19:55:45 -0300 Subject: [PATCH] fix `TestApply*` and `TestInit*` on Windows (#3203) Signed-off-by: Diogenes Fernandes --- internal/command/command_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/command/command_test.go b/internal/command/command_test.go index 01a1f61d62..a778b333f3 100644 --- a/internal/command/command_test.go +++ b/internal/command/command_test.go @@ -20,6 +20,7 @@ import ( "os/exec" "path" "path/filepath" + "runtime" "strings" "syscall" "testing" @@ -940,6 +941,14 @@ func testCopyDir(t *testing.T, src, dst string) { } } } + + t.Cleanup(func() { + // Trigger garbage collection to ensure that all open file handles are closed. + // This prevents TempDir RemoveAll cleanup errors on Windows. + if runtime.GOOS == "windows" { + runtime.GC() + } + }) } // normalizeJSON removes all insignificant whitespace from the given JSON buffer