1*bcb5dc79SHONG Yifan# Copyright 2019 The Bazel Authors. All rights reserved. 2*bcb5dc79SHONG Yifan# 3*bcb5dc79SHONG Yifan# Licensed under the Apache License, Version 2.0 (the "License"); 4*bcb5dc79SHONG Yifan# you may not use this file except in compliance with the License. 5*bcb5dc79SHONG Yifan# You may obtain a copy of the License at 6*bcb5dc79SHONG Yifan# 7*bcb5dc79SHONG Yifan# http://www.apache.org/licenses/LICENSE-2.0 8*bcb5dc79SHONG Yifan# 9*bcb5dc79SHONG Yifan# Unless required by applicable law or agreed to in writing, software 10*bcb5dc79SHONG Yifan# distributed under the License is distributed on an "AS IS" BASIS, 11*bcb5dc79SHONG Yifan# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*bcb5dc79SHONG Yifan# See the License for the specific language governing permissions and 13*bcb5dc79SHONG Yifan# limitations under the License. 14*bcb5dc79SHONG Yifan 15*bcb5dc79SHONG Yifan"""Unit tests for build_test.bzl.""" 16*bcb5dc79SHONG Yifan 17*bcb5dc79SHONG Yifanload("//rules:build_test.bzl", "build_test") 18*bcb5dc79SHONG Yifan 19*bcb5dc79SHONG Yifan# buildifier: disable=unnamed-macro 20*bcb5dc79SHONG Yifandef build_test_test_suite(): 21*bcb5dc79SHONG Yifan # Since the rules doesn't do anything really, it just makes some targets 22*bcb5dc79SHONG Yifan # to get Bazel to build other targets via a `bazel test`, just make some 23*bcb5dc79SHONG Yifan # targets to exercise the rule. 24*bcb5dc79SHONG Yifan 25*bcb5dc79SHONG Yifan # Make a source file 26*bcb5dc79SHONG Yifan native.genrule( 27*bcb5dc79SHONG Yifan name = "build_test__make_src", 28*bcb5dc79SHONG Yifan outs = ["build_test__src.cc"], 29*bcb5dc79SHONG Yifan cmd = "echo 'int dummy() { return 0; }' > $@", 30*bcb5dc79SHONG Yifan ) 31*bcb5dc79SHONG Yifan 32*bcb5dc79SHONG Yifan # Use it in a non-test target 33*bcb5dc79SHONG Yifan native.cc_library( 34*bcb5dc79SHONG Yifan name = "build_test__build_target", 35*bcb5dc79SHONG Yifan srcs = [":build_test__make_src"], 36*bcb5dc79SHONG Yifan ) 37*bcb5dc79SHONG Yifan 38*bcb5dc79SHONG Yifan # Wrap a build test around the target. 39*bcb5dc79SHONG Yifan build_test( 40*bcb5dc79SHONG Yifan name = "build_test__test", 41*bcb5dc79SHONG Yifan targets = [":build_test__build_target"], 42*bcb5dc79SHONG Yifan ) 43