From 601f76f96d1936d03500e84276c821a1f3904e72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Wed, 22 Jun 2016 15:31:29 +0200 Subject: [PATCH] Fix consumeAndLogOutput Primarily, make it actually work; reading into a non-zero-capacity but zero-length slice would just return 0, the goroutine would terminate, and even the producer of the output could fail with EPIPE/SIGPIPE. Also make the logged output readable, converting it into a string instead of a series of hexadecimal byte values. --- integration/utils.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/integration/utils.go b/integration/utils.go index 1af87270..3dd6f552 100644 --- a/integration/utils.go +++ b/integration/utils.go @@ -2,6 +2,7 @@ package main import ( "io" + "strings" "github.com/go-check/check" ) @@ -14,11 +15,11 @@ func consumeAndLogOutput(c *check.C, id string, f io.ReadCloser, err error) { f.Close() c.Logf("Output %s: Closed", id) }() - buf := make([]byte, 0, 1024) + buf := make([]byte, 1024) for { c.Logf("Output %s: waiting", id) n, err := f.Read(buf) - c.Logf("Output %s: got %d,%#v: %#v", id, n, err, buf[:n]) + c.Logf("Output %s: got %d,%#v: %s", id, n, err, strings.TrimSuffix(string(buf[:n]), "\n")) if n <= 0 { break }