Open rogpeppe opened 5 years ago
Hi, I can confirm that the output is discarded, here is the writer used in the context of the benchmark https://github.com/golang/go/blob/fbc6a972226f889d2ab1150468755615098ee80f/src/testing/benchmark.go#L772
Calls from Log, Error, or Fatal will print nothing, because the Write call of the discard
writer does nothing.
https://github.com/golang/go/blob/fbc6a972226f889d2ab1150468755615098ee80f/src/testing/benchmark.go#L783-L785
I stumbled upon this today, any updates on this? It feels like a pretty valid case and I was hoping it could do one of the following:
testing.Benchmark
takes io.Writer
as an input.testing.B
and call Benchmark
on top of it.If anyone from the team agrees the the approach of creating a new func that take a io.Writer and uses it here https://github.com/golang/go/blob/fbc6a972226f889d2ab1150468755615098ee80f/src/testing/benchmark.go#L772 I can do the code, should be pretty easy to add and test 😊
Benchmark functions can call Log, Error and Fatal, but if the benchmark is run with the Benchmark function, all messages are discarded.
https://play.golang.org/p/fd5Ed-il70V
Perhaps the messages should be printed to standard error?