aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/test/test.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2018-12-11 17:13:50 -0500
committerBryan C. Mills <bcmills@google.com>2019-07-18 19:06:47 +0000
commit4a2d3d06873559df2b6933f260dc8f75c54c9771 (patch)
tree4a323df3ac68b4ca07c654518c4a37adf3f2b4d1 /src/cmd/go/internal/test/test.go
parent5ba15db77f7ba92884b9a2fce21c9938c233967f (diff)
downloadgo-4a2d3d06873559df2b6933f260dc8f75c54c9771.tar.gz
go-4a2d3d06873559df2b6933f260dc8f75c54c9771.zip
cmd/go: in module mode, populate PackagePublic.Root with the module root
'go test' uses the Root field to determine the set of files that invalidate test results, and there is no other sensible meaning of “root” for code within a module. Fixes #29111 Change-Id: Icf1be90a26d22665613e42cb968087b63c36e74c Reviewed-on: https://go-review.googlesource.com/c/go/+/154100 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src/cmd/go/internal/test/test.go')
-rw-r--r--src/cmd/go/internal/test/test.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/cmd/go/internal/test/test.go b/src/cmd/go/internal/test/test.go
index eed2d437c9..cc7c4564e5 100644
--- a/src/cmd/go/internal/test/test.go
+++ b/src/cmd/go/internal/test/test.go
@@ -1250,6 +1250,15 @@ func (c *runCache) tryCacheWithID(b *work.Builder, a *work.Action, id string) bo
return false
}
+ if a.Package.Root == "" {
+ // Caching does not apply to tests outside of any module, GOPATH, or GOROOT.
+ if cache.DebugTest {
+ fmt.Fprintf(os.Stderr, "testcache: caching disabled for package outside of module root, GOPATH, or GOROOT: %s\n", a.Package.ImportPath)
+ }
+ c.disableCache = true
+ return false
+ }
+
var cacheArgs []string
for _, arg := range testArgs {
i := strings.Index(arg, "=")
@@ -1437,8 +1446,8 @@ func computeTestInputsID(a *work.Action, testlog []byte) (cache.ActionID, error)
if !filepath.IsAbs(name) {
name = filepath.Join(pwd, name)
}
- if !inDir(name, a.Package.Root) {
- // Do not recheck files outside the GOPATH or GOROOT root.
+ if a.Package.Root == "" || !inDir(name, a.Package.Root) {
+ // Do not recheck files outside the module, GOPATH, or GOROOT root.
break
}
fmt.Fprintf(h, "stat %s %x\n", name, hashStat(name))
@@ -1446,8 +1455,8 @@ func computeTestInputsID(a *work.Action, testlog []byte) (cache.ActionID, error)
if !filepath.IsAbs(name) {
name = filepath.Join(pwd, name)
}
- if !inDir(name, a.Package.Root) {
- // Do not recheck files outside the GOPATH or GOROOT root.
+ if a.Package.Root == "" || !inDir(name, a.Package.Root) {
+ // Do not recheck files outside the module, GOPATH, or GOROOT root.
break
}
fh, err := hashOpen(name)