Merge pull request #10921 from duglin/FixNonverboseBuild

Build w/o verbose hangs w/RUN
This commit is contained in:
Jessie Frazelle 2015-02-23 15:15:12 -08:00
commit ac06d0c46a
2 changed files with 40 additions and 2 deletions

View file

@ -556,8 +556,11 @@ func (b *Builder) run(c *daemon.Container) error {
return err
}
if err := <-errCh; err != nil {
return err
if b.Verbose {
// Block on reading output from container, stop on err or chan closed
if err := <-errCh; err != nil {
return err
}
}
// Wait for it to finish

View file

@ -4921,3 +4921,38 @@ func TestBuildDotDotFile(t *testing.T) {
}
logDone("build - ..file")
}
func TestBuildNotVerbose(t *testing.T) {
defer deleteAllContainers()
defer deleteImages("verbose")
ctx, err := fakeContext("FROM busybox\nENV abc=hi\nRUN echo $abc there", map[string]string{})
if err != nil {
t.Fatal(err)
}
defer ctx.Close()
// First do it w/verbose - baseline
buildCmd := exec.Command(dockerBinary, "build", "--no-cache", "-t", "verbose", ".")
buildCmd.Dir = ctx.Dir
out, _, err := runCommandWithOutput(buildCmd)
if err != nil {
t.Fatalf("failed to build the image w/o -q: %s, %v", out, err)
}
if !strings.Contains(out, "hi there") {
t.Fatalf("missing output:%s\n", out)
}
// Now do it w/o verbose
buildCmd = exec.Command(dockerBinary, "build", "--no-cache", "-q", "-t", "verbose", ".")
buildCmd.Dir = ctx.Dir
out, _, err = runCommandWithOutput(buildCmd)
if err != nil {
t.Fatalf("failed to build the image w/ -q: %s, %v", out, err)
}
if strings.Contains(out, "hi there") {
t.Fatalf("Bad output, should not contain 'hi there':%s", out)
}
logDone("build - not verbose")
}