xref: /aosp_15_r20/external/bazel-skylib/tests/expand_template/template_test.sh (revision bcb5dc7965af6ee42bf2f21341a2ec00233a8c8a)
1*bcb5dc79SHONG Yifan#!/usr/bin/env bash
2*bcb5dc79SHONG Yifan
3*bcb5dc79SHONG Yifan# Copyright 2022 The Bazel Authors. All rights reserved.
4*bcb5dc79SHONG Yifan#
5*bcb5dc79SHONG Yifan# Licensed under the Apache License, Version 2.0 (the "License");
6*bcb5dc79SHONG Yifan# you may not use this file except in compliance with the License.
7*bcb5dc79SHONG Yifan# You may obtain a copy of the License at
8*bcb5dc79SHONG Yifan#
9*bcb5dc79SHONG Yifan#    http://www.apache.org/licenses/LICENSE-2.0
10*bcb5dc79SHONG Yifan#
11*bcb5dc79SHONG Yifan# Unless required by applicable law or agreed to in writing, software
12*bcb5dc79SHONG Yifan# distributed under the License is distributed on an "AS IS" BASIS,
13*bcb5dc79SHONG Yifan# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14*bcb5dc79SHONG Yifan# See the License for the specific language governing permissions and
15*bcb5dc79SHONG Yifan# limitations under the License.
16*bcb5dc79SHONG Yifan
17*bcb5dc79SHONG Yifan# --- begin runfiles.bash initialization v2 ---
18*bcb5dc79SHONG Yifan# Copy-pasted from the Bazel Bash runfiles library v2.
19*bcb5dc79SHONG Yifanset -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
20*bcb5dc79SHONG Yifansource "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
21*bcb5dc79SHONG Yifan    source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
22*bcb5dc79SHONG Yifan    source "$0.runfiles/$f" 2>/dev/null || \
23*bcb5dc79SHONG Yifan    source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
24*bcb5dc79SHONG Yifan    source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
25*bcb5dc79SHONG Yifan    { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
26*bcb5dc79SHONG Yifan# --- end runfiles.bash initialization v2 ---
27*bcb5dc79SHONG Yifan
28*bcb5dc79SHONG Yifansource "$(rlocation $TEST_WORKSPACE/tests/unittest.bash)" \
29*bcb5dc79SHONG Yifan  || { echo "Could not source bazel_skylib/tests/unittest.bash" >&2; exit 1; }
30*bcb5dc79SHONG Yifan
31*bcb5dc79SHONG Yifanfunction test_expand_template() {
32*bcb5dc79SHONG Yifan  cat "$(rlocation $TEST_WORKSPACE/tests/expand_template/foo/test.yaml)" >"$TEST_log"
33*bcb5dc79SHONG Yifan  expect_log 'name: test'
34*bcb5dc79SHONG Yifan  expect_log 'version: 1.1.1'
35*bcb5dc79SHONG Yifan}
36*bcb5dc79SHONG Yifan
37*bcb5dc79SHONG Yifanrun_suite "expand_template_tests test suite"