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
This commit is contained in:
Djordje Lukic 2020-05-27 01:05:19 -07:00 committed by GitHub
commit 4c4ebbdb56
2 changed files with 16 additions and 0 deletions

View File

@ -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)

View File

@ -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()