Move flag.Parse in tests to TestMain

This this fixes issues with custom and testing flags in Go 1.3 and should work
in previous go versions.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2019-10-11 13:27:54 -04:00
parent 38937f0607
commit d5b7bf51aa
No known key found for this signature in database
GPG Key ID: F3D4D52BDC000749

View File

@ -54,7 +54,6 @@ func init() {
flag.StringVar(&address, "address", defaultAddress, "The address to the containerd socket for use in the tests") flag.StringVar(&address, "address", defaultAddress, "The address to the containerd socket for use in the tests")
flag.BoolVar(&noDaemon, "no-daemon", false, "Do not start a dedicated daemon for the tests") flag.BoolVar(&noDaemon, "no-daemon", false, "Do not start a dedicated daemon for the tests")
flag.BoolVar(&noCriu, "no-criu", false, "Do not run the checkpoint tests") flag.BoolVar(&noCriu, "no-criu", false, "Do not run the checkpoint tests")
flag.Parse()
} }
func testContext(t testing.TB) (context.Context, context.CancelFunc) { func testContext(t testing.TB) (context.Context, context.CancelFunc) {
@ -67,6 +66,7 @@ func testContext(t testing.TB) (context.Context, context.CancelFunc) {
} }
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
flag.Parse()
if testing.Short() { if testing.Short() {
os.Exit(m.Run()) os.Exit(m.Run())
} }