• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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# TODO(absl-team): This script isn't fully hermetic because
18# -DABSL_USE_GOOGLETEST_HEAD=ON means that this script isn't pinned to a fixed
19# version of GoogleTest. This means that an upstream change to GoogleTest could
20# break this test. Fix this by allowing this script to pin to a known-good
21# version of GoogleTest.
22
23set -euox pipefail
24
25if [ -z ${ABSEIL_ROOT:-} ]; then
26  ABSEIL_ROOT="$(realpath $(dirname ${0})/..)"
27fi
28
29if [ -z ${ABSL_CMAKE_CXX_STANDARDS:-} ]; then
30  ABSL_CMAKE_CXX_STANDARDS="11 14 17"
31fi
32
33if [ -z ${ABSL_CMAKE_BUILD_TYPES:-} ]; then
34  ABSL_CMAKE_BUILD_TYPES="Debug Release"
35fi
36
37readonly DOCKER_CONTAINER="gcr.io/google.com/absl-177019/alpine:20191016"
38
39for std in ${ABSL_CMAKE_CXX_STANDARDS}; do
40  for compilation_mode in ${ABSL_CMAKE_BUILD_TYPES}; do
41    echo "--------------------------------------------------------------------"
42    echo "Testing with CMAKE_BUILD_TYPE=${compilation_mode} and -std=c++${std}"
43
44    time docker run \
45      --volume="${ABSEIL_ROOT}:/abseil-cpp:ro" \
46      --workdir=/abseil-cpp \
47      --tmpfs=/buildfs:exec \
48      --cap-add=SYS_PTRACE \
49      --rm \
50      -e CFLAGS="-Werror" \
51      -e CXXFLAGS="-Werror" \
52      "${DOCKER_CONTAINER}" \
53      /bin/sh -c "
54        cd /buildfs && \
55        cmake /abseil-cpp \
56          -DABSL_USE_GOOGLETEST_HEAD=ON \
57          -DABSL_RUN_TESTS=ON \
58          -DCMAKE_BUILD_TYPE=${compilation_mode} \
59          -DCMAKE_CXX_STANDARD=${std} && \
60        make -j$(nproc) && \
61        ctest -j$(nproc) --output-on-failure"
62  done
63done
64