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