From 2a8220bce9b833da5e08d828489e46a8b0875260 Mon Sep 17 00:00:00 2001 From: helly25 <6420169+helly25@users.noreply.github.com> Date: Sat, 31 Oct 2026 14:44:14 +0000 Subject: [PATCH 1/3] Keep execution properties on tests and prepare 0.7.1 --- CHANGELOG.md | 3 +++ README.md | 5 ++++- bashtest/bashtest.bzl | 4 ++-- bashtest/tests/BUILD.bazel | 4 +++- bashtest/tests/exec_properties_test.sh | 27 ++++++++++++++++++++++++++ bashtest/tests/tool_fixture.bzl | 20 +++++++++++++++++++ 6 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 bashtest/tests/exec_properties_test.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 70f1ca0..83467a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # 0.7.1 +* Keep test execution properties, including `test.no-sandbox`, on the outer test + without forwarding them to generated binary launchers. + * Stream stdout/stderr live while capturing JUnit output without losing shared test state. Write provisional active-function reports for interrupted runs, drain capture workers before final results, and fail on capture/report errors. diff --git a/README.md b/README.md index e9e5daf..f1d3bf1 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,9 @@ bashtest( ) ``` +Execution properties such as `exec_properties = {"test.no-sandbox": "1"}` apply +to the test execution only; generated launcher binaries do not inherit them. + ### Checking commands Use `expect_success command args...` or `expect_exit_code status command args...` @@ -146,7 +149,7 @@ Use the latest published version from through the Bazel Central Registry. ``` -bazel_dep(name = "mboworks_bashtest", version = "0.7.0") +bazel_dep(name = "mboworks_bashtest", version = "0.7.1") ``` Executable helpers can be declared with `tools = {"GENERATOR": "//tools:generator"}`. diff --git a/bashtest/bashtest.bzl b/bashtest/bashtest.bzl index 2f3c5db..f09884e 100644 --- a/bashtest/bashtest.bzl +++ b/bashtest/bashtest.bzl @@ -78,7 +78,7 @@ def bashtest( deps: Dependencies which will have bashtest_sh automatically added. env: Environment name that automatically adds `mboworks_bashtest`. tools: Environment variable names mapped to executable targets built for test execution. - **kwargs: All other attributes are passed through as is. + **kwargs: Attributes of the outer test. Test execution properties are not forwarded to binary launchers. """ # Keep configurable srcs working; rlocationpath validates that the selected @@ -99,7 +99,7 @@ def bashtest( # owns both this executable and every execution-platform tool dependency. runner_name = name + "__bashtest_launcher" launcher_kwargs = dict(kwargs) - for attribute in ["args", "env_inherit", "size", "timeout", "flaky", "shard_count", "local", "exec_group_compatible_with"]: + for attribute in ["args", "env_inherit", "size", "timeout", "flaky", "shard_count", "local", "exec_group_compatible_with", "exec_properties"]: launcher_kwargs.pop(attribute, None) launcher_kwargs["testonly"] = True compatibility = kwargs.get("target_compatible_with", []) diff --git a/bashtest/tests/BUILD.bazel b/bashtest/tests/BUILD.bazel index c77a60f..42e0f98 100644 --- a/bashtest/tests/BUILD.bazel +++ b/bashtest/tests/BUILD.bazel @@ -16,7 +16,7 @@ load("@rules_shell//shell:sh_binary.bzl", "sh_binary") load("@rules_shell//shell:sh_test.bzl", "sh_test") load("//bashtest:bashtest.bzl", "bashtest") -load(":tool_fixture.bzl", "configuration_data", "tool_source") +load(":tool_fixture.bzl", "configuration_data", "execution_properties_test", "tool_source") package(default_visibility = ["//visibility:private"]) @@ -141,3 +141,5 @@ filegroup( ], visibility = ["//tools:__pkg__"], ) + +execution_properties_test(name = "exec_properties_test") diff --git a/bashtest/tests/exec_properties_test.sh b/bashtest/tests/exec_properties_test.sh new file mode 100644 index 0000000..a83bebf --- /dev/null +++ b/bashtest/tests/exec_properties_test.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +# SPDX-FileCopyrightText: Copyright (c) M. Boerger, the MBO Works authors +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -euo pipefail +# shellcheck disable=SC1090,SC1091,SC2154 +source "${mboworks_bashtest}" + +# shellcheck disable=SC2317 # Functions are discovered by test_runner. +test::test_scoped_execution_properties() { + expect_success true +} + +test_runner diff --git a/bashtest/tests/tool_fixture.bzl b/bashtest/tests/tool_fixture.bzl index 5aed08b..a5a4338 100644 --- a/bashtest/tests/tool_fixture.bzl +++ b/bashtest/tests/tool_fixture.bzl @@ -15,6 +15,8 @@ """Test-only configuration fixtures; not part of bashtest's public API.""" +load("//bashtest:bashtest.bzl", "bashtest") + visibility("private") def _path(ctx, file): @@ -43,3 +45,21 @@ tool_source = rule( implementation = _tool_source_impl, attrs = {"data": attr.label(allow_single_file = True)}, ) + +def execution_properties_test(name): + """Verify execution properties belong only to the test, then run its launcher. + + Args: + name: Name of the executable regression test. + """ + properties = {"test.no-sandbox": "1"} + bashtest( + name = name, + srcs = ["exec_properties_test.sh"], + exec_properties = properties, + ) + if native.existing_rule(name).get("exec_properties") != properties: + fail("The outer test must retain its execution properties") + for suffix in ["__bashtest_launcher", "__bashtest_launcher_windows"]: + if native.existing_rule(name + suffix).get("exec_properties"): + fail("Binary launchers must not inherit test execution properties") From 4c70a7dc13e944be64f90e31bf590b5226c71c58 Mon Sep 17 00:00:00 2001 From: helly25 <6420169+helly25@users.noreply.github.com> Date: Sat, 31 Oct 2026 14:48:58 +0000 Subject: [PATCH 2/3] Use portable test execution property in launcher regression --- bashtest/tests/tool_fixture.bzl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bashtest/tests/tool_fixture.bzl b/bashtest/tests/tool_fixture.bzl index a5a4338..8c69594 100644 --- a/bashtest/tests/tool_fixture.bzl +++ b/bashtest/tests/tool_fixture.bzl @@ -52,7 +52,9 @@ def execution_properties_test(name): Args: name: Name of the executable regression test. """ - properties = {"test.no-sandbox": "1"} + + # A neutral property exercises the test exec group in every runfiles mode. + properties = {"test.bashtest-regression": "1"} bashtest( name = name, srcs = ["exec_properties_test.sh"], From c4281136289dd94d879810128c6da2974ddd4e63 Mon Sep 17 00:00:00 2001 From: helly25 <6420169+helly25@users.noreply.github.com> Date: Sat, 31 Oct 2026 14:50:24 +0000 Subject: [PATCH 3/3] Isolate execution property fixture from copied tool fixtures --- bashtest/tests/BUILD.bazel | 3 +- bashtest/tests/exec_properties_fixture.bzl | 40 ++++++++++++++++++++++ bashtest/tests/tool_fixture.bzl | 22 ------------ 3 files changed, 42 insertions(+), 23 deletions(-) create mode 100644 bashtest/tests/exec_properties_fixture.bzl diff --git a/bashtest/tests/BUILD.bazel b/bashtest/tests/BUILD.bazel index 42e0f98..1597c54 100644 --- a/bashtest/tests/BUILD.bazel +++ b/bashtest/tests/BUILD.bazel @@ -16,7 +16,8 @@ load("@rules_shell//shell:sh_binary.bzl", "sh_binary") load("@rules_shell//shell:sh_test.bzl", "sh_test") load("//bashtest:bashtest.bzl", "bashtest") -load(":tool_fixture.bzl", "configuration_data", "execution_properties_test", "tool_source") +load(":exec_properties_fixture.bzl", "execution_properties_test") +load(":tool_fixture.bzl", "configuration_data", "tool_source") package(default_visibility = ["//visibility:private"]) diff --git a/bashtest/tests/exec_properties_fixture.bzl b/bashtest/tests/exec_properties_fixture.bzl new file mode 100644 index 0000000..70bae06 --- /dev/null +++ b/bashtest/tests/exec_properties_fixture.bzl @@ -0,0 +1,40 @@ +# SPDX-FileCopyrightText: Copyright (c) M. Boerger, the MBO Works authors +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Execution-property regression fixture; not part of the consumer fixtures.""" + +load("//bashtest:bashtest.bzl", "bashtest") + +visibility("private") + +def execution_properties_test(name): + """Verify execution properties belong only to the test, then run its launcher. + + Args: + name: Name of the executable regression test. + """ + + # A neutral property exercises the test exec group in every runfiles mode. + properties = {"test.bashtest-regression": "1"} + bashtest( + name = name, + srcs = ["exec_properties_test.sh"], + exec_properties = properties, + ) + if native.existing_rule(name).get("exec_properties") != properties: + fail("The outer test must retain its execution properties") + for suffix in ["__bashtest_launcher", "__bashtest_launcher_windows"]: + if native.existing_rule(name + suffix).get("exec_properties"): + fail("Binary launchers must not inherit test execution properties") diff --git a/bashtest/tests/tool_fixture.bzl b/bashtest/tests/tool_fixture.bzl index 8c69594..5aed08b 100644 --- a/bashtest/tests/tool_fixture.bzl +++ b/bashtest/tests/tool_fixture.bzl @@ -15,8 +15,6 @@ """Test-only configuration fixtures; not part of bashtest's public API.""" -load("//bashtest:bashtest.bzl", "bashtest") - visibility("private") def _path(ctx, file): @@ -45,23 +43,3 @@ tool_source = rule( implementation = _tool_source_impl, attrs = {"data": attr.label(allow_single_file = True)}, ) - -def execution_properties_test(name): - """Verify execution properties belong only to the test, then run its launcher. - - Args: - name: Name of the executable regression test. - """ - - # A neutral property exercises the test exec group in every runfiles mode. - properties = {"test.bashtest-regression": "1"} - bashtest( - name = name, - srcs = ["exec_properties_test.sh"], - exec_properties = properties, - ) - if native.existing_rule(name).get("exec_properties") != properties: - fail("The outer test must retain its execution properties") - for suffix in ["__bashtest_launcher", "__bashtest_launcher_windows"]: - if native.existing_rule(name + suffix).get("exec_properties"): - fail("Binary launchers must not inherit test execution properties")