MCPcopy
hub / github.com/grpc/grpc-go / declareLogNoise

Function declareLogNoise

test/end2end_test.go:5127–5143  ·  view source on GitHub ↗

declareLogNoise declares that t is expected to emit the following noisy phrases, even on success. Those phrases will be filtered from log output and only be shown if *verbose_logs or t ends up failing. The returned restore function should be called with defer to be run before the test ends.

(t *testing.T, phrases ...string)

Source from the content-addressed store, hash-verified

5125// only be shown if *verbose_logs or t ends up failing. The returned restore
5126// function should be called with defer to be run before the test ends.
5127func declareLogNoise(t *testing.T, phrases ...string) (restore func()) {
5128 if *verboseLogs {
5129 return noop
5130 }
5131 fw := &filterWriter{dst: os.Stderr, filter: phrases}
5132 testLogOutput.setWriter(fw)
5133 return func() {
5134 if t.Failed() {
5135 fw.mu.Lock()
5136 defer fw.mu.Unlock()
5137 if fw.buf.Len() > 0 {
5138 t.Logf("Complete log output:\n%s", fw.buf.Bytes())
5139 }
5140 }
5141 testLogOutput.setWriter(os.Stderr)
5142 }
5143}
5144
5145type filterWriter struct {
5146 dst io.Writer

Callers 1

declareLogNoiseMethod · 0.85

Calls 6

setWriterMethod · 0.80
LenMethod · 0.65
LogfMethod · 0.65
BytesMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected