#!/bin/bash # Copyright 2016 The Bazel Authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Tests that our --host_javabase startup selection algorithm works. # Load the test setup defined in the parent directory global CURRENT_DIR := $[cd $[dirname $(BASH_SOURCE[0])] && pwd] source "$(CURRENT_DIR)/../integration_test_setup.sh" \ || do { echo "integration_test_setup.sh not found!" > !2; exit 1; } proc test_use_depot_javabase { bazel --batch version > !$TEST_log || fail "Couldn't run $(PRODUCT_NAME)" expect_not_log "Couldn't find java at" expect_not_log "Problem with java installation" } proc test_fallback_depot_javabase { bazel --batch --host_javabase=/does/not/exist version > !$TEST_log || shell {expect_log "Couldn't find java at" && expect_not_log "Problem with java installation"} } run_suite "Tests of specifying custom javabase." (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:CURRENT_DIR) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [ (AndOr children: [ (C {(cd)} { (DQ (CommandSubPart command_list: (CommandList children: [ (C {(dirname)} { (DQ (BracedVarSub token: bracket_op: (ArrayIndex expr: (ArithWord w:{(Lit_Digits 0)}) ) spids: [60 65] ) ) } ) ] ) left_token: spids: [56 67] ) ) } ) (C {(pwd)}) ] op_id: Op_DAmp ) ] ) left_token: spids: [52 73] ) ) } spids: [50] ) ] spids: [50] ) (AndOr children: [ (C {(source)} {(DQ (${ VSub_Name CURRENT_DIR) (/../integration_test_setup.sh))}) (BraceGroup children: [ (Sentence child: (SimpleCommand words: [{(echo)} {(DQ ("integration_test_setup.sh not found!"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[97])] ) terminator: ) (Sentence child:(C {(exit)} {(1)}) terminator:) ] spids: [89] ) ] op_id: Op_DPipe ) (FuncDef name: test_use_depot_javabase body: (BraceGroup children: [ (AndOr children: [ (SimpleCommand words: [{(bazel)} {(--batch)} {(version)}] redirects: [ (Redir op_id: Redir_GreatAnd fd: -1 arg_word: {($ VSub_Name "$TEST_log")} spids: [124] ) ] ) (C {(fail)} {(DQ ("Couldn't run ") (${ VSub_Name PRODUCT_NAME))}) ] op_id: Op_DPipe ) (C {(expect_not_log)} {(DQ ("Couldn't find java at"))}) (C {(expect_not_log)} {(DQ ("Problem with java installation"))}) ] spids: [115] ) spids: [109 114] ) (FuncDef name: test_fallback_depot_javabase body: (BraceGroup children: [ (AndOr children: [ (SimpleCommand words: [ {(bazel)} {(--batch)} {(--host_javabase) (Lit_Other "=") (/does/not/exist)} {(version)} ] redirects: [ (Redir op_id: Redir_GreatAnd fd: -1 arg_word: {($ VSub_Name "$TEST_log")} spids: [175] ) ] ) (Subshell child: (AndOr children: [ (C {(expect_log)} {(DQ ("Couldn't find java at"))}) (C {(expect_not_log)} {(DQ ("Problem with java installation"))}) ] op_id: Op_DAmp ) spids: [182 197] ) ] op_id: Op_DPipe ) ] spids: [162] ) spids: [156 161] ) (C {(run_suite)} {(DQ ("Tests of specifying custom javabase."))}) ] )