Skip to content

Commit 87b5372

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 <fredbi@yahoo.com>
1 parent 7285c2a commit 87b5372

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
@@ -5,7 +5,6 @@ package antest
55

66
import (
77
"os"
8-
"runtime"
98
"testing"
109

1110
"github.com/go-openapi/testify/v2/require"
@@ -58,7 +57,7 @@ func prepareBadDoc(t testing.TB, kind string, invalidFormat bool) (string, func(
5857

5958
switch kind {
6059
case "yaml", "yml":
61-
f, err := os.CreateTemp(workaroundTempDir(t)(), "*.yaml")
60+
f, err := os.CreateTemp(t.TempDir(), "*.yaml")
6261
require.NoError(t, err)
6362
file = f.Name()
6463

@@ -76,7 +75,7 @@ info:
7675
}
7776

7877
case "json":
79-
f, err := os.CreateTemp(workaroundTempDir(t)(), "*.json")
78+
f, err := os.CreateTemp(t.TempDir(), "*.json")
8079
require.NoError(t, err)
8180
file = f.Name()
8281

@@ -104,16 +103,3 @@ info:
104103

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

internal/debug/debug_test.go

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

66
import (
77
"os"
8-
"runtime"
98
"testing"
109

1110
"github.com/go-openapi/testify/v2/assert"
1211
"github.com/go-openapi/testify/v2/require"
1312
)
1413

1514
func TestDebug(t *testing.T) {
16-
tmpFile, err := os.CreateTemp(workaroundTempDir(t)(), "debug-test")
15+
tmpFile, err := os.CreateTemp(t.TempDir(), "debug-test")
1716
require.NoError(t, err)
1817

1918
output = tmpFile
@@ -28,7 +27,7 @@ func TestDebug(t *testing.T) {
2827

2928
assert.Contains(t, string(flushed), "A debug: a string")
3029

31-
tmpEmptyFile, err := os.CreateTemp(workaroundTempDir(t)(), "debug-test")
30+
tmpEmptyFile, err := os.CreateTemp(t.TempDir(), "debug-test")
3231
require.NoError(t, err)
3332
tmpEmpty := tmpEmptyFile.Name()
3433
testLogger = GetLogger("test", false)
@@ -41,16 +40,3 @@ func TestDebug(t *testing.T) {
4140

4241
assert.Empty(t, flushed)
4342
}
44-
45-
func workaroundTempDir(t testing.TB) func() string {
46-
// Workaround for go testing bug on Windows: https://github.com/golang/go/issues/71544
47-
// On windows, t.TempDir() doesn't properly release file handles yet,
48-
// se we just leave it unchecked (no cleanup would take place).
49-
if runtime.GOOS == "windows" {
50-
return func() string {
51-
return ""
52-
}
53-
}
54-
55-
return t.TempDir
56-
}

0 commit comments

Comments
 (0)