Merge pull request #46398 from vvoland/tests-integration-cli-build-multline-images
integration-cli/build: Parse multiline images -q output
This commit is contained in:
commit
7abd7fa739
1 changed files with 18 additions and 8 deletions
|
@ -26,7 +26,7 @@ import (
|
|||
"github.com/moby/buildkit/frontend/dockerfile/command"
|
||||
"github.com/opencontainers/go-digest"
|
||||
"gotest.tools/v3/assert"
|
||||
"gotest.tools/v3/assert/cmp"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
"gotest.tools/v3/icmd"
|
||||
)
|
||||
|
||||
|
@ -4623,7 +4623,12 @@ func (s *DockerCLIBuildSuite) TestBuildMultiStageArg(c *testing.T) {
|
|||
result.Assert(c, icmd.Success)
|
||||
|
||||
result = cli.DockerCmd(c, "images", "-q", "-f", "label=multifromtest=1")
|
||||
parentID := strings.TrimSpace(result.Stdout())
|
||||
result.Assert(c, icmd.Success)
|
||||
|
||||
imgs := strings.Split(strings.TrimSpace(result.Stdout()), "\n")
|
||||
assert.Assert(c, is.Len(imgs, 1), `only one image with "multifromtest" label is expected`)
|
||||
|
||||
parentID := imgs[0]
|
||||
|
||||
result = cli.DockerCmd(c, "run", "--rm", parentID, "cat", "/out")
|
||||
assert.Assert(c, strings.Contains(result.Stdout(), "foo=abc"))
|
||||
|
@ -4648,7 +4653,12 @@ func (s *DockerCLIBuildSuite) TestBuildMultiStageGlobalArg(c *testing.T) {
|
|||
result.Assert(c, icmd.Success)
|
||||
|
||||
result = cli.DockerCmd(c, "images", "-q", "-f", "label=multifromtest=1")
|
||||
parentID := strings.TrimSpace(result.Stdout())
|
||||
result.Assert(c, icmd.Success)
|
||||
|
||||
imgs := strings.Split(strings.TrimSpace(result.Stdout()), "\n")
|
||||
assert.Assert(c, is.Len(imgs, 1), `only one image with "multifromtest" label is expected`)
|
||||
|
||||
parentID := imgs[0]
|
||||
|
||||
result = cli.DockerCmd(c, "run", "--rm", parentID, "cat", "/out")
|
||||
assert.Assert(c, !strings.Contains(result.Stdout(), "tag"))
|
||||
|
@ -4773,7 +4783,7 @@ func (s *DockerCLIBuildSuite) TestBuildFollowSymlinkToFile(c *testing.T) {
|
|||
cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
|
||||
|
||||
out := cli.DockerCmd(c, "run", "--rm", name, "cat", "target").Combined()
|
||||
assert.Assert(c, cmp.Regexp("^bar$", out))
|
||||
assert.Assert(c, is.Regexp("^bar$", out))
|
||||
|
||||
// change target file should invalidate cache
|
||||
err = os.WriteFile(filepath.Join(ctx.Dir, "foo"), []byte("baz"), 0o644)
|
||||
|
@ -4782,7 +4792,7 @@ func (s *DockerCLIBuildSuite) TestBuildFollowSymlinkToFile(c *testing.T) {
|
|||
result := cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
|
||||
assert.Assert(c, !strings.Contains(result.Combined(), "Using cache"))
|
||||
out = cli.DockerCmd(c, "run", "--rm", name, "cat", "target").Combined()
|
||||
assert.Assert(c, cmp.Regexp("^baz$", out))
|
||||
assert.Assert(c, is.Regexp("^baz$", out))
|
||||
}
|
||||
|
||||
func (s *DockerCLIBuildSuite) TestBuildFollowSymlinkToDir(c *testing.T) {
|
||||
|
@ -4803,7 +4813,7 @@ func (s *DockerCLIBuildSuite) TestBuildFollowSymlinkToDir(c *testing.T) {
|
|||
cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
|
||||
|
||||
out := cli.DockerCmd(c, "run", "--rm", name, "cat", "abc", "def").Combined()
|
||||
assert.Assert(c, cmp.Regexp("^barbaz$", out))
|
||||
assert.Assert(c, is.Regexp("^barbaz$", out))
|
||||
|
||||
// change target file should invalidate cache
|
||||
err = os.WriteFile(filepath.Join(ctx.Dir, "foo/def"), []byte("bax"), 0o644)
|
||||
|
@ -4812,7 +4822,7 @@ func (s *DockerCLIBuildSuite) TestBuildFollowSymlinkToDir(c *testing.T) {
|
|||
result := cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
|
||||
assert.Assert(c, !strings.Contains(result.Combined(), "Using cache"))
|
||||
out = cli.DockerCmd(c, "run", "--rm", name, "cat", "abc", "def").Combined()
|
||||
assert.Assert(c, cmp.Regexp("^barbax$", out))
|
||||
assert.Assert(c, is.Regexp("^barbax$", out))
|
||||
}
|
||||
|
||||
// TestBuildSymlinkBasename tests that target file gets basename from symlink,
|
||||
|
@ -4834,7 +4844,7 @@ func (s *DockerCLIBuildSuite) TestBuildSymlinkBasename(c *testing.T) {
|
|||
cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
|
||||
|
||||
out := cli.DockerCmd(c, "run", "--rm", name, "cat", "asymlink").Combined()
|
||||
assert.Assert(c, cmp.Regexp("^bar$", out))
|
||||
assert.Assert(c, is.Regexp("^bar$", out))
|
||||
}
|
||||
|
||||
// #17827
|
||||
|
|
Loading…
Add table
Reference in a new issue