xref: /aosp_15_r20/external/bazel-skylib/tests/build_test_tests.bzl (revision bcb5dc7965af6ee42bf2f21341a2ec00233a8c8a)
1# Copyright 2019 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
15"""Unit tests for build_test.bzl."""
16
17load("//rules:build_test.bzl", "build_test")
18
19# buildifier: disable=unnamed-macro
20def build_test_test_suite():
21    # Since the rules doesn't do anything really, it just makes some targets
22    # to get Bazel to build other targets via a `bazel test`, just make some
23    # targets to exercise the rule.
24
25    # Make a source file
26    native.genrule(
27        name = "build_test__make_src",
28        outs = ["build_test__src.cc"],
29        cmd = "echo 'int dummy() { return 0; }' > $@",
30    )
31
32    # Use it in a non-test target
33    native.cc_library(
34        name = "build_test__build_target",
35        srcs = [":build_test__make_src"],
36    )
37
38    # Wrap a build test around the target.
39    build_test(
40        name = "build_test__test",
41        targets = [":build_test__build_target"],
42    )
43