]> Cypherpunks repositories - gostls13.git/commitdiff
testing: document that TestMain can be used with benchmarks
authorJulien Tant <julien@craftyx.fr>
Tue, 27 Apr 2021 21:32:18 +0000 (21:32 +0000)
committerIan Lance Taylor <iant@golang.org>
Tue, 27 Apr 2021 21:44:16 +0000 (21:44 +0000)
Fixes #45764

Change-Id: Ie6c18bb5c20721c2ffa8b4a9cf9f97cdc665a450
GitHub-Last-Rev: 8bcea7e0ff60227c05437b372c0a3546e151af31
GitHub-Pull-Request: golang/go#45808
Reviewed-on: https://go-review.googlesource.com/c/go/+/314349
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Bryan C. Mills <bcmills@google.com>

src/testing/testing.go

index 2146195956f1f9dd0012717f875db030e8d9500d..1562eadef08592a7e472b857236c50dc0a9453fd 100644 (file)
 //
 // Main
 //
-// It is sometimes necessary for a test program to do extra setup or teardown
-// before or after testing. It is also sometimes necessary for a test to control
+// It is sometimes necessary for a test or benchmark program to do extra setup or teardown
+// before or after it executes. It is also sometimes necessary to control
 // which code runs on the main thread. To support these and other cases,
 // if a test file contains a function:
 //
 //     func TestMain(m *testing.M)
 //
-// then the generated test will call TestMain(m) instead of running the tests
+// then the generated test will call TestMain(m) instead of running the tests or benchmarks
 // directly. TestMain runs in the main goroutine and can do whatever setup
 // and teardown is necessary around a call to m.Run. m.Run will return an exit
 // code that may be passed to os.Exit. If TestMain returns, the test wrapper