Browse Source

Merge pull request #10908 from duglin/EnvDollarTest

Add a ENV tests with special chars in the values
Jessie Frazelle 10 năm trước cách đây
mục cha
commit
fd185eddf6

+ 23 - 0
integration-cli/docker_cli_build_test.go

@@ -3732,6 +3732,9 @@ ENV	   FROM hello/docker/world
 ENV    TO /docker/world/hello
 ENV    TO /docker/world/hello
 ADD    $FROM $TO
 ADD    $FROM $TO
 RUN    [ "$(cat $TO)" = "hello" ]
 RUN    [ "$(cat $TO)" = "hello" ]
+ENV    abc=def
+ENV    ghi=$abc
+RUN    [ "$ghi" = "def" ]
 `
 `
 	ctx, err := fakeContext(dockerfile, map[string]string{
 	ctx, err := fakeContext(dockerfile, map[string]string{
 		"hello/docker/world": "hello",
 		"hello/docker/world": "hello",
@@ -3774,6 +3777,26 @@ ENV    abc 'yyy'
 RUN    [ $abc = \'yyy\' ]
 RUN    [ $abc = \'yyy\' ]
 ENV    abc=
 ENV    abc=
 RUN    [ "$abc" = "" ]
 RUN    [ "$abc" = "" ]
+
+# use grep to make sure if the builder substitutes \$foo by mistake
+# we don't get a false positive
+ENV    abc=\$foo
+RUN    [ "$abc" = "\$foo" ] && (echo "$abc" | grep foo)
+ENV    abc \$foo
+RUN    [ "$abc" = "\$foo" ] && (echo "$abc" | grep foo)
+
+ENV    abc=\'foo\'
+RUN    [ "$abc" = "'foo'" ]
+ENV    abc=\"foo\"
+RUN    [ "$abc" = "\"foo\"" ]
+ENV    abc "foo"
+RUN    [ "$abc" = "\"foo\"" ]
+ENV    abc 'foo'
+RUN    [ "$abc" = "'foo'" ]
+ENV    abc \'foo\'
+RUN    [ "$abc" = "\\'foo\\'" ]
+ENV    abc \"foo\"
+RUN    [ "$abc" = "\\\"foo\\\"" ]
 `
 `
 	ctx, err := fakeContext(dockerfile, map[string]string{
 	ctx, err := fakeContext(dockerfile, map[string]string{
 		"hello/docker/world": "hello",
 		"hello/docker/world": "hello",