aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing.go')
-rw-r--r--src/testing/testing.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/testing/testing.go b/src/testing/testing.go
index d546f56478..44bccd384e 100644
--- a/src/testing/testing.go
+++ b/src/testing/testing.go
@@ -806,7 +806,12 @@ func (c *common) Cleanup(f func()) {
func (c *common) TempDir() string {
c.tempDirOnce.Do(func() {
c.Helper()
- c.tempDir, c.tempDirErr = ioutil.TempDir("", c.Name())
+
+ // ioutil.TempDir doesn't like path separators in its pattern,
+ // so mangle the name to accommodate subtests.
+ pattern := strings.ReplaceAll(c.Name(), "/", "_")
+
+ c.tempDir, c.tempDirErr = ioutil.TempDir("", pattern)
if c.tempDirErr == nil {
c.Cleanup(func() {
if err := os.RemoveAll(c.tempDir); err != nil {