Skip to content

Commit ffad9ba

Browse files
committed
use py_reconfig_test for no_unsafe_paths tests instead
1 parent 988fe91 commit ffad9ba

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,16 +11,10 @@
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
load(":venv_relative_path_tests.bzl", "relative_path_test_suite")
1817

19-
_SUPPORTS_BOOTSTRAP_SCRIPT = select({
20-
"@platforms//os:windows": ["@platforms//:incompatible"],
21-
"//conditions:default": [],
22-
}) if IS_BAZEL_7_OR_HIGHER else ["@platforms//:incompatible"]
23-
2418
sh_py_run_test(
2519
name = "run_binary_zip_no_test",
2620
build_python_zip = "no",
@@ -41,7 +35,7 @@ sh_py_run_test(
4135
build_python_zip = "yes",
4236
py_src = "bin.py",
4337
sh_src = "run_binary_zip_yes_test.sh",
44-
target_compatible_with = _SUPPORTS_BOOTSTRAP_SCRIPT,
38+
target_compatible_with = SUPPORTS_BOOTSTRAP_SCRIPT,
4539
)
4640

4741
sh_py_run_test(
@@ -50,7 +44,7 @@ sh_py_run_test(
5044
build_python_zip = "no",
5145
py_src = "bin.py",
5246
sh_src = "run_binary_zip_no_test.sh",
53-
target_compatible_with = _SUPPORTS_BOOTSTRAP_SCRIPT,
47+
target_compatible_with = SUPPORTS_BOOTSTRAP_SCRIPT,
5448
)
5549

5650
py_reconfig_test(
@@ -60,7 +54,7 @@ py_reconfig_test(
6054
env = {"BOOTSTRAP": "script"},
6155
imports = ["./USER_IMPORT/site-packages"],
6256
main = "sys_path_order_test.py",
63-
target_compatible_with = _SUPPORTS_BOOTSTRAP_SCRIPT,
57+
target_compatible_with = SUPPORTS_BOOTSTRAP_SCRIPT,
6458
)
6559

6660
py_reconfig_test(
@@ -77,7 +71,7 @@ sh_py_run_test(
7771
bootstrap_impl = "script",
7872
py_src = "bin.py",
7973
sh_src = "inherit_pythonsafepath_env_test.sh",
80-
target_compatible_with = _SUPPORTS_BOOTSTRAP_SCRIPT,
74+
target_compatible_with = SUPPORTS_BOOTSTRAP_SCRIPT,
8175
)
8276

8377
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
)

tests/integration/no_unsafe_paths/test.py renamed to tests/no_unsafe_paths/test.py

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy