From ef40743669b75c859b09e14c9229677f6408fb46 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Wed, 3 Apr 2019 11:29:36 +0100 Subject: [PATCH] e2e: Add a TestMain for cli plugins tests This was omitted when these tests were added. Adding this means that the tests now see the `$DOCKER_HOST` configured (via `$TEST_DOCKER_HOST`) where they didn't before. In some cases (specifically the `test-e2e-connhelper-ssh` case) this results in additional output on stderr when `-D` (debug) is used: time="2019-04-03T11:10:27Z" level=debug msg="commandconn: starting ssh with [-l penguin 172.20.0.2 -- docker system dial-stdio]" Address this by switching the affected test cases to use `-l info` instead of `-D`, they all just require some option not specifically `-D`. Note that `info` is the default log level so this is effectively a nop (which is good). Signed-off-by: Ian Campbell --- e2e/cli-plugins/main_test.go | 17 +++++++++++++++++ e2e/cli-plugins/run_test.go | 10 +++++----- 2 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 e2e/cli-plugins/main_test.go diff --git a/e2e/cli-plugins/main_test.go b/e2e/cli-plugins/main_test.go new file mode 100644 index 0000000000..911a5c065e --- /dev/null +++ b/e2e/cli-plugins/main_test.go @@ -0,0 +1,17 @@ +package cliplugins + +import ( + "fmt" + "os" + "testing" + + "github.com/docker/cli/internal/test/environment" +) + +func TestMain(m *testing.M) { + if err := environment.Setup(); err != nil { + fmt.Println(err.Error()) + os.Exit(3) + } + os.Exit(m.Run()) +} diff --git a/e2e/cli-plugins/run_test.go b/e2e/cli-plugins/run_test.go index 1309cc0d58..3c9426e042 100644 --- a/e2e/cli-plugins/run_test.go +++ b/e2e/cli-plugins/run_test.go @@ -135,7 +135,7 @@ func TestHelpGood(t *testing.T) { run, _, cleanup := prepare(t) defer cleanup() - res := icmd.RunCmd(run("-D", "help", "helloworld")) + res := icmd.RunCmd(run("-l", "info", "help", "helloworld")) res.Assert(t, icmd.Expected{ ExitCode: 0, Err: icmd.None, @@ -150,7 +150,7 @@ func TestGoodHelp(t *testing.T) { run, _, cleanup := prepare(t) defer cleanup() - res := icmd.RunCmd(run("-D", "helloworld", "--help")) + res := icmd.RunCmd(run("-l", "info", "helloworld", "--help")) res.Assert(t, icmd.Expected{ ExitCode: 0, Err: icmd.None, @@ -159,7 +159,7 @@ func TestGoodHelp(t *testing.T) { golden.Assert(t, res.Stdout(), "docker-help-helloworld.golden") // Short -h should be the same, modulo the deprecation message exp := shortHFlagDeprecated + res.Stdout() - res = icmd.RunCmd(run("-D", "helloworld", "-h")) + res = icmd.RunCmd(run("-l", "info", "helloworld", "-h")) res.Assert(t, icmd.Expected{ ExitCode: 0, // This should be identical to the --help case above @@ -188,7 +188,7 @@ func TestHelpGoodSubcommand(t *testing.T) { run, _, cleanup := prepare(t) defer cleanup() - res := icmd.RunCmd(run("-D", "help", "helloworld", "goodbye")) + res := icmd.RunCmd(run("-l", "info", "help", "helloworld", "goodbye")) res.Assert(t, icmd.Expected{ ExitCode: 0, Err: icmd.None, @@ -203,7 +203,7 @@ func TestGoodSubcommandHelp(t *testing.T) { run, _, cleanup := prepare(t) defer cleanup() - res := icmd.RunCmd(run("-D", "helloworld", "goodbye", "--help")) + res := icmd.RunCmd(run("-l", "info", "helloworld", "goodbye", "--help")) res.Assert(t, icmd.Expected{ ExitCode: 0, Err: icmd.None,