Skip to content

Commit

Permalink
fix flake
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditi Sharma committed Aug 21, 2020
1 parent b410db9 commit b19a663
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tests/helper/helper_generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,13 @@ func WatchNonRetCmdStdOut(cmdStr string, timeout time.Duration, success func(out
// for commands like odo log -f which streams continuous data and does not terminate by their own
// we need to read the stream data from buffer.
func RunCmdWithMatchOutputFromBuffer(timeoutAfter time.Duration, matchString, program string, args ...string) (bool, error) {
var buf, errBuf bytes.Buffer

buf := bytes.NewBuffer(make([]byte, 0, 10))
errBuf := bytes.NewBuffer(make([]byte, 0, 10))

command := exec.Command(program, args...)
command.Stdout = &buf
command.Stderr = &errBuf
command.Stdout = buf
command.Stderr = errBuf

timeoutCh := time.After(timeoutAfter)
matchOutputCh := make(chan bool)
Expand All @@ -196,6 +198,8 @@ func RunCmdWithMatchOutputFromBuffer(timeoutAfter time.Duration, matchString, pr
return false, err
}

defer command.Process.Kill()

// go routine which is reading data from buffer until expected string matched
go func() {
for {
Expand Down

0 comments on commit b19a663

Please sign in to comment.