ExpectNoMatchBefore validates that `match` does not occur before `before`.
(ctx context.Context, match, before string)
| 209 | |
| 210 | // ExpectNoMatchBefore validates that `match` does not occur before `before`. |
| 211 | func (e *outExpecter) ExpectNoMatchBefore(ctx context.Context, match, before string) string { |
| 212 | e.t.Helper() |
| 213 | |
| 214 | var buffer bytes.Buffer |
| 215 | err := e.doMatchWithDeadline(ctx, "ExpectNoMatchBefore", func(rd *bufio.Reader) error { |
| 216 | for { |
| 217 | r, _, err := rd.ReadRune() |
| 218 | if err != nil { |
| 219 | return err |
| 220 | } |
| 221 | _, err = buffer.WriteRune(r) |
| 222 | if err != nil { |
| 223 | return err |
| 224 | } |
| 225 | |
| 226 | if strings.Contains(buffer.String(), match) { |
| 227 | return xerrors.Errorf("found %q before %q", match, before) |
| 228 | } |
| 229 | |
| 230 | if strings.Contains(buffer.String(), before) { |
| 231 | return nil |
| 232 | } |
| 233 | } |
| 234 | }) |
| 235 | if err != nil { |
| 236 | e.fatalf("read error", "%v (wanted no %q before %q; got %q)", err, match, before, buffer.String()) |
| 237 | return "" |
| 238 | } |
| 239 | e.logf("matched %q = %q", before, stripansi.Strip(buffer.String())) |
| 240 | return buffer.String() |
| 241 | } |
| 242 | |
| 243 | func (e *outExpecter) Peek(ctx context.Context, n int) []byte { |
| 244 | e.t.Helper() |