From: Michael Matloob Date: Fri, 4 Nov 2022 20:42:52 +0000 (-0400) Subject: cmd/go: use clean GOCACHE in TestNewReleaseRebuildsStalePackagesInGOPATH X-Git-Tag: go1.20rc1~411 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=6d58aea5d412d135ec08463db515ee9453c508b5;p=gostls13.git cmd/go: use clean GOCACHE in TestNewReleaseRebuildsStalePackagesInGOPATH Now that most GOROOT packages do not have install targets, their staleness depends on whether their builds have been cached. That means that, from a clean cache, once TestNewReleaseRebuildsStalePackagesInGOPATH builds certain targets, they will stay non-stale for the second run of the test, becasue the will still be in the cache. So the first run of the test from a clean cache will pass and the second will fail. Set GOCACHE to a temporary directory in the test to use a clean cache and avoid this. Change-Id: I91f954138a4723d81545134441148badbfc515f5 Reviewed-on: https://go-review.googlesource.com/c/go/+/448018 Reviewed-by: Bryan Mills Reviewed-by: Than McIntosh Run-TryBot: Michael Matloob TryBot-Result: Gopher Robot --- diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go index f5f583fbea..4f451e614b 100644 --- a/src/cmd/go/go_test.go +++ b/src/cmd/go/go_test.go @@ -894,6 +894,11 @@ func TestNewReleaseRebuildsStalePackagesInGOPATH(t *testing.T) { defer tg.cleanup() tg.parallel() + // Set GOCACHE to an empty directory so that a previous run of + // this test does not affect the staleness of the packages it builds. + tg.tempDir("gocache") + tg.setenv("GOCACHE", tg.path("gocache")) + // Copy the runtime packages into a temporary GOROOT // so that we can change files. for _, copydir := range []string{