| # 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"], |
| ) |