Skip to content

Commit

Permalink
fix bazel_with_jdk_test to properly depend on JAVABASE
Browse files Browse the repository at this point in the history
Progress towards #8033

Closes #8042.

PiperOrigin-RevId: 243606106
  • Loading branch information
buchgr authored and copybara-github committed Apr 15, 2019
1 parent 8fe5479 commit 6b1f66c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/test/shell/bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -641,12 +641,14 @@ sh_test(
name = "bazel_with_jdk_test",
size = "medium",
srcs = ["bazel_with_jdk_test.sh"],
args = ["$(JAVABASE)"],
data = [
":test-deps",
"//src:bazel",
"@bazel_tools//tools/bash/runfiles",
],
tags = ["no_windows"],
toolchains = ["@bazel_tools//tools/jdk:current_java_runtime"],
)

sh_test(
Expand Down
15 changes: 14 additions & 1 deletion src/test/shell/bazel/bazel_with_jdk_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@ if "$is_windows"; then
export MSYS2_ARG_CONV_EXCL="*"
fi

if "$is_windows"; then
EXE_EXT=".exe"
else
EXE_EXT=""
fi

javabase="$1"
if [[ $javabase = external/* ]]; then
javabase=${javabase#external/}
fi
javabase="$(rlocation "${javabase}/bin/java${EXE_EXT}")"
javabase=${javabase%/bin/java${EXE_EXT}}

function bazel() {
$(rlocation io_bazel/src/bazel) --bazelrc=$TEST_TMPDIR/bazelrc "$@"
return $?
Expand All @@ -82,7 +95,7 @@ function set_up() {
fgrep -v -- "--host_javabase" "$TEST_TMPDIR/bazelrc" > "$TEST_TMPDIR/bazelrc.new"
mv "$TEST_TMPDIR/bazelrc.new" "$TEST_TMPDIR/bazelrc"
# ... but ensure JAVA_HOME is set, so we can find a default --javabase
export JAVA_HOME="${bazel_javabase}"
export JAVA_HOME="${javabase}"
}

function test_bazel_uses_bundled_jdk() {
Expand Down

0 comments on commit 6b1f66c

Please sign in to comment.