0

I'm using the go_test rule from rule_go in Bazel, and I'd like to access the workspace directory at runtime. I can't find it in the environment variables, and $PWD is the temp sandbox directory. How can I access this variable? Ideally, it's something I can pass into my rule and not a command-line argument to bazel test so that I don't have to write it out every time.

michaelsnowden
  • 6,031
  • 2
  • 38
  • 83

1 Answers1

0

Typically you would use the data attribute to declare files that you want to access at runtime. The docs for go_test.data
https://github.com/bazelbuild/rules_go/blob/master/docs/go/core/rules.md#go_test-data

point to this library
https://pkg.go.dev/github.com/bazelbuild/rules_go/go/tools/bazel

for conveniently accessing data dependencies.

ahumesky
  • 4,203
  • 8
  • 12