Skip to content

Commit

Permalink
Do not export rlocation from test setup
Browse files Browse the repository at this point in the history
The `rlocation` implementation lacks many of the features of the shell runfiles library, which should be dependend on explicitly instead.

When called, `rlocation` will now fail with an error message.

Closes #24256.

PiperOrigin-RevId: 695241586
Change-Id: I7059c329fd6ca518623d7be8ad3514082097c191
  • Loading branch information
fmeum authored and bazel-io committed Nov 11, 2024
1 parent 2a5c0b7 commit f72f3ad
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tools/test/test-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@ function rlocation() {
fi
}

export -f rlocation
export -f is_absolute
# If RUNFILES_MANIFEST_ONLY is set to 1 and the manifest file does exist,
# then test programs should use manifest file to find runfiles.
if [[ "${RUNFILES_MANIFEST_ONLY:-}" == "1" && -e "${RUNFILES_MANIFEST_FILE:-}" ]]; then
Expand Down Expand Up @@ -236,6 +234,15 @@ else
TEST_PATH="$(rlocation $TEST_WORKSPACE/$EXE)"
fi

# Redefine rlocation to notify users of its removal - it used to be exported.
# TODO: Remove this before Bazel 9.
function rlocation() {
read LINE SUB FILE < <(caller 0);
>&2 echo "ERROR: rlocation is no longer implicitly provided by Bazel's test setup, but called from $SUB in line $LINE of $FILE. Please use https://github.com/bazelbuild/rules_shell/blob/main/shell/runfiles/runfiles.bash instead."
exit 1
}
export -f rlocation

# TODO(jsharpe): Use --test_env=TEST_SHORT_EXEC_PATH=true to activate this code
# path to workaround a bug with long executable paths when executing remote
# tests on Windows.
Expand Down

0 comments on commit f72f3ad

Please sign in to comment.