1#!/bin/bash 2# 3# Copyright 2019 The Abseil Authors. 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# https://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# This script is invoked on Kokoro to test Abseil on macOS. 18# It is not hermetic and may break when Kokoro is updated. 19 20set -euox pipefail 21 22# Use Xcode 16.0 23sudo xcode-select -s /Applications/Xcode_16.0.app/Contents/Developer 24 25if [[ -z ${ABSEIL_ROOT:-} ]]; then 26 ABSEIL_ROOT="$(realpath $(dirname ${0})/..)" 27fi 28 29# If we are running on Kokoro, check for a versioned Bazel binary. 30KOKORO_GFILE_BAZEL_BIN="bazel-8.0.0-darwin-x86_64" 31if [[ ${KOKORO_GFILE_DIR:-} ]] && [[ -f ${KOKORO_GFILE_DIR}/${KOKORO_GFILE_BAZEL_BIN} ]]; then 32 BAZEL_BIN="${KOKORO_GFILE_DIR}/${KOKORO_GFILE_BAZEL_BIN}" 33 chmod +x ${BAZEL_BIN} 34else 35 BAZEL_BIN="bazel" 36fi 37 38# Avoid depending on external sites like GitHub by checking --distdir for 39# external dependencies first. 40# https://docs.bazel.build/versions/master/guide.html#distdir 41if [[ ${KOKORO_GFILE_DIR:-} ]] && [[ -d "${KOKORO_GFILE_DIR}/distdir" ]]; then 42 BAZEL_EXTRA_ARGS="--distdir=${KOKORO_GFILE_DIR}/distdir ${BAZEL_EXTRA_ARGS:-}" 43fi 44 45# Print the compiler and Bazel versions. 46echo "---------------" 47gcc -v 48echo "---------------" 49${BAZEL_BIN} version 50echo "---------------" 51 52cd ${ABSEIL_ROOT} 53 54if [[ -n "${ALTERNATE_OPTIONS:-}" ]]; then 55 cp ${ALTERNATE_OPTIONS:-} absl/base/options.h || exit 1 56fi 57 58# Avoid using the system version of google-benchmark. 59brew uninstall google-benchmark 60 61${BAZEL_BIN} test ... \ 62 --copt="-DGTEST_REMOVE_LEGACY_TEST_CASEAPI_=1" \ 63 --copt="-Werror" \ 64 --cxxopt="-std=c++17" \ 65 --enable_bzlmod=true \ 66 --features=external_include_paths \ 67 --keep_going \ 68 --show_timestamps \ 69 --test_env="TZDIR=${ABSEIL_ROOT}/absl/time/internal/cctz/testdata/zoneinfo" \ 70 --test_output=errors \ 71 --test_tag_filters=-benchmark \ 72 ${BAZEL_EXTRA_ARGS:-} 73