Skip to content

cmd/go: GO111MODULE does not invalidate test cache #69203

@rittneje

Description

@rittneje

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.)

Metadata

Metadata

Assignees

Labels

GoCommandcmd/goNeedsFixThe path to resolution is known, but the work has not been done.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions