Skip to content

Commit 9a078aa

Browse files
committed
test: removed special case for handling testing dirs on windows
golang/go#71544 is still officially open. However a fix has been committed to go codebase. This issue is not really blocking: the problem lies on windows not reliaby cleaning up the temporary directory. Signed-off-by: Frédéric BIDON <[email protected]>
1 parent 8037270 commit 9a078aa

File tree

2 files changed

+4
-32
lines changed

2 files changed

+4
-32
lines changed

internal/antest/helpers_test.go

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package antest
22

33
import (
44
"os"
5-
"runtime"
65
"testing"
76

87
"github.com/stretchr/testify/require"
@@ -55,7 +54,7 @@ func prepareBadDoc(t testing.TB, kind string, invalidFormat bool) (string, func(
5554

5655
switch kind {
5756
case "yaml", "yml":
58-
f, err := os.CreateTemp(workaroundTempDir(t)(), "*.yaml")
57+
f, err := os.CreateTemp(t.TempDir(), "*.yaml")
5958
require.NoError(t, err)
6059
file = f.Name()
6160

@@ -73,7 +72,7 @@ info:
7372
}
7473

7574
case "json":
76-
f, err := os.CreateTemp(workaroundTempDir(t)(), "*.json")
75+
f, err := os.CreateTemp(t.TempDir(), "*.json")
7776
require.NoError(t, err)
7877
file = f.Name()
7978

@@ -101,16 +100,3 @@ info:
101100

102101
return file, func() {}
103102
}
104-
105-
func workaroundTempDir(t testing.TB) func() string {
106-
// Workaround for go testing bug on Windows: https://github.com/golang/go/issues/71544
107-
// On windows, t.TempDir() doesn't properly release file handles yet,
108-
// se we just leave it unchecked (no cleanup would take place).
109-
if runtime.GOOS == "windows" {
110-
return func() string {
111-
return ""
112-
}
113-
}
114-
115-
return t.TempDir
116-
}

internal/debug/debug_test.go

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ package debug
1616

1717
import (
1818
"os"
19-
"runtime"
2019
"testing"
2120

2221
"github.com/stretchr/testify/assert"
2322
"github.com/stretchr/testify/require"
2423
)
2524

2625
func TestDebug(t *testing.T) {
27-
tmpFile, err := os.CreateTemp(workaroundTempDir(t)(), "debug-test")
26+
tmpFile, err := os.CreateTemp(t.TempDir(), "debug-test")
2827
require.NoError(t, err)
2928

3029
output = tmpFile
@@ -39,7 +38,7 @@ func TestDebug(t *testing.T) {
3938

4039
assert.Contains(t, string(flushed), "A debug: a string")
4140

42-
tmpEmptyFile, err := os.CreateTemp(workaroundTempDir(t)(), "debug-test")
41+
tmpEmptyFile, err := os.CreateTemp(t.TempDir(), "debug-test")
4342
require.NoError(t, err)
4443
tmpEmpty := tmpEmptyFile.Name()
4544
testLogger = GetLogger("test", false)
@@ -52,16 +51,3 @@ func TestDebug(t *testing.T) {
5251

5352
assert.Empty(t, flushed)
5453
}
55-
56-
func workaroundTempDir(t testing.TB) func() string {
57-
// Workaround for go testing bug on Windows: https://github.com/golang/go/issues/71544
58-
// On windows, t.TempDir() doesn't properly release file handles yet,
59-
// se we just leave it unchecked (no cleanup would take place).
60-
if runtime.GOOS == "windows" {
61-
return func() string {
62-
return ""
63-
}
64-
}
65-
66-
return t.TempDir
67-
}

0 commit comments

Comments
 (0)