]> Cypherpunks repositories - gostls13.git/commitdiff
testing: update description of Setenv
authorNobuki Fujii <scofni@gmail.com>
Fri, 23 Sep 2022 13:53:31 +0000 (22:53 +0900)
committerGopher Robot <gobot@golang.org>
Thu, 29 Sep 2022 22:16:42 +0000 (22:16 +0000)
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>
src/testing/testing.go

index b64286c00596acbb378aa224e8069f8e48afca78..c7d51a13e3900e7c07255cec51c637b4a5986fb6 100644 (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