1*9356374aSAndroid Build Coastguard Worker#!/bin/bash 2*9356374aSAndroid Build Coastguard Worker# 3*9356374aSAndroid Build Coastguard Worker# Copyright 2019 The Abseil Authors. 4*9356374aSAndroid Build Coastguard Worker# 5*9356374aSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); 6*9356374aSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License. 7*9356374aSAndroid Build Coastguard Worker# You may obtain a copy of the License at 8*9356374aSAndroid Build Coastguard Worker# 9*9356374aSAndroid Build Coastguard Worker# https://www.apache.org/licenses/LICENSE-2.0 10*9356374aSAndroid Build Coastguard Worker# 11*9356374aSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 12*9356374aSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, 13*9356374aSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14*9356374aSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and 15*9356374aSAndroid Build Coastguard Worker# limitations under the License. 16*9356374aSAndroid Build Coastguard Worker 17*9356374aSAndroid Build Coastguard Worker# This script is invoked on Kokoro to test Abseil on macOS. 18*9356374aSAndroid Build Coastguard Worker# It is not hermetic and may break when Kokoro is updated. 19*9356374aSAndroid Build Coastguard Worker 20*9356374aSAndroid Build Coastguard Workerset -euox pipefail 21*9356374aSAndroid Build Coastguard Worker 22*9356374aSAndroid Build Coastguard Workerif [[ -z ${ABSEIL_ROOT:-} ]]; then 23*9356374aSAndroid Build Coastguard Worker ABSEIL_ROOT="$(realpath $(dirname ${0})/..)" 24*9356374aSAndroid Build Coastguard Workerfi 25*9356374aSAndroid Build Coastguard Worker 26*9356374aSAndroid Build Coastguard Worker# If we are running on Kokoro, check for a versioned Bazel binary. 27*9356374aSAndroid Build Coastguard WorkerKOKORO_GFILE_BAZEL_BIN="bazel-7.0.0-darwin-x86_64" 28*9356374aSAndroid Build Coastguard Workerif [[ ${KOKORO_GFILE_DIR:-} ]] && [[ -f ${KOKORO_GFILE_DIR}/${KOKORO_GFILE_BAZEL_BIN} ]]; then 29*9356374aSAndroid Build Coastguard Worker BAZEL_BIN="${KOKORO_GFILE_DIR}/${KOKORO_GFILE_BAZEL_BIN}" 30*9356374aSAndroid Build Coastguard Worker chmod +x ${BAZEL_BIN} 31*9356374aSAndroid Build Coastguard Workerelse 32*9356374aSAndroid Build Coastguard Worker BAZEL_BIN="bazel" 33*9356374aSAndroid Build Coastguard Workerfi 34*9356374aSAndroid Build Coastguard Worker 35*9356374aSAndroid Build Coastguard Worker# Avoid depending on external sites like GitHub by checking --distdir for 36*9356374aSAndroid Build Coastguard Worker# external dependencies first. 37*9356374aSAndroid Build Coastguard Worker# https://docs.bazel.build/versions/master/guide.html#distdir 38*9356374aSAndroid Build Coastguard Workerif [[ ${KOKORO_GFILE_DIR:-} ]] && [[ -d "${KOKORO_GFILE_DIR}/distdir" ]]; then 39*9356374aSAndroid Build Coastguard Worker BAZEL_EXTRA_ARGS="--distdir=${KOKORO_GFILE_DIR}/distdir ${BAZEL_EXTRA_ARGS:-}" 40*9356374aSAndroid Build Coastguard Workerfi 41*9356374aSAndroid Build Coastguard Worker 42*9356374aSAndroid Build Coastguard Worker# Print the compiler and Bazel versions. 43*9356374aSAndroid Build Coastguard Workerecho "---------------" 44*9356374aSAndroid Build Coastguard Workergcc -v 45*9356374aSAndroid Build Coastguard Workerecho "---------------" 46*9356374aSAndroid Build Coastguard Worker${BAZEL_BIN} version 47*9356374aSAndroid Build Coastguard Workerecho "---------------" 48*9356374aSAndroid Build Coastguard Worker 49*9356374aSAndroid Build Coastguard Workercd ${ABSEIL_ROOT} 50*9356374aSAndroid Build Coastguard Worker 51*9356374aSAndroid Build Coastguard Workerif [[ -n "${ALTERNATE_OPTIONS:-}" ]]; then 52*9356374aSAndroid Build Coastguard Worker cp ${ALTERNATE_OPTIONS:-} absl/base/options.h || exit 1 53*9356374aSAndroid Build Coastguard Workerfi 54*9356374aSAndroid Build Coastguard Worker 55*9356374aSAndroid Build Coastguard Worker${BAZEL_BIN} test ... \ 56*9356374aSAndroid Build Coastguard Worker --copt="-DGTEST_REMOVE_LEGACY_TEST_CASEAPI_=1" \ 57*9356374aSAndroid Build Coastguard Worker --copt="-Werror" \ 58*9356374aSAndroid Build Coastguard Worker --cxxopt="-std=c++14" \ 59*9356374aSAndroid Build Coastguard Worker --enable_bzlmod=true \ 60*9356374aSAndroid Build Coastguard Worker --features=external_include_paths \ 61*9356374aSAndroid Build Coastguard Worker --keep_going \ 62*9356374aSAndroid Build Coastguard Worker --show_timestamps \ 63*9356374aSAndroid Build Coastguard Worker --test_env="TZDIR=${ABSEIL_ROOT}/absl/time/internal/cctz/testdata/zoneinfo" \ 64*9356374aSAndroid Build Coastguard Worker --test_output=errors \ 65*9356374aSAndroid Build Coastguard Worker --test_tag_filters=-benchmark \ 66*9356374aSAndroid Build Coastguard Worker ${BAZEL_EXTRA_ARGS:-} 67