Go version
go version go1.22.6 darwin/amd64
Output of go env
in your module/workspace:
GO111MODULE='auto'
GOARCH='amd64'
GOBIN=''
GOCACHE='/tmp/.gocache'
GOENV='/Users/rittneje/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/rittneje/go/pkg/mod'
GONOPROXY='[REDACTED]'
GONOSUMDB='[REDACTED]'
GOOS='darwin'
GOPATH='/Users/rittneje/go'
GOPRIVATE='[REDACTED]'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/rittneje/go1.22.6'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/Users/rittneje/go1.22.6/pkg/tool/darwin_amd64'
GOVCS='[REDACTED]'
GOVERSION='go1.22.6'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD=''
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/kf/kr7_s3xx0l12zbj3jrn082hmzy5gvy/T/go-build1131392119=/tmp/go-build -gno-record-gcc-switches -fno-common'
What did you do?
$ GO111MODULE=auto go test net/http -v -run=^TestReadResponseErrors$
=== RUN TestReadResponseErrors
response_test.go:944: status "200 OK" "Content-Length:\r\nContent-Length:\r\n\r\nGophers\r\n": unexpected success; want error with substring "invalid empty Content-Length"
--- FAIL: TestReadResponseErrors (0.00s)
FAIL
FAIL net/http 0.282s
FAIL
$ GO111MODULE=on go test net/http -v -run=^TestReadResponseErrors$
=== RUN TestReadResponseErrors
--- PASS: TestReadResponseErrors (0.00s)
PASS
ok net/http 0.278s
$ GO111MODULE=auto go test net/http -v -run=^TestReadResponseErrors$
=== RUN TestReadResponseErrors
--- PASS: TestReadResponseErrors (0.00s)
PASS
ok net/http (cached)
$ go clean -testcache
$ GO111MODULE=auto go test net/http -v -run=^TestReadResponseErrors$
=== RUN TestReadResponseErrors
response_test.go:944: status "200 OK" "Content-Length:\r\nContent-Length:\r\n\r\nGophers\r\n": unexpected success; want error with substring "invalid empty Content-Length"
--- FAIL: TestReadResponseErrors (0.00s)
FAIL
FAIL net/http 0.366s
FAIL
What did you see happen?
As seen above, changing GO111MODULE
did not invalidate the test cache, even though it factors into the compiler's behavior around the default GODEBUG
selection and thus by extension the behavior of the code being tested.
What did you expect to see?
Changing GO111MODULE
should invalidate the test cache, given that it changes the default GODEBUG
. (Or at least, the default GODEBUG
itself ought to factor into the cache.)
Comment From: gabyhelp
Related Issues and Documentation
- cmd/go: standard library tests fail with GO111MODULE=auto #69202
- cmd/go clean -testcache does not clean test cache #29757 (closed)
- cmd/go: 'go test' fails to cache test result due to modified `.git` directory #52573 (closed)
- cmd/go: accessing temp files invalidates test caching in module mode #29111 (closed)
- cmd/go: cache not invalidated if testdata files are changed while the test is running #26790
- GOCACHE=off causes modules to exit the tests #26809 (closed)
- cmd/go: go clean -testcache fails if GOCACHE directory does not exist #29100 (closed)
- testing: calling os.Getenv in TestMain does not factor into test cache #59849 (closed)
- go test broken with parameters #33869 (closed)
- testing: feature request: mechanism to disable test caching for specific unit tests #34635 (closed)
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Comment From: dmitshur
CC @matloob, @samthanawalla.
Comment From: matloob
I wonder why we don't seem to be adding the default GODEBUG to the action id for the link step? I think we could just add it to printLinkerConfig here: https://cs.opensource.google/go/go/+/master:src/cmd/go/internal/work/exec.go;drc=6b2ffc72b67713de4f08915937a64392aa4dbff0;l=347
Comment From: matloob
So we don't currently add it because it's usually a part of the buildinfo, which is used as part of the action id: https://cs.opensource.google/go/go/+/master:src/cmd/go/internal/work/exec.go;l=327;drc=6b2ffc72b67713de4f08915937a64392aa4dbff0 . But the buildinfo isn't generated for tests unless the test is a test of package main.
I think we should probably still explicitly add default GODEBUG to the link action id. One alternative would be to add build info for all tests, but we'd be doing unnecessary work to get the build info.
Comment From: gopherbot
Change https://go.dev/cl/610875 mentions this issue: cmd/go: explicitly add default GODEBUG to linker config