Documentation
¶
Index ¶
- func BuiltWithBazel() bool
- func NewTmpDir(prefix string) (string, error)
- func RelativeTestTargetPath() string
- func Runfile(path string) (string, error)
- func RunfilesPath() (string, error)
- func SetGoEnv()
- func TestDataPath(t testing.TB, relative ...string) string
- func TestTmpDir() string
- type RunfileEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuiltWithBazel ¶
func BuiltWithBazel() bool
BuiltWithBazel returns true iff this library was built with Bazel.
func NewTmpDir ¶
NewTmpDir creates a new temporary directory with the given prefix. The caller is responsible for cleaning it up.
func RelativeTestTargetPath ¶
func RelativeTestTargetPath() string
RelativeTestTargetPath has no meaning outside Bazel.
func Runfile ¶
Runfile resolves path against, in order: an absolute path, the current working directory, the module root, and the test-data root. External test data is a lazy fixture: if the path is not on disk but maps to a known external-data archive, that archive is fetched (once, idempotently) and resolution retried. It returns an error if the file/dir still cannot be found.
func SetGoEnv ¶
func SetGoEnv()
SetGoEnv is a no-op outside Bazel: the Go toolchain is already on PATH.
func TestDataPath ¶
TestDataPath returns a path to an asset in the testdata directory. It knows to access accesses the right path when executing under bazel.
For example, if there is a file testdata/a.txt, you can get a path to that file using TestDataPath(t, "a.txt").
It uses testing.TB directly (rather than the testing/require helper) so this package stays non-testonly and can be imported by non-test code (e.g. testing/benchmark, which feeds the benchmark-files-gen binary).
Types ¶
type RunfileEntry ¶ added in v7.1.8
type RunfileEntry struct {
// Path is the absolute path to the file on disk.
Path string
// ShortPath is the path relative to the runfiles (or test-data) root, using
// forward slashes.
ShortPath string
// Workspace is the workspace/repository the file originated from.
// (It is left empty by the non-Bazel implementation.)
Workspace string
}
RunfileEntry describes a single runfile.
func ListRunfiles ¶ added in v7.1.8
func ListRunfiles() ([]RunfileEntry, error)
ListRunfiles walks the test-data root and returns every file as a RunfileEntry.