dashboard, cmd/coordinator: add controls to skip subrepo dirs in GOPATH mode
This change adds controls to the dashboard package that makes it
possible to skip certain directories in subrepos from being tested
in GOPATH mode.
It uses this control mechanism to skip the gopls directory in x/tools
from being tested in GOPATH mode. That directory and everything inside
is developed with support for module mode only. All other packages
in x/tools continue to be supported both in module and GOPATH modes
for the current and previous releases, as per release policy¹.
¹ https://golang.org/doc/devel/release.html#policy
Fixes golang/go#34190
Change-Id: Icdb4d0e1419f69c84c9a3f9a33727a09a35599f4
Reviewed-on: https://go-review.googlesource.com/c/build/+/194397
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/dashboard/builders.go b/dashboard/builders.go
index 1327d7d..5384bfd 100644
--- a/dashboard/builders.go
+++ b/dashboard/builders.go
@@ -733,7 +733,30 @@
case "oauth2", "build", "perf", "website":
env = append(env, "GO111MODULE=on")
}
- return
+ return env
+}
+
+// ShouldTestPackageInGOPATHMode is used to control whether the package
+// with the specified import path should be tested in GOPATH mode.
+//
+// When running tests for all golang.org/* repositories in GOPATH mode,
+// this method is called repeatedly with the full import path of each
+// package that is found and is being considered for testing in GOPATH
+// mode. It's not used and has no effect on import paths in the main
+// "go" repository. It has no effect on tests done in module mode.
+//
+// When considering making changes here, keep the release policy in mind:
+//
+// https://golang.org/doc/devel/release.html#policy
+//
+func (*BuildConfig) ShouldTestPackageInGOPATHMode(importPath string) bool {
+ if importPath == "golang.org/x/tools/gopls" ||
+ strings.HasPrefix(importPath, "golang.org/x/tools/gopls/") {
+ // Don't test golang.org/x/tools/gopls/... in GOPATH mode.
+ return false
+ }
+ // Test everything else in GOPATH mode as usual.
+ return true
}
func (c *BuildConfig) IsReverse() bool { return c.hostConf().IsReverse }
diff --git a/dashboard/builders_test.go b/dashboard/builders_test.go
index 6a029d9..c004433 100644
--- a/dashboard/builders_test.go
+++ b/dashboard/builders_test.go
@@ -595,3 +595,30 @@
}
}
}
+
+func TestShouldTestPackageInGOPATHMode(t *testing.T) {
+ // This function doesn't change behavior depending on the builder
+ // at this time, so just use a common one.
+ bc, ok := Builders["linux-amd64"]
+ if !ok {
+ t.Fatal("unknown builder")
+ }
+
+ tests := []struct {
+ importPath string
+ want bool
+ }{
+ {"golang.org/x/image/bmp", true},
+ {"golang.org/x/tools/go/ast/astutil", true},
+ {"golang.org/x/tools/go/packages", true},
+ {"golang.org/x/tools", true}, // Three isn't a package there, but if there was, it should be tested.
+ {"golang.org/x/tools/gopls", false},
+ {"golang.org/x/tools/gopls/internal/foobar", false},
+ }
+ for _, tt := range tests {
+ got := bc.ShouldTestPackageInGOPATHMode(tt.importPath)
+ if got != tt.want {
+ t.Errorf("ShouldTestPackageInGOPATHMode(%q) = %v; want %v", tt.importPath, got, tt.want)
+ }
+ }
+}