mirror of
https://github.com/moby/moby.git
synced 2025-07-29 07:21:35 +03:00
rm-gocheck: Matches -> cmp.Regexp
sed -E -i '0,/^import "github\.com/ s/^(import "github\.com.*)/\1\nimport "gotest.tools\/assert\/cmp")/' \ -- "integration-cli/docker_cli_build_test.go" "integration-cli/docker_cli_history_test.go" "integration-cli/docker_cli_links_test.go" \ && \ sed -E -i '0,/^\t+"github\.com/ s/(^\t+"github\.com.*)/\1\n"gotest.tools\/assert\/cmp"/' \ -- "integration-cli/docker_cli_build_test.go" "integration-cli/docker_cli_history_test.go" "integration-cli/docker_cli_links_test.go" \ && \ sed -E -i 's#\bassert\.Assert\(c, (.*), checker\.Matches, (.*)\)$#assert.Assert(c, eg_matches(is.Regexp, \1, \2))#g' \ -- "integration-cli/docker_cli_images_test.go" "integration-cli/docker_api_containers_test.go" \ && \ sed -E -i 's#\bassert\.Assert\(c, (.*), checker\.Matches, (.*)\)$#assert.Assert(c, eg_matches(cmp.Regexp, \1, \2))#g' \ -- "integration-cli/docker_cli_build_test.go" "integration-cli/docker_cli_history_test.go" "integration-cli/docker_cli_links_test.go" \ && \ go get -d golang.org/x/tools/cmd/eg && dir=$(go env GOPATH)/src/golang.org/x/tools && git -C "$dir" fetch https://github.com/tiborvass/tools handle-variadic && git -C "$dir" checkout 61a94b82347c29b3289e83190aa3dda74d47abbb && go install golang.org/x/tools/cmd/eg \ && \ /bin/echo -e 'package main\nvar eg_matches func(func(cmp.RegexOrPattern, string) cmp.Comparison, interface{}, string, ...interface{}) bool' > ./integration-cli/eg_helper.go \ && \ goimports -w ./integration-cli \ && \ eg -w -t template.matches.go -- ./integration-cli \ && \ rm -f ./integration-cli/eg_helper.go \ && \ go run rm-gocheck.go redress '\bassert\.Assert\b.*(\(|,)\s*$' \ "integration-cli/docker_api_containers_test.go" "integration-cli/docker_cli_build_test.go" "integration-cli/docker_cli_history_test.go" "integration-cli/docker_cli_images_test.go" "integration-cli/docker_cli_links_test.go" Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
@ -30,6 +30,7 @@ import (
|
||||
"github.com/moby/buildkit/frontend/dockerfile/command"
|
||||
"github.com/opencontainers/go-digest"
|
||||
"gotest.tools/assert"
|
||||
"gotest.tools/assert/cmp"
|
||||
"gotest.tools/icmd"
|
||||
)
|
||||
|
||||
@ -4803,7 +4804,12 @@ func (s *DockerSuite) TestBuildFollowSymlinkToFile(c *testing.T) {
|
||||
cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
|
||||
|
||||
out := cli.DockerCmd(c, "run", "--rm", name, "cat", "target").Combined()
|
||||
assert.Assert(c, out, checker.Matches, "bar")
|
||||
assert.Assert(c, cmp.Regexp("^"+
|
||||
|
||||
"bar"+
|
||||
"$",
|
||||
|
||||
out))
|
||||
|
||||
// change target file should invalidate cache
|
||||
err = ioutil.WriteFile(filepath.Join(ctx.Dir, "foo"), []byte("baz"), 0644)
|
||||
@ -4813,7 +4819,13 @@ func (s *DockerSuite) TestBuildFollowSymlinkToFile(c *testing.T) {
|
||||
assert.Assert(c, result.Combined(), checker.Not(checker.Contains), "Using cache")
|
||||
|
||||
out = cli.DockerCmd(c, "run", "--rm", name, "cat", "target").Combined()
|
||||
assert.Assert(c, out, checker.Matches, "baz")
|
||||
assert.Assert(c, cmp.Regexp("^"+
|
||||
|
||||
"baz"+
|
||||
"$",
|
||||
|
||||
out))
|
||||
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestBuildFollowSymlinkToDir(c *testing.T) {
|
||||
@ -4834,7 +4846,12 @@ func (s *DockerSuite) 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, out, checker.Matches, "barbaz")
|
||||
assert.Assert(c, cmp.Regexp("^"+
|
||||
|
||||
"barbaz"+
|
||||
"$",
|
||||
|
||||
out))
|
||||
|
||||
// change target file should invalidate cache
|
||||
err = ioutil.WriteFile(filepath.Join(ctx.Dir, "foo/def"), []byte("bax"), 0644)
|
||||
@ -4844,7 +4861,12 @@ func (s *DockerSuite) TestBuildFollowSymlinkToDir(c *testing.T) {
|
||||
assert.Assert(c, result.Combined(), checker.Not(checker.Contains), "Using cache")
|
||||
|
||||
out = cli.DockerCmd(c, "run", "--rm", name, "cat", "abc", "def").Combined()
|
||||
assert.Assert(c, out, checker.Matches, "barbax")
|
||||
assert.Assert(c, cmp.Regexp("^"+
|
||||
|
||||
"barbax"+
|
||||
"$",
|
||||
|
||||
out))
|
||||
|
||||
}
|
||||
|
||||
@ -4867,7 +4889,13 @@ func (s *DockerSuite) TestBuildSymlinkBasename(c *testing.T) {
|
||||
cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx))
|
||||
|
||||
out := cli.DockerCmd(c, "run", "--rm", name, "cat", "asymlink").Combined()
|
||||
assert.Assert(c, out, checker.Matches, "bar")
|
||||
assert.Assert(c, cmp.Regexp("^"+
|
||||
|
||||
"bar"+
|
||||
"$",
|
||||
|
||||
out))
|
||||
|
||||
}
|
||||
|
||||
// #17827
|
||||
|
Reference in New Issue
Block a user