testfiles

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package testfiles provides utilities for writing Go tests with files in testdata.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyDirToTmp

func CopyDirToTmp(t testing.TB, srcdir string) string

CopyDirToTmp copies dir to a temporary test directory using CopyTestFiles and returns the path to the test directory.

func CopyFS

func CopyFS(dstdir string, src fs.FS) error

CopyFS copies the files and directories in src to a destination directory dst. Paths to files and directories ending in a ".test" extension have the ".test" extension removed. This 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

The resulting files will be:

dst/
    go.mod
    a/a.go
    b/b.go

func ExtractTxtar

func ExtractTxtar(dstdir string, ar *txtar.Archive) error

ExtractTxtar writes each archive file to the corresponding location beneath dir.

TODO(adonovan): move this to txtar package, we need it all the time (#61386).

func ExtractTxtarFileToTmp

func ExtractTxtarFileToTmp(t testing.TB, archiveFile string) string

ExtractTxtarFileToTmp read a txtar archive on a given path, extracts it to a temporary directory, and returns the temporary directory.

func ExtractTxtarToTmp

func ExtractTxtarToTmp(t testing.TB, ar *txtar.Archive) string

ExtractTxtarToTmp extracts the given archive to a temp directory, and returns that temporary directory.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL