1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #29773 from forever043/fix_TestDaemonStartWithoutColors

test: Fix "--raw-logs=true" option test in TestDaemonStartWithoutColors
This commit is contained in:
Vincent Demeester 2017-01-03 09:29:19 +01:00 committed by GitHub
commit 2fd995bc99

View file

@ -2165,6 +2165,9 @@ func (s *DockerDaemonSuite) TestDaemonStartWithoutColors(c *check.C) {
infoLog := "\x1b[34mINFO\x1b"
b := bytes.NewBuffer(nil)
done := make(chan bool)
p, tty, err := pty.Open()
c.Assert(err, checker.IsNil)
defer func() {
@ -2172,19 +2175,38 @@ func (s *DockerDaemonSuite) TestDaemonStartWithoutColors(c *check.C) {
p.Close()
}()
b := bytes.NewBuffer(nil)
go io.Copy(b, p)
go func() {
io.Copy(b, p)
done <- true
}()
// Enable coloring explicitly
s.d.StartWithLogFile(tty, "--raw-logs=false")
s.d.Stop(c)
// Wait for io.Copy() before checking output
<-done
c.Assert(b.String(), checker.Contains, infoLog)
b.Reset()
// "tty" is already closed in prev s.d.Stop(),
// we have to close the other side "p" and open another pair of
// pty for the next test.
p.Close()
p, tty, err = pty.Open()
c.Assert(err, checker.IsNil)
go func() {
io.Copy(b, p)
done <- true
}()
// Disable coloring explicitly
s.d.StartWithLogFile(tty, "--raw-logs=true")
s.d.Stop(c)
// Wait for io.Copy() before checking output
<-done
c.Assert(b.String(), check.Not(check.Equals), "")
c.Assert(b.String(), check.Not(checker.Contains), infoLog)
}