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_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)
+		}
+	}
+}