aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/race
diff options
context:
space:
mode:
authorianwoolf <btw515wolf2@gmail.com>2021-04-07 20:16:58 +0800
committerEmmanuel Odeke <emmanuel@orijtech.com>2021-04-08 07:33:58 +0000
commita7e16abb22f1b249d2691b32a5d20206282898f2 (patch)
tree68c912580165de3096390796f15234f4b8c8eae9 /src/runtime/race
parent2123dfba651e3522ed039d1b38fde91ededf47a3 (diff)
downloadgo-a7e16abb22f1b249d2691b32a5d20206282898f2.tar.gz
go-a7e16abb22f1b249d2691b32a5d20206282898f2.zip
runtime: replace os.MkdirTemp with T.TempDir
Updates #45402 Change-Id: I3aa82fc2486b4de49b45388bbab24f5ffe558f91 Reviewed-on: https://go-review.googlesource.com/c/go/+/307989 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Tobias Klauser <tobias.klauser@gmail.com>
Diffstat (limited to 'src/runtime/race')
-rw-r--r--src/runtime/race/output_test.go12
-rw-r--r--src/runtime/race/testdata/io_test.go2
2 files changed, 3 insertions, 11 deletions
diff --git a/src/runtime/race/output_test.go b/src/runtime/race/output_test.go
index 2a2197ae26..99052071d0 100644
--- a/src/runtime/race/output_test.go
+++ b/src/runtime/race/output_test.go
@@ -20,11 +20,7 @@ import (
)
func TestOutput(t *testing.T) {
- pkgdir, err := os.MkdirTemp("", "go-build-race-output")
- if err != nil {
- t.Fatal(err)
- }
- defer os.RemoveAll(pkgdir)
+ pkgdir := t.TempDir()
out, err := exec.Command(testenv.GoToolPath(t), "install", "-race", "-pkgdir="+pkgdir, "testing").CombinedOutput()
if err != nil {
t.Fatalf("go install -race: %v\n%s", err, out)
@@ -35,11 +31,7 @@ func TestOutput(t *testing.T) {
t.Logf("test %v runs only on %v, skipping: ", test.name, test.goos)
continue
}
- dir, err := os.MkdirTemp("", "go-build")
- if err != nil {
- t.Fatalf("failed to create temp directory: %v", err)
- }
- defer os.RemoveAll(dir)
+ dir := t.TempDir()
source := "main.go"
if test.run == "test" {
source = "main_test.go"
diff --git a/src/runtime/race/testdata/io_test.go b/src/runtime/race/testdata/io_test.go
index c5055f7837..3303cb0717 100644
--- a/src/runtime/race/testdata/io_test.go
+++ b/src/runtime/race/testdata/io_test.go
@@ -17,7 +17,7 @@ import (
func TestNoRaceIOFile(t *testing.T) {
x := 0
- path, _ := os.MkdirTemp("", "race_test")
+ path := t.TempDir()
fname := filepath.Join(path, "data")
go func() {
x = 42