diff options
-rw-r--r-- | cmd/podman/containers/rm.go | 19 | ||||
-rw-r--r-- | test/e2e/info_test.go | 14 | ||||
-rw-r--r-- | test/e2e/rm_test.go | 1 |
3 files changed, 18 insertions, 16 deletions
diff --git a/cmd/podman/containers/rm.go b/cmd/podman/containers/rm.go index 12a7a3d89..3021853a9 100644 --- a/cmd/podman/containers/rm.go +++ b/cmd/podman/containers/rm.go @@ -95,11 +95,9 @@ func rm(cmd *cobra.Command, args []string) error { } responses, err := registry.ContainerEngine().ContainerRm(context.Background(), args, rmOptions) if err != nil { - // TODO exitcode is a global main variable to track exit codes. - // we need this enabled - //if len(c.InputArgs) < 2 { - // exitCode = setExitCode(err) - //} + if len(args) < 2 { + setExitCode(err) + } return err } for _, r := range responses { @@ -108,6 +106,7 @@ func rm(cmd *cobra.Command, args []string) error { if errors.Cause(err) == define.ErrWillDeadlock { logrus.Errorf("Potential deadlock detected - please run 'podman system renumber' to resolve") } + setExitCode(r.Err) errs = append(errs, r.Err) } else { fmt.Println(r.Id) @@ -115,3 +114,13 @@ func rm(cmd *cobra.Command, args []string) error { } return errs.PrintErrors() } + +func setExitCode(err error) { + cause := errors.Cause(err) + switch cause { + case define.ErrNoSuchCtr: + registry.SetExitCode(1) + case define.ErrCtrStateInvalid: + registry.SetExitCode(2) + } +} diff --git a/test/e2e/info_test.go b/test/e2e/info_test.go index e5173e7a1..ff3615dcd 100644 --- a/test/e2e/info_test.go +++ b/test/e2e/info_test.go @@ -16,7 +16,6 @@ var _ = Describe("Podman Info", func() { ) BeforeEach(func() { - Skip(v2fail) tempdir, err = CreateTempDirInTempDir() if err != nil { os.Exit(1) @@ -38,22 +37,17 @@ var _ = Describe("Podman Info", func() { Expect(session.ExitCode()).To(Equal(0)) }) - It("podman system info json output", func() { - session := podmanTest.Podman([]string{"system", "info", "--format=json"}) - session.WaitWithDefaultTimeout() - Expect(session.ExitCode()).To(Equal(0)) - }) - It("podman info --format JSON GO template", func() { - session := podmanTest.Podman([]string{"info", "--format", "{{ json .}}"}) + It("podman info --format GO template", func() { + session := podmanTest.Podman([]string{"info", "--format", "{{.Store.GraphRoot}}"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) - Expect(session.IsJSONOutputValid()).To(BeTrue()) }) It("podman info --format GO template", func() { - session := podmanTest.Podman([]string{"info", "--format", "{{ .Store.GraphRoot }}"}) + session := podmanTest.Podman([]string{"info", "--format", "{{.Registries}}"}) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(ContainSubstring("registry")) }) }) diff --git a/test/e2e/rm_test.go b/test/e2e/rm_test.go index 83d20afa9..4eb568879 100644 --- a/test/e2e/rm_test.go +++ b/test/e2e/rm_test.go @@ -17,7 +17,6 @@ var _ = Describe("Podman rm", func() { ) BeforeEach(func() { - Skip(v2fail) tempdir, err = CreateTempDirInTempDir() if err != nil { os.Exit(1) |