Skip to content

Commit

Permalink
Add the ability to force the path to the test binary to a fixed lengt…
Browse files Browse the repository at this point in the history
…h by using a symlink.

This is enabled with --test_env=TEST_SHORT_EXEC_PATH=true.

Passing CI run: https://buildkite.com/bazel/google-bazel-presubmit/builds/3576

RELNOTES: N/A
PiperOrigin-RevId: 200050318
  • Loading branch information
Googler authored and Copybara-Service committed Jun 11, 2018
1 parent 6517366 commit bbf3e42
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tools/test/test-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ function is_absolute {
[[ "$1" = /* ]] || [[ "$1" =~ ^[a-zA-Z]:[/\\].* ]]
}

# The original execution root. Usually this script changes directory into the
# runfiles directory, so using $PWD is not a reliable way to find the execution
# root.
EXEC_ROOT="$PWD"

# Bazel sets some environment vars to relative paths to improve caching and
# support remote execution, where the absolute path may not be known to Bazel.
# Convert them to absolute paths here before running the actual test.
Expand Down Expand Up @@ -213,6 +218,20 @@ else
TEST_PATH="$(rlocation $TEST_WORKSPACE/$EXE)"
fi

# 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.
if [ ! -z "$TEST_SHORT_EXEC_PATH" ]; then
# Use a short path like "t0" in the execution root. Use the smallest numeric
# suffix that doesn't collide with an existing file or directory.
QUALIFIER=0
while [[ -e "${EXEC_ROOT}/t${QUALIFIER}" ]]; do
((QUALIFIER++))
done
ln -s "${TEST_PATH}" "${EXEC_ROOT}/t${QUALIFIER}"
TEST_PATH="${EXEC_ROOT}/t${QUALIFIER}"
fi

exitCode=0
signals="$(trap -l | sed -E 's/[0-9]+\)//g')"
for signal in $signals; do
Expand Down

0 comments on commit bbf3e42

Please sign in to comment.