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>
| ... | ... |
@@ -1066,7 +1066,13 @@ func (s *DockerSuite) TestContainerAPICopyResourcePathEmptyPre124(c *testing.T) |
| 1066 | 1066 |
} |
| 1067 | 1067 |
b, err := request.ReadBody(body) |
| 1068 | 1068 |
assert.NilError(c, err) |
| 1069 |
- assert.Assert(c, string(b), checker.Matches, "Path cannot be empty\n") |
|
| 1069 |
+ assert.Assert(c, is.Regexp("^"+
|
|
| 1070 |
+ |
|
| 1071 |
+ "Path cannot be empty\n"+ |
|
| 1072 |
+ "$", |
|
| 1073 |
+ |
|
| 1074 |
+ string(b))) |
|
| 1075 |
+ |
|
| 1070 | 1076 |
} |
| 1071 | 1077 |
|
| 1072 | 1078 |
func (s *DockerSuite) TestContainerAPICopyResourcePathNotFoundPre124(c *testing.T) {
|
| ... | ... |
@@ -1087,7 +1093,13 @@ func (s *DockerSuite) TestContainerAPICopyResourcePathNotFoundPre124(c *testing. |
| 1087 | 1087 |
} |
| 1088 | 1088 |
b, err := request.ReadBody(body) |
| 1089 | 1089 |
assert.NilError(c, err) |
| 1090 |
- assert.Assert(c, string(b), checker.Matches, "Could not find the file /notexist in container "+name+"\n") |
|
| 1090 |
+ assert.Assert(c, is.Regexp("^"+
|
|
| 1091 |
+ |
|
| 1092 |
+ ("Could not find the file /notexist in container "+name+"\n")+
|
|
| 1093 |
+ "$", |
|
| 1094 |
+ |
|
| 1095 |
+ string(b))) |
|
| 1096 |
+ |
|
| 1091 | 1097 |
} |
| 1092 | 1098 |
|
| 1093 | 1099 |
func (s *DockerSuite) TestContainerAPICopyContainerNotFoundPr124(c *testing.T) {
|
| ... | ... |
@@ -30,6 +30,7 @@ import ( |
| 30 | 30 |
"github.com/moby/buildkit/frontend/dockerfile/command" |
| 31 | 31 |
"github.com/opencontainers/go-digest" |
| 32 | 32 |
"gotest.tools/assert" |
| 33 |
+ "gotest.tools/assert/cmp" |
|
| 33 | 34 |
"gotest.tools/icmd" |
| 34 | 35 |
) |
| 35 | 36 |
|
| ... | ... |
@@ -4803,7 +4804,12 @@ func (s *DockerSuite) TestBuildFollowSymlinkToFile(c *testing.T) {
|
| 4803 | 4803 |
cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx)) |
| 4804 | 4804 |
|
| 4805 | 4805 |
out := cli.DockerCmd(c, "run", "--rm", name, "cat", "target").Combined() |
| 4806 |
- assert.Assert(c, out, checker.Matches, "bar") |
|
| 4806 |
+ assert.Assert(c, cmp.Regexp("^"+
|
|
| 4807 |
+ |
|
| 4808 |
+ "bar"+ |
|
| 4809 |
+ "$", |
|
| 4810 |
+ |
|
| 4811 |
+ out)) |
|
| 4807 | 4812 |
|
| 4808 | 4813 |
// change target file should invalidate cache |
| 4809 | 4814 |
err = ioutil.WriteFile(filepath.Join(ctx.Dir, "foo"), []byte("baz"), 0644)
|
| ... | ... |
@@ -4813,7 +4819,13 @@ func (s *DockerSuite) TestBuildFollowSymlinkToFile(c *testing.T) {
|
| 4813 | 4813 |
assert.Assert(c, result.Combined(), checker.Not(checker.Contains), "Using cache") |
| 4814 | 4814 |
|
| 4815 | 4815 |
out = cli.DockerCmd(c, "run", "--rm", name, "cat", "target").Combined() |
| 4816 |
- assert.Assert(c, out, checker.Matches, "baz") |
|
| 4816 |
+ assert.Assert(c, cmp.Regexp("^"+
|
|
| 4817 |
+ |
|
| 4818 |
+ "baz"+ |
|
| 4819 |
+ "$", |
|
| 4820 |
+ |
|
| 4821 |
+ out)) |
|
| 4822 |
+ |
|
| 4817 | 4823 |
} |
| 4818 | 4824 |
|
| 4819 | 4825 |
func (s *DockerSuite) TestBuildFollowSymlinkToDir(c *testing.T) {
|
| ... | ... |
@@ -4834,7 +4846,12 @@ func (s *DockerSuite) TestBuildFollowSymlinkToDir(c *testing.T) {
|
| 4834 | 4834 |
cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx)) |
| 4835 | 4835 |
|
| 4836 | 4836 |
out := cli.DockerCmd(c, "run", "--rm", name, "cat", "abc", "def").Combined() |
| 4837 |
- assert.Assert(c, out, checker.Matches, "barbaz") |
|
| 4837 |
+ assert.Assert(c, cmp.Regexp("^"+
|
|
| 4838 |
+ |
|
| 4839 |
+ "barbaz"+ |
|
| 4840 |
+ "$", |
|
| 4841 |
+ |
|
| 4842 |
+ out)) |
|
| 4838 | 4843 |
|
| 4839 | 4844 |
// change target file should invalidate cache |
| 4840 | 4845 |
err = ioutil.WriteFile(filepath.Join(ctx.Dir, "foo/def"), []byte("bax"), 0644)
|
| ... | ... |
@@ -4844,7 +4861,12 @@ func (s *DockerSuite) TestBuildFollowSymlinkToDir(c *testing.T) {
|
| 4844 | 4844 |
assert.Assert(c, result.Combined(), checker.Not(checker.Contains), "Using cache") |
| 4845 | 4845 |
|
| 4846 | 4846 |
out = cli.DockerCmd(c, "run", "--rm", name, "cat", "abc", "def").Combined() |
| 4847 |
- assert.Assert(c, out, checker.Matches, "barbax") |
|
| 4847 |
+ assert.Assert(c, cmp.Regexp("^"+
|
|
| 4848 |
+ |
|
| 4849 |
+ "barbax"+ |
|
| 4850 |
+ "$", |
|
| 4851 |
+ |
|
| 4852 |
+ out)) |
|
| 4848 | 4853 |
|
| 4849 | 4854 |
} |
| 4850 | 4855 |
|
| ... | ... |
@@ -4867,7 +4889,13 @@ func (s *DockerSuite) TestBuildSymlinkBasename(c *testing.T) {
|
| 4867 | 4867 |
cli.BuildCmd(c, name, build.WithExternalBuildContext(ctx)) |
| 4868 | 4868 |
|
| 4869 | 4869 |
out := cli.DockerCmd(c, "run", "--rm", name, "cat", "asymlink").Combined() |
| 4870 |
- assert.Assert(c, out, checker.Matches, "bar") |
|
| 4870 |
+ assert.Assert(c, cmp.Regexp("^"+
|
|
| 4871 |
+ |
|
| 4872 |
+ "bar"+ |
|
| 4873 |
+ "$", |
|
| 4874 |
+ |
|
| 4875 |
+ out)) |
|
| 4876 |
+ |
|
| 4871 | 4877 |
} |
| 4872 | 4878 |
|
| 4873 | 4879 |
// #17827 |
| ... | ... |
@@ -11,6 +11,7 @@ import ( |
| 11 | 11 |
"github.com/docker/docker/integration-cli/cli/build" |
| 12 | 12 |
"github.com/go-check/check" |
| 13 | 13 |
"gotest.tools/assert" |
| 14 |
+ "gotest.tools/assert/cmp" |
|
| 14 | 15 |
) |
| 15 | 16 |
|
| 16 | 17 |
// This is a heisen-test. Because the created timestamp of images and the behavior of |
| ... | ... |
@@ -116,6 +117,11 @@ func (s *DockerSuite) TestHistoryHumanOptionTrue(c *testing.T) {
|
| 116 | 116 |
endIndex = len(lines[i]) |
| 117 | 117 |
} |
| 118 | 118 |
sizeString := lines[i][startIndex:endIndex] |
| 119 |
- assert.Assert(c, strings.TrimSpace(sizeString), checker.Matches, humanSizeRegexRaw, check.Commentf("The size '%s' was not in human format", sizeString))
|
|
| 119 |
+ assert.Assert(c, cmp.Regexp("^"+
|
|
| 120 |
+ |
|
| 121 |
+ humanSizeRegexRaw+ |
|
| 122 |
+ "$", |
|
| 123 |
+ |
|
| 124 |
+ strings.TrimSpace(sizeString)), check.Commentf("The size '%s' was not in human format", sizeString))
|
|
| 120 | 125 |
} |
| 121 | 126 |
} |
| ... | ... |
@@ -93,8 +93,20 @@ func (s *DockerSuite) TestImagesFilterLabelMatch(c *testing.T) {
|
| 93 | 93 |
|
| 94 | 94 |
out, _ := dockerCmd(c, "images", "--no-trunc", "-q", "-f", "label=match") |
| 95 | 95 |
out = strings.TrimSpace(out) |
| 96 |
- assert.Assert(c, out, checker.Matches, fmt.Sprintf("[\\s\\w:]*%s[\\s\\w:]*", image1ID))
|
|
| 97 |
- assert.Assert(c, out, checker.Matches, fmt.Sprintf("[\\s\\w:]*%s[\\s\\w:]*", image2ID))
|
|
| 96 |
+ assert.Assert(c, is.Regexp("^"+
|
|
| 97 |
+ |
|
| 98 |
+ fmt.Sprintf("[\\s\\w:]*%s[\\s\\w:]*", image1ID)+
|
|
| 99 |
+ "$", |
|
| 100 |
+ |
|
| 101 |
+ out)) |
|
| 102 |
+ |
|
| 103 |
+ assert.Assert(c, is.Regexp("^"+
|
|
| 104 |
+ |
|
| 105 |
+ fmt.Sprintf("[\\s\\w:]*%s[\\s\\w:]*", image2ID)+
|
|
| 106 |
+ "$", |
|
| 107 |
+ |
|
| 108 |
+ out)) |
|
| 109 |
+ |
|
| 98 | 110 |
assert.Assert(c, !is.Regexp("^"+fmt.Sprintf("[\\s\\w:]*%s[\\s\\w:]*", image3ID)+"$", out)().Success())
|
| 99 | 111 |
|
| 100 | 112 |
out, _ = dockerCmd(c, "images", "--no-trunc", "-q", "-f", "label=match=me too") |
| ... | ... |
@@ -12,6 +12,7 @@ import ( |
| 12 | 12 |
"github.com/docker/docker/runconfig" |
| 13 | 13 |
"github.com/go-check/check" |
| 14 | 14 |
"gotest.tools/assert" |
| 15 |
+ "gotest.tools/assert/cmp" |
|
| 15 | 16 |
) |
| 16 | 17 |
|
| 17 | 18 |
func (s *DockerSuite) TestLinksPingUnlinkedContainers(c *testing.T) {
|
| ... | ... |
@@ -230,7 +231,13 @@ func (s *DockerSuite) TestLinksEtcHostsRegularFile(c *testing.T) {
|
| 230 | 230 |
testRequires(c, DaemonIsLinux, NotUserNamespace) |
| 231 | 231 |
out, _ := dockerCmd(c, "run", "--net=host", "busybox", "ls", "-la", "/etc/hosts") |
| 232 | 232 |
// /etc/hosts should be a regular file |
| 233 |
- assert.Assert(c, out, checker.Matches, "^-.+\n") |
|
| 233 |
+ assert.Assert(c, cmp.Regexp("^"+
|
|
| 234 |
+ |
|
| 235 |
+ "^-.+\n"+ |
|
| 236 |
+ "$", |
|
| 237 |
+ |
|
| 238 |
+ out)) |
|
| 239 |
+ |
|
| 234 | 240 |
} |
| 235 | 241 |
|
| 236 | 242 |
func (s *DockerSuite) TestLinksMultipleWithSameName(c *testing.T) {
|