Skip to content

Commit

Permalink
Passing CLI Test Arguments
Browse files Browse the repository at this point in the history
* Adding `"$@"` to bats test wrapper script.
  * This passes through any arguments given to the wrapper script from the command line.
  * Compatible with Bazel's `--test_arg`.
  * Allows passing Bats arguments to tests, like `--count`, `--filter`, etc.
  * Arguments added to bats arguments after `{bats_args}` to allow precedence/overriding target defined arguments with CLI arguments (where compatible).
  * If no CLI arguments are passed, this is noop.
  • Loading branch information
CauhxMilloy authored and filmil committed Mar 3, 2024
1 parent c0eb5dc commit 16c2529
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def _dirname(path):
return prefix.rstrip("/")

def _test_files(bats, srcs, attr):
return '"{bats_bin}" {bats_args} {test_paths}'.format(
return '"{bats_bin}" {bats_args} "$@" {test_paths}'.format(
bats_bin = bats.short_path,
bats_args = " ".join(attr.bats_args),
test_paths = " ".join(['"{}"'.format(s.short_path) for s in srcs]),
Expand Down

0 comments on commit 16c2529

Please sign in to comment.