]> Cypherpunks.ru repositories - gostls13.git/commit
testing: flush test summaries to stdout atomically when streaming output
authorBryan C. Mills <bcmills@google.com>
Wed, 19 Aug 2020 02:47:12 +0000 (22:47 -0400)
committerBryan C. Mills <bcmills@google.com>
Wed, 2 Sep 2020 14:22:42 +0000 (14:22 +0000)
commit51c0bdc6d15dcd7f753c25896039ab41ac787ebb
treecf798ee7a2ce7b96873056e84d3f5dcdee25e356
parente6583dc95375c4e266bffab6f8888e8e557b6355
testing: flush test summaries to stdout atomically when streaming output

While debugging #40771, I realized that the chatty printer should only
ever print to a single io.Writer (normally os.Stdout). The other
Writer implementations in the chain write to local buffers, but if we
wrote a test's output to a local buffer, then we did *not* write it to
stdout and we should not store it as the most recently logged test.

Because the chatty printer should only ever print to one place, it
shouldn't receive an io.Writer as an argument — rather, it shouldn't
be used at all for destinations other than the main output stream.

On the other hand, when we flush the output buffer to stdout in the
top-level flushToParent call, it is important that we not allow some
other test's output to intrude between the test summary header and the
remainder of the test's output. cmd/test2json doesn't know how to
parse such an intrusion, and it's confusing to humans too.

No test because I couldn't reproduce the user-reported error without
modifying the testing package. (This behavior seems to be very
sensitive to output size and/or goroutine scheduling.)

Fixes #40771
Updates #38458

Change-Id: Ic19bf1d535672b096ba1c8583a3b74aab6d6d766
Reviewed-on: https://go-review.googlesource.com/c/go/+/249026
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/testing/benchmark.go
src/testing/sub_test.go
src/testing/testing.go