Commit 1cd6d8b9 authored by Ian Lance Taylor's avatar Ian Lance Taylor

cmd/vet: let TestMain run deferred functions

Split TestMain into two functions so that we can defer cleanups.

Updates #30500

Change-Id: I1fa7957be0779c079ec4d221a8321b45ddb973e2
Reviewed-on: https://go-review.googlesource.com/c/164860
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarDaniel Martí <mvdan@mvdan.cc>
parent b45f5b5e
...@@ -28,16 +28,19 @@ var binary string ...@@ -28,16 +28,19 @@ var binary string
// We implement TestMain so remove the test binary when all is done. // We implement TestMain so remove the test binary when all is done.
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
os.Exit(testMain(m))
}
func testMain(m *testing.M) int {
dir, err := ioutil.TempDir("", "vet_test") dir, err := ioutil.TempDir("", "vet_test")
if err != nil { if err != nil {
fmt.Fprintln(os.Stderr, err) fmt.Fprintln(os.Stderr, err)
os.Exit(1) return 1
} }
defer os.RemoveAll(dir) defer os.RemoveAll(dir)
binary = filepath.Join(dir, "testvet.exe") binary = filepath.Join(dir, "testvet.exe")
result := m.Run() return m.Run()
os.Exit(result)
} }
var ( var (
......
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