xref: /aosp_15_r20/external/grpc-grpc/tools/bazelify_tests/test/strict_tests.bzl (revision cc02d7e222339f7a4f6ba5f422e6413f4bd931f2)
1# Copyright 2023 The gRPC Authors
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
15"""
16Generates a suite of strict build tests, to minimize runtime.
17"""
18
19load("//tools/bazelify_tests:build_defs.bzl", "grpc_run_simple_command_test")
20
21def _safe_target_name(name):
22    """Returns a sanitized name for a target"""
23    return name.replace(":", "").replace("/", "_").replace(".", "").replace(" ", "_")
24
25def generate_strict_tests(name = ""):
26    """Generates a suite of strict build tests, to minimize runtime.
27
28    Args:
29        name: unused (required by buildifier)
30    """
31    strict_warning_jobs = []
32
33    for source in [
34        ":all //src/core/... //src/compiler/... //examples/... -//examples/android/binder/...",
35        "//test/... -//test/core/... -//test/cpp/...",
36        "//test/core/end2end/...",
37        "//test/core/... -//test/core/end2end/...",
38        "//test/cpp/... -//test/cpp/end2end/...",
39        "//test/cpp/end2end/xds/...",
40        "//test/cpp/end2end/... -//test/cpp/end2end/xds/...",
41    ]:
42        test_name = "bazel_build_with_strict_warnings_linux_" + _safe_target_name(source)
43        strict_warning_jobs.append(":" + test_name)
44        grpc_run_simple_command_test(
45            name = test_name,
46            size = "enormous",
47            args = ["tools/bazelify_tests/test/bazel_build_with_strict_warnings_linux.sh " + source],
48            docker_image_version = "tools/dockerfile/test/bazel.current_version",
49        )
50
51    native.test_suite(
52        name = "bazel_build_with_strict_warnings_linux",
53        tests = strict_warning_jobs,
54    )
55