xref: /aosp_15_r20/external/bazel-skylib/tests/expand_template/BUILD (revision bcb5dc7965af6ee42bf2f21341a2ec00233a8c8a)
1# Copyright 2022 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# This package aids testing the 'diff_test' rule.
16
17load("//rules:expand_template.bzl", "expand_template")
18
19package(
20    default_applicable_licenses = ["//:license"],
21    default_testonly = 1,
22)
23
24expand_template(
25    name = "filled_template",
26    out = "foo/test.yaml",
27    substitutions = {
28        "@name@": "test",
29        "@version@": "1.1.1",
30    },
31    template = "test.tpl.yaml",
32)
33
34sh_test(
35    name = "template_test",
36    srcs = ["template_test.sh"],
37    data = [
38        "foo/test.yaml",
39        ":filled_template",
40        "//tests:unittest.bash",
41    ],
42    deps = [
43        "@bazel_tools//tools/bash/runfiles",
44    ],
45)
46
47expand_template(
48    name = "version",
49    out = "version.h",
50    substitutions = {
51        "@VERSION@": "2.3.4",
52    },
53    template = "version.h.in",
54)
55
56cc_test(
57    name = "test",
58    srcs = [
59        "test.cc",
60        ":version",
61    ],
62)
63