From 985261429162edc07e0e97741f425c5aded55641 Mon Sep 17 00:00:00 2001 From: Shenghou Ma Date: Fri, 15 Jun 2012 02:52:18 +0800 Subject: [PATCH] exp/types: clean up objects after test Fixes #3739. R=bradfitz, rsc CC=golang-dev https://golang.org/cl/6295083 --- src/pkg/exp/types/gcimporter_test.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/pkg/exp/types/gcimporter_test.go b/src/pkg/exp/types/gcimporter_test.go index 20247b0dc4..61a085d847 100644 --- a/src/pkg/exp/types/gcimporter_test.go +++ b/src/pkg/exp/types/gcimporter_test.go @@ -36,15 +36,18 @@ func init() { gcPath = filepath.Join(build.ToolDir, gc) } -func compile(t *testing.T, dirname, filename string) { +func compile(t *testing.T, dirname, filename string) (outFn string) { cmd := exec.Command(gcPath, filename) cmd.Dir = dirname out, err := cmd.CombinedOutput() if err != nil { - t.Errorf("%s %s failed: %s", gcPath, filename, err) - return + t.Fatalf("%s %s failed: %s", gcPath, filename, err) + return "" } t.Logf("%s", string(out)) + archCh, _ := build.ArchChar(runtime.GOARCH) + // filename should end with ".go" + return filepath.Join(dirname, filename[:len(filename)-2]+archCh) } // Use the same global imports map for all tests. The effect is @@ -99,7 +102,9 @@ func TestGcImport(t *testing.T) { return } - compile(t, "testdata", "exports.go") + if outFn := compile(t, "testdata", "exports.go"); outFn != "" { + defer os.Remove(outFn) + } nimports := 0 if testPath(t, "./testdata/exports") { -- 2.48.1