ExitWithError() - enforce required exit status & stderr

Final followup to #22270. That PR added a temporary convention
allowing a new form of ExitWithError(), one with an exit code
and stderr substring. In order to allow bite-size progress,
the old no-args form was still allowed. This PR removes
support for no-args ExitWithError().

This PR also adds one piece of new functionality: passing ""
(empty string) as the stderr arg means "expect exit code
but fail if there's anything at all in stderr".

Signed-off-by: Ed Santiago <santiago@redhat.com>
This commit is contained in:
Ed Santiago
2024-05-13 09:58:40 -06:00
parent 82f9811a8d
commit d4e40fedaf
5 changed files with 15 additions and 39 deletions

View File

@@ -39,7 +39,7 @@ var _ = Describe("Podman start", func() {
Expect(session).Should(ExitWithError(125, "not found in $PATH"))
session = podmanTest.Podman([]string{"container", "exists", "test"})
session.WaitWithDefaultTimeout()
Expect(session).To(ExitWithError(1))
Expect(session).To(ExitWithError(1, ""))
})
It("podman start --rm --attach removed on failure", func() {
@@ -52,7 +52,7 @@ var _ = Describe("Podman start", func() {
Expect(session).Should(ExitWithError(125, "not found in $PATH"))
session = podmanTest.Podman([]string{"container", "exists", cid})
session.WaitWithDefaultTimeout()
Expect(session).To(ExitWithError(1))
Expect(session).To(ExitWithError(1, ""))
})
It("podman container start single container by id", func() {
@@ -97,7 +97,7 @@ var _ = Describe("Podman start", func() {
session = podmanTest.Podman([]string{"start", "--attach", cid})
session.WaitWithDefaultTimeout()
// It should forward the signal
Expect(session).Should(ExitWithError(1))
Expect(session).Should(ExitWithError(1, ""))
})
It("podman start multiple containers", func() {