Merge pull request #4435 from kaswhy:main
PiperOrigin-RevId: 602385832
Change-Id: I755dae5707e98b6157930a74de90a8e19ef17603
diff --git a/.gitignore b/.gitignore
index fede02f..f0df39d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,7 @@
bazel-googletest
bazel-out
bazel-testlogs
+MODULE.bazel.lock
# python
*.pyc
diff --git a/MODULE.bazel b/MODULE.bazel
new file mode 100644
index 0000000..d4ad2b3
--- /dev/null
+++ b/MODULE.bazel
@@ -0,0 +1,57 @@
+# 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 = "head",
+ 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 = "20240116.0",
+ repo_name = "com_google_absl")
+
+bazel_dep(name = "platforms",
+ version = "0.0.8")
+
+bazel_dep(name = "re2",
+ repo_name = "com_googlesource_code_re2",
+ version = "2023-11-01")
+
+bazel_dep(name = "rules_python",
+ version = "0.29.0")
+
+# https://github.com/bazelbuild/rules_python/blob/main/BZLMOD_SUPPORT.md#default-toolchain-is-not-the-local-system-python
+register_toolchains("@bazel_tools//tools/python:autodetecting_toolchain")
diff --git a/WORKSPACE b/WORKSPACE
index f819ffe..92cfd25 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -6,22 +6,24 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
- name = "rules_python", # 2023-07-31T20:39:27Z
- sha256 = "1250b59a33c591a1c4ba68c62e95fc88a84c334ec35a2e23f46cbc1b9a5a8b55",
- strip_prefix = "rules_python-e355becc30275939d87116a4ec83dad4bb50d9e1",
- urls = ["https://github.com/bazelbuild/rules_python/archive/e355becc30275939d87116a4ec83dad4bb50d9e1.zip"],
+ 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/0.29.0
+load("@rules_python//python:repositories.bzl", "py_repositories")
+py_repositories()
+
+http_archive(
+ name = "bazel_skylib",
+ sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94",
+ urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz"],
)
http_archive(
- name = "bazel_skylib", # 2023-05-31T19:24:07Z
- sha256 = "08c0386f45821ce246bbbf77503c973246ed6ee5c3463e41efc197fa9bc3a7f4",
- strip_prefix = "bazel-skylib-288731ef9f7f688932bd50e704a91a45ec185f9b",
- urls = ["https://github.com/bazelbuild/bazel-skylib/archive/288731ef9f7f688932bd50e704a91a45ec185f9b.zip"],
-)
-
-http_archive(
- name = "platforms", # 2023-07-28T19:44:27Z
- sha256 = "40eb313613ff00a5c03eed20aba58890046f4d38dec7344f00bb9a8867853526",
- strip_prefix = "platforms-4ad40ef271da8176d4fc0194d2089b8a76e19d7b",
- urls = ["https://github.com/bazelbuild/platforms/archive/4ad40ef271da8176d4fc0194d2089b8a76e19d7b.zip"],
+ name = "platforms",
+ sha256 = "8150406605389ececb6da07cbcb509d5637a3ab9a24bc69b1101531367d89d74",
+ urls = ["https://github.com/bazelbuild/platforms/releases/download/0.0.8/platforms-0.0.8.tar.gz"],
)
diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod
new file mode 100644
index 0000000..381432c
--- /dev/null
+++ b/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/ci/linux-presubmit.sh b/ci/linux-presubmit.sh
index a1caa27..35e1670 100644
--- a/ci/linux-presubmit.sh
+++ b/ci/linux-presubmit.sh
@@ -31,7 +31,7 @@
set -euox pipefail
-readonly LINUX_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20230816"
+readonly LINUX_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20231218"
readonly LINUX_GCC_FLOOR_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-floor:20230120"
if [[ -z ${GTEST_ROOT:-} ]]; then
@@ -67,6 +67,9 @@
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" \
@@ -80,7 +83,6 @@
--copt="-Wuninitialized" \
--copt="-Wundef" \
--copt="-Wno-error=pragmas" \
- --distdir="/bazel-distdir" \
--features=external_include_paths \
--keep_going \
--show_timestamps \
@@ -102,7 +104,7 @@
--copt="-Wuninitialized" \
--copt="-Wundef" \
--define="absl=${absl}" \
- --distdir="/bazel-distdir" \
+ --enable_bzlmod=true \
--features=external_include_paths \
--keep_going \
--show_timestamps \
@@ -127,7 +129,7 @@
--copt="-Wuninitialized" \
--copt="-Wundef" \
--define="absl=${absl}" \
- --distdir="/bazel-distdir" \
+ --enable_bzlmod=true \
--features=external_include_paths \
--keep_going \
--linkopt="--gcc-toolchain=/usr/local" \
diff --git a/ci/macos-presubmit.sh b/ci/macos-presubmit.sh
index 681ebc2..70eaa74 100644
--- a/ci/macos-presubmit.sh
+++ b/ci/macos-presubmit.sh
@@ -53,7 +53,7 @@
# 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-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}
@@ -69,6 +69,7 @@
--copt="-Wundef" \
--cxxopt="-std=c++14" \
--define="absl=${absl}" \
+ --enable_bzlmod=true \
--features=external_include_paths \
--keep_going \
--show_timestamps \
diff --git a/ci/windows-presubmit.bat b/ci/windows-presubmit.bat
index 48962eb..9753f9c 100644
--- a/ci/windows-presubmit.bat
+++ b/ci/windows-presubmit.bat
@@ -1,6 +1,6 @@
SETLOCAL ENABLEDELAYEDEXPANSION
-SET BAZEL_EXE=%KOKORO_GFILE_DIR%\bazel-5.1.1-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
@@ -51,7 +51,7 @@
--compilation_mode=dbg ^
--copt=/std:c++14 ^
--copt=/WX ^
- --features=external_include_paths ^
+ --enable_bzlmod=true ^
--keep_going ^
--test_output=errors ^
--test_tag_filters=-no_test_msvc2017
diff --git a/docs/advanced.md b/docs/advanced.md
index 715bd04..2ecce63 100644
--- a/docs/advanced.md
+++ b/docs/advanced.md
@@ -1004,19 +1004,20 @@
Environment* AddGlobalTestEnvironment(Environment* env);
```
-Now, when `RUN_ALL_TESTS()` is invoked, it first calls the `SetUp()` method.
-The tests are then executed, provided that none of the environments have reported
-fatal failures and `GTEST_SKIP()` has not been invoked. Finally, `TearDown()` is called.
+Now, when `RUN_ALL_TESTS()` is invoked, it first calls the `SetUp()` method. The
+tests are then executed, provided that none of the environments have reported
+fatal failures and `GTEST_SKIP()` has not been invoked. Finally, `TearDown()` is
+called.
-Note that `SetUp()` and `TearDown()` are only invoked if there is at least one test
-to be performed. Importantly, `TearDown()` is executed even if the test is not
-run due to a fatal failure or `GTEST_SKIP()`.
+Note that `SetUp()` and `TearDown()` are only invoked if there is at least one
+test to be performed. Importantly, `TearDown()` is executed even if the test is
+not run due to a fatal failure or `GTEST_SKIP()`.
-Calling `SetUp()` and `TearDown()` for each iteration depends on the
-`gtest_recreate_environments_when_repeating variable`. `SetUp()` and `TearDown()`
-are called for each environment object when they are recreated for each iteration.
-However, if the test environments are not recreated for each iteration,
-`SetUp()` is called only on the first iteration, and `TearDown()` is called only
+Calling `SetUp()` and `TearDown()` for each iteration depends on the flag
+`gtest_recreate_environments_when_repeating`. `SetUp()` and `TearDown()` are
+called for each environment object when the object is recreated for each
+iteration. However, if test environments are not recreated for each iteration,
+`SetUp()` is called only on the first iteration, and `TearDown()` is called only
on the last iteration.
It's OK to register multiple environment objects. In this suite, their `SetUp()`
diff --git a/docs/reference/testing.md b/docs/reference/testing.md
index ead66b3..81640fd 100644
--- a/docs/reference/testing.md
+++ b/docs/reference/testing.md
@@ -1317,7 +1317,9 @@
Initializes GoogleTest. This must be called before calling
[`RUN_ALL_TESTS()`](#RUN_ALL_TESTS). In particular, it parses the command line
for the flags that GoogleTest recognizes. Whenever a GoogleTest flag is seen, it
-is removed from `argv`, and `*argc` is decremented.
+is removed from `argv`, and `*argc` is decremented. Keep in mind that `argv`
+must terminate with a `NULL` pointer (i.e. `argv[argc]` is `NULL`), which is
+already the case with the default `argv` passed to `main`.
No value is returned. Instead, the GoogleTest flag variables are updated.
diff --git a/googletest/CMakeLists.txt b/googletest/CMakeLists.txt
index 51a67c9..dce6a7c 100644
--- a/googletest/CMakeLists.txt
+++ b/googletest/CMakeLists.txt
@@ -147,7 +147,7 @@
target_include_directories(gtest_main SYSTEM INTERFACE
"$<BUILD_INTERFACE:${dirs}>"
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
-if(CMAKE_SYSTEM_NAME MATCHES "QNX")
+if(CMAKE_SYSTEM_NAME MATCHES "QNX" AND CMAKE_SYSTEM_VERSION VERSION_GREATER_EQUAL 7.1)
target_link_libraries(gtest PUBLIC regex)
endif()
target_link_libraries(gtest_main PUBLIC gtest)
diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h
index 1b12ef6..b2822bc 100644
--- a/googletest/include/gtest/gtest-printers.h
+++ b/googletest/include/gtest/gtest-printers.h
@@ -124,7 +124,7 @@
#if GTEST_INTERNAL_HAS_STD_SPAN
#include <span> // NOLINT
-#endif // GTEST_INTERNAL_HAS_STD_SPAN
+#endif // GTEST_INTERNAL_HAS_STD_SPAN
namespace testing {
@@ -241,8 +241,8 @@
// ADL (possibly involving implicit conversions).
// (Use SFINAE via return type, because it seems GCC < 12 doesn't handle name
// lookup properly when we do it in the template parameter list.)
- static auto PrintValue(const T& value, ::std::ostream* os)
- -> decltype((void)(*os << value)) {
+ static auto PrintValue(const T& value,
+ ::std::ostream* os) -> decltype((void)(*os << value)) {
// Call streaming operator found by ADL, possibly with implicit conversions
// of the arguments.
*os << value;
@@ -552,49 +552,63 @@
int full = std::numeric_limits<FloatType>::max_digits10;
if (val < 0) val = -val;
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wfloat-equal"
+#endif
if (val < 1000000) {
FloatType mulfor6 = 1e10;
- if (val >= 100000.0) { // 100,000 to 999,999
+ // Without these static casts, the template instantiation for float would
+ // fail to compile when -Wdouble-promotion is enabled, as the arithmetic and
+ // comparison logic would promote floats to doubles.
+ if (val >= static_cast<FloatType>(100000.0)) { // 100,000 to 999,999
mulfor6 = 1.0;
- } else if (val >= 10000.0) {
+ } else if (val >= static_cast<FloatType>(10000.0)) {
mulfor6 = 1e1;
- } else if (val >= 1000.0) {
+ } else if (val >= static_cast<FloatType>(1000.0)) {
mulfor6 = 1e2;
- } else if (val >= 100.0) {
+ } else if (val >= static_cast<FloatType>(100.0)) {
mulfor6 = 1e3;
- } else if (val >= 10.0) {
+ } else if (val >= static_cast<FloatType>(10.0)) {
mulfor6 = 1e4;
- } else if (val >= 1.0) {
+ } else if (val >= static_cast<FloatType>(1.0)) {
mulfor6 = 1e5;
- } else if (val >= 0.1) {
+ } else if (val >= static_cast<FloatType>(0.1)) {
mulfor6 = 1e6;
- } else if (val >= 0.01) {
+ } else if (val >= static_cast<FloatType>(0.01)) {
mulfor6 = 1e7;
- } else if (val >= 0.001) {
+ } else if (val >= static_cast<FloatType>(0.001)) {
mulfor6 = 1e8;
- } else if (val >= 0.0001) {
+ } else if (val >= static_cast<FloatType>(0.0001)) {
mulfor6 = 1e9;
}
- if (static_cast<FloatType>(static_cast<int32_t>(val * mulfor6 + 0.5)) /
+ if (static_cast<FloatType>(static_cast<int32_t>(
+ val * mulfor6 + (static_cast<FloatType>(0.5)))) /
mulfor6 ==
val)
return 6;
- } else if (val < 1e10) {
- FloatType divfor6 = 1.0;
- if (val >= 1e9) { // 1,000,000,000 to 9,999,999,999
+ } else if (val < static_cast<FloatType>(1e10)) {
+ FloatType divfor6 = static_cast<FloatType>(1.0);
+ if (val >= static_cast<FloatType>(1e9)) { // 1,000,000,000 to 9,999,999,999
divfor6 = 10000;
- } else if (val >= 1e8) { // 100,000,000 to 999,999,999
+ } else if (val >=
+ static_cast<FloatType>(1e8)) { // 100,000,000 to 999,999,999
divfor6 = 1000;
- } else if (val >= 1e7) { // 10,000,000 to 99,999,999
+ } else if (val >=
+ static_cast<FloatType>(1e7)) { // 10,000,000 to 99,999,999
divfor6 = 100;
- } else if (val >= 1e6) { // 1,000,000 to 9,999,999
+ } else if (val >= static_cast<FloatType>(1e6)) { // 1,000,000 to 9,999,999
divfor6 = 10;
}
- if (static_cast<FloatType>(static_cast<int32_t>(val / divfor6 + 0.5)) *
+ if (static_cast<FloatType>(static_cast<int32_t>(
+ val / divfor6 + (static_cast<FloatType>(0.5)))) *
divfor6 ==
val)
return 6;
}
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
return full;
}
diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h
index 4f077fc..806b086 100644
--- a/googletest/include/gtest/internal/gtest-internal.h
+++ b/googletest/include/gtest/internal/gtest-internal.h
@@ -555,7 +555,7 @@
// type_param: the name of the test's type parameter, or NULL if
// this is not a typed or a type-parameterized test.
// value_param: text representation of the test's value parameter,
-// or NULL if this is not a type-parameterized test.
+// or NULL if this is not a value-parameterized test.
// code_location: code location where the test is defined
// fixture_class_id: ID of the test fixture class
// set_up_tc: pointer to the function that sets up the test suite
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index d061a49..fa457b7 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -338,9 +338,10 @@
#define GTEST_HAS_NOTIFICATION_ 0
#endif
-#ifdef GTEST_HAS_ABSL
-#include "absl/flags/declare.h"
+#if defined(GTEST_HAS_ABSL) && !defined(GTEST_NO_ABSL_FLAGS)
+#define GTEST_INTERNAL_HAS_ABSL_FLAGS // Used only in this file.
#include "absl/flags/flag.h"
+#include "absl/flags/declare.h"
#include "absl/flags/reflection.h"
#endif
@@ -2005,7 +2006,9 @@
namespace posix {
// File system porting.
-#if GTEST_HAS_FILE_SYSTEM
+// Note: Not every I/O-related function is related to file systems, so don't
+// just disable all of them here. For example, fileno() and isatty(), etc. must
+// always be available in order to detect if a pipe points to a terminal.
#ifdef GTEST_OS_WINDOWS
typedef struct _stat StatStruct;
@@ -2016,27 +2019,32 @@
// time and thus not defined there.
#else
inline int FileNo(FILE* file) { return _fileno(file); }
+#if GTEST_HAS_FILE_SYSTEM
inline int Stat(const char* path, StatStruct* buf) { return _stat(path, buf); }
inline int RmDir(const char* dir) { return _rmdir(dir); }
inline bool IsDir(const StatStruct& st) { return (_S_IFDIR & st.st_mode) != 0; }
+#endif
#endif // GTEST_OS_WINDOWS_MOBILE
#elif defined(GTEST_OS_ESP8266)
typedef struct stat StatStruct;
inline int FileNo(FILE* file) { return fileno(file); }
+#if GTEST_HAS_FILE_SYSTEM
inline int Stat(const char* path, StatStruct* buf) {
// stat function not implemented on ESP8266
return 0;
}
inline int RmDir(const char* dir) { return rmdir(dir); }
inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
+#endif
#else
typedef struct stat StatStruct;
inline int FileNo(FILE* file) { return fileno(file); }
+#if GTEST_HAS_FILE_SYSTEM
inline int Stat(const char* path, StatStruct* buf) { return stat(path, buf); }
#ifdef GTEST_OS_QURT
// QuRT doesn't support any directory functions, including rmdir
@@ -2045,9 +2053,9 @@
inline int RmDir(const char* dir) { return rmdir(dir); }
#endif
inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
+#endif
#endif // GTEST_OS_WINDOWS
-#endif // GTEST_HAS_FILE_SYSTEM
// Other functions with a different name on Windows.
@@ -2245,7 +2253,7 @@
#endif // !defined(GTEST_FLAG)
// Pick a command line flags implementation.
-#ifdef GTEST_HAS_ABSL
+#ifdef GTEST_INTERNAL_HAS_ABSL_FLAGS
// Macros for defining flags.
#define GTEST_DEFINE_bool_(name, default_val, doc) \
@@ -2270,7 +2278,8 @@
(void)(::absl::SetFlag(>EST_FLAG(name), value))
#define GTEST_USE_OWN_FLAGFILE_FLAG_ 0
-#else // GTEST_HAS_ABSL
+#undef GTEST_INTERNAL_HAS_ABSL_FLAGS
+#else // ndef GTEST_INTERNAL_HAS_ABSL_FLAGS
// Macros for defining flags.
#define GTEST_DEFINE_bool_(name, default_val, doc) \
@@ -2312,7 +2321,7 @@
#define GTEST_FLAG_SET(name, value) (void)(::testing::GTEST_FLAG(name) = value)
#define GTEST_USE_OWN_FLAGFILE_FLAG_ 1
-#endif // GTEST_HAS_ABSL
+#endif // GTEST_INTERNAL_HAS_ABSL_FLAGS
// Thread annotations
#if !defined(GTEST_EXCLUSIVE_LOCK_REQUIRED_)
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 479b2ee..7dc8059 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -162,6 +162,10 @@
#define GTEST_HAS_BUILTIN(x) 0
#endif // defined(__has_builtin)
+#if defined(GTEST_HAS_ABSL) && !defined(GTEST_NO_ABSL_FLAGS)
+#define GTEST_HAS_ABSL_FLAGS
+#endif
+
namespace testing {
using internal::CountIf;
@@ -459,7 +463,12 @@
UnitTest::GetInstance()->AddTestPartResult(
data_->type, data_->file, data_->line,
AppendUserMessage(data_->message, message),
- UnitTest::GetInstance()->impl()->CurrentOsStackTraceExceptTop(1)
+ // Suppress emission of the stack trace for GTEST_SKIP() since skipping is
+ // an intentional act by the developer rather than a failure requiring
+ // investigation.
+ data_->type != TestPartResult::kSkip
+ ? UnitTest::GetInstance()->impl()->CurrentOsStackTraceExceptTop(1)
+ : ""
// Skips the stack frame for this function itself.
); // NOLINT
}
@@ -3283,11 +3292,9 @@
va_start(args, fmt);
static const bool in_color_mode =
-#if GTEST_HAS_FILE_SYSTEM
+ // We don't condition this on GTEST_HAS_FILE_SYSTEM because we still need
+ // to be able to detect terminal I/O regardless.
ShouldUseColor(posix::IsATTY(posix::FileNo(stdout)) != 0);
-#else
- false;
-#endif // GTEST_HAS_FILE_SYSTEM
const bool use_color = in_color_mode && (color != GTestColor::kDefault);
@@ -6685,7 +6692,7 @@
// remain in place. Unrecognized flags are not reported and do not cause the
// program to exit.
void ParseGoogleTestFlagsOnly(int* argc, char** argv) {
-#ifdef GTEST_HAS_ABSL
+#ifdef GTEST_HAS_ABSL_FLAGS
if (*argc <= 0) return;
std::vector<char*> positional_args;
@@ -6771,11 +6778,13 @@
#ifdef GTEST_HAS_ABSL
absl::InitializeSymbolizer(g_argvs[0].c_str());
+#ifdef GTEST_HAS_ABSL_FLAGS
// When using the Abseil Flags library, set the program usage message to the
// help message, but remove the color-encoding from the message first.
absl::SetProgramUsageMessage(absl::StrReplaceAll(
kColorEncodedHelpMessage,
{{"@D", ""}, {"@R", ""}, {"@G", ""}, {"@Y", ""}, {"@@", "@"}}));
+#endif // GTEST_HAS_ABSL_FLAGS
#endif // GTEST_HAS_ABSL
ParseGoogleTestFlagsOnly(argc, argv);
diff --git a/googletest/test/googletest-output-test-golden-lin.txt b/googletest/test/googletest-output-test-golden-lin.txt
index 6ddf822..e06856a 100644
--- a/googletest/test/googletest-output-test-golden-lin.txt
+++ b/googletest/test/googletest-output-test-golden-lin.txt
@@ -970,7 +970,6 @@
[0;32m[----------] [m1 test from TestSuiteThatSkipsInSetUp
googletest-output-test_.cc:#: Skipped
Skip entire test suite
-Stack trace: (omitted)
[0;32m[ RUN ] [mTestSuiteThatSkipsInSetUp.ShouldNotRun
googletest-output-test_.cc:#: Skipped
diff --git a/googletest/test/gtest_xml_output_unittest.py b/googletest/test/gtest_xml_output_unittest.py
index 422569e..c3fea2c 100755
--- a/googletest/test/gtest_xml_output_unittest.py
+++ b/googletest/test/gtest_xml_output_unittest.py
@@ -112,20 +112,23 @@
</testsuite>
<testsuite name="SkippedTest" tests="3" failures="1" disabled="0" skipped="2" errors="0" time="*" timestamp="*">
<testcase name="Skipped" status="run" file="gtest_xml_output_unittest_.cc" line="75" result="skipped" time="*" timestamp="*" classname="SkippedTest">
- <skipped message="gtest_xml_output_unittest_.cc:*
%(stack_entity)s"><![CDATA[gtest_xml_output_unittest_.cc:*
-%(stack)s]]></skipped>
+ <skipped message="gtest_xml_output_unittest_.cc:*

"><![CDATA[gtest_xml_output_unittest_.cc:*
+
+]]></skipped>
</testcase>
<testcase name="SkippedWithMessage" file="gtest_xml_output_unittest_.cc" line="79" status="run" result="skipped" time="*" timestamp="*" classname="SkippedTest">
- <skipped message="gtest_xml_output_unittest_.cc:*
It is good practice to tell why you skip a test.%(stack_entity)s"><![CDATA[gtest_xml_output_unittest_.cc:*
-It is good practice to tell why you skip a test.%(stack)s]]></skipped>
+ <skipped message="gtest_xml_output_unittest_.cc:*
It is good practice to tell why you skip a test.
"><![CDATA[gtest_xml_output_unittest_.cc:*
+It is good practice to tell why you skip a test.
+]]></skipped>
</testcase>
<testcase name="SkippedAfterFailure" file="gtest_xml_output_unittest_.cc" line="83" status="run" result="completed" time="*" timestamp="*" classname="SkippedTest">
<failure message="gtest_xml_output_unittest_.cc:*
Expected equality of these values:
 1
 2%(stack_entity)s" type=""><![CDATA[gtest_xml_output_unittest_.cc:*
Expected equality of these values:
1
2%(stack)s]]></failure>
- <skipped message="gtest_xml_output_unittest_.cc:*
It is good practice to tell why you skip a test.%(stack_entity)s"><![CDATA[gtest_xml_output_unittest_.cc:*
-It is good practice to tell why you skip a test.%(stack)s]]></skipped>
+ <skipped message="gtest_xml_output_unittest_.cc:*
It is good practice to tell why you skip a test.
"><![CDATA[gtest_xml_output_unittest_.cc:*
+It is good practice to tell why you skip a test.
+]]></skipped>
</testcase>
</testsuite>
diff --git a/googletest_deps.bzl b/googletest_deps.bzl
index 8f19cbe..8958890 100644
--- a/googletest_deps.bzl
+++ b/googletest_deps.bzl
@@ -7,16 +7,16 @@
if not native.existing_rule("com_googlesource_code_re2"):
http_archive(
- name = "com_googlesource_code_re2", # 2023-03-17T11:36:51Z
- sha256 = "cb8b5312a65f2598954545a76e8bce913f35fbb3a21a5c88797a4448e9f9b9d9",
- strip_prefix = "re2-578843a516fd1da7084ae46209a75f3613b6065e",
- urls = ["https://github.com/google/re2/archive/578843a516fd1da7084ae46209a75f3613b6065e.zip"],
+ name = "com_googlesource_code_re2",
+ sha256 = "828341ad08524618a626167bd320b0c2acc97bd1c28eff693a9ea33a7ed2a85f",
+ strip_prefix = "re2-2023-11-01",
+ urls = ["https://github.com/google/re2/releases/download/2023-11-01/re2-2023-11-01.zip"],
)
if not native.existing_rule("com_google_absl"):
http_archive(
- name = "com_google_absl", # 2023-09-13T14:58:42Z
- sha256 = "7766815ef6293dc7bca58fef59a96d7d3230874412dcd36dafb0e313ed1356f2",
- strip_prefix = "abseil-cpp-9e1789ffea47fdeb3133aa42aa9592f3673fb6ed",
- urls = ["https://github.com/abseil/abseil-cpp/archive/9e1789ffea47fdeb3133aa42aa9592f3673fb6ed.zip"],
+ name = "com_google_absl",
+ sha256 = "338420448b140f0dfd1a1ea3c3ce71b3bc172071f24f4d9a57d59b45037da440",
+ strip_prefix = "abseil-cpp-20240116.0",
+ urls = ["https://github.com/abseil/abseil-cpp/releases/download/20240116.0/abseil-cpp-20240116.0.tar.gz"],
)