mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
test(cli): improve TestServer/SpammyLogs line count (#16814)
This commit is contained in:
committed by
GitHub
parent
77479cdd51
commit
cc946f199d
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user