github.com/stevenmatthewt/agent@v3.5.4+incompatible/bootstrap/integration/main_test.go (about) 1 package integration 2 3 import ( 4 "fmt" 5 "os" 6 "testing" 7 8 "github.com/buildkite/agent/agent" 9 "github.com/buildkite/agent/clicommand" 10 "github.com/buildkite/bintest" 11 "github.com/urfave/cli" 12 ) 13 14 func TestMain(m *testing.M) { 15 // If we are passed "bootstrap", execute like the bootstrap cli 16 if len(os.Args) > 1 && os.Args[1] == `bootstrap` { 17 app := cli.NewApp() 18 app.Name = "buildkite-agent" 19 app.Version = agent.Version() 20 app.Commands = []cli.Command{ 21 clicommand.BootstrapCommand, 22 } 23 24 if err := app.Run(os.Args); err != nil { 25 fmt.Printf("%v\n", err) 26 os.Exit(1) 27 } 28 29 os.Exit(0) 30 } 31 32 if os.Getenv(`BINTEST_DEBUG`) == "1" { 33 bintest.Debug = true 34 } 35 36 // Start a server to share 37 _, err := bintest.StartServer() 38 if err != nil { 39 fmt.Printf("Error starting server: %v", err) 40 os.Exit(1) 41 } 42 43 code := m.Run() 44 os.Exit(code) 45 }