pkg/testutils: return errors after restoring stdout
Ensures Ginkgo is able to print detailed failure messages instead of them being captured by the pipe.
This commit is contained in:
parent
1bc8141105
commit
5a984f0dee
@ -46,13 +46,15 @@ func CmdAddWithResult(cniNetns, cniIfname string, conf []byte, f func() error) (
|
||||
os.Stdout = w
|
||||
err = f()
|
||||
w.Close()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// parse the result
|
||||
out, err := ioutil.ReadAll(r)
|
||||
var out []byte
|
||||
if err == nil {
|
||||
out, err = ioutil.ReadAll(r)
|
||||
}
|
||||
os.Stdout = oldStdout
|
||||
|
||||
// Return errors after restoring stdout so Ginkgo will correctly
|
||||
// emit verbose error information on stdout
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user