var allCodegen … var runSkips … var linkshared … var updateErrors … var runoutputLimit … var force … var target … var shard … var shards … // defaultAllCodeGen returns the default value of the -all_codegen // flag. By default, we prefer to be fast (returning false), except on // the linux-amd64 builder that's already very fast, so we get more // test coverage on trybots. See https://go.dev/issue/34297. func defaultAllCodeGen() bool { … } var goTool … var goos … var goarch … var cgoEnabled … var goExperiment … var goDebug … var tmpDir … var dirs … // Test is the main entrypoint that runs tests in the GOROOT/test directory. // // Each .go file test case in GOROOT/test is registered as a subtest with // a full name like "Test/fixedbugs/bug000.go" ('/'-separated relative path). func Test(t *testing.T) { … } func shardMatch(name string) bool { … } func goFiles(t *testing.T, dir string) []string { … } type runCmd … func compileFile(runcmd runCmd, longname string, flags []string) (out []byte, err error) { … } func compileInDir(runcmd runCmd, dir string, flags []string, importcfg string, pkgname string, names ...string) (out []byte, err error) { … } var stdlibImportcfg … var stdlibImportcfgFile … func linkFile(runcmd runCmd, goname string, importcfg string, ldflags []string) (err error) { … } type testCommon … type test … // expectFail reports whether the (overall) test recipe is // expected to fail under the current build+test configuration. func (t test) expectFail() bool { … } func (t test) goFileName() string { … } func (t test) goDirName() string { … } // goDirFiles returns .go files in dir. func goDirFiles(dir string) (filter []fs.DirEntry, _ error) { … } var packageRE … func getPackageNameFromSource(fn string) (string, error) { … } type goDirPkg … // goDirPackages returns distinct Go packages in dir. // If singlefilepkgs is set, each file is considered a separate package // even if the package names are the same. func goDirPackages(t *testing.T, dir string, singlefilepkgs bool) []*goDirPkg { … } type context … // shouldTest looks for build tags in a source file and returns // whether the file should be used according to the tags. func shouldTest(src string, goos, goarch string) (ok bool, whyNot string) { … } func (ctxt *context) match(name string) bool { … } // goGcflags returns the -gcflags argument to use with go build / go run. // This must match the flags used for building the standard library, // or else the commands will rebuild any needed packages (like runtime) // over and over. func (test) goGcflags() string { … } func (test) goGcflagsIsEmpty() bool { … } var errTimeout … // run runs the test case. // // When there is a problem, run uses t.Fatal to signify that it's an unskippable // infrastructure error (such as failing to read an input file or the test recipe // being malformed), or it returns a non-nil error to signify a test case error. // // t.Error isn't used here to give the caller the opportunity to decide whether // the test case failing is expected before promoting it to a real test failure. // See expectFail and -f flag. func (t test) run() error { … } var findExecCmd … // checkExpectedOutput compares the output from compiling and/or running with the contents // of the corresponding reference output file, if any (replace ".go" with ".out"). // If they don't match, fail with an informative message. func (t test) checkExpectedOutput(gotBytes []byte) error { … } func splitOutput(out string, wantAuto bool) []string { … } // errorCheck matches errors in outStr against comments in source files. // For each line of the source files which should generate an error, // there should be a comment of the form // ERROR "regexp". // If outStr has an error for a line which has no such comment, // this function will report an error. // Likewise if outStr does not have an error for a line which has a comment, // or if the error message does not match the <regexp>. // The <regexp> syntax is Perl but it's best to stick to egrep. // // Sources files are supplied as fullshort slice. // It consists of pairs: full path to source file and its base name. func (t test) errorCheck(outStr string, wantAuto bool, fullshort ...string) (err error) { … } func (test) updateErrors(out, file string) { … } // matchPrefix reports whether s is of the form ^(.*/)?prefix(:|[), // That is, it needs the file name prefix followed by a : or a [, // and possibly preceded by a directory name. func matchPrefix(s, prefix string) bool { … } func partitionStrings(prefix string, strs []string) (matched, unmatched []string) { … } type wantedError … var errRx … var errAutoRx … var errQuotesRx … var lineRx … func (t test) wantedErrors(file, short string) (errs []wantedError) { … } const reMatchCheck … var rxAsmComment … var rxAsmPlatform … var rxAsmCheck … var archVariants … type wantedAsmOpcode … type buildEnv … // Environ returns the environment it represents in cmd.Environ() "key=val" format // For instance, "linux/386/sse2".Environ() returns {"GOOS=linux", "GOARCH=386", "GO386=sse2"} func (b buildEnv) Environ() []string { … } type asmChecks … // Envs returns all the buildEnv in which at least one check is present func (a asmChecks) Envs() []buildEnv { … } func (t test) wantedAsmOpcodes(fn string) asmChecks { … } func (t test) asmCheck(outStr string, fn string, env buildEnv, fullops map[string][]wantedAsmOpcode) error { … } // defaultRunOutputLimit returns the number of runoutput tests that // can be executed in parallel. func defaultRunOutputLimit() int { … } func TestShouldTest(t *testing.T) { … } // overlayDir makes a minimal-overhead copy of srcRoot in which new files may be added. func overlayDir(dstRoot, srcRoot string) error { … } var types2Failures … var types2Failures32Bit … var _ … func setOf(keys ...string) map[string]bool { … } // splitQuoted splits the string s around each instance of one or more consecutive // white space characters while taking into account quotes and escaping, and // returns an array of substrings of s or an empty list if s contains only white space. // Single quotes and double quotes are recognized to prevent splitting within the // quoted region, and are removed from the resulting substrings. If a quote in s // isn't closed err will be set and r will have the unclosed argument as the // last element. The backslash is used for escaping. // // For example, the following string: // // a b:"c d" 'e''f' "g\"" // // Would be parsed as: // // []string{"a", "b:c d", "ef", `g"`} // // [copied from src/go/build/build.go] func splitQuoted(s string) (r []string, err error) { … } // replacePrefix is like strings.ReplaceAll, but only replaces instances of old // that are preceded by ' ', '\t', or appear at the beginning of a line. // // This does the same kind of filename string replacement as cmd/go. // Pilfered from src/cmd/go/internal/work/shell.go . func replacePrefix(s, old, new string) string { … }