// CopyToTmp copies the files and directories in src to a new temporary testing // directory dst, and returns dst on success. // // After copying the files, it processes each of the 'old,new,' rename // directives in order. Each rename directive moves the relative path "old" // to the relative path "new" within the directory. // // Renaming allows tests to hide files whose names have // special meaning, such as "go.mod" files or "testdata" directories // from the go command, or ill-formed Go source files from gofmt. // // For example if we copy the directory testdata: // // testdata/ // go.mod.test // a/a.go // b/b.go // // with the rename "go.mod.test,go.mod", the resulting files will be: // // dst/ // go.mod // a/a.go // b/b.go func CopyToTmp(t testing.TB, src fs.FS, rename ...string) string { … } // Copy the files in src to dst. // Use os.CopyFS when 1.23 can be used in x/tools. func copyFS(dstdir string, src fs.FS) error { … } // ExtractTxtarFileToTmp read a txtar archive on a given path, // extracts it to a temporary directory, and returns the // temporary directory. func ExtractTxtarFileToTmp(t testing.TB, file string) string { … } // LoadPackages loads typed syntax for all packages that match the // patterns, interpreted relative to the archive root. // // The packages must be error-free. func LoadPackages(t testing.TB, ar *txtar.Archive, patterns ...string) []*packages.Package { … }