1
0
mirror of https://github.com/golang/go synced 2024-11-22 15:54:52 -07:00

testing: document that TestMain can be used with benchmarks

Fixes #45764

Change-Id: Ie6c18bb5c20721c2ffa8b4a9cf9f97cdc665a450
GitHub-Last-Rev: 8bcea7e0ff
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>
This commit is contained in:
Julien Tant 2021-04-27 21:32:18 +00:00 committed by Ian Lance Taylor
parent 30002e6656
commit 645cb62ee3

View File

@ -208,14 +208,14 @@
//
// 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