MCPcopy Index your code
hub / github.com/coder/coder / expectMatcherFunc

Method expectMatcherFunc

pty/ptytest/ptytest.go:183–208  ·  view source on GitHub ↗
(ctx context.Context, str string, fn func(src, pattern string) bool)

Source from the content-addressed store, hash-verified

181}
182
183func (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`.
211func (e *outExpecter) ExpectNoMatchBefore(ctx context.Context, match, before string) string {

Callers 2

ExpectMatchContextMethod · 0.95

Calls 6

doMatchWithDeadlineMethod · 0.95
fatalfMethod · 0.95
logfMethod · 0.95
HelperMethod · 0.65
ReadRuneMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected