The branch stable/14 has been updated by ngie: URL: https://cgit.FreeBSD.org/src/commit/?id=887f0f125fd1282c8054b402ad72af371a9f5dec
commit 887f0f125fd1282c8054b402ad72af371a9f5dec Author: Enji Cooper <[email protected]> AuthorDate: 2026-02-22 05:17:40 +0000 Commit: Enji Cooper <[email protected]> CommitDate: 2026-02-22 05:17:40 +0000 Revert "GoogleTest: import 1.17.0" This reverts commit 227baf32d26360137492b108aba06c6a54c0949b. --- contrib/googletest/.github/workflows/gtest-ci.yml | 43 +++ contrib/googletest/.gitignore | 1 - contrib/googletest/.travis.yml | 81 ++++ contrib/googletest/BUILD.bazel | 40 +- contrib/googletest/CMakeLists.txt | 4 +- contrib/googletest/MODULE.bazel | 49 ++- contrib/googletest/README.md | 15 +- contrib/googletest/WORKSPACE | 49 +-- contrib/googletest/ci/linux-presubmit.sh | 76 ++-- contrib/googletest/ci/macos-presubmit.sh | 11 +- contrib/googletest/ci/windows-presubmit.bat | 38 +- contrib/googletest/docs/advanced.md | 120 +++--- contrib/googletest/docs/faq.md | 13 + contrib/googletest/docs/gmock_cook_book.md | 73 +--- contrib/googletest/docs/primer.md | 4 +- contrib/googletest/docs/quickstart-bazel.md | 53 +-- contrib/googletest/docs/reference/actions.md | 3 +- contrib/googletest/docs/reference/assertions.md | 11 +- contrib/googletest/docs/reference/matchers.md | 11 +- contrib/googletest/docs/reference/testing.md | 99 +---- contrib/googletest/fake_fuchsia_sdk.bzl | 36 +- .../googlemock/include/gmock/gmock-actions.h | 119 +----- .../googlemock/include/gmock/gmock-matchers.h | 419 ++++----------------- .../googlemock/include/gmock/gmock-more-actions.h | 16 +- .../googlemock/include/gmock/gmock-spec-builders.h | 10 +- .../include/gmock/internal/gmock-internal-utils.h | 5 + .../googlemock/include/gmock/internal/gmock-port.h | 1 - .../googlemock/src/gmock-cardinalities.cc | 8 +- .../googlemock/test/gmock-actions_test.cc | 78 +--- .../googlemock/test/gmock-function-mocker_test.cc | 4 +- .../test/gmock-matchers-arithmetic_test.cc | 237 ++---------- .../test/gmock-matchers-comparisons_test.cc | 136 +------ .../test/gmock-matchers-containers_test.cc | 336 +---------------- .../googlemock/test/gmock-matchers-misc_test.cc | 105 ++---- .../googlemock/test/gmock-more-actions_test.cc | 49 +-- .../googletest/googlemock/test/gmock-pp_test.cc | 2 +- .../googlemock/test/gmock-spec-builders_test.cc | 7 +- .../googletest/googlemock/test/gmock_link_test.h | 2 +- contrib/googletest/googletest/README.md | 6 +- .../googletest/cmake/internal_utils.cmake | 2 +- .../include/gtest/gtest-assertion-result.h | 7 - .../googletest/include/gtest/gtest-matchers.h | 6 +- .../googletest/include/gtest/gtest-param-test.h | 134 ++----- .../googletest/include/gtest/gtest-printers.h | 39 -- .../googletest/include/gtest/gtest-typed-test.h | 126 ++++--- .../googletest/googletest/include/gtest/gtest.h | 4 +- .../include/gtest/internal/gtest-internal.h | 84 +++-- .../include/gtest/internal/gtest-param-util.h | 62 +-- .../googletest/include/gtest/internal/gtest-port.h | 82 +++- .../googletest/googletest/src/gtest-internal-inl.h | 4 - contrib/googletest/googletest/src/gtest.cc | 191 ++-------- contrib/googletest/googletest/test/BUILD.bazel | 68 +--- .../googletest/test/googletest-filter-unittest.py | 19 - .../test/googletest-json-output-unittest.py | 111 +----- .../googletest/test/googletest-param-test-test.cc | 70 ---- .../googletest/test/googletest-printers-test.cc | 32 +- .../test/googletest-setuptestsuite-test_.cc | 4 +- .../googletest/googletest/test/gtest_unittest.cc | 56 +-- .../googletest/test/gtest_xml_output_unittest.py | 93 ++--- .../googletest/test/gtest_xml_output_unittest_.cc | 22 +- contrib/googletest/googletest_deps.bzl | 14 +- 61 files changed, 916 insertions(+), 2684 deletions(-) diff --git a/contrib/googletest/.github/workflows/gtest-ci.yml b/contrib/googletest/.github/workflows/gtest-ci.yml new file mode 100644 index 000000000000..03a8cc5e287b --- /dev/null +++ b/contrib/googletest/.github/workflows/gtest-ci.yml @@ -0,0 +1,43 @@ +name: ci + +on: + push: + pull_request: + +env: + BAZEL_CXXOPTS: -std=c++14 + +jobs: + Linux: + runs-on: ubuntu-latest + steps: + + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Tests + run: bazel test --cxxopt=-std=c++14 --features=external_include_paths --test_output=errors ... + + macOS: + runs-on: macos-latest + steps: + + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Tests + run: bazel test --cxxopt=-std=c++14 --features=external_include_paths --test_output=errors ... + + + Windows: + runs-on: windows-latest + steps: + + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Tests + run: bazel test --cxxopt=/std:c++14 --features=external_include_paths --test_output=errors ... diff --git a/contrib/googletest/.gitignore b/contrib/googletest/.gitignore index f0df39db1d7e..fede02f65093 100644 --- a/contrib/googletest/.gitignore +++ b/contrib/googletest/.gitignore @@ -8,7 +8,6 @@ bazel-genfiles bazel-googletest bazel-out bazel-testlogs -MODULE.bazel.lock # python *.pyc diff --git a/contrib/googletest/.travis.yml b/contrib/googletest/.travis.yml new file mode 100644 index 000000000000..4e7413a4f9a3 --- /dev/null +++ b/contrib/googletest/.travis.yml @@ -0,0 +1,81 @@ +# Build matrix / environment variable are explained on: +# https://docs.travis-ci.com/user/customizing-the-build/ +# This file can be validated on: +# http://lint.travis-ci.org/ + +sudo: false +language: cpp + +# Define the matrix explicitly, manually expanding the combinations of (os, compiler, env). +# It is more tedious, but grants us far more flexibility. +matrix: + include: + - os: linux + compiler: gcc + sudo : true + install: ./ci/install-linux.sh && ./ci/log-config.sh + script: ./ci/build-linux-bazel.sh + - os: linux + compiler: clang + sudo : true + install: ./ci/install-linux.sh && ./ci/log-config.sh + script: ./ci/build-linux-bazel.sh + - os: linux + group: deprecated-2017Q4 + compiler: gcc + install: ./ci/install-linux.sh && ./ci/log-config.sh + script: ./ci/build-linux-autotools.sh + - os: linux + group: deprecated-2017Q4 + compiler: gcc + env: BUILD_TYPE=Debug VERBOSE=1 CXX_FLAGS=-std=c++11 + - os: linux + group: deprecated-2017Q4 + compiler: clang + env: BUILD_TYPE=Debug VERBOSE=1 + - os: linux + group: deprecated-2017Q4 + compiler: clang + env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 + - os: linux + compiler: clang + env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 NO_EXCEPTION=ON NO_RTTI=ON COMPILER_IS_GNUCXX=ON + - os: osx + compiler: gcc + env: BUILD_TYPE=Debug VERBOSE=1 + - os: osx + compiler: gcc + env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 + - os: osx + compiler: clang + env: BUILD_TYPE=Debug VERBOSE=1 + if: type != pull_request + - os: osx + env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 + if: type != pull_request + +# These are the install and build (script) phases for the most common entries in the matrix. They could be included +# in each entry in the matrix, but that is just repetitive. +install: + - ./ci/install-${TRAVIS_OS_NAME}.sh + - . ./ci/env-${TRAVIS_OS_NAME}.sh + - ./ci/log-config.sh + +script: ./ci/travis.sh + +# For sudo=false builds this section installs the necessary dependencies. +addons: + apt: + # List of whitelisted in travis packages for ubuntu-precise can be found here: + # https://github.com/travis-ci/apt-package-whitelist/blob/master/ubuntu-precise + # List of whitelisted in travis apt-sources: + # https://github.com/travis-ci/apt-source-whitelist/blob/master/ubuntu.json + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.9 + packages: + - g++-4.9 + - clang-3.9 + +notifications: + email: false diff --git a/contrib/googletest/BUILD.bazel b/contrib/googletest/BUILD.bazel index 53501454ce4f..e407ae29f44c 100644 --- a/contrib/googletest/BUILD.bazel +++ b/contrib/googletest/BUILD.bazel @@ -83,10 +83,6 @@ cc_library( ) # Google Test including Google Mock - -# For an actual test, use `gtest` and also `gtest_main` if you depend on gtest's -# main(). For a library, use `gtest_for_library` instead if the library can be -# testonly. cc_library( name = "gtest", srcs = glob( @@ -142,19 +138,19 @@ cc_library( }), deps = select({ ":has_absl": [ - "@abseil-cpp//absl/container:flat_hash_set", - "@abseil-cpp//absl/debugging:failure_signal_handler", - "@abseil-cpp//absl/debugging:stacktrace", - "@abseil-cpp//absl/debugging:symbolize", - "@abseil-cpp//absl/flags:flag", - "@abseil-cpp//absl/flags:parse", - "@abseil-cpp//absl/flags:reflection", - "@abseil-cpp//absl/flags:usage", - "@abseil-cpp//absl/strings", - "@abseil-cpp//absl/types:any", - "@abseil-cpp//absl/types:optional", - "@abseil-cpp//absl/types:variant", - "@re2//:re2", + "@com_google_absl//absl/container:flat_hash_set", + "@com_google_absl//absl/debugging:failure_signal_handler", + "@com_google_absl//absl/debugging:stacktrace", + "@com_google_absl//absl/debugging:symbolize", + "@com_google_absl//absl/flags:flag", + "@com_google_absl//absl/flags:parse", + "@com_google_absl//absl/flags:reflection", + "@com_google_absl//absl/flags:usage", + "@com_google_absl//absl/strings", + "@com_google_absl//absl/types:any", + "@com_google_absl//absl/types:optional", + "@com_google_absl//absl/types:variant", + "@com_googlesource_code_re2//:re2", ], "//conditions:default": [], }) + select({ @@ -171,16 +167,6 @@ cc_library( }), ) -# `gtest`, but testonly. See guidance on `gtest` for when to use this. -alias( - name = "gtest_for_library", - actual = ":gtest", - testonly = True, -) - -# Implements main() for tests using gtest. Prefer to depend on `gtest` as well -# to ensure compliance with the layering_check Bazel feature where only the -# direct hdrs values are available. cc_library( name = "gtest_main", srcs = ["googlemock/src/gmock_main.cc"], diff --git a/contrib/googletest/CMakeLists.txt b/contrib/googletest/CMakeLists.txt index 0567ae7daa32..512e5c3d480f 100644 --- a/contrib/googletest/CMakeLists.txt +++ b/contrib/googletest/CMakeLists.txt @@ -1,10 +1,10 @@ # Note: CMake support is community-based. The maintainers do not use CMake # internally. -cmake_minimum_required(VERSION 3.16) +cmake_minimum_required(VERSION 3.13) project(googletest-distribution) -set(GOOGLETEST_VERSION 1.17.0) +set(GOOGLETEST_VERSION 1.15.2) if(NOT CYGWIN AND NOT MSYS AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL QNX) set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/contrib/googletest/MODULE.bazel b/contrib/googletest/MODULE.bazel index 5cb0b156f40c..61d5e2223512 100644 --- a/contrib/googletest/MODULE.bazel +++ b/contrib/googletest/MODULE.bazel @@ -32,45 +32,38 @@ module( name = "googletest", - version = "1.17.0", + version = "1.15.2", compatibility_level = 1, ) # Only direct dependencies need to be listed below. # Please keep the versions in sync with the versions in the WORKSPACE file. -bazel_dep( - name = "abseil-cpp", - version = "20250127.1", -) -bazel_dep( - name = "platforms", - version = "0.0.11", -) -bazel_dep( - name = "re2", - version = "2024-07-02.bcr.1", -) +bazel_dep(name = "abseil-cpp", + version = "20240116.2", + repo_name = "com_google_absl") -bazel_dep( - name = "rules_python", - version = "1.3.0", - dev_dependency = True, -) +bazel_dep(name = "platforms", + version = "0.0.10") + +bazel_dep(name = "re2", + repo_name = "com_googlesource_code_re2", + version = "2024-07-02") + +bazel_dep(name = "rules_python", + version = "0.34.0", + dev_dependency = True) # https://rules-python.readthedocs.io/en/stable/toolchains.html#library-modules-with-dev-only-python-usage python = use_extension( "@rules_python//python/extensions:python.bzl", "python", - dev_dependency = True, -) -python.toolchain( - ignore_root_user_error = True, - is_default = True, - python_version = "3.12", + dev_dependency = True ) -# See fake_fuchsia_sdk.bzl for instructions on how to override this with a real SDK, if needed. -fuchsia_sdk = use_extension("//:fake_fuchsia_sdk.bzl", "fuchsia_sdk") -fuchsia_sdk.create_fake() -use_repo(fuchsia_sdk, "fuchsia_sdk") +python.toolchain(python_version = "3.12", + is_default = True, + ignore_root_user_error = True) + +fake_fuchsia_sdk = use_repo_rule("//:fake_fuchsia_sdk.bzl", "fake_fuchsia_sdk") +fake_fuchsia_sdk(name = "fuchsia_sdk") diff --git a/contrib/googletest/README.md b/contrib/googletest/README.md index 598cf31242b7..f50c670534d5 100644 --- a/contrib/googletest/README.md +++ b/contrib/googletest/README.md @@ -2,18 +2,27 @@ ### Announcements +#### Live at Head + +GoogleTest now follows the +[Abseil Live at Head philosophy](https://abseil.io/about/philosophy#upgrade-support). +We recommend +[updating to the latest commit in the `main` branch as often as possible](https://github.com/abseil/abseil-cpp/blob/master/FAQ.md#what-is-live-at-head-and-how-do-i-do-it). +We do publish occasional semantic versions, tagged with +`v${major}.${minor}.${patch}` (e.g. `v1.15.0`). + #### Documentation Updates Our documentation is now live on GitHub Pages at https://google.github.io/googletest/. We recommend browsing the documentation on GitHub Pages rather than directly in the repository. -#### Release 1.17.0 +#### Release 1.15.0 -[Release 1.17.0](https://github.com/google/googletest/releases/tag/v1.17.0) is +[Release 1.15.0](https://github.com/google/googletest/releases/tag/v1.15.0) is now available. -The 1.17.x branch [requires at least C++17]((https://opensource.google/documentation/policies/cplusplus-support#c_language_standard). +The 1.15.x branch requires at least C++14. #### Continuous Integration diff --git a/contrib/googletest/WORKSPACE b/contrib/googletest/WORKSPACE index 0ae5dee92baf..218e6c2e8c2b 100644 --- a/contrib/googletest/WORKSPACE +++ b/contrib/googletest/WORKSPACE @@ -1,34 +1,4 @@ -# Copyright 2024 Google Inc. -# All Rights Reserved. -# -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following disclaimer -# in the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Google Inc. nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -workspace(name = "googletest") +workspace(name = "com_google_googletest") load("//:googletest_deps.bzl", "googletest_deps") googletest_deps() @@ -36,12 +6,13 @@ googletest_deps() load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( - name = "rules_python", - sha256 = "2cc26bbd53854ceb76dd42a834b1002cd4ba7f8df35440cf03482e045affc244", - strip_prefix = "rules_python-1.3.0", - url = "https://github.com/bazelbuild/rules_python/releases/download/1.3.0/rules_python-1.3.0.tar.gz", + name = "rules_python", + sha256 = "d71d2c67e0bce986e1c5a7731b4693226867c45bfe0b7c5e0067228a536fc580", + strip_prefix = "rules_python-0.29.0", + urls = ["https://github.com/bazelbuild/rules_python/releases/download/0.29.0/rules_python-0.29.0.tar.gz"], ) -# https://github.com/bazelbuild/rules_python/releases/tag/1.1.0 + +# https://github.com/bazelbuild/rules_python/releases/tag/0.29.0 load("@rules_python//python:repositories.bzl", "py_repositories") py_repositories() @@ -54,8 +25,8 @@ http_archive( http_archive( name = "platforms", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.11/platforms-0.0.11.tar.gz", - "https://github.com/bazelbuild/platforms/releases/download/0.0.11/platforms-0.0.11.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz", + "https://github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz", ], - sha256 = "29742e87275809b5e598dc2f04d86960cc7a55b3067d97221c9abbc9926bff0f", + sha256 = "218efe8ee736d26a3572663b374a253c012b716d8af0c07e842e82f238a0a7ee", ) diff --git a/contrib/googletest/ci/linux-presubmit.sh b/contrib/googletest/ci/linux-presubmit.sh index 6491e79844b8..6d2b3fb573a0 100644 --- a/contrib/googletest/ci/linux-presubmit.sh +++ b/contrib/googletest/ci/linux-presubmit.sh @@ -31,68 +31,51 @@ set -euox pipefail -readonly LINUX_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20241218" -readonly LINUX_GCC_FLOOR_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-floor:20250205" +readonly LINUX_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20240523" +readonly LINUX_GCC_FLOOR_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-floor:20230120" if [[ -z ${GTEST_ROOT:-} ]]; then GTEST_ROOT="$(realpath $(dirname ${0})/..)" fi if [[ -z ${STD:-} ]]; then - STD="c++17 c++20" + STD="c++14 c++17 c++20" fi -# Test CMake + GCC -for cmake_off_on in OFF ON; do - time docker run \ - --volume="${GTEST_ROOT}:/src:ro" \ - --tmpfs="/build:exec" \ - --workdir="/build" \ - --rm \ - --env="CC=/usr/local/bin/gcc" \ - --env=CXXFLAGS="-Werror -Wdeprecated" \ - ${LINUX_LATEST_CONTAINER} \ - /bin/bash -c " - cmake /src \ - -DCMAKE_CXX_STANDARD=17 \ - -Dgtest_build_samples=ON \ - -Dgtest_build_tests=ON \ - -Dgmock_build_tests=ON \ - -Dcxx_no_exception=${cmake_off_on} \ - -Dcxx_no_rtti=${cmake_off_on} && \ - make -j$(nproc) && \ - ctest -j$(nproc) --output-on-failure" -done - -# Test CMake + Clang -for cmake_off_on in OFF ON; do - time docker run \ - --volume="${GTEST_ROOT}:/src:ro" \ - --tmpfs="/build:exec" \ - --workdir="/build" \ - --rm \ - --env="CC=/opt/llvm/clang/bin/clang" \ - --env=CXXFLAGS="-Werror -Wdeprecated --gcc-toolchain=/usr/local" \ - ${LINUX_LATEST_CONTAINER} \ - /bin/bash -c " - cmake /src \ - -DCMAKE_CXX_STANDARD=17 \ - -Dgtest_build_samples=ON \ - -Dgtest_build_tests=ON \ - -Dgmock_build_tests=ON \ - -Dcxx_no_exception=${cmake_off_on} \ - -Dcxx_no_rtti=${cmake_off_on} && \ - make -j$(nproc) && \ - ctest -j$(nproc) --output-on-failure" +# Test the CMake build +for cc in /usr/local/bin/gcc /opt/llvm/clang/bin/clang; do + for cmake_off_on in OFF ON; do + time docker run \ + --volume="${GTEST_ROOT}:/src:ro" \ + --tmpfs="/build:exec" \ + --workdir="/build" \ + --rm \ + --env="CC=${cc}" \ + --env=CXXFLAGS="-Werror -Wdeprecated" \ + ${LINUX_LATEST_CONTAINER} \ + /bin/bash -c " + cmake /src \ + -DCMAKE_CXX_STANDARD=14 \ + -Dgtest_build_samples=ON \ + -Dgtest_build_tests=ON \ + -Dgmock_build_tests=ON \ + -Dcxx_no_exception=${cmake_off_on} \ + -Dcxx_no_rtti=${cmake_off_on} && \ + make -j$(nproc) && \ + ctest -j$(nproc) --output-on-failure" + done done # Do one test with an older version of GCC +# TODO(googletest-team): This currently uses Bazel 5. When upgrading to a +# version of Bazel that supports Bzlmod, add --enable_bzlmod=false to keep test +# coverage for the old WORKSPACE dependency management. time docker run \ --volume="${GTEST_ROOT}:/src:ro" \ --workdir="/src" \ --rm \ --env="CC=/usr/local/bin/gcc" \ - --env="BAZEL_CXXOPTS=-std=c++17" \ + --env="BAZEL_CXXOPTS=-std=c++14" \ ${LINUX_GCC_FLOOR_CONTAINER} \ /usr/local/bin/bazel test ... \ --copt="-Wall" \ @@ -100,7 +83,6 @@ time docker run \ --copt="-Wuninitialized" \ --copt="-Wundef" \ --copt="-Wno-error=pragmas" \ - --enable_bzlmod=false \ --features=external_include_paths \ --keep_going \ --show_timestamps \ diff --git a/contrib/googletest/ci/macos-presubmit.sh b/contrib/googletest/ci/macos-presubmit.sh index 5370ed60d3d8..70eaa74fb490 100644 --- a/contrib/googletest/ci/macos-presubmit.sh +++ b/contrib/googletest/ci/macos-presubmit.sh @@ -31,9 +31,6 @@ set -euox pipefail -# Use Xcode 16.0 -sudo xcode-select -s /Applications/Xcode_16.0.app/Contents/Developer - if [[ -z ${GTEST_ROOT:-} ]]; then GTEST_ROOT="$(realpath $(dirname ${0})/..)" fi @@ -43,20 +40,20 @@ for cmake_off_on in OFF ON; do BUILD_DIR=$(mktemp -d build_dir.XXXXXXXX) cd ${BUILD_DIR} time cmake ${GTEST_ROOT} \ - -DCMAKE_CXX_STANDARD=17 \ + -DCMAKE_CXX_STANDARD=14 \ -Dgtest_build_samples=ON \ -Dgtest_build_tests=ON \ -Dgmock_build_tests=ON \ -Dcxx_no_exception=${cmake_off_on} \ -Dcxx_no_rtti=${cmake_off_on} - time make -j$(nproc) + time make time ctest -j$(nproc) --output-on-failure done # Test the Bazel build # If we are running on Kokoro, check for a versioned Bazel binary. -KOKORO_GFILE_BAZEL_BIN="bazel-8.0.0-darwin-x86_64" +KOKORO_GFILE_BAZEL_BIN="bazel-7.0.0-darwin-x86_64" if [[ ${KOKORO_GFILE_DIR:-} ]] && [[ -f ${KOKORO_GFILE_DIR}/${KOKORO_GFILE_BAZEL_BIN} ]]; then BAZEL_BIN="${KOKORO_GFILE_DIR}/${KOKORO_GFILE_BAZEL_BIN}" chmod +x ${BAZEL_BIN} @@ -70,7 +67,7 @@ for absl in 0 1; do --copt="-Wall" \ --copt="-Werror" \ --copt="-Wundef" \ - --cxxopt="-std=c++17" \ + --cxxopt="-std=c++14" \ --define="absl=${absl}" \ --enable_bzlmod=true \ --features=external_include_paths \ diff --git a/contrib/googletest/ci/windows-presubmit.bat b/contrib/googletest/ci/windows-presubmit.bat index e2664c538da6..1adc1a16ffa8 100644 --- a/contrib/googletest/ci/windows-presubmit.bat +++ b/contrib/googletest/ci/windows-presubmit.bat @@ -1,6 +1,6 @@ SETLOCAL ENABLEDELAYEDEXPANSION -SET BAZEL_EXE=%KOKORO_GFILE_DIR%\bazel-8.0.0-windows-x86_64.exe +SET BAZEL_EXE=%KOKORO_GFILE_DIR%\bazel-7.0.0-windows-x86_64.exe SET PATH=C:\Python34;%PATH% SET BAZEL_PYTHON=C:\python34\python.exe @@ -11,18 +11,21 @@ SET CTEST_OUTPUT_ON_FAILURE=1 SET CMAKE_BUILD_PARALLEL_LEVEL=16 SET CTEST_PARALLEL_LEVEL=16 -SET GTEST_ROOT=%~dp0\.. +IF EXIST git\googletest ( + CD git\googletest +) ELSE IF EXIST github\googletest ( + CD github\googletest +) + IF %errorlevel% neq 0 EXIT /B 1 :: ---------------------------------------------------------------------------- :: CMake -SET CMAKE_BUILD_PATH=cmake_msvc2022 -MKDIR %CMAKE_BUILD_PATH% -CD %CMAKE_BUILD_PATH% +MKDIR cmake_msvc2022 +CD cmake_msvc2022 -%CMAKE_BIN% %GTEST_ROOT% ^ +%CMAKE_BIN% .. ^ -G "Visual Studio 17 2022" ^ - -DCMAKE_CXX_STANDARD=17 ^ -DPYTHON_EXECUTABLE:FILEPATH=c:\python37\python.exe ^ -DPYTHON_INCLUDE_DIR:PATH=c:\python37\include ^ -DPYTHON_LIBRARY:FILEPATH=c:\python37\lib\site-packages\pip ^ @@ -37,8 +40,8 @@ IF %errorlevel% neq 0 EXIT /B 1 %CTEST_BIN% -C Debug --timeout 600 IF %errorlevel% neq 0 EXIT /B 1 -CD %GTEST_ROOT% -RMDIR /S /Q %CMAKE_BUILD_PATH% +CD .. +RMDIR /S /Q cmake_msvc2022 :: ---------------------------------------------------------------------------- :: Bazel @@ -47,26 +50,11 @@ RMDIR /S /Q %CMAKE_BUILD_PATH% :: because of Windows limitations on path length. :: --output_user_root=C:\tmp causes Bazel to use a shorter path. SET BAZEL_VS=C:\Program Files\Microsoft Visual Studio\2022\Community - -:: C++17 -%BAZEL_EXE% ^ - --output_user_root=C:\tmp ^ - test ... ^ - --compilation_mode=dbg ^ - --copt=/std:c++17 ^ - --copt=/WX ^ - --enable_bzlmod=true ^ - --keep_going ^ - --test_output=errors ^ - --test_tag_filters=-no_test_msvc2017 -IF %errorlevel% neq 0 EXIT /B 1 - -:: C++20 %BAZEL_EXE% ^ --output_user_root=C:\tmp ^ test ... ^ --compilation_mode=dbg ^ - --copt=/std:c++20 ^ + --copt=/std:c++14 ^ --copt=/WX ^ --enable_bzlmod=true ^ --keep_going ^ diff --git a/contrib/googletest/docs/advanced.md b/contrib/googletest/docs/advanced.md index 9b1220a1e09a..240588a83b4e 100644 --- a/contrib/googletest/docs/advanced.md +++ b/contrib/googletest/docs/advanced.md @@ -286,7 +286,7 @@ For example: ```c++ TEST(SkipTest, DoesSkip) { GTEST_SKIP() << "Skipping single test"; - FAIL(); // Won't fail; it won't be executed + EXPECT_EQ(0, 1); // Won't fail; it won't be executed } class SkipFixture : public ::testing::Test { @@ -298,7 +298,7 @@ class SkipFixture : public ::testing::Test { // Tests for SkipFixture won't be executed. TEST_F(SkipFixture, SkipsOneTest) { - FAIL(); // Won't fail; it won't be executed + EXPECT_EQ(5, 7); // Won't fail } ``` @@ -405,51 +405,6 @@ EXPECT_TRUE(IsCorrectPointIntVector(point_ints)) For more details regarding `AbslStringify()` and its integration with other libraries, see go/abslstringify. -## Regular Expression Syntax - -When built with Bazel and using Abseil, GoogleTest uses the -[RE2](https://github.com/google/re2/wiki/Syntax) syntax. Otherwise, for POSIX -systems (Linux, Cygwin, Mac), GoogleTest uses the -[POSIX extended regular expression](https://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html#tag_09_04) -syntax. To learn about POSIX syntax, you may want to read this -[Wikipedia entry](https://en.wikipedia.org/wiki/Regular_expression#POSIX_extended). - -On Windows, GoogleTest uses its own simple regular expression implementation. It -lacks many features. For example, we don't support union (`"x|y"`), grouping -(`"(xy)"`), brackets (`"[xy]"`), and repetition count (`"x{5,7}"`), among -others. Below is what we do support (`A` denotes a literal character, period -(`.`), or a single `\\ ` escape sequence; `x` and `y` denote regular -expressions.): - -Expression | Meaning ----------- | -------------------------------------------------------------- -`c` | matches any literal character `c` -`\\d` | matches any decimal digit -`\\D` | matches any character that's not a decimal digit -`\\f` | matches `\f` -`\\n` | matches `\n` -`\\r` | matches `\r` -`\\s` | matches any ASCII whitespace, including `\n` -`\\S` | matches any character that's not a whitespace -`\\t` | matches `\t` -`\\v` | matches `\v` -`\\w` | matches any letter, `_`, or decimal digit -`\\W` | matches any character that `\\w` doesn't match -`\\c` | matches any literal character `c`, which must be a punctuation -`.` | matches any single character except `\n` -`A?` | matches 0 or 1 occurrences of `A` -`A*` | matches 0 or many occurrences of `A` -`A+` | matches 1 or many occurrences of `A` -`^` | matches the beginning of a string (not that of each line) -`$` | matches the end of a string (not that of each line) -`xy` | matches `x` followed by `y` - -To help you determine which capability is available on your system, GoogleTest -defines macros to govern which regular expression it is using. The macros are: -`GTEST_USES_SIMPLE_RE=1` or `GTEST_USES_POSIX_RE=1`. If you want your death -tests to work in all cases, you can either `#if` on these macros or use the more -limited syntax only. - ## Death Tests In many applications, there are assertions that can cause application failure if @@ -461,7 +416,7 @@ corruption, security holes, or worse. Hence it is vitally important to test that such assertion statements work as expected. Since these precondition checks cause the processes to die, we call such tests -*death tests*. More generally, any test that checks that a program terminates +_death tests_. More generally, any test that checks that a program terminates (except by throwing an exception) in an expected fashion is also a death test. Note that if a piece of code throws an exception, we don't consider it "death" @@ -507,12 +462,6 @@ verifies that: exit with exit code 0, and * calling `KillProcess()` kills the process with signal `SIGKILL`. -{: .callout .warning} -Warning: If your death test contains mocks and is expecting a specific exit -code, then you must allow the mock objects to be leaked via `Mock::AllowLeak`. -This is because the mock leak detector will exit with its own error code if it -detects a leak. - The test function body may contain other assertions and statements as well, if necessary. @@ -554,6 +503,51 @@ TEST_F(FooDeathTest, DoesThat) { } ``` +### Regular Expression Syntax + +When built with Bazel and using Abseil, GoogleTest uses the +[RE2](https://github.com/google/re2/wiki/Syntax) syntax. Otherwise, for POSIX +systems (Linux, Cygwin, Mac), GoogleTest uses the +[POSIX extended regular expression](https://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html#tag_09_04) +syntax. To learn about POSIX syntax, you may want to read this +[Wikipedia entry](https://en.wikipedia.org/wiki/Regular_expression#POSIX_extended). + +On Windows, GoogleTest uses its own simple regular expression implementation. It +lacks many features. For example, we don't support union (`"x|y"`), grouping +(`"(xy)"`), brackets (`"[xy]"`), and repetition count (`"x{5,7}"`), among +others. Below is what we do support (`A` denotes a literal character, period +(`.`), or a single `\\ ` escape sequence; `x` and `y` denote regular +expressions.): + +Expression | Meaning +---------- | -------------------------------------------------------------- +`c` | matches any literal character `c` +`\\d` | matches any decimal digit +`\\D` | matches any character that's not a decimal digit +`\\f` | matches `\f` +`\\n` | matches `\n` +`\\r` | matches `\r` +`\\s` | matches any ASCII whitespace, including `\n` +`\\S` | matches any character that's not a whitespace +`\\t` | matches `\t` +`\\v` | matches `\v` +`\\w` | matches any letter, `_`, or decimal digit +`\\W` | matches any character that `\\w` doesn't match +`\\c` | matches any literal character `c`, which must be a punctuation +`.` | matches any single character except `\n` +`A?` | matches 0 or 1 occurrences of `A` +`A*` | matches 0 or many occurrences of `A` +`A+` | matches 1 or many occurrences of `A` +`^` | matches the beginning of a string (not that of each line) +`$` | matches the end of a string (not that of each line) +`xy` | matches `x` followed by `y` + +To help you determine which capability is available on your system, GoogleTest +defines macros to govern which regular expression it is using. The macros are: +`GTEST_USES_SIMPLE_RE=1` or `GTEST_USES_POSIX_RE=1`. If you want your death +tests to work in all cases, you can either `#if` on these macros or use the more +limited syntax only. + ### How It Works See [Death Assertions](reference/assertions.md#death) in the Assertions @@ -733,7 +727,7 @@ Some tips on using `SCOPED_TRACE`: ### Propagating Fatal Failures A common pitfall when using `ASSERT_*` and `FAIL*` is not understanding that -when they fail they only abort the *current function*, not the entire test. For +when they fail they only abort the _current function_, not the entire test. For example, the following test will segfault: ```c++ @@ -1929,20 +1923,6 @@ the `--gtest_also_run_disabled_tests` flag or set the You can combine this with the `--gtest_filter` flag to further select which disabled tests to run. -### Enforcing Having At Least One Test Case - -A not uncommon programmer mistake is to write a test program that has no test -case linked in. This can happen, for example, when you put test case definitions -in a library and the library is not marked as "always link". - -To catch such mistakes, run the test program with the -`--gtest_fail_if_no_test_linked` flag or set the `GTEST_FAIL_IF_NO_TEST_LINKED` -environment variable to a value other than `0`. Now the program will fail if no -test case is linked in. - -Note that *any* test case linked in makes the program valid for the purpose of -this check. In particular, even a disabled test case suffices. - ### Repeating the Tests Once in a while you'll run into a test whose result is hit-or-miss. Perhaps it @@ -2402,7 +2382,7 @@ IMPORTANT: The exact format of the JSON document is subject to change. #### Detecting Test Premature Exit -Google Test implements the *premature-exit-file* protocol for test runners to +Google Test implements the _premature-exit-file_ protocol for test runners to catch any kind of unexpected exits of test programs. Upon start, Google Test creates the file which will be automatically deleted after all work has been finished. Then, the test runner can check if this file exists. In case the file diff --git a/contrib/googletest/docs/faq.md b/contrib/googletest/docs/faq.md index 4e958384673a..c7d10b5006ba 100644 --- a/contrib/googletest/docs/faq.md +++ b/contrib/googletest/docs/faq.md @@ -511,6 +511,19 @@ However, there are cases where you have to define your own: list of the constructor. (Early versions of `gcc` doesn't force you to initialize the const member. It's a bug that has been fixed in `gcc 4`.) +## Why does ASSERT_DEATH complain about previous threads that were already joined? + +With the Linux pthread library, there is no turning back once you cross the line +from a single thread to multiple threads. The first time you create a thread, a +manager thread is created in addition, so you get 3, not 2, threads. Later when +the thread you create joins the main thread, the thread count decrements by 1, +but the manager thread will never be killed, so you still have 2 threads, which +means you cannot safely run a death test. + +The new NPTL thread library doesn't suffer from this problem, as it doesn't +create a manager thread. However, if you don't control which machine your test +runs on, you shouldn't depend on this. + ## Why does GoogleTest require the entire test suite, instead of individual tests, to be named `*DeathTest` when it uses `ASSERT_DEATH`? GoogleTest does not interleave tests from different test suites. That is, it diff --git a/contrib/googletest/docs/gmock_cook_book.md b/contrib/googletest/docs/gmock_cook_book.md index 9e59b4cf438c..f1b10b472d27 100644 --- a/contrib/googletest/docs/gmock_cook_book.md +++ b/contrib/googletest/docs/gmock_cook_book.md @@ -177,7 +177,7 @@ class StackInterface { template <typename Elem> class MockStack : public StackInterface<Elem> { ... - MOCK_METHOD(int, GetSize, (), (const, override)); + MOCK_METHOD(int, GetSize, (), (override)); MOCK_METHOD(void, Push, (const Elem& x), (override)); }; ``` @@ -936,8 +936,8 @@ casts a matcher `m` to type `Matcher<T>`. To ensure safety, gMock checks that floating-point numbers), the conversion from `T` to `U` is not lossy (in other words, any value representable by `T` can also be represented by `U`); and -3. When `U` is a non-const reference, `T` must also be a reference (as the - underlying matcher may be interested in the address of the `U` value). +3. When `U` is a reference, `T` must also be a reference (as the underlying + matcher may be interested in the address of the `U` value). The code won't compile if any of these conditions isn't met. @@ -3387,9 +3387,9 @@ With this definition, the above assertion will give a better message: #### Using EXPECT_ Statements in Matchers -You can also use `EXPECT_...` statements inside custom matcher definitions. In -many cases, this allows you to write your matcher more concisely while still -providing an informative error message. For example: +You can also use `EXPECT_...` (and `ASSERT_...`) statements inside custom +matcher definitions. In many cases, this allows you to write your matcher more +concisely while still providing an informative error message. For example: ```cpp MATCHER(IsDivisibleBy7, "") { @@ -3419,14 +3419,14 @@ itself, as gMock already prints it for you. #### Argument Types -The type of the value being matched (`arg_type`) is determined by the context in -which you use the matcher and is supplied to you by the compiler, so you don't -need to worry about declaring it (nor can you). This allows the matcher to be -polymorphic. For example, `IsDivisibleBy7()` can be used to match any type where -the value of `(arg % 7) == 0` can be implicitly converted to a `bool`. In the -`Bar(IsDivisibleBy7())` example above, if method `Bar()` takes an `int`, -`arg_type` will be `int`; if it takes an `unsigned long`, `arg_type` will be -`unsigned long`; and so on. +The type of the value being matched (`arg_type`) is determined by the +context in which you use the matcher and is supplied to you by the compiler, so +you don't need to worry about declaring it (nor can you). This allows the +matcher to be polymorphic. For example, `IsDivisibleBy7()` can be used to match +any type where the value of `(arg % 7) == 0` can be implicitly converted to a +`bool`. In the `Bar(IsDivisibleBy7())` example above, if method `Bar()` takes an +`int`, `arg_type` will be `int`; if it takes an `unsigned long`, `arg_type` will *** 5160 LINES SKIPPED ***
