diff options
author | Josh Bleecher Snyder <josharian@gmail.com> | 2021-01-14 14:38:55 -0800 |
---|---|---|
committer | Josh Bleecher Snyder <josharian@gmail.com> | 2021-02-24 16:38:56 +0000 |
commit | 27684ea195641ead8a8f08cb345925da889a12ed (patch) | |
tree | 4d21632fe63abd13843396dc3f42ddbbcbe02208 /src/testing | |
parent | ae1fa08e4138c49c8e7fa10c3eadbfca0233842b (diff) | |
download | go-27684ea195641ead8a8f08cb345925da889a12ed.tar.gz go-27684ea195641ead8a8f08cb345925da889a12ed.zip |
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 <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/sub_test.go | 2 | ||||
-rw-r--r-- | src/testing/testing.go | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/testing/sub_test.go b/src/testing/sub_test.go index 5b226f85ad..6c7d83aac2 100644 --- a/src/testing/sub_test.go +++ b/src/testing/sub_test.go @@ -822,7 +822,7 @@ func TestLogAfterComplete(t *T) { c2 <- fmt.Sprintf("subtest panic with unexpected value %v", p) return } - const want = "Log in goroutine after TestLateLog has completed" + const want = "Log in goroutine after TestLateLog has completed: log after test" if !strings.Contains(s, want) { c2 <- fmt.Sprintf("subtest panic %q does not contain %q", s, want) } diff --git a/src/testing/testing.go b/src/testing/testing.go index 80354d5ce8..466dd96981 100644 --- a/src/testing/testing.go +++ b/src/testing/testing.go @@ -762,7 +762,7 @@ func (c *common) logDepth(s string, depth int) { return } } - panic("Log in goroutine after " + c.name + " has completed") + panic("Log in goroutine after " + c.name + " has completed: " + s) } else { if c.chatty != nil { if c.bench { |