From: Ian Lance Taylor Date: Fri, 1 Mar 2019 20:55:43 +0000 (-0800) Subject: cmd/link: reliably remove temporary directory in testDwarf X-Git-Tag: go1.13beta1~1264 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=44dc661453a59587a81265c17f7c469b60e9059a;p=gostls13.git cmd/link: reliably remove temporary directory in testDwarf We were using t.Parallel in a subtest, which meant that the main test would not wait for the subtest, so the main test would delete the temporary directory before the subtest used it. The subtest worked because "go build -o /tmp/x/y/p.exe p" creates /tmp/x/y as needed. Updates #30500 Change-Id: I5904ecac748d15ded4cb609f049fa548b8916a0e Reviewed-on: https://go-review.googlesource.com/c/164857 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- diff --git a/src/cmd/link/dwarf_test.go b/src/cmd/link/dwarf_test.go index 880b2ced6d..9c3bc624ef 100644 --- a/src/cmd/link/dwarf_test.go +++ b/src/cmd/link/dwarf_test.go @@ -37,17 +37,17 @@ func testDWARF(t *testing.T, buildmode string, expectDWARF bool, env ...string) t.Fatalf("cmd/link is stale - run go install cmd/link") } - tmpDir, err := ioutil.TempDir("", "go-link-TestDWARF") - if err != nil { - t.Fatal("TempDir failed: ", err) - } - defer os.RemoveAll(tmpDir) - for _, prog := range []string{"testprog", "testprogcgo"} { prog := prog t.Run(prog, func(t *testing.T) { t.Parallel() + tmpDir, err := ioutil.TempDir("", "go-link-TestDWARF") + if err != nil { + t.Fatal(err) + } + defer os.RemoveAll(tmpDir) + exe := filepath.Join(tmpDir, prog+".exe") dir := "../../runtime/testdata/" + prog cmd := exec.Command(testenv.GoToolPath(t), "build", "-o", exe)