| 156 | } |
| 157 | |
| 158 | func (e *Expecter) expectMatcherFunc(ctx context.Context, str string, fn func(src, pattern string) bool) string { |
| 159 | e.t.Helper() |
| 160 | |
| 161 | var buffer bytes.Buffer |
| 162 | err := e.doMatchWithDeadline(ctx, "ExpectMatchContext", func(rd *bufio.Reader) error { |
| 163 | for { |
| 164 | r, _, err := rd.ReadRune() |
| 165 | if err != nil { |
| 166 | return err |
| 167 | } |
| 168 | _, err = buffer.WriteRune(r) |
| 169 | if err != nil { |
| 170 | return err |
| 171 | } |
| 172 | if fn(buffer.String(), str) { |
| 173 | return nil |
| 174 | } |
| 175 | } |
| 176 | }) |
| 177 | if err != nil { |
| 178 | e.fatalf("read error", "%v (wanted %q; got %q)", err, str, buffer.String()) |
| 179 | return "" |
| 180 | } |
| 181 | e.Logf("matched %q = %q", str, buffer.String()) |
| 182 | return buffer.String() |
| 183 | } |
| 184 | |
| 185 | // ExpectNoMatchBefore validates that `match` does not occur before `before`. |
| 186 | func (e *Expecter) ExpectNoMatchBefore(ctx context.Context, match, before string) string { |