diff --git a/internal/antest/helpers_test.go b/internal/antest/helpers_test.go index b8fd170..f0f00ff 100644 --- a/internal/antest/helpers_test.go +++ b/internal/antest/helpers_test.go @@ -2,7 +2,6 @@ package antest import ( "os" - "runtime" "testing" "github.com/stretchr/testify/require" @@ -55,7 +54,7 @@ func prepareBadDoc(t testing.TB, kind string, invalidFormat bool) (string, func( switch kind { case "yaml", "yml": - f, err := os.CreateTemp(workaroundTempDir(t)(), "*.yaml") + f, err := os.CreateTemp(t.TempDir(), "*.yaml") require.NoError(t, err) file = f.Name() @@ -73,7 +72,7 @@ info: } case "json": - f, err := os.CreateTemp(workaroundTempDir(t)(), "*.json") + f, err := os.CreateTemp(t.TempDir(), "*.json") require.NoError(t, err) file = f.Name() @@ -101,16 +100,3 @@ info: return file, func() {} } - -func workaroundTempDir(t testing.TB) func() string { - // Workaround for go testing bug on Windows: https://github.com/golang/go/issues/71544 - // On windows, t.TempDir() doesn't properly release file handles yet, - // se we just leave it unchecked (no cleanup would take place). - if runtime.GOOS == "windows" { - return func() string { - return "" - } - } - - return t.TempDir -} diff --git a/internal/debug/debug_test.go b/internal/debug/debug_test.go index 1df57fa..9b490c8 100644 --- a/internal/debug/debug_test.go +++ b/internal/debug/debug_test.go @@ -16,7 +16,6 @@ package debug import ( "os" - "runtime" "testing" "github.com/stretchr/testify/assert" @@ -24,7 +23,7 @@ import ( ) func TestDebug(t *testing.T) { - tmpFile, err := os.CreateTemp(workaroundTempDir(t)(), "debug-test") + tmpFile, err := os.CreateTemp(t.TempDir(), "debug-test") require.NoError(t, err) output = tmpFile @@ -39,7 +38,7 @@ func TestDebug(t *testing.T) { assert.Contains(t, string(flushed), "A debug: a string") - tmpEmptyFile, err := os.CreateTemp(workaroundTempDir(t)(), "debug-test") + tmpEmptyFile, err := os.CreateTemp(t.TempDir(), "debug-test") require.NoError(t, err) tmpEmpty := tmpEmptyFile.Name() testLogger = GetLogger("test", false) @@ -52,16 +51,3 @@ func TestDebug(t *testing.T) { assert.Empty(t, flushed) } - -func workaroundTempDir(t testing.TB) func() string { - // Workaround for go testing bug on Windows: https://github.com/golang/go/issues/71544 - // On windows, t.TempDir() doesn't properly release file handles yet, - // se we just leave it unchecked (no cleanup would take place). - if runtime.GOOS == "windows" { - return func() string { - return "" - } - } - - return t.TempDir -}