aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorThomas Van Lenten <thomasvl@google.com>2019-01-25 14:34:15 -0500
committerc-parsons <cparsons@google.com>2019-01-25 14:34:15 -0500
commitf5e50bc53c52708abd29919a66bac307c6dc2e07 (patch)
tree3ca1955750e03dbf0ed3901ecf6f5c1dad685845 /tests
parent9b85311ab47548ec051171213a1b3b4b3b3c9dc8 (diff)
downloadbazel-skylib-f5e50bc53c52708abd29919a66bac307c6dc2e07.tar.gz
Add a build_test rule. (#97)
* Add a build_test rule. This rules (marco) provides a 'test' target that can be used to ensure other targets build.
Diffstat (limited to 'tests')
-rw-r--r--tests/BUILD3
-rw-r--r--tests/build_test_tests.bzl39
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/BUILD b/tests/BUILD
index 8657cae..fdf00ad 100644
--- a/tests/BUILD
+++ b/tests/BUILD
@@ -1,3 +1,4 @@
+load(":build_test_tests.bzl", "build_test_test_suite")
load(":collections_tests.bzl", "collections_test_suite")
load(":dicts_tests.bzl", "dicts_test_suite")
load(":maprule_tests.bzl", "maprule_test_suite")
@@ -13,6 +14,8 @@ load(":versions_tests.bzl", "versions_test_suite")
licenses(["notice"])
+build_test_test_suite()
+
collections_test_suite()
dicts_test_suite()
diff --git a/tests/build_test_tests.bzl b/tests/build_test_tests.bzl
new file mode 100644
index 0000000..df3671f
--- /dev/null
+++ b/tests/build_test_tests.bzl
@@ -0,0 +1,39 @@
+# 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.
+
+load("//rules:build_test.bzl", "build_test")
+
+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
+ native.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"],
+ )