[infra] Remove remaining users of testutils.TempDir
Change-Id: I93e3356cfbb9b1d495e24272366a16e8c871a6f7
Reviewed-on: https://skia-review.googlesource.com/c/buildbot/+/372499
Reviewed-by: Eric Boren <borenet@google.com>
diff --git a/go/git/vfs_test.go b/go/git/vfs_test.go
index 85a5416..2c13a43 100644
--- a/go/git/vfs_test.go
+++ b/go/git/vfs_test.go
@@ -13,9 +13,7 @@
unittest.MediumTest(t)
ctx := context.Background()
- tmp, cleanup := shared_tests.MakeTestFiles(t)
- defer cleanup()
-
+ tmp := shared_tests.MakeTestFiles(t)
gd := GitDir(tmp)
_, err := gd.Git(ctx, "init")
require.NoError(t, err)
diff --git a/go/gitiles/testutils/vfs_test.go b/go/gitiles/testutils/vfs_test.go
index 68bc2ab..12774f4 100644
--- a/go/gitiles/testutils/vfs_test.go
+++ b/go/gitiles/testutils/vfs_test.go
@@ -21,8 +21,7 @@
repoURL := "https://fake.repo.git"
urlMock := mockhttpclient.NewURLMock()
repo := gitiles.NewRepo(repoURL, urlMock.Client())
- tmp, cleanup := shared_tests.MakeTestFiles(t)
- defer cleanup()
+ tmp := shared_tests.MakeTestFiles(t)
gd := git.GitDir(tmp)
_, err := gd.Git(ctx, "init")
require.NoError(t, err)
diff --git a/go/sktest/sktest.go b/go/sktest/sktest.go
index 9da0832..cc2111c 100644
--- a/go/sktest/sktest.go
+++ b/go/sktest/sktest.go
@@ -20,4 +20,5 @@
SkipNow()
Skipf(string, ...interface{})
Skipped() bool
+ TempDir() string
}
diff --git a/go/testutils/testutils.go b/go/testutils/testutils.go
index 4042f59..8c88e7f 100644
--- a/go/testutils/testutils.go
+++ b/go/testutils/testutils.go
@@ -111,17 +111,6 @@
require.NoError(t, os.RemoveAll(fp))
}
-// TempDir is a wrapper for ioutil.TempDir. Returns the path to the directory and a cleanup
-// function to defer.
-// TODO(kjlubick) replace this with testing.TempDir()
-func TempDir(t sktest.TestingT) (string, func()) {
- d, err := ioutil.TempDir("", "testutils")
- require.NoError(t, err)
- return d, func() {
- RemoveAll(t, d)
- }
-}
-
// MarshalJSON encodes the given interface to a JSON string.
func MarshalJSON(t sktest.TestingT, i interface{}) string {
b, err := json.Marshal(i)
diff --git a/go/vfs/shared_tests/local_test.go b/go/vfs/shared_tests/local_test.go
index d37a7e5..4af4de6 100644
--- a/go/vfs/shared_tests/local_test.go
+++ b/go/vfs/shared_tests/local_test.go
@@ -12,9 +12,7 @@
unittest.MediumTest(t)
ctx := context.Background()
- tmp, cleanup := MakeTestFiles(t)
- defer cleanup()
-
+ tmp := MakeTestFiles(t)
fs := vfs.Local(tmp)
TestFS(ctx, t, fs)
}
diff --git a/go/vfs/shared_tests/shared_tests.go b/go/vfs/shared_tests/shared_tests.go
index 5639336..0d73e98 100644
--- a/go/vfs/shared_tests/shared_tests.go
+++ b/go/vfs/shared_tests/shared_tests.go
@@ -9,7 +9,6 @@
"github.com/stretchr/testify/require"
"go.skia.org/infra/go/sktest"
- "go.skia.org/infra/go/testutils"
"go.skia.org/infra/go/vfs"
)
@@ -84,10 +83,10 @@
// MakeTestFiles creates a temporary directory containing the files and
// directories expected by TestFS.
-func MakeTestFiles(t sktest.TestingT) (string, func()) {
- tmp, cleanup := testutils.TempDir(t)
+func MakeTestFiles(t sktest.TestingT) string {
+ tmp := t.TempDir()
require.NoError(t, os.MkdirAll(filepath.Join(tmp, "subdir"), os.ModePerm))
require.NoError(t, ioutil.WriteFile(filepath.Join(tmp, "rootFile"), []byte("rootFile contents"), os.ModePerm))
require.NoError(t, ioutil.WriteFile(filepath.Join(tmp, "subdir", "subDirFile"), []byte("subDirFile contents"), os.ModePerm))
- return tmp, cleanup
+ return tmp
}