]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: document that tests must not write to their source modules
authorBryan C. Mills <bcmills@google.com>
Fri, 29 Oct 2021 00:54:45 +0000 (20:54 -0400)
committerBryan C. Mills <bcmills@google.com>
Fri, 29 Oct 2021 19:30:03 +0000 (19:30 +0000)
Fixes #28386
Updates #48495

Change-Id: I76186077c7bbe3f8f608026ee1865de83fe169b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/359574
Trust: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

src/cmd/go/alldocs.go
src/cmd/go/internal/test/test.go

index 487a8f580b95d2c7159ea8a853d9cdc3aeb03078..0dcb31799561ab0565b3a178bc9e8dac2784bb73 100644 (file)
 // When 'go test' runs a test binary, it does so from within the
 // corresponding package's source code directory. Depending on the test,
 // it may be necessary to do the same when invoking a generated test
-// binary directly.
+// binary directly. Because that directory may be located within the
+// module cache, which may be read-only and is verified by checksums, the
+// test must not write to it or any other directory within the module
+// unless explicitly requested by the user (such as with the -fuzz flag,
+// which writes failures to testdata/fuzz).
 //
 // The command-line package list, if present, must appear before any
 // flag not known to the go test command. Continuing the example above,
index c435cc3fb2646a1a0f044cacbed4f2646412e8c2..cfb0a1465fbc91ff0ebfdff88b3c288728d2ae58 100644 (file)
@@ -407,7 +407,11 @@ leave the test binary in pkg.test for use when analyzing the profiles.
 When 'go test' runs a test binary, it does so from within the
 corresponding package's source code directory. Depending on the test,
 it may be necessary to do the same when invoking a generated test
-binary directly.
+binary directly. Because that directory may be located within the
+module cache, which may be read-only and is verified by checksums, the
+test must not write to it or any other directory within the module
+unless explicitly requested by the user (such as with the -fuzz flag,
+which writes failures to testdata/fuzz).
 
 The command-line package list, if present, must appear before any
 flag not known to the go test command. Continuing the example above,