xref: /aosp_15_r20/external/bazelbuild-rules_python/tests/bootstrap_impls/BUILD.bazel (revision 60517a1edbc8ecf509223e9af94a7adec7d736b8)
1*60517a1eSAndroid Build Coastguard Worker# Copyright 2023 The Bazel Authors. All rights reserved.
2*60517a1eSAndroid Build Coastguard Worker#
3*60517a1eSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License");
4*60517a1eSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License.
5*60517a1eSAndroid Build Coastguard Worker# You may obtain a copy of the License at
6*60517a1eSAndroid Build Coastguard Worker#
7*60517a1eSAndroid Build Coastguard Worker#    http://www.apache.org/licenses/LICENSE-2.0
8*60517a1eSAndroid Build Coastguard Worker#
9*60517a1eSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software
10*60517a1eSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS,
11*60517a1eSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*60517a1eSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and
13*60517a1eSAndroid Build Coastguard Worker# limitations under the License.
14*60517a1eSAndroid Build Coastguard Worker
15*60517a1eSAndroid Build Coastguard Workerload("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER")  # buildifier: disable=bzl-visibility
16*60517a1eSAndroid Build Coastguard Workerload("//tests/support:sh_py_run_test.bzl", "py_reconfig_test", "sh_py_run_test")
17*60517a1eSAndroid Build Coastguard Worker
18*60517a1eSAndroid Build Coastguard Worker_SUPPORTS_BOOTSTRAP_SCRIPT = select({
19*60517a1eSAndroid Build Coastguard Worker    "@platforms//os:windows": ["@platforms//:incompatible"],
20*60517a1eSAndroid Build Coastguard Worker    "//conditions:default": [],
21*60517a1eSAndroid Build Coastguard Worker}) if IS_BAZEL_7_OR_HIGHER else ["@platforms//:incompatible"]
22*60517a1eSAndroid Build Coastguard Worker
23*60517a1eSAndroid Build Coastguard Workersh_py_run_test(
24*60517a1eSAndroid Build Coastguard Worker    name = "run_binary_zip_no_test",
25*60517a1eSAndroid Build Coastguard Worker    build_python_zip = "no",
26*60517a1eSAndroid Build Coastguard Worker    py_src = "bin.py",
27*60517a1eSAndroid Build Coastguard Worker    sh_src = "run_binary_zip_no_test.sh",
28*60517a1eSAndroid Build Coastguard Worker)
29*60517a1eSAndroid Build Coastguard Worker
30*60517a1eSAndroid Build Coastguard Workersh_py_run_test(
31*60517a1eSAndroid Build Coastguard Worker    name = "run_binary_zip_yes_test",
32*60517a1eSAndroid Build Coastguard Worker    build_python_zip = "yes",
33*60517a1eSAndroid Build Coastguard Worker    py_src = "bin.py",
34*60517a1eSAndroid Build Coastguard Worker    sh_src = "run_binary_zip_yes_test.sh",
35*60517a1eSAndroid Build Coastguard Worker)
36*60517a1eSAndroid Build Coastguard Worker
37*60517a1eSAndroid Build Coastguard Workersh_py_run_test(
38*60517a1eSAndroid Build Coastguard Worker    name = "run_binary_bootstrap_script_zip_yes_test",
39*60517a1eSAndroid Build Coastguard Worker    bootstrap_impl = "script",
40*60517a1eSAndroid Build Coastguard Worker    build_python_zip = "yes",
41*60517a1eSAndroid Build Coastguard Worker    py_src = "bin.py",
42*60517a1eSAndroid Build Coastguard Worker    sh_src = "run_binary_zip_yes_test.sh",
43*60517a1eSAndroid Build Coastguard Worker    target_compatible_with = _SUPPORTS_BOOTSTRAP_SCRIPT,
44*60517a1eSAndroid Build Coastguard Worker)
45*60517a1eSAndroid Build Coastguard Worker
46*60517a1eSAndroid Build Coastguard Workersh_py_run_test(
47*60517a1eSAndroid Build Coastguard Worker    name = "run_binary_bootstrap_script_zip_no_test",
48*60517a1eSAndroid Build Coastguard Worker    bootstrap_impl = "script",
49*60517a1eSAndroid Build Coastguard Worker    build_python_zip = "no",
50*60517a1eSAndroid Build Coastguard Worker    py_src = "bin.py",
51*60517a1eSAndroid Build Coastguard Worker    sh_src = "run_binary_zip_no_test.sh",
52*60517a1eSAndroid Build Coastguard Worker    target_compatible_with = _SUPPORTS_BOOTSTRAP_SCRIPT,
53*60517a1eSAndroid Build Coastguard Worker)
54*60517a1eSAndroid Build Coastguard Worker
55*60517a1eSAndroid Build Coastguard Workerpy_reconfig_test(
56*60517a1eSAndroid Build Coastguard Worker    name = "sys_path_order_bootstrap_script_test",
57*60517a1eSAndroid Build Coastguard Worker    srcs = ["sys_path_order_test.py"],
58*60517a1eSAndroid Build Coastguard Worker    bootstrap_impl = "script",
59*60517a1eSAndroid Build Coastguard Worker    env = {"BOOTSTRAP": "script"},
60*60517a1eSAndroid Build Coastguard Worker    imports = ["./site-packages"],
61*60517a1eSAndroid Build Coastguard Worker    main = "sys_path_order_test.py",
62*60517a1eSAndroid Build Coastguard Worker    target_compatible_with = _SUPPORTS_BOOTSTRAP_SCRIPT,
63*60517a1eSAndroid Build Coastguard Worker)
64*60517a1eSAndroid Build Coastguard Worker
65*60517a1eSAndroid Build Coastguard Workerpy_reconfig_test(
66*60517a1eSAndroid Build Coastguard Worker    name = "sys_path_order_bootstrap_system_python_test",
67*60517a1eSAndroid Build Coastguard Worker    srcs = ["sys_path_order_test.py"],
68*60517a1eSAndroid Build Coastguard Worker    bootstrap_impl = "system_python",
69*60517a1eSAndroid Build Coastguard Worker    env = {"BOOTSTRAP": "system_python"},
70*60517a1eSAndroid Build Coastguard Worker    imports = ["./site-packages"],
71*60517a1eSAndroid Build Coastguard Worker    main = "sys_path_order_test.py",
72*60517a1eSAndroid Build Coastguard Worker)
73*60517a1eSAndroid Build Coastguard Worker
74*60517a1eSAndroid Build Coastguard Workersh_py_run_test(
75*60517a1eSAndroid Build Coastguard Worker    name = "inherit_pythonsafepath_env_test",
76*60517a1eSAndroid Build Coastguard Worker    bootstrap_impl = "script",
77*60517a1eSAndroid Build Coastguard Worker    py_src = "bin.py",
78*60517a1eSAndroid Build Coastguard Worker    sh_src = "inherit_pythonsafepath_env_test.sh",
79*60517a1eSAndroid Build Coastguard Worker    target_compatible_with = _SUPPORTS_BOOTSTRAP_SCRIPT,
80*60517a1eSAndroid Build Coastguard Worker)
81