aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorSean Liao <sean@liao.dev>2025-03-10 19:41:09 +0000
committerGopher Robot <gobot@golang.org>2025-03-10 15:02:26 -0700
commit2abe5ceb1968edb882c8318af674c4133dd0bb75 (patch)
treee60b9ad8a8ab3c9933de53018532cc3935924ac8 /src/testing
parent574a9fa60e593154fbbe64f992b7e6656e3ab0b7 (diff)
downloadgo-2abe5ceb1968edb882c8318af674c4133dd0bb75.tar.xz
testing: warn against calling Log after a test completes
Fixes #40343 Change-Id: Id266f4b57131e9e148e5aa2be86b67fe6d73b20a Reviewed-on: https://go-review.googlesource.com/c/go/+/656415 Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/testing.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/testing/testing.go b/src/testing/testing.go
index 8b0915a0ef..471046e89d 100644
--- a/src/testing/testing.go
+++ b/src/testing/testing.go
@@ -1083,6 +1083,7 @@ func (c *common) logDepth(s string, depth int) {
// and records the text in the error log. For tests, the text will be printed only if
// the test fails or the -test.v flag is set. For benchmarks, the text is always
// printed to avoid having performance depend on the value of the -test.v flag.
+// It is an error to call Log after a test or benchmark returns.
func (c *common) Log(args ...any) {
c.checkFuzzFn("Log")
c.log(fmt.Sprintln(args...))
@@ -1093,6 +1094,7 @@ func (c *common) Log(args ...any) {
// tests, the text will be printed only if the test fails or the -test.v flag is
// set. For benchmarks, the text is always printed to avoid having performance
// depend on the value of the -test.v flag.
+// It is an error to call Logf after a test or benchmark returns.
func (c *common) Logf(format string, args ...any) {
c.checkFuzzFn("Logf")
c.log(fmt.Sprintf(format, args...))