]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/vet: let TestMain run deferred functions
authorIan Lance Taylor <iant@golang.org>
Fri, 1 Mar 2019 21:08:30 +0000 (13:08 -0800)
committerIan Lance Taylor <iant@golang.org>
Fri, 1 Mar 2019 21:32:30 +0000 (21:32 +0000)
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>
src/cmd/vet/vet_test.go

index e9b8c69d53bb65d0c4235befbff45bbce258e20e..5d8139d977b81393c0d7d8db8e269ef219f27509 100644 (file)
@@ -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 (