1# Copyright 2024 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# --- begin runfiles.bash initialization v3 --- 16# Copy-pasted from the Bazel Bash runfiles library v3. 17set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash 18source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ 19 source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ 20 source "$0.runfiles/$f" 2>/dev/null || \ 21 source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ 22 source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ 23 { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e 24# --- end runfiles.bash initialization v3 --- 25set +e 26 27bin=$(rlocation $BIN_RLOCATION) 28if [[ -z "$bin" ]]; then 29 echo "Unable to locate test binary: $BIN_RLOCATION" 30 exit 1 31fi 32actual=$($bin) 33 34# How we detect if a zip file was executed from depends on which bootstrap 35# is used. 36# bootstrap_impl=script outputs RULES_PYTHON_ZIP_DIR:<somepath> 37# bootstrap_impl=system_python outputs file:.*Bazel.runfiles 38expected_pattern="RULES_PYTHON_ZIP_DIR:/\|file:.*Bazel.runfiles" 39if ! (echo "$actual" | grep "$expected_pattern" ) >/dev/null; then 40 echo "expected output to match: $expected_pattern" 41 echo "but got: $actual" 42 exit 1 43fi 44 45