From a14ac8635f673218c91e13c103cb2f3e29ff4b74 Mon Sep 17 00:00:00 2001 From: Nobuki Fujii Date: Fri, 23 Sep 2022 22:53:31 +0900 Subject: [PATCH] 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 Run-TryBot: Bryan Mills TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor Reviewed-by: Bryan Mills --- src/testing/testing.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/testing/testing.go b/src/testing/testing.go index b64286c005..c7d51a13e3 100644 --- a/src/testing/testing.go +++ b/src/testing/testing.go @@ -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