github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/integration/plugin/common/main_test.go (about) 1 package common // import "github.com/demonoid81/moby/integration/plugin/common" 2 3 import ( 4 "fmt" 5 "os" 6 "testing" 7 8 "github.com/demonoid81/moby/pkg/reexec" 9 "github.com/demonoid81/moby/testutil/environment" 10 ) 11 12 var testEnv *environment.Execution 13 14 func TestMain(m *testing.M) { 15 if reexec.Init() { 16 return 17 } 18 var err error 19 testEnv, err = environment.New() 20 if err != nil { 21 fmt.Println(err) 22 os.Exit(1) 23 } 24 testEnv.Print() 25 os.Exit(m.Run()) 26 } 27 28 func setupTest(t *testing.T) func() { 29 environment.ProtectAll(t, testEnv) 30 return func() { testEnv.Clean(t) } 31 }