Skip to content

Commit 246f5d5

Browse files
committed
parse bazel build options
allow additional options passed to bazel build
1 parent 55280e1 commit 246f5d5

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

testing_utils/build_tools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ def find_target_path(self, target_name: str, *, expect_exists: bool = True) -> P
335335

336336
return target_path
337337

338-
def build(self, target_name: str) -> Path:
338+
def build(self, target_name: str, *options) -> Path:
339339
"""
340340
Run build for selected target.
341341
@@ -345,7 +345,7 @@ def build(self, target_name: str) -> Path:
345345
Name of the target to build.
346346
"""
347347
# Run build.
348-
command = ["bazel", "build", target_name]
348+
command = ["bazel", "build", target_name, *options]
349349
with Popen(command, text=True) as p:
350350
_, _ = p.communicate(timeout=self.build_timeout)
351351
if p.returncode != 0:

tests/test_build_tools.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,4 +472,13 @@ def expected_target_path(self, tmp_project: tuple[str, Path]) -> Path:
472472
target_name, project_path = tmp_project
473473
return project_path / "bazel-out" / "k8-fastbuild" / "bin" / target_name
474474

475+
def test_build_additional_params(self, tools_type: type[BuildTools], tmp_project: tuple[str, Path]) -> None:
476+
target_name, path = tmp_project
477+
with cwd(path):
478+
tools = tools_type()
479+
target_path = tools.build(target_name, "--verbose_failures", "--action_env=TEST_VAR=TEST_VALUE")
480+
481+
# Check executable exists.
482+
assert target_path.exists()
483+
475484
# TODO: add query tests. # noqa: FIX002

0 commit comments

Comments
 (0)