xref: /aosp_15_r20/external/bazelbuild-rules_python/tests/integration/BUILD.bazel (revision 60517a1edbc8ecf509223e9af94a7adec7d736b8)
1# Copyright 2023 The Bazel Authors. All rights reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#    http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15load("@bazel_binaries//:defs.bzl", "bazel_binaries")
16load("@rules_bazel_integration_test//bazel_integration_test:defs.bzl", "default_test_runner")
17load("//python:py_library.bzl", "py_library")
18load(":integration_test.bzl", "rules_python_integration_test")
19
20licenses(["notice"])
21
22_LEGACY_WORKSPACE_FLAGS = [
23    "--noenable_bzlmod",
24]
25
26_WORKSPACE_FLAGS = _LEGACY_WORKSPACE_FLAGS + [
27    "--enable_workspace",
28]
29
30_WORKSPACE_GAZELLE_PLUGIN_FLAGS = [
31    "--override_repository=rules_python_gazelle_plugin=../../../rules_python_gazelle_plugin",
32]
33
34_GAZELLE_PLUGIN_FLAGS = [
35    "--override_module=rules_python_gazelle_plugin=../../../rules_python_gazelle_plugin",
36]
37
38default_test_runner(
39    name = "bazel_6_4_workspace_test_runner",
40    bazel_cmds = [
41        "info {}".format(" ".join(_LEGACY_WORKSPACE_FLAGS)),
42        "test {} //...".format(" ".join(_LEGACY_WORKSPACE_FLAGS)),
43    ],
44    visibility = ["//visibility:public"],
45)
46
47default_test_runner(
48    name = "bazel_6_4_workspace_test_runner_gazelle_plugin",
49    bazel_cmds = [
50        "info {}".format(" ".join(_LEGACY_WORKSPACE_FLAGS + _WORKSPACE_GAZELLE_PLUGIN_FLAGS)),
51        "test {} //...".format(" ".join(_LEGACY_WORKSPACE_FLAGS + _WORKSPACE_GAZELLE_PLUGIN_FLAGS)),
52    ],
53    visibility = ["//visibility:public"],
54)
55
56default_test_runner(
57    name = "workspace_test_runner",
58    bazel_cmds = [
59        "info {}".format(" ".join(_WORKSPACE_FLAGS)),
60        "test {} //...".format(" ".join(_WORKSPACE_FLAGS)),
61    ],
62    visibility = ["//visibility:public"],
63)
64
65default_test_runner(
66    name = "workspace_test_runner_gazelle_plugin",
67    bazel_cmds = [
68        "info {}".format(" ".join(_WORKSPACE_FLAGS + _WORKSPACE_GAZELLE_PLUGIN_FLAGS)),
69        "test {} //...".format(" ".join(_WORKSPACE_FLAGS + _WORKSPACE_GAZELLE_PLUGIN_FLAGS)),
70    ],
71    visibility = ["//visibility:public"],
72)
73
74default_test_runner(
75    name = "test_runner",
76    visibility = ["//visibility:public"],
77)
78
79default_test_runner(
80    name = "test_runner_gazelle_plugin",
81    bazel_cmds = [
82        "info {}".format(" ".join(_GAZELLE_PLUGIN_FLAGS)),
83        "test {} //...".format(" ".join(_GAZELLE_PLUGIN_FLAGS)),
84    ],
85    visibility = ["//visibility:public"],
86)
87
88# TODO: add compile_pip_requirements_test_from_external_repo
89
90rules_python_integration_test(
91    name = "compile_pip_requirements_test",
92)
93
94rules_python_integration_test(
95    name = "compile_pip_requirements_workspace_test",
96    bzlmod = False,
97    workspace_path = "compile_pip_requirements",
98)
99
100rules_python_integration_test(
101    name = "ignore_root_user_error_test",
102)
103
104rules_python_integration_test(
105    name = "ignore_root_user_error_workspace_test",
106    bzlmod = False,
107    workspace_path = "ignore_root_user_error",
108)
109
110rules_python_integration_test(
111    name = "local_toolchains_test",
112    bazel_versions = [
113        version
114        for version in bazel_binaries.versions.all
115        if not version.startswith("6.")
116    ],
117)
118
119rules_python_integration_test(
120    name = "pip_parse_test",
121)
122
123rules_python_integration_test(
124    name = "pip_parse_workspace_test",
125    bzlmod = False,
126    workspace_path = "pip_parse",
127)
128
129rules_python_integration_test(
130    name = "py_cc_toolchain_registered_test",
131)
132
133rules_python_integration_test(
134    name = "py_cc_toolchain_registered_workspace_test",
135    bzlmod = False,
136    workspace_path = "py_cc_toolchain_registered",
137)
138
139rules_python_integration_test(
140    name = "custom_commands_test",
141    py_main = "custom_commands_test.py",
142)
143
144py_library(
145    name = "runner_lib",
146    srcs = ["runner.py"],
147    imports = ["../../"],
148)
149