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

Method ReadLine

pty/ptytest/ptytest.go:278–325  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

276}
277
278func (e *outExpecter) ReadLine(ctx context.Context) string {
279 e.t.Helper()
280
281 var buffer bytes.Buffer
282 err := e.doMatchWithDeadline(ctx, "ReadLine", func(rd *bufio.Reader) error {
283 for {
284 r, _, err := rd.ReadRune()
285 if err != nil {
286 return err
287 }
288 if r == '\n' {
289 return nil
290 }
291 if r == '\r' {
292 // Peek the next rune to see if it's an LF and then consume
293 // it.
294
295 // Unicode code points can be up to 4 bytes, but the
296 // ones we're looking for are only 1 byte.
297 b, _ := rd.Peek(1)
298 if len(b) == 0 {
299 return nil
300 }
301
302 r, _ = utf8.DecodeRune(b)
303 if r == '\n' {
304 _, _, err = rd.ReadRune()
305 if err != nil {
306 return err
307 }
308 }
309
310 return nil
311 }
312
313 _, err = buffer.WriteRune(r)
314 if err != nil {
315 return err
316 }
317 }
318 })
319 if err != nil {
320 e.fatalf("read error", "%v (wanted newline; got %q)", err, buffer.String())
321 return ""
322 }
323 e.logf("matched newline = %q", buffer.String())
324 return buffer.String()
325}
326
327func (e *outExpecter) ReadAll() []byte {
328 e.t.Helper()

Callers 11

TestServerFunction · 0.45
TestExpMcpServerFunction · 0.45
TestExpMcpReporterFunction · 0.45
TestOpenVSCodeFunction · 0.45
TestPtytestFunction · 0.45
Test_ProxyCRUDFunction · 0.45
TestProvisionerKeysFunction · 0.45
parseAndVerifyExamplesFunction · 0.45

Calls 7

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

Tested by 10

TestServerFunction · 0.36
TestExpMcpServerFunction · 0.36
TestExpMcpReporterFunction · 0.36
TestOpenVSCodeFunction · 0.36
TestPtytestFunction · 0.36
Test_ProxyCRUDFunction · 0.36
TestProvisionerKeysFunction · 0.36