1
0
mirror of https://github.com/moby/moby.git synced 2025-08-01 05:47:11 +03:00

Merge pull request #26516 from yongtang/26453-build-bad-syntax

Check bad syntax on dockerfile before building.
This commit is contained in:
Vincent Demeester
2016-09-23 12:24:20 +02:00
committed by GitHub
15 changed files with 120 additions and 7 deletions

View File

@ -6913,3 +6913,21 @@ func (s *DockerSuite) TestBuildStepsWithProgress(c *check.C) {
c.Assert(out, checker.Contains, fmt.Sprintf("Step %d/%d : RUN echo foo", i, 1+totalRun))
}
}
func (s *DockerSuite) TestBuildWithFailure(c *check.C) {
name := "testbuildwithfailure"
// First test case can only detect `nobody` in runtime so all steps will show up
buildCmd := "FROM busybox\nRUN nobody"
_, stdout, _, err := buildImageWithStdoutStderr(name, buildCmd, false, "--force-rm", "--rm")
c.Assert(err, checker.NotNil)
c.Assert(stdout, checker.Contains, "Step 1/2 : FROM busybox")
c.Assert(stdout, checker.Contains, "Step 2/2 : RUN nobody")
// Second test case `FFOM` should have been detected before build runs so no steps
buildCmd = "FFOM nobody\nRUN nobody"
_, stdout, _, err = buildImageWithStdoutStderr(name, buildCmd, false, "--force-rm", "--rm")
c.Assert(err, checker.NotNil)
c.Assert(stdout, checker.Not(checker.Contains), "Step 1/2 : FROM busybox")
c.Assert(stdout, checker.Not(checker.Contains), "Step 2/2 : RUN nobody")
}