diff options
author | Ian Lance Taylor <iant@golang.org> | 2019-03-01 13:08:30 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2019-03-01 21:32:30 +0000 |
commit | 1cd6d8b974517e6c0506d3959a9ad08f98e89902 (patch) | |
tree | 1a8e681ff50fa367b51ac7c4dd927f6491a25b6d /src/cmd/vet | |
parent | b45f5b5e16c8176c909b441ebfa731cd6ff0cd63 (diff) | |
download | go-1cd6d8b974517e6c0506d3959a9ad08f98e89902.tar.gz go-1cd6d8b974517e6c0506d3959a9ad08f98e89902.zip |
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: Daniel Martà <mvdan@mvdan.cc>
Diffstat (limited to 'src/cmd/vet')
-rw-r--r-- | src/cmd/vet/vet_test.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/cmd/vet/vet_test.go b/src/cmd/vet/vet_test.go index e9b8c69d53..5d8139d977 100644 --- a/src/cmd/vet/vet_test.go +++ b/src/cmd/vet/vet_test.go @@ -28,16 +28,19 @@ var binary string // We implement TestMain so remove the test binary when all is done. func TestMain(m *testing.M) { + os.Exit(testMain(m)) +} + +func testMain(m *testing.M) int { dir, err := ioutil.TempDir("", "vet_test") if err != nil { fmt.Fprintln(os.Stderr, err) - os.Exit(1) + return 1 } defer os.RemoveAll(dir) binary = filepath.Join(dir, "testvet.exe") - result := m.Run() - os.Exit(result) + return m.Run() } var ( |