Skip to content

Commit

Permalink
[7.3.0] Add path mapping test for multiplex sandboxing (bazelbuild#23134
Browse files Browse the repository at this point in the history
)

Javac actions gained support for multiplex sandboxing with rules_java
7.5.0, which makes it possible to test path mapping in this mode.

Fixes bazelbuild#21091

Closes bazelbuild#21837.

PiperOrigin-RevId: 657111790
Change-Id: Ib08f2c0bc48d210cce013e328da0e871f73278aa

Commit
bazelbuild@8e79fe0

Co-authored-by: Fabian Meumertzheim <[email protected]>
  • Loading branch information
bazel-io and fmeum authored Jul 29, 2024
1 parent ffe1df5 commit 867cfe4
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/test/shell/bazel/path_mapping_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,54 @@ function test_path_stripping_singleplex_worker() {
expect_not_log '[0-9] worker'
}

function test_path_stripping_multiplex_worker() {
if is_windows; then
echo "Skipping test_path_stripping_multiplex_worker on Windows as it requires sandboxing"
return
fi

mkdir toolchain
cat > toolchain/BUILD <<'EOF'
load("@bazel_tools//tools/jdk:default_java_toolchain.bzl", "default_java_toolchain")
default_java_toolchain(
name = "java_toolchain",
source_version = "17",
target_version = "17",
javac_supports_worker_multiplex_sandboxing = True,
)
EOF

cache_dir=$(mktemp -d)

bazel run -c fastbuild \
--disk_cache=$cache_dir \
--experimental_output_paths=strip \
--strategy=Javac=worker \
--experimental_worker_multiplex_sandboxing \
--extra_toolchains=//toolchain:java_toolchain_definition \
--java_language_version=17 \
//src/main/java/com/example:Main &> $TEST_log || fail "run failed unexpectedly"
expect_log 'Hello, World!'
# JavaToolchainCompileBootClasspath, JavaToolchainCompileClasses and header compilation.
expect_log '3 \(linux\|darwin\|processwrapper\)-sandbox'
# Actual compilation actions.
expect_log '2 worker'
expect_not_log 'disk cache hit'

bazel run -c opt \
--disk_cache=$cache_dir \
--experimental_output_paths=strip \
--strategy=Javac=worker \
--experimental_worker_multiplex_sandboxing \
--extra_toolchains=//toolchain:java_toolchain_definition \
--java_language_version=17 \
//src/main/java/com/example:Main &> $TEST_log || fail "run failed unexpectedly"
expect_log 'Hello, World!'
expect_log '5 disk cache hit'
expect_not_log '[0-9] \(linux\|darwin\|processwrapper\)-sandbox'
expect_not_log '[0-9] worker'
}

function test_path_stripping_remote() {
bazel run -c fastbuild \
--experimental_output_paths=strip \
Expand Down

0 comments on commit 867cfe4

Please sign in to comment.