From 1a630b0c950081ca7670c5aa235d67a4fbe25729 Mon Sep 17 00:00:00 2001 From: hvd Date: Wed, 8 May 2024 10:14:14 +0200 Subject: [PATCH] Improve errors in integration tests when the local jdk is not found Related: https://github.com/bazelbuild/bazel/pull/21392 https://github.com/bazelbuild/bazel/pull/22228 --- src/test/shell/testenv.sh.tmpl | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/test/shell/testenv.sh.tmpl b/src/test/shell/testenv.sh.tmpl index 8a57f2e89f800d..e4f3c15aba0b54 100755 --- a/src/test/shell/testenv.sh.tmpl +++ b/src/test/shell/testenv.sh.tmpl @@ -258,9 +258,19 @@ function try_with_timeout() { function setup_localjdk_javabase() { if [[ $PLATFORM =~ msys ]]; then - jdk_dir="$(cygpath -m $(cd $(rlocation local_jdk/bin/java.exe)/../..; pwd))" + jdk_binary=local_jdk/bin/java.exe else - jdk_dir="$(dirname $(dirname $(rlocation local_jdk/bin/java)))" + jdk_binary=local_jdk/bin/java + fi + jdk_binary_rlocation=$(rlocation ${jdk_binary}) + if [[ -z "${jdk_binary_rlocation}" ]]; then + echo "error: failed to find $jdk_binary, make sure you have java \ +installed or pass --java_runtime_verison=XX with the correct version" >&2 + fi + if [[ $PLATFORM =~ msys ]]; then + jdk_dir="$(cygpath -m $(cd ${jdk_binary_rlocation}/../..; pwd))" + else + jdk_dir="$(dirname $(dirname ${jdk_binary_rlocation}))" fi bazel_javabase="${jdk_dir}" }