Skip to content

Commit b19a663

Browse files
author
Aditi Sharma
committed
fix flake
1 parent b410db9 commit b19a663

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tests/helper/helper_generic.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,13 @@ func WatchNonRetCmdStdOut(cmdStr string, timeout time.Duration, success func(out
176176
// for commands like odo log -f which streams continuous data and does not terminate by their own
177177
// we need to read the stream data from buffer.
178178
func RunCmdWithMatchOutputFromBuffer(timeoutAfter time.Duration, matchString, program string, args ...string) (bool, error) {
179-
var buf, errBuf bytes.Buffer
179+
180+
buf := bytes.NewBuffer(make([]byte, 0, 10))
181+
errBuf := bytes.NewBuffer(make([]byte, 0, 10))
180182

181183
command := exec.Command(program, args...)
182-
command.Stdout = &buf
183-
command.Stderr = &errBuf
184+
command.Stdout = buf
185+
command.Stderr = errBuf
184186

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

201+
defer command.Process.Kill()
202+
199203
// go routine which is reading data from buffer until expected string matched
200204
go func() {
201205
for {

0 commit comments

Comments
 (0)