diff options
Diffstat (limited to 'src/testing/testing.go')
| -rw-r--r-- | src/testing/testing.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/testing/testing.go b/src/testing/testing.go index 6ab9b79196..bbb10263c3 100644 --- a/src/testing/testing.go +++ b/src/testing/testing.go @@ -479,6 +479,9 @@ func (c *common) decorate(s string, skip int) string { buf := new(strings.Builder) // Every line is indented at least 4 spaces. buf.WriteString(" ") + if c.chatty { + fmt.Fprintf(buf, "%s: ", c.name) + } fmt.Fprintf(buf, "%s:%d: ", file, line) lines := strings.Split(s, "\n") if l := len(lines); l > 1 && lines[l-1] == "" { @@ -662,9 +665,7 @@ func (c *common) log(s string) { func (c *common) logDepth(s string, depth int) { c.mu.Lock() defer c.mu.Unlock() - if !c.done { - c.output = append(c.output, c.decorate(s, depth+1)...) - } else { + if c.done { // This test has already finished. Try and log this message // with our parent. If we don't have a parent, panic. for parent := c.parent; parent != nil; parent = parent.parent { @@ -676,6 +677,12 @@ func (c *common) logDepth(s string, depth int) { } } panic("Log in goroutine after " + c.name + " has completed") + } else { + if c.chatty { + fmt.Print(c.decorate(s, depth+1)) + return + } + c.output = append(c.output, c.decorate(s, depth+1)...) } } |
