Skip to content

Commit 4dfc32f

Browse files
committed
use py_reconfig_test for no_unsafe_paths tests instead
1 parent f71b0a4 commit 4dfc32f

File tree

10 files changed

+27
-102
lines changed

10 files changed

+27
-102
lines changed

.bazelrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# (Note, we cannot use `common --deleted_packages` because the bazel version command doesn't support it)
55
# To update these lines, execute
66
# `bazel run @rules_bazel_integration_test//tools:update_deleted_packages`
7-
build --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/pythonconfig,gazelle/python/private,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/ignore_root_user_error,tests/integration/ignore_root_user_error/submodule,tests/integration/local_toolchains,tests/integration/no_unsafe_paths,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered
8-
query --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/pythonconfig,gazelle/python/private,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/ignore_root_user_error,tests/integration/ignore_root_user_error/submodule,tests/integration/local_toolchains,tests/integration/no_unsafe_paths,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered
7+
build --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/pythonconfig,gazelle/python/private,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/ignore_root_user_error,tests/integration/ignore_root_user_error/submodule,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered
8+
query --deleted_packages=examples/build_file_generation,examples/build_file_generation/random_number_generator,examples/bzlmod,examples/bzlmod_build_file_generation,examples/bzlmod_build_file_generation/other_module/other_module/pkg,examples/bzlmod_build_file_generation/runfiles,examples/bzlmod/entry_points,examples/bzlmod/entry_points/tests,examples/bzlmod/libs/my_lib,examples/bzlmod/other_module,examples/bzlmod/other_module/other_module/pkg,examples/bzlmod/patches,examples/bzlmod/py_proto_library,examples/bzlmod/py_proto_library/example.com/another_proto,examples/bzlmod/py_proto_library/example.com/proto,examples/bzlmod/runfiles,examples/bzlmod/tests,examples/bzlmod/tests/other_module,examples/bzlmod/whl_mods,examples/multi_python_versions/libs/my_lib,examples/multi_python_versions/requirements,examples/multi_python_versions/tests,examples/pip_parse,examples/pip_parse_vendored,examples/pip_repository_annotations,examples/py_proto_library,examples/py_proto_library/example.com/another_proto,examples/py_proto_library/example.com/proto,gazelle,gazelle/manifest,gazelle/manifest/generate,gazelle/manifest/hasher,gazelle/manifest/test,gazelle/modules_mapping,gazelle/python,gazelle/pythonconfig,gazelle/python/private,tests/integration/compile_pip_requirements,tests/integration/compile_pip_requirements_test_from_external_repo,tests/integration/custom_commands,tests/integration/ignore_root_user_error,tests/integration/ignore_root_user_error/submodule,tests/integration/local_toolchains,tests/integration/pip_parse,tests/integration/pip_parse/empty,tests/integration/py_cc_toolchain_registered
99

1010
test --test_output=errors
1111

tests/bootstrap_impls/BUILD.bazel

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,9 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
15-
load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER") # buildifier: disable=bzl-visibility
14+
load("//tests/support:support.bzl", "SUPPORTS_BOOTSTRAP_SCRIPT")
1615
load("//tests/support:sh_py_run_test.bzl", "py_reconfig_test", "sh_py_run_test")
1716

18-
_SUPPORTS_BOOTSTRAP_SCRIPT = select({
19-
"@platforms//os:windows": ["@platforms//:incompatible"],
20-
"//conditions:default": [],
21-
}) if IS_BAZEL_7_OR_HIGHER else ["@platforms//:incompatible"]
22-
2317
sh_py_run_test(
2418
name = "run_binary_zip_no_test",
2519
build_python_zip = "no",
@@ -40,7 +34,7 @@ sh_py_run_test(
4034
build_python_zip = "yes",
4135
py_src = "bin.py",
4236
sh_src = "run_binary_zip_yes_test.sh",
43-
target_compatible_with = _SUPPORTS_BOOTSTRAP_SCRIPT,
37+
target_compatible_with = SUPPORTS_BOOTSTRAP_SCRIPT,
4438
)
4539

4640
sh_py_run_test(
@@ -49,7 +43,7 @@ sh_py_run_test(
4943
build_python_zip = "no",
5044
py_src = "bin.py",
5145
sh_src = "run_binary_zip_no_test.sh",
52-
target_compatible_with = _SUPPORTS_BOOTSTRAP_SCRIPT,
46+
target_compatible_with = SUPPORTS_BOOTSTRAP_SCRIPT,
5347
)
5448

5549
py_reconfig_test(
@@ -59,7 +53,7 @@ py_reconfig_test(
5953
env = {"BOOTSTRAP": "script"},
6054
imports = ["./USER_IMPORT/site-packages"],
6155
main = "sys_path_order_test.py",
62-
target_compatible_with = _SUPPORTS_BOOTSTRAP_SCRIPT,
56+
target_compatible_with = SUPPORTS_BOOTSTRAP_SCRIPT,
6357
)
6458

6559
py_reconfig_test(
@@ -76,7 +70,7 @@ sh_py_run_test(
7670
bootstrap_impl = "script",
7771
py_src = "bin.py",
7872
sh_src = "inherit_pythonsafepath_env_test.sh",
79-
target_compatible_with = _SUPPORTS_BOOTSTRAP_SCRIPT,
73+
target_compatible_with = SUPPORTS_BOOTSTRAP_SCRIPT,
8074
)
8175

8276
sh_py_run_test(

tests/integration/BUILD.bazel

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,6 @@ rules_python_integration_test(
141141
py_main = "custom_commands_test.py",
142142
)
143143

144-
rules_python_integration_test(
145-
name = "no_unsafe_paths_test",
146-
# Starlark implementation of core rules only available on Bazel 7+
147-
bazel_versions = [
148-
version
149-
for version in bazel_binaries.versions.all
150-
if not version.startswith("6.")
151-
],
152-
)
153-
154144
py_library(
155145
name = "runner_lib",
156146
srcs = ["runner.py"],

tests/integration/no_unsafe_paths/.bazelrc

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests/integration/no_unsafe_paths/MODULE.bazel

Lines changed: 0 additions & 37 deletions
This file was deleted.

tests/integration/no_unsafe_paths/WORKSPACE

Lines changed: 0 additions & 20 deletions
This file was deleted.

tests/integration/no_unsafe_paths/WORKSPACE.bzlmod

Whitespace-only changes.

tests/integration/no_unsafe_paths/BUILD.bazel renamed to tests/no_unsafe_paths/BUILD.bazel

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,23 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
load("//tests/support:sh_py_run_test.bzl", "py_reconfig_test")
15+
load("//tests/support:support.bzl", "SUPPORTS_BOOTSTRAP_SCRIPT")
1416

15-
load("@python//3.10:defs.bzl", py_test_3_10 = "py_test")
16-
load("@python//3.11:defs.bzl", py_test_3_11 = "py_test")
17-
18-
py_test_3_10(
19-
name = "test_py_3_10",
17+
py_reconfig_test(
18+
name = "no_unsafe_paths_3.10_test",
2019
srcs = ["test.py"],
21-
env = {
22-
"RULES_PYTHON_BOOTSTRAP_VERBOSE": "1",
23-
},
2420
main = "test.py",
21+
python_version = "3.10",
22+
bootstrap_impl = "script",
23+
target_compatible_with = SUPPORTS_BOOTSTRAP_SCRIPT,
2524
)
2625

27-
py_test_3_11(
28-
name = "test_py_3_11",
26+
py_reconfig_test(
27+
name = "no_unsafe_paths_3.11_test",
2928
srcs = ["test.py"],
30-
env = {
31-
"RULES_PYTHON_BOOTSTRAP_VERBOSE": "1",
32-
},
3329
main = "test.py",
30+
python_version = "3.11",
31+
bootstrap_impl = "script",
32+
target_compatible_with = SUPPORTS_BOOTSTRAP_SCRIPT,
3433
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ def test_no_unsafe_paths_in_search_path(self):
4141

4242

4343
if __name__ == '__main__':
44-
unittest.main()
44+
unittest.main()

tests/support/support.bzl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
# rules_testing or as config_setting values, which don't support Label in some
2020
# places.
2121

22+
load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER") # buildifier: disable=bzl-visibility
23+
2224
MAC = Label("//tests/support:mac")
2325
MAC_X86_64 = Label("//tests/support:mac_x86_64")
2426
LINUX = Label("//tests/support:linux")
@@ -39,3 +41,8 @@ PRECOMPILE_SOURCE_RETENTION = str(Label("//python/config_settings:precompile_sou
3941
PYC_COLLECTION = str(Label("//python/config_settings:pyc_collection"))
4042
PYTHON_VERSION = str(Label("//python/config_settings:python_version"))
4143
VISIBLE_FOR_TESTING = str(Label("//python/private:visible_for_testing"))
44+
45+
SUPPORTS_BOOTSTRAP_SCRIPT = select({
46+
"@platforms//os:windows": ["@platforms//:incompatible"],
47+
"//conditions:default": [],
48+
}) if IS_BAZEL_7_OR_HIGHER else ["@platforms//:incompatible"]

0 commit comments

Comments
 (0)