diff --git a/integration-cli/docker_cli_run_test.go b/integration-cli/docker_cli_run_test.go index 6bef936369..34a500de8c 100644 --- a/integration-cli/docker_cli_run_test.go +++ b/integration-cli/docker_cli_run_test.go @@ -141,8 +141,6 @@ func TestRunPingGoogle(t *testing.T) { t.Fatalf("failed to run container: %v, output: %q", err, out) } - errorOut(err, t, "container should've been able to ping 8.8.8.8") - deleteAllContainers() logDone("run - ping 8.8.8.8") @@ -152,11 +150,8 @@ func TestRunPingGoogle(t *testing.T) { // some versions of lxc might make this test fail func TestRunExitCodeZero(t *testing.T) { runCmd := exec.Command(dockerBinary, "run", "busybox", "true") - exitCode, err := runCommand(runCmd) - errorOut(err, t, fmt.Sprintf("%s", err)) - - if exitCode != 0 { - t.Errorf("container should've exited with exit code 0") + if out, _, err := runCommandWithOutput(runCmd); err != nil { + t.Errorf("container should've exited with exit code 0: %s, %v", out, err) } deleteAllContainers() @@ -193,26 +188,31 @@ func TestRunStdinPipe(t *testing.T) { out = stripTrailingCharacters(out) inspectCmd := exec.Command(dockerBinary, "inspect", out) - inspectOut, _, err := runCommandWithOutput(inspectCmd) - errorOut(err, t, fmt.Sprintf("out should've been a container id: %s %s", out, inspectOut)) + if out, _, err := runCommandWithOutput(inspectCmd); err != nil { + t.Fatalf("out should've been a container id: %s %v", out, err) + } waitCmd := exec.Command(dockerBinary, "wait", out) - _, _, err = runCommandWithOutput(waitCmd) - errorOut(err, t, fmt.Sprintf("error thrown while waiting for container: %s", out)) + if waitOut, _, err := runCommandWithOutput(waitCmd); err != nil { + t.Fatalf("error thrown while waiting for container: %s, %v", waitOut, err) + } logsCmd := exec.Command(dockerBinary, "logs", out) - containerLogs, _, err := runCommandWithOutput(logsCmd) - errorOut(err, t, fmt.Sprintf("error thrown while trying to get container logs: %s", err)) + logsOut, _, err := runCommandWithOutput(logsCmd) + if err != nil { + t.Fatalf("error thrown while trying to get container logs: %s, %v", logsOut, err) + } - containerLogs = stripTrailingCharacters(containerLogs) + containerLogs := stripTrailingCharacters(logsOut) if containerLogs != "blahblah" { t.Errorf("logs didn't print the container's logs %s", containerLogs) } rmCmd := exec.Command(dockerBinary, "rm", out) - _, _, err = runCommandWithOutput(rmCmd) - errorOut(err, t, fmt.Sprintf("rm failed to remove container %s", err)) + if out, _, err = runCommandWithOutput(rmCmd); err != nil { + t.Fatalf("rm failed to remove container: %s, %v", out, err) + } deleteAllContainers() @@ -230,16 +230,20 @@ func TestRunDetachedContainerIDPrinting(t *testing.T) { out = stripTrailingCharacters(out) inspectCmd := exec.Command(dockerBinary, "inspect", out) - inspectOut, _, err := runCommandWithOutput(inspectCmd) - errorOut(err, t, fmt.Sprintf("out should've been a container id: %s %s", out, inspectOut)) + if inspectOut, _, err := runCommandWithOutput(inspectCmd); err != nil { + t.Fatalf("out should've been a container id: %s %v", inspectOut, err) + } waitCmd := exec.Command(dockerBinary, "wait", out) - _, _, err = runCommandWithOutput(waitCmd) - errorOut(err, t, fmt.Sprintf("error thrown while waiting for container: %s", out)) + if waitOut, _, err := runCommandWithOutput(waitCmd); err != nil { + t.Fatalf("error thrown while waiting for container: %s, %v", waitOut, err) + } rmCmd := exec.Command(dockerBinary, "rm", out) rmOut, _, err := runCommandWithOutput(rmCmd) - errorOut(err, t, "rm failed to remove container") + if err != nil { + t.Fatalf("rm failed to remove container: %s, %v", rmOut, err) + } rmOut = stripTrailingCharacters(rmOut) if rmOut != out { @@ -267,7 +271,9 @@ func TestRunWorkingDirectory(t *testing.T) { runCmd = exec.Command(dockerBinary, "run", "--workdir", "/root", "busybox", "pwd") out, _, _, err = runCommandWithStdoutStderr(runCmd) - errorOut(err, t, out) + if err != nil { + t.Fatal(out, err) + } out = stripTrailingCharacters(out)