mirror of
https://github.com/containers/skopeo.git
synced 2025-08-12 11:52:39 +00:00
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.
This commit is contained in:
parent
2f2a688026
commit
601f76f96d
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/go-check/check"
|
"github.com/go-check/check"
|
||||||
)
|
)
|
||||||
@ -14,11 +15,11 @@ func consumeAndLogOutput(c *check.C, id string, f io.ReadCloser, err error) {
|
|||||||
f.Close()
|
f.Close()
|
||||||
c.Logf("Output %s: Closed", id)
|
c.Logf("Output %s: Closed", id)
|
||||||
}()
|
}()
|
||||||
buf := make([]byte, 0, 1024)
|
buf := make([]byte, 1024)
|
||||||
for {
|
for {
|
||||||
c.Logf("Output %s: waiting", id)
|
c.Logf("Output %s: waiting", id)
|
||||||
n, err := f.Read(buf)
|
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 {
|
if n <= 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user