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
|
os.Stdout = w
|
||||||
err = f()
|
err = f()
|
||||||
w.Close()
|
w.Close()
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// parse the result
|
var out []byte
|
||||||
out, err := ioutil.ReadAll(r)
|
if err == nil {
|
||||||
|
out, err = ioutil.ReadAll(r)
|
||||||
|
}
|
||||||
os.Stdout = oldStdout
|
os.Stdout = oldStdout
|
||||||
|
|
||||||
|
// Return errors after restoring stdout so Ginkgo will correctly
|
||||||
|
// emit verbose error information on stdout
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user