mirror of
https://github.com/moby/moby.git
synced 2025-07-29 07:21:35 +03:00
Remove most of the runCommandWithOutput from integration tests
There is 5 calls left, that use StdinPipe that is not yet supported by icmd. Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
@ -7,7 +7,6 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"regexp"
|
||||
@ -1149,10 +1148,7 @@ func (s *DockerSuite) TestBuildWithInaccessibleFilesInContext(c *check.C) {
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestBuildForceRm(c *check.C) {
|
||||
containerCountBefore, err := getContainerCount()
|
||||
if err != nil {
|
||||
c.Fatalf("failed to get the container count: %s", err)
|
||||
}
|
||||
containerCountBefore := getContainerCount(c)
|
||||
name := "testbuildforcerm"
|
||||
|
||||
buildImage(name, withBuildFlags("--force-rm"), withBuildContext(c,
|
||||
@ -1162,11 +1158,7 @@ func (s *DockerSuite) TestBuildForceRm(c *check.C) {
|
||||
ExitCode: 1,
|
||||
})
|
||||
|
||||
containerCountAfter, err := getContainerCount()
|
||||
if err != nil {
|
||||
c.Fatalf("failed to get the container count: %s", err)
|
||||
}
|
||||
|
||||
containerCountAfter := getContainerCount(c)
|
||||
if containerCountBefore != containerCountAfter {
|
||||
c.Fatalf("--force-rm shouldn't have left containers behind")
|
||||
}
|
||||
@ -1196,19 +1188,12 @@ func (s *DockerSuite) TestBuildRm(c *check.C) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
containerCountBefore, err := getContainerCount()
|
||||
if err != nil {
|
||||
c.Fatalf("failed to get the container count: %s", err)
|
||||
}
|
||||
containerCountBefore := getContainerCount(c)
|
||||
|
||||
buildImageSuccessfully(c, name, withBuildFlags(tc.buildflags...), withDockerfile(`FROM busybox
|
||||
RUN echo hello world`))
|
||||
|
||||
containerCountAfter, err := getContainerCount()
|
||||
if err != nil {
|
||||
c.Fatalf("failed to get the container count: %s", err)
|
||||
}
|
||||
|
||||
containerCountAfter := getContainerCount(c)
|
||||
if tc.shouldLeftContainerBehind {
|
||||
if containerCountBefore == containerCountAfter {
|
||||
c.Fatalf("flags %v should have left containers behind", tc.buildflags)
|
||||
@ -2863,13 +2848,10 @@ func (s *DockerSuite) TestBuildAddTarXz(c *check.C) {
|
||||
c.Fatalf("failed to close tar archive: %v", err)
|
||||
}
|
||||
|
||||
xzCompressCmd := exec.Command("xz", "-k", "test.tar")
|
||||
xzCompressCmd.Dir = tmpDir
|
||||
out, _, err := runCommandWithOutput(xzCompressCmd)
|
||||
if err != nil {
|
||||
c.Fatal(err, out)
|
||||
}
|
||||
|
||||
icmd.RunCmd(icmd.Cmd{
|
||||
Command: []string{"xz", "-k", "test.tar"},
|
||||
Dir: tmpDir,
|
||||
}).Assert(c, icmd.Success)
|
||||
if err := ioutil.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(dockerfile), 0644); err != nil {
|
||||
c.Fatalf("failed to open destination dockerfile: %v", err)
|
||||
}
|
||||
@ -2913,20 +2895,15 @@ func (s *DockerSuite) TestBuildAddTarXzGz(c *check.C) {
|
||||
c.Fatalf("failed to close tar archive: %v", err)
|
||||
}
|
||||
|
||||
xzCompressCmd := exec.Command("xz", "-k", "test.tar")
|
||||
xzCompressCmd.Dir = tmpDir
|
||||
out, _, err := runCommandWithOutput(xzCompressCmd)
|
||||
if err != nil {
|
||||
c.Fatal(err, out)
|
||||
}
|
||||
|
||||
gzipCompressCmd := exec.Command("gzip", "test.tar.xz")
|
||||
gzipCompressCmd.Dir = tmpDir
|
||||
out, _, err = runCommandWithOutput(gzipCompressCmd)
|
||||
if err != nil {
|
||||
c.Fatal(err, out)
|
||||
}
|
||||
icmd.RunCmd(icmd.Cmd{
|
||||
Command: []string{"xz", "-k", "test.tar"},
|
||||
Dir: tmpDir,
|
||||
}).Assert(c, icmd.Success)
|
||||
|
||||
icmd.RunCmd(icmd.Cmd{
|
||||
Command: []string{"gzip", "test.tar.xz"},
|
||||
Dir: tmpDir,
|
||||
})
|
||||
if err := ioutil.WriteFile(filepath.Join(tmpDir, "Dockerfile"), []byte(dockerfile), 0644); err != nil {
|
||||
c.Fatalf("failed to open destination dockerfile: %v", err)
|
||||
}
|
||||
@ -5591,8 +5568,7 @@ func (s *DockerSuite) TestBuildSquashParent(c *check.C) {
|
||||
dockerCmd(c, "run", "--rm", id, "/bin/sh", "-c", `[ "$(echo $HELLO)" == "world" ]`)
|
||||
|
||||
// make sure the ID produced is the ID of the tag we specified
|
||||
inspectID, err := inspectImage("test", ".ID")
|
||||
c.Assert(err, checker.IsNil)
|
||||
inspectID := inspectImage(c, "test", ".ID")
|
||||
c.Assert(inspectID, checker.Equals, id)
|
||||
|
||||
origHistory, _ := dockerCmd(c, "history", origID)
|
||||
@ -5602,8 +5578,7 @@ func (s *DockerSuite) TestBuildSquashParent(c *check.C) {
|
||||
splitTestHistory := strings.Split(strings.TrimSpace(testHistory), "\n")
|
||||
c.Assert(len(splitTestHistory), checker.Equals, len(splitOrigHistory)+1)
|
||||
|
||||
out, err = inspectImage(id, "len .RootFS.Layers")
|
||||
c.Assert(err, checker.IsNil)
|
||||
out = inspectImage(c, id, "len .RootFS.Layers")
|
||||
c.Assert(strings.TrimSpace(out), checker.Equals, "3")
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user