Dave MacLachlan | 4800626 | 2016-02-03 23:31:39 +0000 | [diff] [blame] | 1 | #!/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 | # |
Googler | bd7a6b9 | 2022-02-24 07:38:58 -0800 | [diff] [blame] | 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
Dave MacLachlan | 4800626 | 2016-02-03 23:31:39 +0000 | [diff] [blame] | 10 | # |
| 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 Csomor | c334bce | 2018-06-27 08:29:32 -0700 | [diff] [blame] | 17 | set -euo pipefail |
| 18 | # --- begin runfiles.bash initialization --- |
| 19 | if [[ ! -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 |
| 27 | fi |
| 28 | if [[ -f "${RUNFILES_DIR:-/dev/null}/bazel_tools/tools/bash/runfiles/runfiles.bash" ]]; then |
| 29 | source "${RUNFILES_DIR}/bazel_tools/tools/bash/runfiles/runfiles.bash" |
| 30 | elif [[ -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-)" |
| 33 | else |
| 34 | echo >&2 "ERROR: cannot find @bazel_tools//tools/bash/runfiles:runfiles.bash" |
| 35 | exit 1 |
| 36 | fi |
| 37 | # --- end runfiles.bash initialization --- |
Dave MacLachlan | 4800626 | 2016-02-03 23:31:39 +0000 | [diff] [blame] | 38 | |
Laszlo Csomor | c334bce | 2018-06-27 08:29:32 -0700 | [diff] [blame] | 39 | source "$(rlocation io_bazel/examples/shell/lib.sh)" |
Dave MacLachlan | 4800626 | 2016-02-03 23:31:39 +0000 | [diff] [blame] | 40 | |
| 41 | function test_output { |
| 42 | OUTPUT=$(showfile) |
Laszlo Csomor | c334bce | 2018-06-27 08:29:32 -0700 | [diff] [blame] | 43 | EXPECTED_OUTPUT=$(cat "$(rlocation io_bazel/examples/shell/data/test_file.txt)") |
Dave MacLachlan | 4800626 | 2016-02-03 23:31:39 +0000 | [diff] [blame] | 44 | |
| 45 | if [ "${OUTPUT}" != "${EXPECTED_OUTPUT}" ]; then |
| 46 | # This would be a failure case. |
| 47 | exit 1 |
| 48 | fi |
| 49 | } |
| 50 | |
| 51 | test_output |