func cmdtest() { … } type tester … type work … // printSkip prints a skip message for all of work. func (w *work) printSkip(t *tester, msg string) { … } type distTest … func (t *tester) run() { … } func (t *tester) shouldRunTest(name string) bool { … } func (t *tester) maybeLogMetadata() error { … } // testName returns the dist test name for a given package and variant. func testName(pkg, variant string) string { … } type goTest … // bgCommand returns a go test Cmd and a post-Run flush function. The result // will write its output to stdout and stderr. If stdout==stderr, bgCommand // ensures Writes are serialized. The caller should call flush() after Cmd exits. func (opts *goTest) bgCommand(t *tester, stdout, stderr io.Writer) (cmd *exec.Cmd, flush func()) { … } // run runs a go test and returns an error if it does not succeed. func (opts *goTest) run(t *tester) error { … } // buildArgs is in internal helper for goTest that constructs the elements of // the "go test" command line. build is the flags for building the test. run is // the flags for running the test. pkgs is the list of packages to build and // run. testFlags is the list of flags to pass to the test package. // // The caller must call setupCmd on the resulting exec.Cmd to set its directory // and environment. func (opts *goTest) buildArgs(t *tester) (build, run, pkgs, testFlags []string, setupCmd func(*exec.Cmd)) { … } // packages returns the full list of packages to be run by this goTest. This // will always include at least one package. func (opts *goTest) packages() []string { … } // printSkip prints a skip message for all of goTest. func (opts *goTest) printSkip(t *tester, msg string) { … } var ranGoTest … var stdMatches … var ranGoBench … var benchMatches … func (t *tester) registerStdTest(pkg string) { … } func (t *tester) registerRaceBenchTest(pkg string) { … } func (t *tester) registerTests() { … } // addTest adds an arbitrary test callback to the test list. // // name must uniquely identify the test and heading must be non-empty. func (t *tester) addTest(name, heading string, fn func(*distTest) error) { … } type registerTestOpt … type rtSkipFunc … func (rtSkipFunc) isRegisterTestOpt() { … } // registerTest registers a test that runs the given goTest. // // Each Go package in goTest will have a corresponding test // "<pkg>:<variant>", which must uniquely identify the test. // // heading and test.variant must be non-empty. func (t *tester) registerTest(heading string, test *goTest, opts ...registerTestOpt) { … } // dirCmd constructs a Cmd intended to be run in the foreground. // The command will be run in dir, and Stdout and Stderr will go to os.Stdout // and os.Stderr. func (t *tester) dirCmd(dir string, cmdline ...interface{ … } // flattenCmdline flattens a mixture of string and []string as single list // and then interprets it as a command line: first element is binary, then args. func flattenCmdline(cmdline []interface{ … } func (t *tester) iOS() bool { … } func (t *tester) out(v string) { … } // extLink reports whether the current goos/goarch supports // external linking. This should match the test in determineLinkMode // in cmd/link/internal/ld/config.go. func (t *tester) extLink() bool { … } func (t *tester) internalLink() bool { … } func (t *tester) internalLinkPIE() bool { … } // supportedBuildMode reports whether the given build mode is supported. func (t *tester) supportedBuildmode(mode string) bool { … } func (t *tester) registerCgoTests(heading string) { … } // runPending runs pending test commands, in parallel, emitting headers as appropriate. // When finished, it emits header for nextTest, which is going to run after the // pending commands are done (and runPending returns). // A test should call runPending if it wants to make sure that it is not // running in parallel with earlier tests, or if it has some other reason // for needing the earlier tests to be done. func (t *tester) runPending(nextTest *distTest) { … } func (t *tester) hasBash() bool { … } // hasParallelism is a copy of the function // internal/testenv.HasParallelism, which can't be used here // because cmd/dist can not import internal packages during bootstrap. func (t *tester) hasParallelism() bool { … } func (t *tester) raceDetectorSupported() bool { … } func isAlpineLinux() bool { … } func (t *tester) registerRaceTests() { … } var cgoPackages … var funcBenchmark … // packageHasBenchmarks reports whether pkg has benchmarks. // On any error, it conservatively returns true. // // This exists just to eliminate work on the builders, since compiling // a test in race mode just to discover it has no benchmarks costs a // second or two per package, and this function returns false for // about 100 packages. func (t *tester) packageHasBenchmarks(pkg string) bool { … } // makeGOROOTUnwritable makes all $GOROOT files & directories non-writable to // check that no tests accidentally write to $GOROOT. func (t *tester) makeGOROOTUnwritable() (undo func()) { … } // raceDetectorSupported is a copy of the function // internal/platform.RaceDetectorSupported, which can't be used here // because cmd/dist can not import internal packages during bootstrap. // The race detector only supports 48-bit VMA on arm64. But we don't have // a good solution to check VMA size (see https://go.dev/issue/29948). // raceDetectorSupported will always return true for arm64. But race // detector tests may abort on non 48-bit VMA configuration, the tests // will be marked as "skipped" in this case. func raceDetectorSupported(goos, goarch string) bool { … } // buildModeSupported is a copy of the function // internal/platform.BuildModeSupported, which can't be used here // because cmd/dist can not import internal packages during bootstrap. func buildModeSupported(compiler, buildmode, goos, goarch string) bool { … } // isUnsupportedVMASize reports whether the failure is caused by an unsupported // VMA for the race detector (for example, running the race detector on an // arm64 machine configured with 39-bit VMA). func isUnsupportedVMASize(w *work) bool { … } // isEnvSet reports whether the environment variable evar is // set in the environment. func isEnvSet(evar string) bool { … }