Discussion on #40771 (comment) confirms that the change in question does seem to fix the reported issue, and we haven't had any reports of it regressing any other behavior on the main branch during the 1.16 cycle. I think we should aim to get this into the next minor release.
…cally 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.)
Run-TryBot: Bryan C. Mills <email@example.com>
TryBot-Result: Gobot Gobot <firstname.lastname@example.org>
Reviewed-by: Jay Conrod <email@example.com>
Reviewed-by: Ian Lance Taylor <firstname.lastname@example.org>
(cherry picked from commit 51c0bdc)
TryBot-Result: Go Bot <email@example.com>
Trust: Bryan C. Mills <firstname.lastname@example.org>