When testing multiple packages go test
buffers the output unless there is a failure, however when benchmarking it defaults to streaming output.
// stream test output (no buffering) when no package has
// been given on the command line (implicit current directory)
// or when benchmarking.
// Also stream if we're showing output anyway with a
// single package under test. In that case, streaming the
// output produces the same result as not streaming,
// just more immediately.
testStreamOutput = len(pkgArgs) == 0 || testBench ||
(len(pkgs) <= 1 && testShowPass)
I don't really get this behavior being forced on the user, as I don't see much use in getting the standard ouput during benchmarking.
Here is an example of my test command, which compiles a coverage profile and performs benchmarking for a single package :
go test -bench=. -benchmem -covermode=count -coverprofile=main.coverprofile PACKAGE
Am I missing something? How can I override this behavior and buffer the output even when benchmarking?