Write writes bytes from p to the underlying testing.TB.
(p []byte)
| 137 | |
| 138 | // Write writes bytes from p to the underlying testing.TB. |
| 139 | func (w TestingWriter) Write(p []byte) (n int, err error) { |
| 140 | n = len(p) |
| 141 | |
| 142 | // Strip trailing newline because t.Log always adds one. |
| 143 | p = bytes.TrimRight(p, "\n") |
| 144 | |
| 145 | // Note: t.Log is safe for concurrent use. |
| 146 | w.t.Logf("%s", p) |
| 147 | if w.markFailed { |
| 148 | w.t.Fail() |
| 149 | } |
| 150 | |
| 151 | return n, nil |
| 152 | } |
| 153 | |
| 154 | // Sync commits the current contents (a no-op for TestingWriter). |
| 155 | func (w TestingWriter) Sync() error { |