Skip to content

Commit

Permalink
Enable Blaze path mapping test for Bazel
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Oct 4, 2023
1 parent 01ad342 commit 73ec1ad
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 25 deletions.
3 changes: 3 additions & 0 deletions src/test/shell/integration/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,9 @@ sh_test(
":test-deps",
"@bazel_tools//tools/bash/runfiles",
],
tags = [
"no_windows", # path mapping is not supported for non-remote execution on Windows
],
)

sh_library(
Expand Down
4 changes: 2 additions & 2 deletions src/test/shell/integration/config_stripped_outputs_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function assert_paths_stripped() {
found_identifying_output=0

# Check every output path in the action command line is stripped.
for o in $(echo $cmd | xargs -d' ' -n 1 | egrep -o "${bazel_out}[^)]*"); do
for o in $(echo $cmd | tr -s ' ' '\n' | xargs -n 1 | grep -E -o "${bazel_out}[^)]*"); do
echo "$o" | grep -v "${bazel_out}/bin" \
&& fail "expected all \"${bazel_out}\" paths to start with " \
"\"${bazel_out}/bin.*\": $o"
Expand All @@ -50,7 +50,7 @@ function assert_paths_stripped() {
done

# Check every output path in every .params file is stripped.
for o in $(echo $cmd | xargs -d' ' -n 1 | egrep -o "${bazel_out}[^)]*.params"); do
for o in $(echo $cmd | tr -s ' ' '\n' | xargs -n 1 | grep -E -o "${bazel_out}[^)]*.params"); do
bin_relative_path=$(echo $o | sed -r "s|${bazel_out}/bin/||")
local_path="${bazel_out:0:5}-bin/${bin_relative_path}"
for k in $(grep "${bazel_out}" $local_path); do
Expand Down
30 changes: 7 additions & 23 deletions src/test/shell/integration/config_stripped_outputs_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,11 @@ source "$(rlocation "io_bazel/src/test/shell/integration/config_stripped_outputs
|| { echo "config_stripped_outputs_lib.sh not found!" >&2; exit 1; }


case "$(uname -s | tr [:upper:] [:lower:])" in
msys*|mingw*|cygwin*)
declare -r is_windows=true
;;
*)
declare -r is_windows=false
;;
esac

if "$is_windows"; then
export MSYS_NO_PATHCONV=1
export MSYS2_ARG_CONV_EXCL="*"
fi

add_to_bazelrc "test --notest_loasd"
add_to_bazelrc "build --package_path=%workspace%"

# This is what triggers config path stripping.
add_to_bazelrc "build --experimental_output_paths=strip"

# Remove this check when Bazel supports path mapping. This requires a complying
# executor. See https://github.com/bazelbuild/bazel/pull/18155.
function is_bazel() {
output_path=$(bazel info | grep '^output_path:')
bazel_out="${output_path##*/}"
Expand All @@ -92,12 +75,16 @@ function is_bazel() {
fi
}

# Remove this check when Javac actions support multiplex worker sandboxing.
if is_bazel; then
add_to_bazelrc "build --strategy=Javac=worker"
add_to_bazelrc "build --worker_sandboxing"
add_to_bazelrc "build --noexperimental_worker_multiplex"
fi

# Tests built-in Java support for stripping config path prefixes from
# platform-independent actions.
function test_builtin_java_support() {
# TODO(https://github.com/bazelbuild/bazel/pull/18155): support Bazel.
if is_bazel; then return; fi

local -r pkg="${FUNCNAME[0]}"
mkdir -p "$pkg"
cat > "$pkg/BUILD" <<EOF
Expand Down Expand Up @@ -180,9 +167,6 @@ EOF
}

function test_inmemory_jdeps_support() {
# TODO(https://github.com/bazelbuild/bazel/pull/18155): support Bazel.
if is_bazel; then return; fi

local -r pkg="${FUNCNAME[0]}"
write_java_classpath_reduction_files "$pkg"

Expand Down

0 comments on commit 73ec1ad

Please sign in to comment.