Skip to content

Commit 5719306

Browse files
derekmaurocopybara-github
authored andcommitted
GoogleTest CI Update
* Use [email protected], which requires C++17 and removes any/optional/variant polyfills * Test C++23 * Support/test GCC15 * Use Bazel vendor mode to reduce reliance on GitHub PiperOrigin-RevId: 759184924 Change-Id: Ifb866cdd7faf1e5be475b44f69870745e21a3104
1 parent 9f79a95 commit 5719306

File tree

5 files changed

+76
-42
lines changed

5 files changed

+76
-42
lines changed

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ module(
4141

4242
bazel_dep(
4343
name = "abseil-cpp",
44-
version = "20250127.1",
44+
version = "20250512.0",
4545
)
4646
bazel_dep(
4747
name = "platforms",

ci/linux-presubmit.sh

Lines changed: 50 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,23 @@
3131

3232
set -euox pipefail
3333

34-
readonly LINUX_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20241218"
35-
readonly LINUX_GCC_FLOOR_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-floor:20250205"
34+
readonly LINUX_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20250430"
35+
readonly LINUX_GCC_FLOOR_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-floor:20250430"
3636

3737
if [[ -z ${GTEST_ROOT:-} ]]; then
3838
GTEST_ROOT="$(realpath $(dirname ${0})/..)"
3939
fi
4040

41+
# Use Bazel Vendor mode to reduce reliance on external dependencies.
42+
# See https://bazel.build/external/vendor and the Dockerfile for
43+
# an explaination of how this works.
44+
if [[ ${KOKORO_GFILE_DIR:-} ]] && [[ -f "${KOKORO_GFILE_DIR}/distdir/googletest_vendor.tar.gz" ]]; then
45+
DOCKER_EXTRA_ARGS="--mount type=bind,source=${KOKORO_GFILE_DIR}/distdir,target=/distdir,readonly --env=BAZEL_VENDOR_ARCHIVE=/distdir/googletest_vendor.tar.gz ${DOCKER_EXTRA_ARGS:-}"
46+
BAZEL_EXTRA_ARGS="--vendor_dir=/googletest_vendor ${BAZEL_EXTRA_ARGS:-}"
47+
fi
48+
4149
if [[ -z ${STD:-} ]]; then
42-
STD="c++17 c++20"
50+
STD="c++17 c++20 c++23"
4351
fi
4452

4553
# Test CMake + GCC
@@ -93,18 +101,21 @@ time docker run \
93101
--rm \
94102
--env="CC=/usr/local/bin/gcc" \
95103
--env="BAZEL_CXXOPTS=-std=c++17" \
104+
${DOCKER_EXTRA_ARGS:-} \
96105
${LINUX_GCC_FLOOR_CONTAINER} \
106+
/bin/bash --login -c "
97107
/usr/local/bin/bazel test ... \
98-
--copt="-Wall" \
99-
--copt="-Werror" \
100-
--copt="-Wuninitialized" \
101-
--copt="-Wundef" \
102-
--copt="-Wno-error=pragmas" \
108+
--copt=\"-Wall\" \
109+
--copt=\"-Werror\" \
110+
--copt=\"-Wuninitialized\" \
111+
--copt=\"-Wundef\" \
112+
--copt=\"-Wno-error=pragmas\" \
103113
--enable_bzlmod=false \
104114
--features=external_include_paths \
105115
--keep_going \
106116
--show_timestamps \
107-
--test_output=errors
117+
--test_output=errors \
118+
${BAZEL_EXTRA_ARGS:-}"
108119

109120
# Test GCC
110121
for std in ${STD}; do
@@ -115,18 +126,21 @@ for std in ${STD}; do
115126
--rm \
116127
--env="CC=/usr/local/bin/gcc" \
117128
--env="BAZEL_CXXOPTS=-std=${std}" \
129+
${DOCKER_EXTRA_ARGS:-} \
118130
${LINUX_LATEST_CONTAINER} \
119-
/usr/local/bin/bazel test ... \
120-
--copt="-Wall" \
121-
--copt="-Werror" \
122-
--copt="-Wuninitialized" \
123-
--copt="-Wundef" \
124-
--define="absl=${absl}" \
125-
--enable_bzlmod=true \
126-
--features=external_include_paths \
127-
--keep_going \
128-
--show_timestamps \
129-
--test_output=errors
131+
/bin/bash --login -c "
132+
/usr/local/bin/bazel test ... \
133+
--copt=\"-Wall\" \
134+
--copt=\"-Werror\" \
135+
--copt=\"-Wuninitialized\" \
136+
--copt=\"-Wundef\" \
137+
--define=\"absl=${absl}\" \
138+
--enable_bzlmod=true \
139+
--features=external_include_paths \
140+
--keep_going \
141+
--show_timestamps \
142+
--test_output=errors \
143+
${BAZEL_EXTRA_ARGS:-}"
130144
done
131145
done
132146

@@ -139,19 +153,22 @@ for std in ${STD}; do
139153
--rm \
140154
--env="CC=/opt/llvm/clang/bin/clang" \
141155
--env="BAZEL_CXXOPTS=-std=${std}" \
156+
${DOCKER_EXTRA_ARGS:-} \
142157
${LINUX_LATEST_CONTAINER} \
143-
/usr/local/bin/bazel test ... \
144-
--copt="--gcc-toolchain=/usr/local" \
145-
--copt="-Wall" \
146-
--copt="-Werror" \
147-
--copt="-Wuninitialized" \
148-
--copt="-Wundef" \
149-
--define="absl=${absl}" \
150-
--enable_bzlmod=true \
151-
--features=external_include_paths \
152-
--keep_going \
153-
--linkopt="--gcc-toolchain=/usr/local" \
154-
--show_timestamps \
155-
--test_output=errors
158+
/bin/bash --login -c "
159+
/usr/local/bin/bazel test ... \
160+
--copt=\"--gcc-toolchain=/usr/local\" \
161+
--copt=\"-Wall\" \
162+
--copt=\"-Werror\" \
163+
--copt=\"-Wuninitialized\" \
164+
--copt=\"-Wundef\" \
165+
--define=\"absl=${absl}\" \
166+
--enable_bzlmod=true \
167+
--features=external_include_paths \
168+
--keep_going \
169+
--linkopt=\"--gcc-toolchain=/usr/local\" \
170+
--show_timestamps \
171+
--test_output=errors \
172+
${BAZEL_EXTRA_ARGS:-}"
156173
done
157174
done

ci/macos-presubmit.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,20 @@ done
5656
# Test the Bazel build
5757

5858
# If we are running on Kokoro, check for a versioned Bazel binary.
59-
KOKORO_GFILE_BAZEL_BIN="bazel-8.0.0-darwin-x86_64"
59+
KOKORO_GFILE_BAZEL_BIN="bazel-8.2.1-darwin-x86_64"
6060
if [[ ${KOKORO_GFILE_DIR:-} ]] && [[ -f ${KOKORO_GFILE_DIR}/${KOKORO_GFILE_BAZEL_BIN} ]]; then
6161
BAZEL_BIN="${KOKORO_GFILE_DIR}/${KOKORO_GFILE_BAZEL_BIN}"
6262
chmod +x ${BAZEL_BIN}
6363
else
6464
BAZEL_BIN="bazel"
6565
fi
6666

67+
# Use Bazel Vendor mode to reduce reliance on external dependencies.
68+
if [[ ${KOKORO_GFILE_DIR:-} ]] && [[ -f "${KOKORO_GFILE_DIR}/distdir/googletest_vendor.tar.gz" ]]; then
69+
tar -xf "${KOKORO_GFILE_DIR}/distdir/googletest_vendor.tar.gz" -C "${TMP}/"
70+
BAZEL_EXTRA_ARGS="--vendor_dir=\"${TMP}/googletest_vendor\" ${BAZEL_EXTRA_ARGS:-}"
71+
fi
72+
6773
cd ${GTEST_ROOT}
6874
for absl in 0 1; do
6975
${BAZEL_BIN} test ... \
@@ -76,5 +82,6 @@ for absl in 0 1; do
7682
--features=external_include_paths \
7783
--keep_going \
7884
--show_timestamps \
79-
--test_output=errors
85+
--test_output=errors \
86+
${BAZEL_EXTRA_ARGS:-}
8087
done

ci/windows-presubmit.bat

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
SETLOCAL ENABLEDELAYEDEXPANSION
22

3-
SET BAZEL_EXE=%KOKORO_GFILE_DIR%\bazel-8.0.0-windows-x86_64.exe
3+
SET BAZEL_EXE=%KOKORO_GFILE_DIR%\bazel-8.2.1-windows-x86_64.exe
44

55
SET PATH=C:\Python34;%PATH%
66
SET BAZEL_PYTHON=C:\python34\python.exe
@@ -48,6 +48,14 @@ RMDIR /S /Q %CMAKE_BUILD_PATH%
4848
:: --output_user_root=C:\tmp causes Bazel to use a shorter path.
4949
SET BAZEL_VS=C:\Program Files\Microsoft Visual Studio\2022\Community
5050

51+
:: Use Bazel Vendor mode to reduce reliance on external dependencies.
52+
IF EXIST "%KOKORO_GFILE_DIR%\distdir\googletest_vendor.tar.gz" (
53+
tar --force-local -xf "%KOKORO_GFILE_DIR%\distdir\googletest_vendor.tar.gz" -C c:
54+
SET VENDOR_FLAG=--vendor_dir=c:\googletest_vendor
55+
) ELSE (
56+
SET VENDOR_FLAG=
57+
)
58+
5159
:: C++17
5260
%BAZEL_EXE% ^
5361
--output_user_root=C:\tmp ^
@@ -58,7 +66,8 @@ SET BAZEL_VS=C:\Program Files\Microsoft Visual Studio\2022\Community
5866
--enable_bzlmod=true ^
5967
--keep_going ^
6068
--test_output=errors ^
61-
--test_tag_filters=-no_test_msvc2017
69+
--test_tag_filters=-no_test_msvc2017 ^
70+
%VENDOR_FLAG%
6271
IF %errorlevel% neq 0 EXIT /B 1
6372

6473
:: C++20
@@ -71,5 +80,6 @@ IF %errorlevel% neq 0 EXIT /B 1
7180
--enable_bzlmod=true ^
7281
--keep_going ^
7382
--test_output=errors ^
74-
--test_tag_filters=-no_test_msvc2017
83+
--test_tag_filters=-no_test_msvc2017 ^
84+
%VENDOR_FLAG%
7585
IF %errorlevel% neq 0 EXIT /B 1

googletest_deps.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ def googletest_deps():
1717
if not native.existing_rule("abseil-cpp"):
1818
http_archive(
1919
name = "abseil-cpp",
20-
sha256 = "b396401fd29e2e679cace77867481d388c807671dc2acc602a0259eeb79b7811",
21-
strip_prefix = "abseil-cpp-20250127.1",
22-
urls = ["https://github.com/abseil/abseil-cpp/releases/download/20250127.1/abseil-cpp-20250127.1.tar.gz"],
20+
sha256 = "7262daa7c1711406248c10f41026d685e88223bc92817d16fb93c19adb57f669",
21+
strip_prefix = "abseil-cpp-20250512.0",
22+
urls = ["https://github.com/abseil/abseil-cpp/releases/download/20250512.0/abseil-cpp-20250512.0.tar.gz"],
2323
)
2424

2525
if not native.existing_rule("fuchsia_sdk"):

0 commit comments

Comments
 (0)