From: Bryan C. Mills Date: Fri, 29 Oct 2021 00:54:45 +0000 (-0400) Subject: cmd/go: document that tests must not write to their source modules X-Git-Tag: go1.18beta1~671 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=459293388ceb74d9cf61c930f02325645cd0cb7d;p=gostls13.git cmd/go: document that tests must not write to their source modules Fixes #28386 Updates #48495 Change-Id: I76186077c7bbe3f8f608026ee1865de83fe169b4 Reviewed-on: https://go-review.googlesource.com/c/go/+/359574 Trust: Bryan C. Mills Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor TryBot-Result: Go Bot --- diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go index 487a8f580b..0dcb317995 100644 --- a/src/cmd/go/alldocs.go +++ b/src/cmd/go/alldocs.go @@ -2951,7 +2951,11 @@ // 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, diff --git a/src/cmd/go/internal/test/test.go b/src/cmd/go/internal/test/test.go index c435cc3fb2..cfb0a1465f 100644 --- a/src/cmd/go/internal/test/test.go +++ b/src/cmd/go/internal/test/test.go @@ -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,