testing: update description of Setenv

Add the description of Setenv that it cannot use if the test have
parallel ancestors.

Fixes #55128

Change-Id: Ia5a1deaa1a3116d1ebb439600a7d316c7d155412
Reviewed-on: https://go-review.googlesource.com/c/go/+/434115
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
This commit is contained in:
Nobuki Fujii 2022-09-23 22:53:31 +09:00 committed by Gopher Robot
parent e7a3d87dda
commit a14ac8635f

View file

@ -1187,7 +1187,8 @@ func removeAll(path string) error {
// restore the environment variable to its original value
// after the test.
//
// This cannot be used in parallel tests.
// Because Setenv affects the whole process, it cannot be used
// in parallel tests or tests with parallel ancestors.
func (c *common) Setenv(key, value string) {
c.checkFuzzFn("Setenv")
prevValue, ok := os.LookupEnv(key)
@ -1324,7 +1325,8 @@ func (t *T) Parallel() {
// restore the environment variable to its original value
// after the test.
//
// This cannot be used in parallel tests.
// Because Setenv affects the whole process, it cannot be used
// in parallel tests or tests with parallel ancestors.
func (t *T) Setenv(key, value string) {
// Non-parallel subtests that have parallel ancestors may still
// run in parallel with other tests: they are only non-parallel