bazel

package
v7.1.8 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

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

func NewTmpDir(prefix string) (string, error)

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

func Runfile(path string) (string, error)

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 RunfilesPath

func RunfilesPath() (string, error)

RunfilesPath returns the module root.

func SetGoEnv

func SetGoEnv()

SetGoEnv is a no-op outside Bazel: the Go toolchain is already on PATH.

func TestDataPath

func TestDataPath(t testing.TB, relative ...string) string

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).

func TestTmpDir

func TestTmpDir() string

TestTmpDir returns the OS temporary directory.

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.

Jump to

Keyboard shortcuts

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