Commit 44dc6614 authored by Ian Lance Taylor's avatar Ian Lance Taylor

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 <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 3415b355
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment