go/src/testing
Bryan C. Mills 26c6b51bc1 [release-branch.go1.14] 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 #40880
Updates #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>
(cherry picked from commit 51c0bdc6d1)
Reviewed-on: https://go-review.googlesource.com/c/go/+/252638
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Bryan C. Mills <bcmills@google.com>
2020-10-05 22:50:05 +00:00
..
internal/testdeps testing/internal/testdeps: delete didSetLogger variable 2019-05-28 16:07:50 +00:00
iotest testing/iotest: add missing tests 2019-11-05 17:57:10 +00:00
quick all: shorten some tests 2019-05-22 12:54:00 +00:00
allocs.go
allocs_test.go
benchmark.go [release-branch.go1.14] testing: flush test summaries to stdout atomically when streaming output 2020-10-05 22:50:05 +00:00
benchmark_test.go testing: shorten go test -short testing 2019-05-16 03:25:08 +00:00
cover.go testing/cover: improve message when a package has no statements 2019-03-13 04:11:58 +00:00
example.go testing: use conventional comments for exported internal funcs & structs 2019-12-10 21:11:20 +00:00
export_test.go testing: stop rounding b.N 2019-03-20 21:19:16 +00:00
helper_test.go testing: allow marking subtest and subbenchmark functions as Helpers 2018-05-14 17:59:59 +00:00
helperfuncs_test.go testing: allow marking subtest and subbenchmark functions as Helpers 2018-05-14 17:59:59 +00:00
match.go testing: fix typo mistake 2018-04-27 13:29:12 +00:00
match_test.go testing: harmonize handling of prefix-matched benchmarks 2017-06-20 14:19:05 +00:00
panic_test.go testing: don't run Cleanup functions until parallel subtests complete 2020-01-16 21:32:12 +00:00
run_example.go testing: enable examples on js/wasm with non os.Pipe runExample 2019-03-11 18:59:53 +00:00
run_example_js.go testing: enable examples on js/wasm with non os.Pipe runExample 2019-03-11 18:59:53 +00:00
sub_test.go [release-branch.go1.14] testing: flush test summaries to stdout atomically when streaming output 2020-10-05 22:50:05 +00:00
testing.go [release-branch.go1.14] testing: flush test summaries to stdout atomically when streaming output 2020-10-05 22:50:05 +00:00
testing_test.go