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:
@ -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")
|
||||
}
|
||||
|
Reference in New Issue
Block a user