all: use t.TempDir in tests

This removes all usage of ioutil.TempDir in tests (and a few cases of
os.TempDir as well, while we're at it), which simplifies test cleanup a
lot.

Compile tested (go test -c) for most platforms (except zos).

Change-Id: I9178f5ec615c0a6cfef36e8de78c6b72e055b7cb
Reviewed-on: https://go-review.googlesource.com/c/sys/+/526297
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Kir Kolyshkin
2023-09-08 15:25:11 +00:00
committed by Gopher Robot
parent 0514fecd90
commit 0e97d69659
12 changed files with 35 additions and 178 deletions
+2 -11
View File
@@ -99,17 +99,8 @@ func TestClonefileatWithCwd(t *testing.T) {
}
func TestClonefileatWithRelativePaths(t *testing.T) {
srcDir, err := ioutil.TempDir("", "src")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(srcDir)
dstDir, err := ioutil.TempDir("", "dest")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dstDir)
srcDir := t.TempDir()
dstDir := t.TempDir()
srcFd, err := unix.Open(srcDir, unix.O_RDONLY|unix.O_DIRECTORY, 0)
if err != nil {