I have a test file that I want to only run when a bit flag is set. I followed the simple example from golang's testing docs:
package mypkg
var myFlagSet = flag.Bool("myflag", false, "")
func TestMain(m *testing.M) {
flag.Parse()
if *myFlagSet {
os.Exit(m.Run())
}
}
if I run go test ./mypkg -myflag
it runs as expected. However, when I run go test ./... -myflag
, all other package tests fail:
flag provided but not defined: -myflag
I want to be able to run all tests and not have to worry about parsing this flag in every test file. Is there a way to do this that I'm missing?