| 181 | } |
| 182 | |
| 183 | func (e *outExpecter) expectMatcherFunc(ctx context.Context, str string, fn func(src, pattern string) bool) string { |
| 184 | e.t.Helper() |
| 185 | |
| 186 | var buffer bytes.Buffer |
| 187 | err := e.doMatchWithDeadline(ctx, "ExpectMatchContext", func(rd *bufio.Reader) error { |
| 188 | for { |
| 189 | r, _, err := rd.ReadRune() |
| 190 | if err != nil { |
| 191 | return err |
| 192 | } |
| 193 | _, err = buffer.WriteRune(r) |
| 194 | if err != nil { |
| 195 | return err |
| 196 | } |
| 197 | if fn(buffer.String(), str) { |
| 198 | return nil |
| 199 | } |
| 200 | } |
| 201 | }) |
| 202 | if err != nil { |
| 203 | e.fatalf("read error", "%v (wanted %q; got %q)", err, str, buffer.String()) |
| 204 | return "" |
| 205 | } |
| 206 | e.logf("matched %q = %q", str, buffer.String()) |
| 207 | return buffer.String() |
| 208 | } |
| 209 | |
| 210 | // ExpectNoMatchBefore validates that `match` does not occur before `before`. |
| 211 | func (e *outExpecter) ExpectNoMatchBefore(ctx context.Context, match, before string) string { |