From 16c2529ad6dcbded022855dbe1232033c70a67c4 Mon Sep 17 00:00:00 2001 From: Cauhx Milloy Date: Sun, 3 Mar 2024 10:29:32 -0800 Subject: [PATCH] Passing CLI Test Arguments * 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. --- rules.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules.bzl b/rules.bzl index 357c8f0..e79ead4 100644 --- a/rules.bzl +++ b/rules.bzl @@ -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]),