package sourceimport ()// These Bazel env vars are documented here:// https://bazel.build/reference/test-encyclopedia// Signifies test executable is being driven by `bazel test`.//// Due to Bazel's compilation and sandboxing strategy,// some care is required to handle resolving the original *.go source file.varinBazelTest = os.Getenv("BAZEL_TEST") == "1"// The name of the target being tested (ex: //some_package:some_package_test)varbazelTestTarget = os.Getenv("TEST_TARGET")// Absolute path to the base of the runfiles treevarbazelTestSrcdir = os.Getenv("TEST_SRCDIR")// The local repository's workspace name (ex: __main__)varbazelTestWorkspace = os.Getenv("TEST_WORKSPACE")func ( string) (string, error) {// Use the env vars to resolve the test source files, // which must be provided as test data in the respective go_test target. = filepath.Join(bazelTestSrcdir, bazelTestWorkspace, ) , := os.Stat()ifos.IsNotExist() {return"", fmt.Errorf(bazelMissingSourceMsg, , bazelTestTarget) }return , nil}varbazelMissingSourceMsg = `the test source file does not exist: %sIt appears that you are running this test under Bazel (target: %s).Check that your test source files are added as test data in your go_test targets.Example: go_test( name = "your_package_test", srcs = ["your_test.go"], deps = ["@tools_gotest_v3//assert"], data = glob(["*_test.go"]) )"`
The pages are generated with Goldsv0.7.6. (GOOS=linux GOARCH=amd64)