diff options
| author | Roger Peppe <rogpeppe@gmail.com> | 2020-05-04 17:37:10 +0100 |
|---|---|---|
| committer | roger peppe <rogpeppe@gmail.com> | 2020-05-19 17:38:32 +0000 |
| commit | 6d6e4827c0b8ce302f7815ab565617f4593c5b46 (patch) | |
| tree | 17f6ed6cfd953d6c182d3d1d0382607e0dec6bb1 /src/testing/testing_test.go | |
| parent | 8fa468d511b8b1197137ce0ad0ea4260167d2348 (diff) | |
| download | go-6d6e4827c0b8ce302f7815ab565617f4593c5b46.tar.xz | |
testing: return unique directory inside same base root for TempDir
We use a single parent directory for all temporary directories
created by a test so they're all kept together.
Fixes #38850
Change-Id: If8edae10c5136efcbcf6fd632487d198b9e3a868
Reviewed-on: https://go-review.googlesource.com/c/go/+/231958
Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/testing/testing_test.go')
| -rw-r--r-- | src/testing/testing_test.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/testing/testing_test.go b/src/testing/testing_test.go index 1340dae5c4..dbef7066e0 100644 --- a/src/testing/testing_test.go +++ b/src/testing/testing_test.go @@ -7,6 +7,7 @@ package testing_test import ( "io/ioutil" "os" + "path/filepath" "testing" ) @@ -55,8 +56,11 @@ func testTempDir(t *testing.T) { t.Fatal("expected dir") } dir2 := t.TempDir() - if dir != dir2 { - t.Fatal("directory changed between calls") + if dir == dir2 { + t.Fatal("subsequent calls to TempDir returned the same directory") + } + if filepath.Dir(dir) != filepath.Dir(dir2) { + t.Fatalf("calls to TempDir do not share a parent; got %q, %q", dir, dir2) } dirCh <- dir fi, err := os.Stat(dir) |
