test(cli): improve TestServer/SpammyLogs line count (#16814)

This commit is contained in:
Mathias Fredriksson
2025-03-05 17:04:35 +02:00
committed by GitHub
parent 77479cdd51
commit cc946f199d
2 changed files with 27 additions and 36 deletions
+17
View File
@@ -319,6 +319,11 @@ func (e *outExpecter) ReadLine(ctx context.Context) string {
return buffer.String()
}
func (e *outExpecter) ReadAll() []byte {
e.t.Helper()
return e.out.ReadAll()
}
func (e *outExpecter) doMatchWithDeadline(ctx context.Context, name string, fn func(*bufio.Reader) error) error {
e.t.Helper()
@@ -460,6 +465,18 @@ func newStdbuf() *stdbuf {
return &stdbuf{more: make(chan struct{}, 1)}
}
func (b *stdbuf) ReadAll() []byte {
b.mu.Lock()
defer b.mu.Unlock()
if b.err != nil {
return nil
}
p := append([]byte(nil), b.b...)
b.b = b.b[len(b.b):]
return p
}
func (b *stdbuf) Read(p []byte) (int, error) {
if b.r == nil {
return b.readOrWaitForMore(p)