1
0
mirror of https://github.com/golang/go synced 2024-10-04 02:21:21 -06:00

exp/types: clean up objects after test

Fixes #3739.

R=bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6295083
This commit is contained in:
Shenghou Ma 2012-06-15 02:52:18 +08:00
parent a11e74daf7
commit 9852614291

View File

@ -36,15 +36,18 @@ func init() {
gcPath = filepath.Join(build.ToolDir, gc) 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 := exec.Command(gcPath, filename)
cmd.Dir = dirname cmd.Dir = dirname
out, err := cmd.CombinedOutput() out, err := cmd.CombinedOutput()
if err != nil { if err != nil {
t.Errorf("%s %s failed: %s", gcPath, filename, err) t.Fatalf("%s %s failed: %s", gcPath, filename, err)
return return ""
} }
t.Logf("%s", string(out)) 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 // Use the same global imports map for all tests. The effect is
@ -99,7 +102,9 @@ func TestGcImport(t *testing.T) {
return return
} }
compile(t, "testdata", "exports.go") if outFn := compile(t, "testdata", "exports.go"); outFn != "" {
defer os.Remove(outFn)
}
nimports := 0 nimports := 0
if testPath(t, "./testdata/exports") { if testPath(t, "./testdata/exports") {