]> Cypherpunks repositories - gostls13.git/commitdiff
misc/cgo/testplugin: let TestMain run deferred functions
authorIan Lance Taylor <iant@golang.org>
Fri, 1 Mar 2019 21:05:33 +0000 (13:05 -0800)
committerIan Lance Taylor <iant@golang.org>
Fri, 1 Mar 2019 21:33:27 +0000 (21:33 +0000)
Split TestMain into two functions so that we can defer cleanups.

Updates #30500

Change-Id: I4a5c7ddb8218a8bd056c8733c3cb9feb895e77a0
Reviewed-on: https://go-review.googlesource.com/c/164859
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
misc/cgo/testplugin/plugin_test.go

index 2c110494d0539cc49cd7376f6e4fe56ae045ff14..54e3db36c4601a7eadcb6a827c24a66bc58310eb 100644 (file)
@@ -23,7 +23,10 @@ var gcflags string = os.Getenv("GO_GCFLAGS")
 
 func TestMain(m *testing.M) {
        log.SetFlags(log.Lshortfile)
+       os.Exit(testMain(m))
+}
 
+func testMain(m *testing.M) int {
        // Copy testdata into GOPATH/src/testarchive, along with a go.mod file
        // declaring the same path.
 
@@ -77,7 +80,7 @@ func TestMain(m *testing.M) {
        goCmd(nil, "build", "-buildmode=plugin", "-o=unnamed2.so", "./unnamed2/main.go")
        goCmd(nil, "build", "-o", "host.exe", "./host")
 
-       os.Exit(m.Run())
+       return m.Run()
 }
 
 func goCmd(t *testing.T, op string, args ...string) {