dashboard: verify that each port is covered by real or misc-compile trybot

Currently, android/{386,arm,arm64} are not covered, so add a
misc-compile builder for these.

Also correct a typo in the comment for the darwin misc-compile builder
and add update the misc-compile-freebsd comment to include
freebsd/arm64.

Change-Id: Ica3b27e98db73c10edf30260acddcd7ea57d9051
Reviewed-on: https://go-review.googlesource.com/c/build/+/205798
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
diff --git a/dashboard/builders.go b/dashboard/builders.go
index 0cc3c0b..cdcb99e 100644
--- a/dashboard/builders.go
+++ b/dashboard/builders.go
@@ -1537,15 +1537,16 @@
 			},
 		})
 	}
-	addMiscCompile("-linuxarm", "^linux-arm")        // 2: arm, arm64
-	addMiscCompile("-darwin", "^darwin")             // 4: 386, amd64 + iOS: armb, arm64
-	addMiscCompile("-mips", "^linux-mips")           // 4: mips, mipsle, mips64, mips64le
-	addMiscCompile("-ppc", "^(linux-ppc64|aix-)")    // 3: linux-ppc64{,le}, aix-ppc64
-	addMiscCompile("-solaris", "^(solaris|illumos)") // 2: both amd64
-	addMiscCompile("-plan9", "^plan9-")              // 3: amd64, 386, arm
-	addMiscCompile("-freebsd", "^freebsd-(386|arm)") // 2: 386, arm (amd64 already trybot)
-	addMiscCompile("-netbsd", "^netbsd-")            // 4: amd64, 386, arm, arm64
-	addMiscCompile("-openbsd", "^openbsd-")          // 4: amd64, 386, arm, arm64
+	addMiscCompile("-linuxarm", "^linux-arm")                // 2: arm, arm64
+	addMiscCompile("-darwin", "^darwin")                     // 4: 386, amd64 + iOS: arm, arm64
+	addMiscCompile("-mips", "^linux-mips")                   // 4: mips, mipsle, mips64, mips64le
+	addMiscCompile("-ppc", "^(linux-ppc64|aix-)")            // 3: linux-ppc64{,le}, aix-ppc64
+	addMiscCompile("-solaris", "^(solaris|illumos)")         // 2: both amd64
+	addMiscCompile("-plan9", "^plan9-")                      // 3: amd64, 386, arm
+	addMiscCompile("-freebsd", `^freebsd-(386|arm|arm64)\b`) // 3: 386, arm, arm64 (amd64 already trybot)
+	addMiscCompile("-netbsd", "^netbsd-")                    // 4: amd64, 386, arm, arm64
+	addMiscCompile("-openbsd", "^openbsd-")                  // 4: amd64, 386, arm, arm64
+	addMiscCompile("-android", `^android-(386|arm|arm64)\b`) // 3: 386, arm, arm64 (amd64 already trybot)
 	// And 3 that don't fit above:
 	addMiscCompile("-other", "^(windows-arm|linux-s390x|dragonfly-amd64)$")
 	// TODO: Issue 25963, get the misc-compile trybots for
diff --git a/dashboard/builders_test.go b/dashboard/builders_test.go
index 0fe9072..017b3d7 100644
--- a/dashboard/builders_test.go
+++ b/dashboard/builders_test.go
@@ -9,6 +9,7 @@
 	"fmt"
 	"os/exec"
 	"path/filepath"
+	"regexp"
 	"runtime"
 	"sort"
 	"strings"
@@ -94,6 +95,7 @@
 				"linux-386",
 				"linux-amd64",
 				"linux-amd64-race",
+				"misc-compile-android",
 				"misc-compile-other",
 				"misc-compile-darwin",
 				"misc-compile-linuxarm",
@@ -118,6 +120,7 @@
 				"linux-386",
 				"linux-amd64",
 				"linux-amd64-race",
+				"misc-compile-android",
 				"misc-compile-other",
 				"misc-compile-darwin",
 				"misc-compile-linuxarm",
@@ -143,6 +146,7 @@
 				"linux-386",
 				"linux-amd64",
 				"linux-amd64-race",
+				"misc-compile-android",
 				"misc-compile-darwin",
 				"misc-compile-freebsd",
 				"misc-compile-linuxarm",
@@ -739,3 +743,58 @@
 		}
 	}
 }
+
+// TestTryBotsCompileAllPorts verifies that each port (go tool dist list) is covered by
+// either a real trybot or a misc-compile trybot.
+func TestTryBotsCompileAllPorts(t *testing.T) {
+	out, err := exec.Command(filepath.Join(runtime.GOROOT(), "bin", "go"), "tool", "dist", "list").Output()
+	if err != nil {
+		t.Errorf("dist list: %v", err)
+	}
+	ports := strings.Fields(string(out))
+
+	done := map[string]bool{}
+	done["nacl-386"] = true // removed in Go 1.14
+	done["nacl-arm"] = true // removed in Go 1.14
+	check := func(goos, goarch string) {
+		goosArch := goos + "-" + goarch
+		if done[goosArch] {
+			return
+		}
+		for _, conf := range Builders {
+			os := conf.GOOS()
+			arch := conf.GOARCH()
+
+			if os == goos && arch == goarch && (conf.tryOnly || conf.tryBot != nil) {
+				done[goosArch] = true
+				break
+			}
+
+			if strings.HasPrefix(conf.Name, "misc-compile-") {
+				re, err := regexp.Compile(conf.allScriptArgs[0])
+				if err != nil {
+					t.Errorf("Invalid misc-compile filtering pattern for builder %q: %q",
+						conf.Name, conf.allScriptArgs[0])
+				}
+
+				if re.MatchString(goosArch) || re.MatchString(goos) {
+					done[goosArch] = true
+					break
+				}
+			}
+		}
+		if _, ok := done[goosArch]; !ok {
+			t.Errorf("Missing trybot or misc-compile trybot: %q", goosArch)
+		}
+
+	}
+
+	for _, port := range ports {
+		slash := strings.IndexByte(port, '/')
+		if slash == -1 {
+			t.Fatalf("unexpected port %q", port)
+		}
+		check(port[:slash], port[slash+1:])
+	}
+
+}