mirror of
https://github.com/moby/moby.git
synced 2025-08-01 05:47:11 +03:00
Check bad syntax on dockerfile before building.
This fix tries to address the issue raised in 26453 where bad syntax on dockerfile is not checked before building, thus user has to wait before seeing error in dockerfile. This fix fixes the issue by evaluating all the instructions and check syntax before dockerfile is invoked actually. All existing tests pass. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
@ -6901,3 +6901,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")
|
||||
}
|
||||
|
Reference in New Issue
Block a user