var skipCleanup … var ErrUnsupported … type Module … type Writer … type Exported … type Exporter … var All … // TestAll invokes the testing function once for each exporter registered in // the All global. // Each exporter will be run as a sub-test named after the exporter being used. func TestAll(t *testing.T, f func(*testing.T, Exporter)) { … } // BenchmarkAll invokes the testing function once for each exporter registered in // the All global. // Each exporter will be run as a sub-test named after the exporter being used. func BenchmarkAll(b *testing.B, f func(*testing.B, Exporter)) { … } // Export is called to write out a test directory from within a test function. // It takes the exporter and the build system agnostic module descriptions, and // uses them to build a temporary directory. // It returns an Exported with the results of the export. // The Exported.Config is prepared for loading from the exported data. // You must invoke Exported.Cleanup on the returned value to clean up. // The file deletion in the cleanup can be skipped by setting the skip-cleanup // flag when invoking the test, allowing the temporary directory to be left for // debugging tests. // // If the Writer for any file within any module returns an error equivalent to // ErrUnspported, Export skips the test. func Export(t testing.TB, exporter Exporter, modules []Module) *Exported { … } // Script returns a Writer that writes out contents to the file and sets the // executable bit on the created file. // It is intended for source files that are shell scripts. func Script(contents string) Writer { … } // Link returns a Writer that creates a hard link from the specified source to // the required file. // This is used to link testdata files into the generated testing tree. // // If hard links to source are not supported on the destination filesystem, the // returned Writer returns an error for which errors.Is(_, ErrUnsupported) // returns true. func Link(source string) Writer { … } // Symlink returns a Writer that creates a symlink from the specified source to the // required file. // This is used to link testdata files into the generated testing tree. // // If symlinks to source are not supported on the destination filesystem, the // returned Writer returns an error for which errors.Is(_, ErrUnsupported) // returns true. func Symlink(source string) Writer { … } // builderMustSupportLinks reports whether we are running on a Go builder // that is known to support hard and symbolic links. func builderMustSupportLinks() bool { … } // openAndStat attempts to open source for reading. func openAndStat(source string) (os.FileInfo, error) { … } // createEmpty creates an empty file or directory (depending on mode) // at dst, with the same permissions as mode. func createEmpty(dst string, mode os.FileMode) error { … } // Copy returns a Writer that copies a file from the specified source to the // required file. // This is used to copy testdata files into the generated testing tree. func Copy(source string) Writer { … } func copyFile(dest, source string, perm os.FileMode) error { … } // GroupFilesByModules attempts to map directories to the modules within each directory. // This function assumes that the folder is structured in the following way: // // dir/ // primarymod/ // *.go files // packages // go.mod (optional) // modules/ // repoa/ // mod1/ // *.go files // packages // go.mod (optional) // // It scans the directory tree anchored at root and adds a Copy writer to the // map for every file found. // This is to enable the common case in tests where you have a full copy of the // package in your testdata. func GroupFilesByModules(root string) ([]Module, error) { … } // MustCopyFileTree returns a file set for a module based on a real directory tree. // It scans the directory tree anchored at root and adds a Copy writer to the // map for every file found. It skips copying files in nested modules. // This is to enable the common case in tests where you have a full copy of the // package in your testdata. // This will panic if there is any kind of error trying to walk the file tree. func MustCopyFileTree(root string) map[string]interface{ … } // Cleanup removes the temporary directory (unless the --skip-cleanup flag was set) // It is safe to call cleanup multiple times. func (e *Exported) Cleanup() { … } // Temp returns the temporary directory that was generated. func (e *Exported) Temp() string { … } // File returns the full path for the given module and file fragment. func (e *Exported) File(module, fragment string) string { … } // FileContents returns the contents of the specified file. // It will use the overlay if the file is present, otherwise it will read it // from disk. func (e *Exported) FileContents(filename string) ([]byte, error) { … }