Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 149e661

Browse files
committed
Check matcher earlier
1 parent 85d6805 commit 149e661

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

testutil/pty.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,14 @@ func ReadUntil(ctx context.Context, t *testing.T, r io.Reader, matcher func(line
5555
case <-ctx.Done():
5656
return ctx.Err()
5757
}
58+
if matcher == nil {
59+
// A nil matcher means to read until EOF.
60+
continue
61+
}
5862
got := term.String()
5963
lines := strings.Split(got, "\n")
6064
for _, line := range lines {
61-
if matcher != nil && matcher(line) {
65+
if matcher(line) {
6266
return nil
6367
}
6468
}

0 commit comments

Comments
 (0)