// goMod returns a go.mod file containing a name and a go directive // for the major version. If major < 0, use the current go toolchain // version. func goMod(name string, major int) []byte { … } // overlayFS returns a simple in-memory filesystem. func overlayFS(overlay map[string][]byte) fstest.MapFS { … } // openTxtar opens a txtar file as a filesystem. func openTxtar(t testing.TB, file string) fs.FS { … } // loadPackages copies the files in a source file system to a unique temporary // directory and loads packages matching the given patterns from the temporary directory. // // TODO(69556): Migrate loader tests to loadPackages. func loadPackages(t testing.TB, src fs.FS, patterns ...string) []*packages.Package { … } // buildPackage builds the content of a go file into: // * a module with the same name as the package at the current go version, // * loads the *package.Package, // * checks that (*packages.Packages).Syntax contains one file, // * builds the *ssa.Package (and not its dependencies), and // * returns the built *ssa.Package and the loaded packages.Package. // // TODO(adonovan): factor with similar loadFile (2x) in cha/cha_test.go and vta/helpers_test.go. func buildPackage(t testing.TB, content string, mode ssa.BuilderMode) (*ssa.Package, *packages.Package) { … } // parsePackageClause is a test helper to extract the package name from a string // containing the content of a go file. func parsePackageClause(t testing.TB, content string) string { … }