diff --git a/test/googletest/.github/ISSUE_TEMPLATE/10-feature_request.yml b/test/googletest/.github/ISSUE_TEMPLATE/10-feature_request.yml index 91ad041..f3bbc09 100644 --- a/test/googletest/.github/ISSUE_TEMPLATE/10-feature_request.yml +++ b/test/googletest/.github/ISSUE_TEMPLATE/10-feature_request.yml @@ -10,21 +10,21 @@ body: description: We recommend using the latest commit from GitHub in your projects. validations: required: true - - type: textarea + - type: textarea id: why attributes: label: Why do we need this feature? description: Ideally, explain why a combination of existing features cannot be used instead. validations: required: true - - type: textarea + - type: textarea id: proposal attributes: label: Describe the proposal. description: Include a detailed description of the feature, with usage examples. validations: required: true - - type: textarea + - type: textarea id: platform attributes: label: Is the feature specific to an operating system, compiler, or build system version? diff --git a/test/googletest/.github/workflows/gtest-ci.yml b/test/googletest/.github/workflows/gtest-ci.yml deleted file mode 100644 index 03a8cc5..0000000 --- a/test/googletest/.github/workflows/gtest-ci.yml +++ /dev/null @@ -1,43 +0,0 @@ -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/test/googletest/.gitignore b/test/googletest/.gitignore index f08cb72..f0df39d 100644 --- a/test/googletest/.gitignore +++ b/test/googletest/.gitignore @@ -8,6 +8,7 @@ bazel-genfiles bazel-googletest bazel-out bazel-testlogs +MODULE.bazel.lock # python *.pyc @@ -24,6 +25,10 @@ Win32-Release/ x64-Debug/ x64-Release/ +# VSCode files +.cache/ +cmake-variants.yaml + # Ignore autoconf / automake files Makefile.in aclocal.m4 diff --git a/test/googletest/BUILD.bazel b/test/googletest/BUILD.bazel index ac62251..03392c6 100644 --- a/test/googletest/BUILD.bazel +++ b/test/googletest/BUILD.bazel @@ -30,6 +30,8 @@ # # Bazel Build for Google C++ Testing Framework(Google Test) +load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") + package(default_visibility = ["//visibility:public"]) licenses(["notice"]) @@ -56,6 +58,12 @@ config_setting( constraint_values = ["@platforms//os:openbsd"], ) +# NOTE: Fuchsia is not an officially supported platform. +config_setting( + name = "fuchsia", + constraint_values = ["@platforms//os:fuchsia"], +) + config_setting( name = "msvc_compiler", flag_values = { @@ -77,6 +85,10 @@ 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( @@ -132,23 +144,41 @@ cc_library( }), deps = select({ ":has_absl": [ - "@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", + "@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", + "@re2", + ], + "//conditions:default": [], + }) + select({ + # `gtest-death-test.cc` has `EXPECT_DEATH` that spawns a process, + # expects it to crash and inspects its logs with the given matcher, + # so that's why these libraries are needed. + # Otherwise, builds targeting Fuchsia would fail to compile. + ":fuchsia": [ + "@fuchsia_sdk//pkg/fdio", + "@fuchsia_sdk//pkg/zx", ], "//conditions:default": [], }), ) +# `gtest`, but testonly. See guidance on `gtest` for when to use this. +alias( + name = "gtest_for_library", + testonly = True, + actual = ":gtest", +) + +# 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"], @@ -157,6 +187,7 @@ cc_library( "//conditions:default": [], }), deps = [":gtest"], + alwayslink = True, ) # The following rules build samples of how to use gTest. diff --git a/test/googletest/CMakeLists.txt b/test/googletest/CMakeLists.txt index 6af4143..793c8d3 100644 --- a/test/googletest/CMakeLists.txt +++ b/test/googletest/CMakeLists.txt @@ -1,22 +1,10 @@ # Note: CMake support is community-based. The maintainers do not use CMake # internally. -cmake_minimum_required(VERSION 3.5) - -if (POLICY CMP0048) - cmake_policy(SET CMP0048 NEW) -endif (POLICY CMP0048) - -if (POLICY CMP0069) - cmake_policy(SET CMP0069 NEW) -endif (POLICY CMP0069) - -if (POLICY CMP0077) - cmake_policy(SET CMP0077 NEW) -endif (POLICY CMP0077) +cmake_minimum_required(VERSION 3.16) project(googletest-distribution) -set(GOOGLETEST_VERSION 1.13.0) +set(GOOGLETEST_VERSION 1.18.0) if(NOT CYGWIN AND NOT MSYS AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL QNX) set(CMAKE_CXX_EXTENSIONS OFF) @@ -27,11 +15,20 @@ enable_testing() include(CMakeDependentOption) include(GNUInstallDirs) -#Note that googlemock target already builds googletest +# Note that googlemock target already builds googletest. option(BUILD_GMOCK "Builds the googlemock subproject" ON) option(INSTALL_GTEST "Enable installation of googletest. (Projects embedding googletest may want to turn this OFF.)" ON) option(GTEST_HAS_ABSL "Use Abseil and RE2. Requires Abseil and RE2 to be separately added to the build." OFF) +if(GTEST_HAS_ABSL) + if(NOT TARGET absl::base) + find_package(absl REQUIRED) + endif() + if(NOT TARGET re2::re2) + find_package(re2 REQUIRED) + endif() +endif() + if(BUILD_GMOCK) add_subdirectory( googlemock ) else() diff --git a/test/googletest/CONTRIBUTING.md b/test/googletest/CONTRIBUTING.md index 8bed14b..ab5a47b 100644 --- a/test/googletest/CONTRIBUTING.md +++ b/test/googletest/CONTRIBUTING.md @@ -47,11 +47,11 @@ PR is acceptable as an alternative. ## The Google Test and Google Mock Communities The Google Test community exists primarily through the -[discussion group](http://groups.google.com/group/googletestframework) and the +[discussion group](https://groups.google.com/group/googletestframework) and the GitHub repository. Likewise, the Google Mock community exists primarily through -their own [discussion group](http://groups.google.com/group/googlemock). You are -definitely encouraged to contribute to the discussion and you can also help us -to keep the effectiveness of the group high by following and promoting the +their own [discussion group](https://groups.google.com/group/googlemock). You +are definitely encouraged to contribute to the discussion and you can also help +us to keep the effectiveness of the group high by following and promoting the guidelines listed here. ### Please Be Friendly diff --git a/test/googletest/CONTRIBUTORS b/test/googletest/CONTRIBUTORS index 77397a5..ccea41e 100644 --- a/test/googletest/CONTRIBUTORS +++ b/test/googletest/CONTRIBUTORS @@ -55,6 +55,7 @@ Russ Cox Russ Rufer Sean Mcafee Sigurður Ásgeirsson +Soyeon Kim Sverre Sundsdal Szymon Sobik Takeshi Yoshino diff --git a/test/googletest/MODULE.bazel b/test/googletest/MODULE.bazel new file mode 100644 index 0000000..badf0de --- /dev/null +++ b/test/googletest/MODULE.bazel @@ -0,0 +1,80 @@ +# 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. + +# https://bazel.build/external/overview#bzlmod + +module( + name = "googletest", + version = "1.18.0", + 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 = "20260526.0", +) +bazel_dep( + name = "platforms", + version = "1.1.0", +) +bazel_dep( + name = "re2", + version = "2025-11-05.bcr.1", +) +bazel_dep( + name = "rules_cc", + version = "0.2.22", +) + +bazel_dep( + name = "rules_python", + version = "2.2.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.13", +) + +# 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") diff --git a/test/googletest/README.md b/test/googletest/README.md index 23eb502..b4e9b43 100644 --- a/test/googletest/README.md +++ b/test/googletest/README.md @@ -2,38 +2,28 @@ ### 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). - #### 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.13.0 +#### Release 1.18.0 -[Release 1.13.0](https://github.com/google/googletest/releases/tag/v1.13.0) is +[Release 1.18.0](https://github.com/google/googletest/releases/tag/v1.18.0) is now available. -The 1.13.x branch requires at least C++14. +The 1.18.x branch +[requires at least C++17](https://opensource.google/documentation/policies/cplusplus-support#c_language_standard). #### Continuous Integration -We use Google's internal systems for continuous integration. \ -GitHub Actions were added for the convenience of open source contributors. They -are exclusively maintained by the open source community and not used by the -GoogleTest team. +We use Google's internal systems for continuous integration. #### Coming Soon * We are planning to take a dependency on [Abseil](https://github.com/abseil/abseil-cpp). -* More documentation improvements are planned. ## Welcome to **GoogleTest**, Google's C++ test framework! @@ -52,16 +42,37 @@ More information about building GoogleTest can be found at ## Features -* An [xUnit](https://en.wikipedia.org/wiki/XUnit) test framework. -* Test discovery. -* A rich set of assertions. -* User-defined assertions. -* Death tests. -* Fatal and non-fatal failures. -* Value-parameterized tests. -* Type-parameterized tests. -* Various options for running the tests. -* XML test report generation. +* xUnit test framework: \ + Googletest is based on the [xUnit](https://en.wikipedia.org/wiki/XUnit) + testing framework, a popular architecture for unit testing. +* Test discovery: \ + Googletest automatically discovers and runs your tests, eliminating the need + to manually register your tests. +* Rich set of assertions: \ + Googletest provides a variety of assertions, such as equality, inequality, + exceptions, and more, making it easy to test your code. +* User-defined assertions: \ + You can define your own assertions with Googletest, making it simple to + write tests that are specific to your code. +* Death tests: \ + Googletest supports death tests, which verify that your code exits in a + certain way, making it useful for testing error-handling code. +* Fatal and non-fatal failures: \ + You can specify whether a test failure should be treated as fatal or + non-fatal with Googletest, allowing tests to continue running even if a + failure occurs. +* Value-parameterized tests: \ + Googletest supports value-parameterized tests, which run multiple times with + different input values, making it useful for testing functions that take + different inputs. +* Type-parameterized tests: \ + Googletest also supports type-parameterized tests, which run with different + data types, making it useful for testing functions that work with different + data types. +* Various options for running tests: \ + Googletest provides many options for running tests including running + individual tests, running tests in a specific order and running tests in + parallel. ## Supported Platforms @@ -69,7 +80,7 @@ GoogleTest follows Google's [Foundational C++ Support Policy](https://opensource.google/documentation/policies/cplusplus-support). See [this table](https://github.com/google/oss-policies-info/blob/main/foundational-cxx-support-matrix.md) -for a list of currently supported versions compilers, platforms, and build +for a list of currently supported versions of compilers, platforms, and build tools. ## Who Is Using GoogleTest? @@ -77,12 +88,12 @@ tools. In addition to many internal projects at Google, GoogleTest is also used by the following notable projects: -* The [Chromium projects](http://www.chromium.org/) (behind the Chrome browser - and Chrome OS). -* The [LLVM](http://llvm.org/) compiler. +* The [Chromium projects](https://www.chromium.org/) (behind the Chrome + browser and Chrome OS). +* The [LLVM](https://llvm.org/) compiler. * [Protocol Buffers](https://github.com/google/protobuf), Google's data interchange format. -* The [OpenCV](http://opencv.org/) computer vision library. +* The [OpenCV](https://opencv.org/) computer vision library. ## Related Open Source Projects diff --git a/test/googletest/WORKSPACE b/test/googletest/WORKSPACE index 0f10a6a..b6635f6 100644 --- a/test/googletest/WORKSPACE +++ b/test/googletest/WORKSPACE @@ -1,40 +1,66 @@ -workspace(name = "com_google_googletest") +# 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") + +load("//:googletest_deps.bzl", "googletest_deps") + +googletest_deps() load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( - name = "com_google_absl", # 2023-01-10T21:08:25Z - sha256 = "f9a4e749f42c386a32a90fddf0e2913ed408d10c42f7f33ccf4c59ac4f0d1d05", - strip_prefix = "abseil-cpp-52835439ca90d86b27bf8cd1708296e95604d724", - urls = ["https://github.com/abseil/abseil-cpp/archive/52835439ca90d86b27bf8cd1708296e95604d724.zip"], + name = "rules_python", + sha256 = "e11d2e1efce1589e5bdfa93986712c74fc7467a0f093143d489d2ef5ebb1ed2a", + strip_prefix = "rules_python-2.2.0", + url = "https://github.com/bazelbuild/rules_python/releases/download/2.2.0/rules_python-2.2.0.tar.gz", ) -# Note this must use a commit from the `abseil` branch of the RE2 project. -# https://github.com/google/re2/tree/abseil -http_archive( - name = "com_googlesource_code_re2", # 2022-12-21T14:29:10Z - sha256 = "b9ce3a51beebb38534d11d40f8928d40509b9e18a735f6a4a97ad3d014c87cb5", - strip_prefix = "re2-d0b1f8f2ecc2ea74956c7608b6f915175314ff0e", - urls = ["https://github.com/google/re2/archive/d0b1f8f2ecc2ea74956c7608b6f915175314ff0e.zip"], -) +# https://github.com/bazelbuild/rules_python/releases/tag/1.1.0 +load("@rules_python//python:repositories.bzl", "py_repositories") + +py_repositories() http_archive( - name = "rules_python", # 2023-01-10T22:00:51Z - sha256 = "5de54486a60ad8948dabe49605bb1c08053e04001a431ab3e96745b4d97a4419", - strip_prefix = "rules_python-70cce26432187a60b4e950118791385e6fb3c26f", - urls = ["https://github.com/bazelbuild/rules_python/archive/70cce26432187a60b4e950118791385e6fb3c26f.zip"], + name = "platforms", + sha256 = "dbad4a23abcca6171e47b79edc53bd6a41067a3b75f9e8b104656b459ff25046", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/1.1.0/platforms-1.1.0.tar.gz", + "https://github.com/bazelbuild/platforms/releases/download/1.1.0/platforms-1.1.0.tar.gz", + ], ) -http_archive( - name = "bazel_skylib", # 2022-11-16T18:29:32Z - sha256 = "a22290c26d29d3ecca286466f7f295ac6cbe32c0a9da3a91176a90e0725e3649", - strip_prefix = "bazel-skylib-5bfcb1a684550626ce138fe0fe8f5f702b3764c3", - urls = ["https://github.com/bazelbuild/bazel-skylib/archive/5bfcb1a684550626ce138fe0fe8f5f702b3764c3.zip"], -) +load("@bazel_features//:deps.bzl", "bazel_features_deps") -http_archive( - name = "platforms", # 2022-11-09T19:18:22Z - sha256 = "b4a3b45dc4202e2b3e34e3bc49d2b5b37295fc23ea58d88fb9e01f3642ad9b55", - strip_prefix = "platforms-3fbc687756043fb58a407c2ea8c944bc2fe1d922", - urls = ["https://github.com/bazelbuild/platforms/archive/3fbc687756043fb58a407c2ea8c944bc2fe1d922.zip"], -) +bazel_features_deps() + +load("@rules_cc//cc:extensions.bzl", "compatibility_proxy_repo") + +compatibility_proxy_repo() diff --git a/test/googletest/WORKSPACE.bzlmod b/test/googletest/WORKSPACE.bzlmod new file mode 100644 index 0000000..381432c --- /dev/null +++ b/test/googletest/WORKSPACE.bzlmod @@ -0,0 +1,35 @@ +# 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. + +# https://bazel.build/external/migration#workspace.bzlmod +# +# This file is intentionally empty. When bzlmod is enabled and this +# file exists, the content of WORKSPACE is ignored. This prevents +# bzlmod builds from unintentionally depending on the WORKSPACE file. diff --git a/test/googletest/ci/linux-presubmit.sh b/test/googletest/ci/linux-presubmit.sh index 626989d..26d2e7a 100644 --- a/test/googletest/ci/linux-presubmit.sh +++ b/test/googletest/ci/linux-presubmit.sh @@ -31,39 +31,66 @@ set -euox pipefail -readonly LINUX_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20230217" -readonly LINUX_GCC_FLOOR_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-floor:20230120" +readonly LINUX_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest@sha256:baa99e65a3cc837bab8e5246f1870d25c76d0adf2b1d598ee5a3ec77fd2e19bd" if [[ -z ${GTEST_ROOT:-} ]]; then GTEST_ROOT="$(realpath $(dirname ${0})/..)" fi -if [[ -z ${STD:-} ]]; then - STD="c++14 c++17 c++20" +# Use Bazel Vendor mode to reduce reliance on external dependencies. +# See https://bazel.build/external/vendor and the Dockerfile for +# an explaination of how this works. +if [[ ${KOKORO_GFILE_DIR:-} ]] && [[ -f "${KOKORO_GFILE_DIR}/distdir/googletest_vendor.tar.gz" ]]; then + 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:-}" + BAZEL_EXTRA_ARGS="--vendor_dir=/googletest_vendor ${BAZEL_EXTRA_ARGS:-}" fi -# 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 +if [[ -z ${STD:-} ]]; then + STD="c++17 c++20 c++23" +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/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" done # Do one test with an older version of GCC @@ -71,19 +98,27 @@ time docker run \ --volume="${GTEST_ROOT}:/src:ro" \ --workdir="/src" \ --rm \ - --env="CC=/usr/local/bin/gcc" \ - --env="BAZEL_CXXOPTS=-std=c++14" \ - ${LINUX_GCC_FLOOR_CONTAINER} \ + --env="CC=/opt/gcc-10/bin/gcc" \ + --env="BAZEL_CXXOPTS=-std=c++17" \ + --env="BAZEL_LINKOPTS=-L/opt/gcc-10/lib64:-Wl,-rpath=/opt/gcc-10/lib64" \ + --env="USE_BAZEL_VERSION=8.5.1" \ + ${DOCKER_EXTRA_ARGS:-} \ + ${LINUX_LATEST_CONTAINER} \ + /bin/bash --login -c " /usr/local/bin/bazel test ... \ - --copt="-Wall" \ - --copt="-Werror" \ - --copt="-Wuninitialized" \ - --copt="-Wno-error=pragmas" \ - --distdir="/bazel-distdir" \ + --copt=\"-Wall\" \ + --copt=\"-Werror\" \ + --copt=\"-Wuninitialized\" \ + --copt=\"-Wundef\" \ + --copt=\"-Wno-error=pragmas\" \ + --enable_bzlmod=false \ + --enable_workspace=true \ --features=external_include_paths \ --keep_going \ + --per_file_copt=\"external/.*@-w\" \ --show_timestamps \ - --test_output=errors + --test_output=errors \ + ${BAZEL_EXTRA_ARGS:-}" # Test GCC for std in ${STD}; do @@ -94,17 +129,23 @@ for std in ${STD}; do --rm \ --env="CC=/usr/local/bin/gcc" \ --env="BAZEL_CXXOPTS=-std=${std}" \ + --env="USE_BAZEL_VERSION=9.1.0" \ + ${DOCKER_EXTRA_ARGS:-} \ ${LINUX_LATEST_CONTAINER} \ - /usr/local/bin/bazel test ... \ - --copt="-Wall" \ - --copt="-Werror" \ - --copt="-Wuninitialized" \ - --define="absl=${absl}" \ - --distdir="/bazel-distdir" \ - --features=external_include_paths \ - --keep_going \ - --show_timestamps \ - --test_output=errors + /bin/bash --login -c " + /usr/local/bin/bazel test ... \ + --copt=\"-Wall\" \ + --copt=\"-Werror\" \ + --copt=\"-Wuninitialized\" \ + --copt=\"-Wundef\" \ + --define=\"absl=${absl}\" \ + --enable_bzlmod=true \ + --features=external_include_paths \ + --keep_going \ + --per_file_copt=\"external/.*@-w\" \ + --show_timestamps \ + --test_output=errors \ + ${BAZEL_EXTRA_ARGS:-}" done done @@ -115,20 +156,26 @@ for std in ${STD}; do --volume="${GTEST_ROOT}:/src:ro" \ --workdir="/src" \ --rm \ - --env="CC=/opt/llvm/clang/bin/clang" \ + --env="CC=/opt/llvm/bin/clang" \ --env="BAZEL_CXXOPTS=-std=${std}" \ + --env="USE_BAZEL_VERSION=9.1.0" \ + ${DOCKER_EXTRA_ARGS:-} \ ${LINUX_LATEST_CONTAINER} \ - /usr/local/bin/bazel test ... \ - --copt="--gcc-toolchain=/usr/local" \ - --copt="-Wall" \ - --copt="-Werror" \ - --copt="-Wuninitialized" \ - --define="absl=${absl}" \ - --distdir="/bazel-distdir" \ - --features=external_include_paths \ - --keep_going \ - --linkopt="--gcc-toolchain=/usr/local" \ - --show_timestamps \ - --test_output=errors + /bin/bash --login -c " + /usr/local/bin/bazel test ... \ + --copt=\"--gcc-toolchain=/usr/local\" \ + --copt=\"-Wall\" \ + --copt=\"-Werror\" \ + --copt=\"-Wuninitialized\" \ + --copt=\"-Wundef\" \ + --define=\"absl=${absl}\" \ + --enable_bzlmod=true \ + --features=external_include_paths \ + --keep_going \ + --linkopt=\"--gcc-toolchain=/usr/local\" \ + --per_file_copt=\"external/.*@-w\" \ + --show_timestamps \ + --test_output=errors \ + ${BAZEL_EXTRA_ARGS:-}" done done diff --git a/test/googletest/ci/macos-presubmit.sh b/test/googletest/ci/macos-presubmit.sh index 8f35df5..46b7a4c 100644 --- a/test/googletest/ci/macos-presubmit.sh +++ b/test/googletest/ci/macos-presubmit.sh @@ -31,6 +31,14 @@ set -euox pipefail +# Use Xcode 26.2 +sudo xcode-select -s /Applications/Xcode_26.2.app/Contents/Developer + +brew install cmake + +export CMAKE_BUILD_PARALLEL_LEVEL=$(sysctl -n hw.ncpu) +export CTEST_PARALLEL_LEVEL=$(sysctl -n hw.ncpu) + if [[ -z ${GTEST_ROOT:-} ]]; then GTEST_ROOT="$(realpath $(dirname ${0})/..)" fi @@ -40,20 +48,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=14 \ + -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} - time make + time make -j$(nproc) 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-5.1.1-darwin-x86_64" +KOKORO_GFILE_BAZEL_BIN="bazel-9.1.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} @@ -61,15 +69,25 @@ else BAZEL_BIN="bazel" fi +# Use Bazel Vendor mode to reduce reliance on external dependencies. +if [[ ${KOKORO_GFILE_DIR:-} ]] && [[ -f "${KOKORO_GFILE_DIR}/distdir/googletest_vendor.tar.gz" ]]; then + tar -xf "${KOKORO_GFILE_DIR}/distdir/googletest_vendor.tar.gz" -C "${HOME}/" + BAZEL_EXTRA_ARGS="--vendor_dir=${HOME}/googletest_vendor ${BAZEL_EXTRA_ARGS:-}" +fi + cd ${GTEST_ROOT} for absl in 0 1; do ${BAZEL_BIN} test ... \ --copt="-Wall" \ --copt="-Werror" \ - --cxxopt="-std=c++14" \ + --copt="-Wundef" \ + --cxxopt="-std=c++17" \ --define="absl=${absl}" \ + --enable_bzlmod=true \ --features=external_include_paths \ --keep_going \ + --per_file_copt="external/.*@-w" \ --show_timestamps \ - --test_output=errors + --test_output=errors \ + ${BAZEL_EXTRA_ARGS:-} done diff --git a/test/googletest/ci/windows-presubmit.bat b/test/googletest/ci/windows-presubmit.bat index 8668ff3..cce732b 100644 --- a/test/googletest/ci/windows-presubmit.bat +++ b/test/googletest/ci/windows-presubmit.bat @@ -1,29 +1,29 @@ SETLOCAL ENABLEDELAYEDEXPANSION -SET BAZEL_EXE=%KOKORO_GFILE_DIR%\bazel-5.1.1-windows-x86_64.exe +SET BAZEL_EXE=%KOKORO_GFILE_DIR%\bazel-9.1.0-windows-x86_64.exe -SET PATH=C:\Python37;%PATH% -SET BAZEL_PYTHON=C:\python37\python.exe +SET PATH=C:\Python34;%PATH% +SET BAZEL_PYTHON=C:\python34\python.exe SET BAZEL_SH=C:\tools\msys64\usr\bin\bash.exe -SET CMAKE_BIN="C:\Program Files\CMake\bin\cmake.exe" -SET CTEST_BIN="C:\Program Files\CMake\bin\ctest.exe" +SET CMAKE_BIN="cmake.exe" +SET CTEST_BIN="ctest.exe" SET CTEST_OUTPUT_ON_FAILURE=1 +SET CMAKE_BUILD_PARALLEL_LEVEL=16 +SET CTEST_PARALLEL_LEVEL=16 -IF EXIST git\googletest ( - CD git\googletest -) ELSE IF EXIST github\googletest ( - CD github\googletest -) - +SET GTEST_ROOT=%~dp0\.. IF %errorlevel% neq 0 EXIT /B 1 :: ---------------------------------------------------------------------------- -:: CMake Visual Studio 15 2017 Win64 -MKDIR cmake_msvc2017 -CD cmake_msvc2017 +:: CMake +SET CMAKE_BUILD_PATH=cmake_msvc2022 +MKDIR %CMAKE_BUILD_PATH% +CD %CMAKE_BUILD_PATH% +SET CXXFLAGS="/WX" -%CMAKE_BIN% .. ^ - -G "Visual Studio 15 2017 Win64" ^ +%CMAKE_BIN% %GTEST_ROOT% ^ + -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 ^ @@ -38,19 +38,52 @@ IF %errorlevel% neq 0 EXIT /B 1 %CTEST_BIN% -C Debug --timeout 600 IF %errorlevel% neq 0 EXIT /B 1 -CD .. -RMDIR /S /Q cmake_msvc2017 +SET "CXXFLAGS=" +CD %GTEST_ROOT% +RMDIR /S /Q %CMAKE_BUILD_PATH% :: ---------------------------------------------------------------------------- -:: Bazel Visual Studio 15 2017 Win64 +:: Bazel -SET BAZEL_VC=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC -%BAZEL_EXE% test ... ^ +:: The default home directory on Kokoro is a long path which causes errors +:: 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 + +:: Use Bazel Vendor mode to reduce reliance on external dependencies. +IF EXIST "%KOKORO_GFILE_DIR%\distdir\googletest_vendor.tar.gz" ( + tar --force-local -xf "%KOKORO_GFILE_DIR%\distdir\googletest_vendor.tar.gz" -C c: + SET VENDOR_FLAG=--vendor_dir=c:\googletest_vendor +) ELSE ( + SET VENDOR_FLAG= +) + +:: C++17 +%BAZEL_EXE% ^ + --output_user_root=C:\tmp ^ + test ... ^ --compilation_mode=dbg ^ - --copt=/std:c++14 ^ + --copt=/std:c++17 ^ --copt=/WX ^ - --features=external_include_paths ^ + --enable_bzlmod=true ^ --keep_going ^ + --per_file_copt=external/.*@/w ^ --test_output=errors ^ - --test_tag_filters=-no_test_msvc2017 + --test_tag_filters=-no_test_msvc2017 ^ + %VENDOR_FLAG% +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=/WX ^ + --enable_bzlmod=true ^ + --keep_going ^ + --per_file_copt=external/.*@/w ^ + --test_output=errors ^ + --test_tag_filters=-no_test_msvc2017 ^ + %VENDOR_FLAG% IF %errorlevel% neq 0 EXIT /B 1 diff --git a/test/googletest/docs/_layouts/default.html b/test/googletest/docs/_layouts/default.html index c7f331b..f0ae474 100644 --- a/test/googletest/docs/_layouts/default.html +++ b/test/googletest/docs/_layouts/default.html @@ -7,15 +7,15 @@ {% seo %} + + -