aboutsummaryrefslogtreecommitdiff
path: root/tests/build_test_tests.bzl
blob: 4d3dfb6adfca53a802b82fa4063ae30d410ce0f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Copyright 2019 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Unit tests for build_test.bzl."""

load("@rules_cc//cc:defs.bzl", "cc_library")
load("//rules:build_test.bzl", "build_test")

# buildifier: disable=unnamed-macro
def build_test_test_suite():
    # Since the rules doesn't do anything really, it just makes some targets
    # to get Bazel to build other targets via a `bazel test`, just make some
    # targets to exercise the rule.

    # Make a source file
    native.genrule(
        name = "build_test__make_src",
        outs = ["build_test__src.cc"],
        cmd = "echo 'int dummy() { return 0; }' > $@",
    )

    # Use it in a non-test target
    cc_library(
        name = "build_test__build_target",
        srcs = [":build_test__make_src"],
    )

    # Wrap a build test around the target.
    build_test(
        name = "build_test__test",
        targets = [":build_test__build_target"],
    )