From e076c1b897b30648db794b66fd10929fe9a9852e Mon Sep 17 00:00:00 2001 From: Raghvender Date: Mon, 11 Dec 2023 15:41:45 -0600 Subject: [PATCH] cmd/go: allow test caching for the -fullpath flag Change-Id: I5662b8ff617772ca2afec8bf419c468a3e69c392 Reviewed-on: https://go-review.googlesource.com/c/go/+/548996 Auto-Submit: Bryan Mills Reviewed-by: Bryan Mills Reviewed-by: Michael Matloob Run-TryBot: Bryan Mills TryBot-Result: Gopher Robot --- src/cmd/go/alldocs.go | 2 +- src/cmd/go/internal/test/test.go | 5 +++-- src/cmd/go/testdata/script/test_cache_inputs.txt | 7 +++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go index 05e42a6d31..a6166a7fdb 100644 --- a/src/cmd/go/alldocs.go +++ b/src/cmd/go/alldocs.go @@ -1802,7 +1802,7 @@ // The rule for a match in the cache is that the run involves the same // test binary and the flags on the command line come entirely from a // restricted set of 'cacheable' test flags, defined as -benchtime, -cpu, -// -list, -parallel, -run, -short, -timeout, -failfast, and -v. +// -list, -parallel, -run, -short, -timeout, -failfast, -fullpath and -v. // If a run of go test has any test or non-test flags outside this set, // the result is not cached. To disable test caching, use any test flag // or argument other than the cacheable flags. The idiomatic way to disable diff --git a/src/cmd/go/internal/test/test.go b/src/cmd/go/internal/test/test.go index 8a40547f2e..b2b5d34027 100644 --- a/src/cmd/go/internal/test/test.go +++ b/src/cmd/go/internal/test/test.go @@ -126,7 +126,7 @@ elapsed time in the summary line. The rule for a match in the cache is that the run involves the same test binary and the flags on the command line come entirely from a restricted set of 'cacheable' test flags, defined as -benchtime, -cpu, --list, -parallel, -run, -short, -timeout, -failfast, and -v. +-list, -parallel, -run, -short, -timeout, -failfast, -fullpath and -v. If a run of go test has any test or non-test flags outside this set, the result is not cached. To disable test caching, use any test flag or argument other than the cacheable flags. The idiomatic way to disable @@ -1717,7 +1717,8 @@ func (c *runCache) tryCacheWithID(b *work.Builder, a *work.Action, id string) bo "-test.short", "-test.timeout", "-test.failfast", - "-test.v": + "-test.v", + "-test.fullpath": // These are cacheable. // Note that this list is documented above, // so if you add to this list, update the docs too. diff --git a/src/cmd/go/testdata/script/test_cache_inputs.txt b/src/cmd/go/testdata/script/test_cache_inputs.txt index 3705c700d1..1868da9842 100644 --- a/src/cmd/go/testdata/script/test_cache_inputs.txt +++ b/src/cmd/go/testdata/script/test_cache_inputs.txt @@ -114,6 +114,13 @@ go test testcache -run=TestOSArgs -failfast go test testcache -run=TestOSArgs -failfast stdout '\(cached\)' +# golang.org/issue/64638: that includes the `-fullpath` argument. +go test testcache -run=TestOSArgs -fullpath +! stdout '\(cached\)' +go test testcache -run=TestOSArgs -fullpath +stdout '\(cached\)' + + # Executables within GOROOT and GOPATH should affect caching, # even if the test does not stat them explicitly. -- 2.48.1