ExpectNoMatchBefore validates that `match` does not occur before `before`.
(ctx context.Context, match, before string)
| 184 | |
| 185 | // ExpectNoMatchBefore validates that `match` does not occur before `before`. |
| 186 | func (e *Expecter) ExpectNoMatchBefore(ctx context.Context, match, before string) string { |
| 187 | e.t.Helper() |
| 188 | |
| 189 | var buffer bytes.Buffer |
| 190 | err := e.doMatchWithDeadline(ctx, "ExpectNoMatchBefore", func(rd *bufio.Reader) error { |
| 191 | for { |
| 192 | r, _, err := rd.ReadRune() |
| 193 | if err != nil { |
| 194 | return err |
| 195 | } |
| 196 | _, err = buffer.WriteRune(r) |
| 197 | if err != nil { |
| 198 | return err |
| 199 | } |
| 200 | |
| 201 | if strings.Contains(buffer.String(), match) { |
| 202 | return xerrors.Errorf("found %q before %q", match, before) |
| 203 | } |
| 204 | |
| 205 | if strings.Contains(buffer.String(), before) { |
| 206 | return nil |
| 207 | } |
| 208 | } |
| 209 | }) |
| 210 | if err != nil { |
| 211 | e.fatalf("read error", "%v (wanted no %q before %q; got %q)", err, match, before, buffer.String()) |
| 212 | return "" |
| 213 | } |
| 214 | e.Logf("matched %q = %q", before, stripansi.Strip(buffer.String())) |
| 215 | return buffer.String() |
| 216 | } |
| 217 | |
| 218 | func (e *Expecter) Peek(ctx context.Context, n int) []byte { |
| 219 | e.t.Helper() |