Skip to content

Commit 27684ea

Browse files
committed
testing: print late arriving log line in panic
When you log after a test has completed, the testing package panics. Print the logged line as part of that panic, to aid in debugging. Change-Id: I3d6689d1eed57c03e300afe37db0c15b2f4acda4 Reviewed-on: https://go-review.googlesource.com/c/go/+/283972 Trust: Josh Bleecher Snyder <[email protected]> Run-TryBot: Josh Bleecher Snyder <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent ae1fa08 commit 27684ea

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/testing/sub_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ func TestLogAfterComplete(t *T) {
822822
c2 <- fmt.Sprintf("subtest panic with unexpected value %v", p)
823823
return
824824
}
825-
const want = "Log in goroutine after TestLateLog has completed"
825+
const want = "Log in goroutine after TestLateLog has completed: log after test"
826826
if !strings.Contains(s, want) {
827827
c2 <- fmt.Sprintf("subtest panic %q does not contain %q", s, want)
828828
}

src/testing/testing.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ func (c *common) logDepth(s string, depth int) {
762762
return
763763
}
764764
}
765-
panic("Log in goroutine after " + c.name + " has completed")
765+
panic("Log in goroutine after " + c.name + " has completed: " + s)
766766
} else {
767767
if c.chatty != nil {
768768
if c.bench {

0 commit comments

Comments
 (0)