|
@@ -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
|