Browse code

Merge pull request #11265 from duglin/ScratchSHfix

Fix builder when num of RUN args is 1

Tibor Vass authored on 2015/03/12 23:30:56
Showing 4 changed files
... ...
@@ -145,7 +145,8 @@ RUN ln -sfv $PWD/.bashrc ~/.bashrc
145 145
 # Get useful and necessary Hub images so we can "docker load" locally instead of pulling
146 146
 COPY contrib/download-frozen-image.sh /go/src/github.com/docker/docker/contrib/
147 147
 RUN ./contrib/download-frozen-image.sh /docker-frozen-images \
148
-	busybox:latest@4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125
148
+	busybox:latest@4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125 \
149
+	hello-world:latest@e45a5af57b00862e5ef5782a9925979a02ba2b12dff832fd0991335f4a11e5c5
149 150
 # see also "hack/make/.ensure-frozen-images" (which needs to be updated any time this list is)
150 151
 
151 152
 # Install man page generator
... ...
@@ -213,8 +213,8 @@ func run(b *Builder, args []string, attributes map[string]bool, original string)
213 213
 
214 214
 	args = handleJsonArgs(args, attributes)
215 215
 
216
-	if len(args) == 1 {
217
-		args = append([]string{"/bin/sh", "-c"}, args[0])
216
+	if !attributes["json"] {
217
+		args = append([]string{"/bin/sh", "-c"}, args...)
218 218
 	}
219 219
 
220 220
 	runCmd := flag.NewFlagSet("run", flag.ContinueOnError)
... ...
@@ -5227,3 +5227,30 @@ func TestBuildNotVerbose(t *testing.T) {
5227 5227
 
5228 5228
 	logDone("build - not verbose")
5229 5229
 }
5230
+
5231
+func TestBuildRUNoneJSON(t *testing.T) {
5232
+	name := "testbuildrunonejson"
5233
+
5234
+	defer deleteAllContainers()
5235
+	defer deleteImages(name)
5236
+
5237
+	ctx, err := fakeContext(`FROM hello-world:latest
5238
+RUN [ "/hello" ]`, map[string]string{})
5239
+	if err != nil {
5240
+		t.Fatal(err)
5241
+	}
5242
+	defer ctx.Close()
5243
+
5244
+	buildCmd := exec.Command(dockerBinary, "build", "--no-cache", "-t", name, ".")
5245
+	buildCmd.Dir = ctx.Dir
5246
+	out, _, err := runCommandWithOutput(buildCmd)
5247
+	if err != nil {
5248
+		t.Fatalf("failed to build the image: %s, %v", out, err)
5249
+	}
5250
+
5251
+	if !strings.Contains(out, "Hello from Docker") {
5252
+		t.Fatalf("bad output: %s", out)
5253
+	}
5254
+
5255
+	logDone("build - RUN with one JSON arg")
5256
+}
... ...
@@ -4,6 +4,7 @@ set -e
4 4
 # this list should match roughly what's in the Dockerfile (minus the explicit image IDs, of course)
5 5
 images=(
6 6
 	busybox:latest
7
+	hello-world:latest
7 8
 )
8 9
 
9 10
 if ! docker inspect "${images[@]}" &> /dev/null; then