blob: 1ba02b266071593fbc4ffbbdd0a0c2a07a6fd1f8 [file] [log] [blame]
Abseil Team74d91752019-07-03 12:13:04 -07001#!/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
Abseil Teamd43b7992020-04-03 13:24:29 -070025if [[ -z ${ABSEIL_ROOT:-} ]]; then
Abseil Team74d91752019-07-03 12:13:04 -070026 ABSEIL_ROOT="$(realpath $(dirname ${0})/..)"
27fi
28
Abseil Teamd43b7992020-04-03 13:24:29 -070029if [[ -z ${ABSL_CMAKE_CXX_STANDARDS:-} ]]; then
Abseil Teamf2c9c662020-09-09 19:13:17 -070030 ABSL_CMAKE_CXX_STANDARDS="11 14 17 20"
Abseil Team74d91752019-07-03 12:13:04 -070031fi
32
Abseil Teamd43b7992020-04-03 13:24:29 -070033if [[ -z ${ABSL_CMAKE_BUILD_TYPES:-} ]]; then
Abseil Team74d91752019-07-03 12:13:04 -070034 ABSL_CMAKE_BUILD_TYPES="Debug Release"
35fi
36
Abseil Team092ed972020-03-20 09:47:42 -070037source "${ABSEIL_ROOT}/ci/linux_docker_containers.sh"
38readonly DOCKER_CONTAINER=${LINUX_GCC_LATEST_CONTAINER}
39
Abseil Team74d91752019-07-03 12:13:04 -070040for std in ${ABSL_CMAKE_CXX_STANDARDS}; do
41 for compilation_mode in ${ABSL_CMAKE_BUILD_TYPES}; do
42 echo "--------------------------------------------------------------------"
43 echo "Testing with CMAKE_BUILD_TYPE=${compilation_mode} and -std=c++${std}"
44
45 time docker run \
46 --volume="${ABSEIL_ROOT}:/abseil-cpp:ro" \
47 --workdir=/abseil-cpp \
48 --tmpfs=/buildfs:exec \
49 --cap-add=SYS_PTRACE \
50 --rm \
51 -e CFLAGS="-Werror" \
52 -e CXXFLAGS="-Werror" \
Abseil Team092ed972020-03-20 09:47:42 -070053 ${DOCKER_CONTAINER} \
Abseil Team74d91752019-07-03 12:13:04 -070054 /bin/bash -c "
55 cd /buildfs && \
56 cmake /abseil-cpp \
57 -DABSL_USE_GOOGLETEST_HEAD=ON \
58 -DABSL_RUN_TESTS=ON \
59 -DCMAKE_BUILD_TYPE=${compilation_mode} \
60 -DCMAKE_CXX_STANDARD=${std} && \
61 make -j$(nproc) && \
62 ctest -j$(nproc) --output-on-failure"
63 done
64done