Skip to content

Conversation

@peakschris
Copy link

@peakschris peakschris commented Feb 10, 2025

This PR supports additional substitutions on env values supplied in env parameter to itest rules. Substitutions are:

  1. $(location... etc as previously supported
  2. $(OTHERENV)/extra - substitute a different envvar from the input env parameter into this value
  3. $(TESTENV)/extra - substitute TESTENV supplied via bazel's --test_env parameter into this value
  4. $(BINDIR) - relative path to bazel's bin directory

This provides extra flexibility for configuring test cases.

To support this, I found a nicely designed implementation of envvar substitution in environment.bzl in rules_bats, and rather than adding a dependency on rules_bats, I have vendored the file into this repo. It seems that the author has tried to get this file added to bazel_skylib (bazelbuild/bazel-skylib#486), and perhaps it has a future in bazel-lib. If this happened, this vendored copy could be deleted.

This PR is draft for now for feedback/guidance.

(there is also included a minor fix to windows path which prevents bazel run //service from working on windows at present)

@dzbarsky
Copy link
Owner

@peakschris I'm a bit worried about increasing analysis time work. If we passed the env vars through os.ExpandEnv on the execution side would that work for you? (See https://pkg.go.dev/os#example-ExpandEnv). We could also apply BINDIR substitution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants