From 54141a9bdd691399e231fc1a3f099558959ddc1a Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Fri, 5 Jun 2020 17:08:42 +0200 Subject: [PATCH] Do not display exit status when classic cli exit in error --- cli/dockerclassic/exec.go | 1 - tests/e2e/e2e_test.go | 6 ++++++ tests/e2e/testdata/unknown-foo-command.golden | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 tests/e2e/testdata/unknown-foo-command.golden diff --git a/cli/dockerclassic/exec.go b/cli/dockerclassic/exec.go index a2d127960..9bd72c29b 100644 --- a/cli/dockerclassic/exec.go +++ b/cli/dockerclassic/exec.go @@ -27,7 +27,6 @@ func Exec(ctx context.Context) { cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil { if exiterr, ok := err.(*exec.ExitError); ok { - fmt.Fprintln(os.Stderr, exiterr.Error()) os.Exit(exiterr.ExitCode()) } fmt.Fprintln(os.Stderr, err) diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index e968212b1..54e39aac4 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -156,6 +156,12 @@ func (s *E2eSuite) TestLegacy() { }) } +func (s *E2eSuite) TestLeaveLegacyErrorMessagesUnchanged() { + output, err := s.NewDockerCommand("foo").Exec() + golden.Assert(s.T(), output, "unknown-foo-command.golden") + Expect(err).NotTo(BeNil()) +} + func (s *E2eSuite) TestMockBackend() { It("creates a new test context to hardcoded example backend", func() { s.NewDockerCommand("context", "create", "test-example", "example").ExecOrDie() diff --git a/tests/e2e/testdata/unknown-foo-command.golden b/tests/e2e/testdata/unknown-foo-command.golden new file mode 100644 index 000000000..80e28cf75 --- /dev/null +++ b/tests/e2e/testdata/unknown-foo-command.golden @@ -0,0 +1,2 @@ +docker: 'foo' is not a docker command. +See 'docker --help'