#!/bin/bash # # Copyright 2015 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. # # Setting up the environment for Bazel integration tests. # test -z $TEST_SRCDIR && do { echo "TEST_SRCDIR not set!" > !2; exit 1; } # Load the unit-testing framework source "$(TEST_SRCDIR)/io_bazel/src/test/shell/unittest.bash" || \ do { echo "Failed to source unittest.bash" > !2; exit 1; } ## OSX/BSD stat and MD5 global PLATFORM := $[uname -s | tr 'A-Z' 'a-z] if [[ "$PLATFORM" = "linux" ]] { proc statfmt { stat -c "%s" $1 } global MD5SUM := 'md5sum' } else { proc statfmt { stat -f "%z" $1 } global MD5SUM := '/sbin/md5' } (CommandList children: [ (AndOr children: [ (C {(Lit_Other "[")} {(-z)} {(DQ ($ VSub_Name "$TEST_SRCDIR"))} {(Lit_Other "]")}) (BraceGroup children: [ (Sentence child: (SimpleCommand words: [{(echo)} {(DQ ("TEST_SRCDIR not set!"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[75])] ) terminator: ) (Sentence child:(C {(exit)} {(1)}) terminator:) ] spids: [67] ) ] op_id: Op_DAmp ) (AndOr children: [ (C {(source)} {(DQ (${ VSub_Name TEST_SRCDIR) (/io_bazel/src/test/shell/unittest.bash))}) (BraceGroup children: [ (Sentence child: (SimpleCommand words: [{(echo)} {(DQ ("Failed to source unittest.bash"))}] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[111])] ) terminator: ) (Sentence child:(C {(exit)} {(1)}) terminator:) ] spids: [103] ) ] op_id: Op_DPipe ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:PLATFORM) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [(C {(uname)} {(-s)}) (C {(tr)} {(SQ )} {(SQ )})] negated: False ) ] ) left_token: spids: [128 144] ) ) } spids: [126] ) ] spids: [126] ) (If arms: [ (if_arm cond: [ (Sentence child: (DBracket expr: (BoolBinary op_id: BoolBinary_GlobEqual left: {(DQ ($ VSub_Name "$PLATFORM"))} right: {(DQ (linux))} ) ) terminator: ) ] action: [ (FuncDef name: statfmt body: (BraceGroup children: [(C {(stat)} {(-c)} {(DQ ("%s"))} {($ VSub_Number "$1")})] spids: [173] ) spids: [167 172] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:MD5SUM) op:Equal rhs:{(md5sum)} spids:[190])] spids: [190] ) ] spids: [-1 164] ) ] else_action: [ (FuncDef name: statfmt body: (BraceGroup children: [(C {(stat)} {(-f)} {(DQ ("%z"))} {($ VSub_Number "$1")})] spids: [202] ) spids: [196 201] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:MD5SUM) op:Equal rhs:{(/sbin/md5)} spids:[219])] spids: [219] ) ] spids: [193 222] ) ] )