|
| 1 | +#!/bin/bash |
| 2 | +# |
| 3 | +# Copyright 2020 The Bazel Authors. All rights reserved. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | +# |
| 17 | +# Test of Bazel's startup option handling cof the nojdk version. |
| 18 | + |
| 19 | +# --- begin runfiles.bash initialization --- |
| 20 | +set -euo pipefail |
| 21 | +if [[ ! -d "${RUNFILES_DIR:-/dev/null}" && ! -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then |
| 22 | + if [[ -f "$0.runfiles_manifest" ]]; then |
| 23 | + export RUNFILES_MANIFEST_FILE="$0.runfiles_manifest" |
| 24 | + elif [[ -f "$0.runfiles/MANIFEST" ]]; then |
| 25 | + export RUNFILES_MANIFEST_FILE="$0.runfiles/MANIFEST" |
| 26 | + elif [[ -f "$0.runfiles/bazel_tools/tools/bash/runfiles/runfiles.bash" ]]; then |
| 27 | + export RUNFILES_DIR="$0.runfiles" |
| 28 | + fi |
| 29 | +fi |
| 30 | +if [[ -f "${RUNFILES_DIR:-/dev/null}/bazel_tools/tools/bash/runfiles/runfiles.bash" ]]; then |
| 31 | + source "${RUNFILES_DIR}/bazel_tools/tools/bash/runfiles/runfiles.bash" |
| 32 | +elif [[ -f "${RUNFILES_MANIFEST_FILE:-/dev/null}" ]]; then |
| 33 | + source "$(grep -m1 "^bazel_tools/tools/bash/runfiles/runfiles.bash " \ |
| 34 | + "$RUNFILES_MANIFEST_FILE" | cut -d ' ' -f 2-)" |
| 35 | +else |
| 36 | + echo >&2 "ERROR: cannot find @bazel_tools//tools/bash/runfiles:runfiles.bash" |
| 37 | + exit 1 |
| 38 | +fi |
| 39 | +# --- end runfiles.bash initialization --- |
| 40 | + |
| 41 | +# We don't want to use the cached, extracted bazel. It will have a different |
| 42 | +# sha1 and fail the test. The 2 version commands below are cheap. |
| 43 | +unset TEST_INSTALL_BASE |
| 44 | + |
| 45 | +export BAZEL_SUFFIX="_nojdk" |
| 46 | +source "$(rlocation "io_bazel/src/test/shell/integration_test_setup.sh")" \ |
| 47 | + || { echo "integration_test_setup.sh not found!" >&2; exit 1; } |
| 48 | + |
| 49 | +case "$(uname -s | tr [:upper:] [:lower:])" in |
| 50 | +msys*|mingw*|cygwin*) |
| 51 | + declare -r is_windows=true |
| 52 | + ;; |
| 53 | +*) |
| 54 | + declare -r is_windows=false |
| 55 | + ;; |
| 56 | +esac |
| 57 | + |
| 58 | +if "$is_windows"; then |
| 59 | + export MSYS_NO_PATHCONV=1 |
| 60 | + export MSYS2_ARG_CONV_EXCL="*" |
| 61 | +fi |
| 62 | + |
| 63 | +# Test that nojdk bazel works with --autodetect_server_javabase |
| 64 | +function test_autodetect_server_javabase() { |
| 65 | + bazel --autodetect_server_javabase version &> $TEST_log || fail "Should pass" |
| 66 | +} |
| 67 | + |
| 68 | +# Test that nojdk bazel fails with --noautodetect_server_javabase |
| 69 | +function test_noautodetect_server_javabase() { |
| 70 | + bazel --noautodetect_server_javabase version &> $TEST_log && fail "Should fail" |
| 71 | + expect_log "FATAL: Could not find embedded or explicit server javabase, and --noautodetect_server_javabase is set." |
| 72 | +} |
| 73 | + |
| 74 | +run_suite "${PRODUCT_NAME} startup options test" |
0 commit comments