From e84cfc6dd5ca75e9d39292d939cdb908d60a049e Mon Sep 17 00:00:00 2001 From: Heschi Kreinick Date: Mon, 26 Oct 2020 16:00:07 -0400 Subject: [PATCH] all: clear GOMODCACHE in tests Various test setups set GOPATH expecting that it will affect GOMODCACHE. If GOMODCACHE is explicitly set in the test's environment, that doesn't happen. Clear the value out as needed. Change-Id: I3520d672ace5c1e13783fd078828212bef7d1c01 Reviewed-on: https://go-review.googlesource.com/c/tools/+/265177 Trust: Heschi Kreinick Run-TryBot: Heschi Kreinick gopls-CI: kokoro TryBot-Result: Go Bot Reviewed-by: Bryan C. Mills --- go/packages/packagestest/modules.go | 1 + internal/imports/mod_test.go | 1 + 2 files changed, 2 insertions(+) diff --git a/go/packages/packagestest/modules.go b/go/packages/packagestest/modules.go index 4608766ac0..42b62067a8 100644 --- a/go/packages/packagestest/modules.go +++ b/go/packages/packagestest/modules.go @@ -163,6 +163,7 @@ func (modules) Finalize(exported *Exported) error { exported.Config.Env = append(exported.Config.Env, "GO111MODULE=on", "GOPATH="+filepath.Join(exported.temp, "modcache"), + "GOMODCACHE=", "GOPROXY="+proxydir.ToURL(modProxyDir), "GOSUMDB=off", ) diff --git a/internal/imports/mod_test.go b/internal/imports/mod_test.go index 5d73c88135..c6bbe56c20 100644 --- a/internal/imports/mod_test.go +++ b/internal/imports/mod_test.go @@ -688,6 +688,7 @@ func setup(t *testing.T, main, wd string) *modTest { env := &ProcessEnv{ Env: map[string]string{ "GOPATH": filepath.Join(dir, "gopath"), + "GOMODCACHE": "", "GO111MODULE": "on", "GOSUMDB": "off", "GOPROXY": proxydir.ToURL(proxyDir),