Skip to content

Commit aef0666

Browse files
committed
Add a shim for the code that exists in newer versions of testing.T.
1 parent b0dd4a7 commit aef0666

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tests/testutil.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"github.com/stretchr/testify/assert"
66
"github.com/stretchr/testify/require"
77
lua "github.com/yuin/gopher-lua"
8+
"os"
89
"strings"
910
"testing"
1011
)
@@ -96,7 +97,14 @@ func tSkipf(L *lua.LState) int {
9697

9798
func tTempDir(L *lua.LState) int {
9899
t := checkT(L, 1)
99-
L.Push(lua.LString(t.TempDir()))
100+
// TODO(scr): WHen the minimal version supported has this on the *testing.T object, remove this shim
101+
//L.Push(lua.LString(t.TempDir()))
102+
tempDir := os.TempDir()
103+
t.Cleanup(func() {
104+
_ = os.RemoveAll(tempDir)
105+
})
106+
107+
L.Push(lua.LString(tempDir))
100108
return 1
101109
}
102110

0 commit comments

Comments
 (0)