From: Ian Lance Taylor Date: Fri, 1 Mar 2019 21:05:33 +0000 (-0800) Subject: misc/cgo/testplugin: let TestMain run deferred functions X-Git-Tag: go1.13beta1~1271 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=7dc3d9f85f424445a49577aad33e576992c1f67d;p=gostls13.git misc/cgo/testplugin: let TestMain run deferred functions 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 TryBot-Result: Gobot Gobot Reviewed-by: Daniel Martí --- diff --git a/misc/cgo/testplugin/plugin_test.go b/misc/cgo/testplugin/plugin_test.go index 2c110494d0..54e3db36c4 100644 --- a/misc/cgo/testplugin/plugin_test.go +++ b/misc/cgo/testplugin/plugin_test.go @@ -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) {