-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`TemplateVariableInfo` provides a mechanism for custom make variable expansion. `string_flag()` contains a simple (pre-built) way to generate flags. This be used with `config_setting()` and can be set via commandline (without `--define`). `TemplateVariableInfo` support was added to `string_flag()` in bazelbuild/bazel-skylib#440. Many other Bazel target rules support make variable expansion on many attributes (e.g. `env`). This PR adds support for `TemplateVariableInfo` (e.g. via `string_flag()`) to bats bazel test rules on the `env` attribute. Changes: * Adding call to `ctx.expand_make_variables()` in `_bats_test_impl()`. * This is done in addition to (after) expansion for `$(location ...)`. * Updating `:hello_world_test` (which tests `env` attribute usage) to also test flag-driven envs. * Adding `@bazel_skylib` to workspace. * Only used to declare/reference `string_flag()` in `tests/BUILD.bazel`. * While this could have been simply covered by a custom rule (to return a `TemplateVariableInfo`) in a test-specific `.bzl` file, it seemed better to just use the common (external/pre-existing) rule. * Refenced via `git_repository()` as the necessary changes are not yet in a tag/release. * Only affects tests, and thus does not cause any extra transitive dependencies on libraries that use this project. * Misc other changes: * Updating bats-support and bats-assert rules to use `glob()`. * Supports newer versions, which separated out contents into multiple `.bash` files. * More flexible than naming exact file names. * Replacing attribute dict `update()` call with dict concat operator `|`. * Renaming some test cases in `hello_world.bats`. See https://bazel.build/rules/lib/providers/TemplateVariableInfo, https://bazel.build/docs/configurable-attributes, https://bazel.build/reference/be/general#config_setting, https://bazel.build/extending/config#defining-build-settings
- Loading branch information
Showing
5 changed files
with
48 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters