blob: 146fcdbc2c79494234b1d20ce427c1013c54efeb [file] [log] [blame]
Dave MacLachlan48006262016-02-03 23:31:39 +00001#!/bin/bash
2
3# Copyright 2016 The Bazel Authors. All rights reserved.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
Googlerbd7a6b92022-02-24 07:38:58 -08009# http://www.apache.org/licenses/LICENSE-2.0
Dave MacLachlan48006262016-02-03 23:31:39 +000010#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
Laszlo Csomorc334bce2018-06-27 08:29:32 -070017set -euo pipefail
18# --- begin runfiles.bash initialization ---
19if [[ ! -d "${RUNFILES_DIR:-/dev/null}" && ! -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then
20 if [[ -f "$0.runfiles_manifest" ]]; then
21 export RUNFILES_MANIFEST_FILE="$0.runfiles_manifest"
22 elif [[ -f "$0.runfiles/MANIFEST" ]]; then
23 export RUNFILES_MANIFEST_FILE="$0.runfiles/MANIFEST"
24 elif [[ -f "$0.runfiles/bazel_tools/tools/bash/runfiles/runfiles.bash" ]]; then
25 export RUNFILES_DIR="$0.runfiles"
26 fi
27fi
28if [[ -f "${RUNFILES_DIR:-/dev/null}/bazel_tools/tools/bash/runfiles/runfiles.bash" ]]; then
29 source "${RUNFILES_DIR}/bazel_tools/tools/bash/runfiles/runfiles.bash"
30elif [[ -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then
31 source "$(grep -m1 "^bazel_tools/tools/bash/runfiles/runfiles.bash " \
32 "$RUNFILES_MANIFEST_FILE" | cut -d ' ' -f 2-)"
33else
34 echo >&2 "ERROR: cannot find @bazel_tools//tools/bash/runfiles:runfiles.bash"
35 exit 1
36fi
37# --- end runfiles.bash initialization ---
Dave MacLachlan48006262016-02-03 23:31:39 +000038
Laszlo Csomorc334bce2018-06-27 08:29:32 -070039source "$(rlocation io_bazel/examples/shell/lib.sh)"
Dave MacLachlan48006262016-02-03 23:31:39 +000040
41function test_output {
42 OUTPUT=$(showfile)
Laszlo Csomorc334bce2018-06-27 08:29:32 -070043 EXPECTED_OUTPUT=$(cat "$(rlocation io_bazel/examples/shell/data/test_file.txt)")
Dave MacLachlan48006262016-02-03 23:31:39 +000044
45 if [ "${OUTPUT}" != "${EXPECTED_OUTPUT}" ]; then
46 # This would be a failure case.
47 exit 1
48 fi
49}
50
51test_output