don't break TestMain funcs

Important for 'garble test', if a package uses one.
pull/22/head
Daniel Martí 5 years ago
parent a6d2891a90
commit ce0137fa6a

@ -363,7 +363,7 @@ func transformGo(node ast.Node, info *types.Info) ast.Node {
return true // might implement an interface return true // might implement an interface
} }
switch node.Name { switch node.Name {
case "main", "init": case "main", "init", "TestMain":
return true // don't break them return true // don't break them
} }
if strings.HasPrefix(node.Name, "Test") && isTestSignature(sign) { if strings.HasPrefix(node.Name, "Test") && isTestSignature(sign) {

@ -45,3 +45,14 @@ func TestSeparateFoo(t *testing.T) {
t.FailNow() t.FailNow()
} }
} }
-- main_test.go --
package bar
import (
"os"
"testing"
)
func TestMain(m *testing.M) {
os.Exit(m.Run())
}

Loading…
Cancel
Save