mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
testing: synchronize writes to the root's Writer
Prior to this change it was possible to see interleaved messages: <<< === RUN Test/LongLongLongLongName48 === RUN Test/LongLon=== RUN Test/LongLongLongLongName50 gLongLongName49 === RUN Test/LongLongLongLongName51 >>> This change fixes it such that you see: <<< === RUN Test/LongLongLongLongName48 === RUN Test/LongLongLongLongName49 === RUN Test/LongLongLongLongName50 === RUN Test/LongLongLongLongName51 >>> Fixes #18741 Change-Id: I2529d724065dc65b3e9eb3d7cbeeda82a2d0cfd4 Reviewed-on: https://go-review.googlesource.com/35556 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
This commit is contained in:
parent
048b8cecc6
commit
7f31971f59
2 changed files with 46 additions and 1 deletions
|
|
@ -259,7 +259,7 @@ var (
|
|||
// common holds the elements common between T and B and
|
||||
// captures common methods such as Errorf.
|
||||
type common struct {
|
||||
mu sync.RWMutex // guards output, failed, and done.
|
||||
mu sync.RWMutex // guards output, w, failed, and done.
|
||||
output []byte // Output generated by test or benchmark.
|
||||
w io.Writer // For flushToParent.
|
||||
chatty bool // A copy of the chatty flag.
|
||||
|
|
@ -687,7 +687,9 @@ func (t *T) Run(name string, f func(t *T)) bool {
|
|||
root := t.parent
|
||||
for ; root.parent != nil; root = root.parent {
|
||||
}
|
||||
root.mu.Lock()
|
||||
fmt.Fprintf(root.w, "=== RUN %s\n", t.name)
|
||||
root.mu.Unlock()
|
||||
}
|
||||
// Instead of reducing the running count of this test before calling the
|
||||
// tRunner and increasing it afterwards, we rely on tRunner keeping the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue