Fix TestDockerCmd*Timeout racey tests
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
parent
c0bd79f3f8
commit
0f1eca7265
2 changed files with 11 additions and 4 deletions
|
@ -105,8 +105,16 @@ func RunCommandWithOutputForDuration(cmd *exec.Cmd, duration time.Duration) (out
|
|||
cmd.Stderr = &outputBuffer
|
||||
|
||||
done := make(chan error)
|
||||
|
||||
// Start the command in the main thread..
|
||||
err = cmd.Start()
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Fail to start command %v : %v", cmd, err)
|
||||
}
|
||||
|
||||
go func() {
|
||||
exitErr := cmd.Run()
|
||||
// And wait for it to exit in the goroutine :)
|
||||
exitErr := cmd.Wait()
|
||||
exitCode = ProcessExitCode(exitErr)
|
||||
done <- exitErr
|
||||
}()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue