Documentation ¶
Overview ¶
Package bazel provides utilities for interacting with the surrounding Bazel environment.
Index ¶
- Constants
- func EnterRunfiles(workspace string, pkg string, binary string, cookie string) error
- func FindBinary(pkg string, binary string) (string, bool)
- func NewTmpDir(prefix string) (string, error)
- func Runfile(path string) (string, error)
- func RunfilesPath() (string, error)
- func SetDefaultTestWorkspace(w string)
- func TestTmpDir() string
- func TestWorkspace() (string, error)
Constants ¶
const TEST_SRCDIR = "TEST_SRCDIR"
const TEST_TMPDIR = "TEST_TMPDIR"
const TEST_WORKSPACE = "TEST_WORKSPACE"
Variables ¶
This section is empty.
Functions ¶
func EnterRunfiles ¶ added in v0.10.0
EnterRunfiles locates the directory under which a built binary can find its data dependencies using relative paths, and enters that directory.
"workspace" indicates the name of the current project, "pkg" indicates the relative path to the build package that contains the binary target, "binary" indicates the basename of the binary searched for, and "cookie" indicates an arbitrary data file that we expect to find within the runfiles tree.
func FindBinary ¶ added in v0.10.0
FindBinary locates the given executable within bazel-bin or the current directory.
"pkg" indicates the relative path to the build package that contains the binary target, and "binary" indicates the basename of the binary searched for.
func Runfile ¶
Runfile returns an absolute path to the specified file in the runfiles directory of the running target. It searches the current working directory, RunfilesPath() directory, and RunfilesPath()/TestWorkspace(). Returns an error if unable to locate RunfilesPath() or if the file does not exist.
func RunfilesPath ¶
RunfilesPath return the path to the run files tree for this test. It returns an error if TEST_SRCDIR does not exist.
func SetDefaultTestWorkspace ¶
func SetDefaultTestWorkspace(w string)
SetDefaultTestWorkspace allows you to set a fake value for the environment variable TEST_WORKSPACE if it is not defined. This is useful when running tests on the command line and not through Bazel.
func TestTmpDir ¶
func TestTmpDir() string
TestTmpDir returns the path the Bazel test temp directory. If TEST_TMPDIR is not defined, it returns the OS default temp dir.
func TestWorkspace ¶
TestWorkspace returns the name of the Bazel workspace for this test. If TEST_WORKSPACE is not defined, it returns an error.
Types ¶
This section is empty.