From 952f7de3b403d2ffb45708ea5f69168bbdbfe1f0 Mon Sep 17 00:00:00 2001 From: Andrei Tudor Călin Date: Thu, 23 Apr 2020 04:04:33 +0300 Subject: testing: make TempDir work for subtests ioutil.TempDir doesn't like path separators in its pattern. Modify (*common).TempDir to replace path separators with underscores before using the test name as a pattern for ioutil.TempDir. Fixes #38465. Change-Id: I9e8ae48b99648b2bf9f561762e845165aff01972 Reviewed-on: https://go-review.googlesource.com/c/go/+/229399 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- src/testing/testing_test.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/testing/testing_test.go') diff --git a/src/testing/testing_test.go b/src/testing/testing_test.go index afb35a96d4..07757a8482 100644 --- a/src/testing/testing_test.go +++ b/src/testing/testing_test.go @@ -19,6 +19,11 @@ func TestMain(m *testing.M) { } func TestTempDir(t *testing.T) { + testTempDir(t) + t.Run("InSubtest", testTempDir) +} + +func testTempDir(t *testing.T) { dirCh := make(chan string, 1) t.Cleanup(func() { // Verify directory has been removed. -- cgit v1.3