Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding expansion.bzl for Improved Env Var Expansion #28

Merged
merged 2 commits into from Feb 3, 2024

Conversation

CauhxMilloy
Copy link
Contributor

@CauhxMilloy CauhxMilloy commented Jan 30, 2024

  • Adding expansion.bzl directly to this project.
    • Allows for better environment variable expansion than built-in skylark methods.
    • I'm also trying to submit this to Skylib (Adding expansion.bzl for Fully Expanding Environment Variables bazelbuild/bazel-skylib#486).
      • I could add this here (instead or in addition to).
      • Obviously, (also) adding this to Skylib would be more reusable for more repos.
      • Once submitted to Skylib (if accepted), this addition of expansion.bzl could be replaced with referencing the one in Skylib.
        • Doing this would add an extra dependency for bazel-bats (needing to pull in Skylib in bazel_bats_dependencies()).
        • Alternatively, could just keep this file here (for no extra dependency).
  • Updating env attribute expansion logic in _bats_test_impl().
    • Allows better environment expansion logic than previously used.
  • Updating tests/hello_world.bats to validate many different environment variable expansion configurations.

This is one approach for improving bats_test environment variable expansion logic (to get at least parity with built-in expansion logic). See https://github.com/CauhxMilloy/bazel-bats/tree/improvedExpansionWithShTest for sh_test approach.

Fixes #27.

* Adding `expansion.bzl` directly to this project.
  * Allows for better environment variable expansion than built-in skylark methods.
  * I'm also trying to submit this to Skylib (bazelbuild/bazel-skylib#486).
    * I could add this here (instead or in addition to).
    * Obviously, (also) adding this to Skylib would be more reusable for more repos.
    * Once submitted to Skylib (if accepted), this addition of `expansion.bzl` could be replaced with referencing the one in Skylib.
      * Doing this would add an extra dependency for bazel-bats (needing to pull in Skylib in `bazel_bats_dependencies()`).
      * Alternatively, could just keep this file here (for no extra dependency).
* Updating `env` attribute expansion logic in `_bats_test_impl()`.
  * Allows better environment expansion logic than previously used.
* Updating `tests/hello_world.bats` to validate many different environment variable expansion configurations.

This is one approach for improving `bats_test` environment variable expansion logic (to get at least parity with built-in expansion logic).
See https://github.com/CauhxMilloy/bazel-bats/tree/improvedExpansionWithShTest for `sh_test` approach.
expansion.bzl Show resolved Hide resolved
expansion.bzl Outdated Show resolved Hide resolved
expansion.bzl Show resolved Hide resolved
expansion.bzl Show resolved Hide resolved
rules.bzl Show resolved Hide resolved
tests/hello_world.bats Show resolved Hide resolved
…bzl`.

* Switching `_odd_count_dollar_sign_repeat()` to `_even_count_dollar_sign_repeat()` and inverting logic at call sites.
* Updating parameter name (`search_start` -> `search_start_index`) for more clarity.
@CauhxMilloy
Copy link
Contributor Author

Thanks for the quick review. Merge whenever you get the chance. (Please create a new tag, after the merge. Thanks!)

@filmil filmil merged commit c0eb5dc into filmil:main Feb 3, 2024
3 checks passed
CauhxMilloy added a commit to CauhxMilloy/bazel-skylib that referenced this pull request Feb 18, 2024
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.

Improving Env Expansion Logic
2 participants