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