Browse Source

Merge pull request #155 from docker/fix_shellout_no_error_message

Ensure we have a clear error message in case of wrong setup for docker-classic
Djordje Lukic 5 years ago
parent
commit
4c4ebbdb56
2 changed files with 16 additions and 0 deletions
  1. 2 0
      cli/main.go
  2. 14 0
      tests/e2e/e2e_test.go

+ 2 - 0
cli/main.go

@@ -192,8 +192,10 @@ func execMoby(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)
 			os.Exit(1)
 		}
 		os.Exit(0)

+ 14 - 0
tests/e2e/e2e_test.go

@@ -31,6 +31,7 @@ import (
 	"fmt"
 	"os"
 	"os/exec"
+	"path/filepath"
 	"testing"
 	"time"
 
@@ -65,6 +66,19 @@ func (s *E2eSuite) TestContextDefault() {
 	})
 }
 
+func (s *E2eSuite) TestSetupError() {
+	It("should display an error if cannot shell out to docker-classic", func() {
+		err := os.Setenv("PATH", s.BinDir)
+		Expect(err).To(BeNil())
+		err = os.Remove(filepath.Join(s.BinDir, "docker-classic"))
+		Expect(err).To(BeNil())
+		output, err := s.NewDockerCommand("ps").Exec()
+		Expect(output).To(ContainSubstring("docker-classic"))
+		Expect(output).To(ContainSubstring("not found"))
+		Expect(err).NotTo(BeNil())
+	})
+}
+
 func (s *E2eSuite) TestLegacy() {
 	It("should list all legacy commands", func() {
 		output := s.NewDockerCommand("--help").ExecOrDie()