mirror of https://github.com/golang/go.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 <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
This commit is contained in:
parent
4aff88ded2
commit
7dc3d9f85f
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue