feat: improved env substitutions
This PR supports additional substitutions on env values supplied in env parameter to itest rules. Substitutions are:
- $(location... etc as previously supported
- $(OTHERENV)/extra - substitute a different envvar from the input env parameter into this value
- $(TESTENV)/extra - substitute TESTENV supplied via bazel's --test_env parameter into this value
- $(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 (https://github.com/bazelbuild/bazel-skylib/pull/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)
@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.