Go version

go version go1.21.4 linux/amd64

What operating system and processor architecture are you using (go env)?

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/michael/.cache/go-build'
GOENV='/home/michael/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/michael/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/michael/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/michael/sdk/go1.21.4'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/michael/sdk/go1.21.4/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.4'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build292685049=/tmp/go-build -gno-record-gcc-switches'

What did you do?

When I run go test ./..., the cache kicks in as expected:

% time CGO_ENABLED=0 go test ./...     
ok      formmailer/cmd/formmailer   (cached)
CGO_ENABLED=0 go test ./...  2,64s user 1,02s system 561% cpu 0,651 total

But adding the -fullpath flag prevents caching:

% time CGO_ENABLED=0 go test -fullpath ./...
ok      formmailer/cmd/formmailer   0.947s
CGO_ENABLED=0 go test -fullpath ./...  7,18s user 1,66s system 592% cpu 1,492 total

% time CGO_ENABLED=0 go test -fullpath ./...
ok      formmailer/cmd/formmailer   0.924s
CGO_ENABLED=0 go test -fullpath ./...  7,60s user 1,69s system 620% cpu 1,496 total

go help test speaks of a restricted set of 'cacheable' test flags, defined as -benchtime, -cpu, -list, -parallel, -run, -short, -timeout, -failfast, and -v.

It seems to me like we should add -fullpath to the list of cacheable test flags.

What did you expect to see?

Caching should work even when using -fullpath

What did you see instead?

Caching did not work.

Comment From: Goclipse27

@stapelberg - seems right.

cc @bcmills - Is this proposal ?

Comment From: bcmills

@raghvenders, this doesn't need a proposal — it's just a bug.

Comment From: Goclipse27

@bcmills - I will work on this.

Comment From: gopherbot

Change https://go.dev/cl/548996 mentions this issue: cmd/go: fix for making test flag -fullpath to run test (cached)

Comment From: stapelberg

This was fixed with commit https://github.com/golang/go/commit/e076c1b897b30648db794b66fd10929fe9a9852e (but the commit lacked a “fixes” line, so the issue wasn’t closed automatically when merging), which was released with Go 1.23.