From 3280a930bf3f2fdb77da9a6cdf5866ef22708ff1 Mon Sep 17 00:00:00 2001 From: Baruch Burstein Date: Sun, 31 Jul 2022 22:50:04 +0300 Subject: [PATCH 001/336] Custom type with Combine(). Fix for #3781 --- docs/reference/testing.md | 1 + googletest/include/gtest/gtest-param-test.h | 40 ++++++++++ googletest/include/gtest/gtest.h | 2 +- .../include/gtest/internal/gtest-param-util.h | 71 +++++++++++++++++ googletest/test/googletest-param-test-test.cc | 76 ++++++++++++++++--- 5 files changed, 180 insertions(+), 10 deletions(-) diff --git a/docs/reference/testing.md b/docs/reference/testing.md index dc4794239..877dfa322 100644 --- a/docs/reference/testing.md +++ b/docs/reference/testing.md @@ -109,6 +109,7 @@ namespace: | `ValuesIn(container)` or `ValuesIn(begin,end)` | Yields values from a C-style array, an STL-style container, or an iterator range `[begin, end)`. | | `Bool()` | Yields sequence `{false, true}`. | | `Combine(g1, g2, ..., gN)` | Yields as `std::tuple` *n*-tuples all combinations (Cartesian product) of the values generated by the given *n* generators `g1`, `g2`, ..., `gN`. | +| `ConvertGenerator(g)` | Yields values generated by generator `g`, `static_cast` to `T`. | The optional last argument *`name_generator`* is a function or functor that generates custom test name suffixes based on the test parameters. The function diff --git a/googletest/include/gtest/gtest-param-test.h b/googletest/include/gtest/gtest-param-test.h index b55119ac6..d59e552e4 100644 --- a/googletest/include/gtest/gtest-param-test.h +++ b/googletest/include/gtest/gtest-param-test.h @@ -407,6 +407,46 @@ internal::CartesianProductHolder Combine(const Generator&... g) { return internal::CartesianProductHolder(g...); } +// ConvertGenerator() wraps a parameter generator in order to cast each prduced +// value through a known type before supplying it to the test suite +// +// Synopsis: +// ConvertGenerator(gen) +// - returns a generator producing the same elements as generated by gen, but +// each element is static_cast to type T before being returned +// +// It is useful when using the Combine() function to get the generated +// parameters in a custom type instead of std::tuple +// +// Example: +// +// This will instantiate tests in test suite AnimalTest each one with +// the parameter values tuple("cat", BLACK), tuple("cat", WHITE), +// tuple("dog", BLACK), and tuple("dog", WHITE): +// +// enum Color { BLACK, GRAY, WHITE }; +// struct ParamType { +// using TupleT = std::tuple; +// std::string animal; +// Color color; +// ParamType(TupleT t) : animal(std::get<0>(t)), color(std::get<1>(t)) {} +// }; +// class AnimalTest +// : public testing::TestWithParam {...}; +// +// TEST_P(AnimalTest, AnimalLooksNice) {...} +// +// INSTANTIATE_TEST_SUITE_P(AnimalVariations, AnimalTest, +// ConvertGenerator( +// Combine(Values("cat", "dog"), +// Values(BLACK, WHITE)))); +// +template +internal::ParamConverterGenerator ConvertGenerator( + internal::ParamGenerator gen) { + return internal::ParamConverterGenerator(gen); +} + #define TEST_P(test_suite_name, test_name) \ class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \ : public test_suite_name { \ diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index d19a587a1..0c97f6c96 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -1625,7 +1625,7 @@ class GTEST_API_ AssertHelper { // the GetParam() method. // // Use it with one of the parameter generator defining functions, like Range(), -// Values(), ValuesIn(), Bool(), and Combine(). +// Values(), ValuesIn(), Bool(), Combine(), and ConvertGenerator(). // // class FooTest : public ::testing::TestWithParam { // protected: diff --git a/googletest/include/gtest/internal/gtest-param-util.h b/googletest/include/gtest/internal/gtest-param-util.h index e7af2f904..c643a3bdf 100644 --- a/googletest/include/gtest/internal/gtest-param-util.h +++ b/googletest/include/gtest/internal/gtest-param-util.h @@ -950,6 +950,77 @@ class CartesianProductHolder { std::tuple generators_; }; +template +class ParamGeneratorConverter : public ParamGeneratorInterface { + public: + ParamGeneratorConverter(ParamGenerator gen) + : generator_(std::move(gen)) {} + + ParamIteratorInterface* Begin() const override { + return new Iterator(this, generator_.begin(), generator_.end()); + } + ParamIteratorInterface* End() const override { + return new Iterator(this, generator_.end(), generator_.end()); + } + + private: + class Iterator : public ParamIteratorInterface { + public: + Iterator(const ParamGeneratorInterface* base, ParamIterator it, + ParamIterator end) + : base_(base), it_(it), end_(end) { + if (it_ != end_) value_ = std::make_shared(static_cast(*it_)); + } + ~Iterator() override {} + + const ParamGeneratorInterface* BaseGenerator() const override { + return base_; + } + void Advance() override { + ++it_; + if (it_ != end_) value_ = std::make_shared(static_cast(*it_)); + } + ParamIteratorInterface* Clone() const override { + return new Iterator(*this); + } + const To* Current() const override { return value_.get(); } + bool Equals(const ParamIteratorInterface& other) const override { + // Having the same base generator guarantees that the other + // iterator is of the same type and we can downcast. + GTEST_CHECK_(BaseGenerator() == other.BaseGenerator()) + << "The program attempted to compare iterators " + << "from different generators." << std::endl; + const ParamIterator other_it = + CheckedDowncastToActualType(&other)->it_; + return it_ == other_it; + } + + private: + Iterator(const Iterator& other) = default; + + const ParamGeneratorInterface* const base_; + ParamIterator it_; + ParamIterator end_; + std::shared_ptr value_; + }; // class ParamGeneratorConverter::Iterator + + ParamGenerator generator_; +}; // class ParamGeneratorConverter + +template +class ParamConverterGenerator { + public: + ParamConverterGenerator(ParamGenerator g) : generator(g) {} + + template + operator ParamGenerator() const { + return ParamGenerator(new ParamGeneratorConverter(generator)); + } + + private: + ParamGenerator generator; +}; + } // namespace internal } // namespace testing diff --git a/googletest/test/googletest-param-test-test.cc b/googletest/test/googletest-param-test-test.cc index e3090ae41..a1d278645 100644 --- a/googletest/test/googletest-param-test-test.cc +++ b/googletest/test/googletest-param-test-test.cc @@ -51,6 +51,7 @@ using ::std::vector; using ::testing::AddGlobalTestEnvironment; using ::testing::Bool; using ::testing::Combine; +using ::testing::ConvertGenerator; using ::testing::Message; using ::testing::Range; using ::testing::TestWithParam; @@ -402,7 +403,7 @@ TEST(BoolTest, BoolWorks) { TEST(CombineTest, CombineWithTwoParameters) { const char* foo = "foo"; const char* bar = "bar"; - const ParamGenerator > gen = + const ParamGenerator> gen = Combine(Values(foo, bar), Values(3, 4)); std::tuple expected_values[] = { @@ -413,7 +414,7 @@ TEST(CombineTest, CombineWithTwoParameters) { // Tests that Combine() with three parameters generates the expected sequence. TEST(CombineTest, CombineWithThreeParameters) { - const ParamGenerator > gen = + const ParamGenerator> gen = Combine(Values(0, 1), Values(3, 4), Values(5, 6)); std::tuple expected_values[] = { std::make_tuple(0, 3, 5), std::make_tuple(0, 3, 6), @@ -427,7 +428,7 @@ TEST(CombineTest, CombineWithThreeParameters) { // sequence generates a sequence with the number of elements equal to the // number of elements in the sequence generated by the second parameter. TEST(CombineTest, CombineWithFirstParameterSingleValue) { - const ParamGenerator > gen = + const ParamGenerator> gen = Combine(Values(42), Values(0, 1)); std::tuple expected_values[] = {std::make_tuple(42, 0), @@ -439,7 +440,7 @@ TEST(CombineTest, CombineWithFirstParameterSingleValue) { // sequence generates a sequence with the number of elements equal to the // number of elements in the sequence generated by the first parameter. TEST(CombineTest, CombineWithSecondParameterSingleValue) { - const ParamGenerator > gen = + const ParamGenerator> gen = Combine(Values(0, 1), Values(42)); std::tuple expected_values[] = {std::make_tuple(0, 42), @@ -450,7 +451,7 @@ TEST(CombineTest, CombineWithSecondParameterSingleValue) { // Tests that when the first parameter produces an empty sequence, // Combine() produces an empty sequence, too. TEST(CombineTest, CombineWithFirstParameterEmptyRange) { - const ParamGenerator > gen = + const ParamGenerator> gen = Combine(Range(0, 0), Values(0, 1)); VerifyGeneratorIsEmpty(gen); } @@ -458,7 +459,7 @@ TEST(CombineTest, CombineWithFirstParameterEmptyRange) { // Tests that when the second parameter produces an empty sequence, // Combine() produces an empty sequence, too. TEST(CombineTest, CombineWithSecondParameterEmptyRange) { - const ParamGenerator > gen = + const ParamGenerator> gen = Combine(Values(0, 1), Range(1, 1)); VerifyGeneratorIsEmpty(gen); } @@ -469,7 +470,7 @@ TEST(CombineTest, CombineWithMaxNumberOfParameters) { const char* foo = "foo"; const char* bar = "bar"; const ParamGenerator< - std::tuple > + std::tuple> gen = Combine(Values(foo, bar), Values(1), Values(2), Values(3), Values(4), Values(5), Values(6), Values(7), Values(8), Values(9)); @@ -497,11 +498,11 @@ class NonDefaultConstructAssignString { }; TEST(CombineTest, NonDefaultConstructAssign) { - const ParamGenerator > gen = + const ParamGenerator> gen = Combine(Values(0, 1), Values(NonDefaultConstructAssignString("A"), NonDefaultConstructAssignString("B"))); - ParamGenerator >::iterator + ParamGenerator>::iterator it = gen.begin(); EXPECT_EQ(0, std::get<0>(*it)); @@ -523,6 +524,63 @@ TEST(CombineTest, NonDefaultConstructAssign) { EXPECT_TRUE(it == gen.end()); } +template +class ConstructFromT { + public: + ConstructFromT(const T& t) : t_(t) {} + template + ConstructFromT(Args&&... args) : t_(std::forward(args)...) {} + + bool operator==(const ConstructFromT& other) const { return other.t_ == t_; } + + const T& get() const { return t_; } + + private: + T t_; +}; + +TEST(ConvertTest, CombineWithTwoParameters) { + const char* foo = "foo"; + const char* bar = "bar"; + const ParamGenerator>> gen = + ConvertGenerator>( + Combine(Values(foo, bar), Values(3, 4))); + + ConstructFromT> expected_values[] = { + {foo, 3}, {foo, 4}, {bar, 3}, {bar, 4}}; + VerifyGenerator(gen, expected_values); +} + +TEST(ConvertTest, NonDefaultConstructAssign) { + const ParamGenerator< + ConstructFromT>> + gen = ConvertGenerator>( + Combine(Values(0, 1), Values(NonDefaultConstructAssignString("A"), + NonDefaultConstructAssignString("B")))); + + ParamGenerator>>::iterator it = + gen.begin(); + + EXPECT_EQ(0, std::get<0>(it->get())); + EXPECT_EQ("A", std::get<1>(it->get()).str()); + ++it; + + EXPECT_EQ(0, std::get<0>(it->get())); + EXPECT_EQ("B", std::get<1>(it->get()).str()); + ++it; + + EXPECT_EQ(1, std::get<0>(it->get())); + EXPECT_EQ("A", std::get<1>(it->get()).str()); + ++it; + + EXPECT_EQ(1, std::get<0>(it->get())); + EXPECT_EQ("B", std::get<1>(it->get()).str()); + ++it; + + EXPECT_TRUE(it == gen.end()); +} + // Tests that an generator produces correct sequence after being // assigned from another generator. TEST(ParamGeneratorTest, AssignmentWorks) { From 91c3669f21cf569f13bd15569b5411e6ca9a8961 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Fri, 19 Aug 2022 11:10:56 -0700 Subject: [PATCH 002/336] bazel: move -std=c++14 to .bazelrc Bazel defaults to -std=c++11 on macOS which gtest doesn't support. --- .bazelrc | 1 + .github/workflows/gtest-ci.yml | 9 +++------ ci/linux-presubmit.sh | 1 - ci/macos-presubmit.sh | 1 - 4 files changed, 4 insertions(+), 8 deletions(-) create mode 100644 .bazelrc diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 000000000..f93facf00 --- /dev/null +++ b/.bazelrc @@ -0,0 +1 @@ +build --cxxopt=-std=c++14 diff --git a/.github/workflows/gtest-ci.yml b/.github/workflows/gtest-ci.yml index b2dcab492..e61880f9a 100644 --- a/.github/workflows/gtest-ci.yml +++ b/.github/workflows/gtest-ci.yml @@ -4,9 +4,6 @@ on: push: pull_request: -env: - BAZEL_CXXOPTS: -std=c++14 - jobs: Linux: runs-on: ubuntu-latest @@ -17,7 +14,7 @@ jobs: fetch-depth: 0 - name: Tests - run: bazel test --cxxopt=-std=c++14 --features=external_include_paths --test_output=errors ... + run: bazel test --features=external_include_paths --test_output=errors ... MacOs: runs-on: macos-latest @@ -28,7 +25,7 @@ jobs: fetch-depth: 0 - name: Tests - run: bazel test --cxxopt=-std=c++14 --features=external_include_paths --test_output=errors ... + run: bazel test --features=external_include_paths --test_output=errors ... Windows: @@ -40,4 +37,4 @@ jobs: fetch-depth: 0 - name: Tests - run: bazel test --cxxopt=-std=c++14 --features=external_include_paths --test_output=errors ... + run: bazel test --features=external_include_paths --test_output=errors ... diff --git a/ci/linux-presubmit.sh b/ci/linux-presubmit.sh index 4eb5bbe4a..f6eb9b7d8 100644 --- a/ci/linux-presubmit.sh +++ b/ci/linux-presubmit.sh @@ -72,7 +72,6 @@ time docker run \ --workdir="/src" \ --rm \ --env="CC=/usr/local/bin/gcc" \ - --env="BAZEL_CXXOPTS=-std=c++14" \ ${LINUX_GCC_FLOOR_CONTAINER} \ /usr/local/bin/bazel test ... \ --copt="-Wall" \ diff --git a/ci/macos-presubmit.sh b/ci/macos-presubmit.sh index 8f35df58d..a5d6635af 100644 --- a/ci/macos-presubmit.sh +++ b/ci/macos-presubmit.sh @@ -66,7 +66,6 @@ for absl in 0 1; do ${BAZEL_BIN} test ... \ --copt="-Wall" \ --copt="-Werror" \ - --cxxopt="-std=c++14" \ --define="absl=${absl}" \ --features=external_include_paths \ --keep_going \ From 0e0d9feefab1b51aaab9dfd70132e93c0b6964e5 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Thu, 1 Sep 2022 07:24:20 -0700 Subject: [PATCH 003/336] Fixed header guards to match style guide conventions. PiperOrigin-RevId: 471524660 Change-Id: Ie11e6a7a5a5497f64d5b9c382f1017094e043093 --- googlemock/include/gmock/gmock-function-mocker.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/googlemock/include/gmock/gmock-function-mocker.h b/googlemock/include/gmock/gmock-function-mocker.h index f565d980c..b568aefe4 100644 --- a/googlemock/include/gmock/gmock-function-mocker.h +++ b/googlemock/include/gmock/gmock-function-mocker.h @@ -34,8 +34,8 @@ // IWYU pragma: private, include "gmock/gmock.h" // IWYU pragma: friend gmock/.* -#ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_ // NOLINT -#define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_ // NOLINT +#ifndef GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_FUNCTION_MOCKER_H_ +#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_FUNCTION_MOCKER_H_ #include // IWYU pragma: keep #include // IWYU pragma: keep @@ -511,4 +511,4 @@ using internal::FunctionMocker; #define GMOCK_MOCKER_(arity, constness, Method) \ GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__) -#endif // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_FUNCTION_MOCKER_H_ +#endif // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_FUNCTION_MOCKER_H_ From 0f6885405c980d5479d6177f7223d4bc7bacca6b Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Thu, 8 Sep 2022 09:41:57 -0700 Subject: [PATCH 004/336] Remove obsolete MSVC warning pragmas for Invalid() Remove the MSVC pragmas for disabling warning C4717 (infinite recursion) for Invalid() because that warning has been fixed in cl/441474979. PiperOrigin-RevId: 473012585 Change-Id: I5f1bf88379bd4f2bf005e029c04766ac4caadd84 --- .../include/gmock/internal/gmock-internal-utils.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h index b1343fdc8..92d8eb9de 100644 --- a/googlemock/include/gmock/internal/gmock-internal-utils.h +++ b/googlemock/include/gmock/internal/gmock-internal-utils.h @@ -290,13 +290,6 @@ class WithoutMatchers { // Internal use only: access the singleton instance of WithoutMatchers. GTEST_API_ WithoutMatchers GetWithoutMatchers(); -// Disable MSVC warnings for infinite recursion, since in this case the -// recursion is unreachable. -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4717) -#endif - // Invalid() is usable as an expression of type T, but will terminate // the program with an assertion failure if actually run. This is useful // when a value of type T is needed for compilation, but the statement @@ -314,10 +307,6 @@ inline T Invalid() { #endif } -#ifdef _MSC_VER -#pragma warning(pop) -#endif - // Given a raw type (i.e. having no top-level reference or const // modifier) RawContainer that's either an STL-style container or a // native array, class StlContainerView has the From c29315dda476f195298ab8da180e564478649b9e Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Fri, 9 Sep 2022 15:14:20 -0700 Subject: [PATCH 005/336] Use UnorderedElementsAre in example about using matchers with maps PiperOrigin-RevId: 473353707 Change-Id: Ief5bdbd2b8e28bac8f47be9aaeac4bb93875a793 --- docs/gmock_cook_book.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/gmock_cook_book.md b/docs/gmock_cook_book.md index 8a11d864f..5be298d3e 100644 --- a/docs/gmock_cook_book.md +++ b/docs/gmock_cook_book.md @@ -1424,11 +1424,12 @@ Use `Pair` when comparing maps or other associative containers. {% raw %} ```cpp -using testing::ElementsAre; -using testing::Pair; +using ::testing::UnorderedElementsAre; +using ::testing::Pair; ... - std::map m = {{"a", 1}, {"b", 2}, {"c", 3}}; - EXPECT_THAT(m, ElementsAre(Pair("a", 1), Pair("b", 2), Pair("c", 3))); + absl::flat_hash_map m = {{"a", 1}, {"b", 2}, {"c", 3}}; + EXPECT_THAT(m, UnorderedElementsAre( + Pair("a", 1), Pair("b", 2), Pair("c", 3))); ``` {% endraw %} @@ -1445,8 +1446,8 @@ using testing::Pair; * If the container is passed by pointer instead of by reference, just write `Pointee(ElementsAre*(...))`. * The order of elements *matters* for `ElementsAre*()`. If you are using it - with containers whose element order are undefined (e.g. `hash_map`) you - should use `WhenSorted` around `ElementsAre`. + with containers whose element order are undefined (such as a + `std::unordered_map`) you should use `UnorderedElementsAre`. ### Sharing Matchers From 7cafeff7bddf0430ae1e68ebb6213bb7c5d4a8ec Mon Sep 17 00:00:00 2001 From: Derek Mauro Date: Tue, 13 Sep 2022 08:14:45 -0700 Subject: [PATCH 006/336] Rollback 4fa8cfe3f4dee8975ee02d98633a5245ab67c6d7 Breaks the intended C++ version on some CI builds PiperOrigin-RevId: 474022587 Change-Id: I41a58893802c90864e0f2cc3d15e6c169c59146d --- .bazelrc | 1 - .github/workflows/gtest-ci.yml | 9 ++++++--- ci/linux-presubmit.sh | 1 + ci/macos-presubmit.sh | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) delete mode 100644 .bazelrc diff --git a/.bazelrc b/.bazelrc deleted file mode 100644 index f93facf00..000000000 --- a/.bazelrc +++ /dev/null @@ -1 +0,0 @@ -build --cxxopt=-std=c++14 diff --git a/.github/workflows/gtest-ci.yml b/.github/workflows/gtest-ci.yml index e61880f9a..b2dcab492 100644 --- a/.github/workflows/gtest-ci.yml +++ b/.github/workflows/gtest-ci.yml @@ -4,6 +4,9 @@ on: push: pull_request: +env: + BAZEL_CXXOPTS: -std=c++14 + jobs: Linux: runs-on: ubuntu-latest @@ -14,7 +17,7 @@ jobs: fetch-depth: 0 - name: Tests - run: bazel test --features=external_include_paths --test_output=errors ... + run: bazel test --cxxopt=-std=c++14 --features=external_include_paths --test_output=errors ... MacOs: runs-on: macos-latest @@ -25,7 +28,7 @@ jobs: fetch-depth: 0 - name: Tests - run: bazel test --features=external_include_paths --test_output=errors ... + run: bazel test --cxxopt=-std=c++14 --features=external_include_paths --test_output=errors ... Windows: @@ -37,4 +40,4 @@ jobs: fetch-depth: 0 - name: Tests - run: bazel test --features=external_include_paths --test_output=errors ... + run: bazel test --cxxopt=-std=c++14 --features=external_include_paths --test_output=errors ... diff --git a/ci/linux-presubmit.sh b/ci/linux-presubmit.sh index f6eb9b7d8..4eb5bbe4a 100644 --- a/ci/linux-presubmit.sh +++ b/ci/linux-presubmit.sh @@ -72,6 +72,7 @@ time docker run \ --workdir="/src" \ --rm \ --env="CC=/usr/local/bin/gcc" \ + --env="BAZEL_CXXOPTS=-std=c++14" \ ${LINUX_GCC_FLOOR_CONTAINER} \ /usr/local/bin/bazel test ... \ --copt="-Wall" \ diff --git a/ci/macos-presubmit.sh b/ci/macos-presubmit.sh index a5d6635af..8f35df58d 100644 --- a/ci/macos-presubmit.sh +++ b/ci/macos-presubmit.sh @@ -66,6 +66,7 @@ for absl in 0 1; do ${BAZEL_BIN} test ... \ --copt="-Wall" \ --copt="-Werror" \ + --cxxopt="-std=c++14" \ --define="absl=${absl}" \ --features=external_include_paths \ --keep_going \ From 1336c4b6d1a6f4bc6beebccb920e5ff858889292 Mon Sep 17 00:00:00 2001 From: Derek Mauro Date: Tue, 13 Sep 2022 10:12:42 -0700 Subject: [PATCH 007/336] Fix MSVC C++14 flag for GitHub workflow PiperOrigin-RevId: 474053482 Change-Id: If5cdf7458139ba3ad04b8c078734d6890199a348 --- .github/workflows/gtest-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gtest-ci.yml b/.github/workflows/gtest-ci.yml index b2dcab492..bcef926b2 100644 --- a/.github/workflows/gtest-ci.yml +++ b/.github/workflows/gtest-ci.yml @@ -40,4 +40,4 @@ jobs: fetch-depth: 0 - name: Tests - run: bazel test --cxxopt=-std=c++14 --features=external_include_paths --test_output=errors ... + run: bazel test --cxxopt=/std:c++14 --features=external_include_paths --test_output=errors ... From 096014a45dc38dff993f5b7bb28a258d8323344b Mon Sep 17 00:00:00 2001 From: Paul Groke Date: Thu, 15 Sep 2022 13:36:49 +0200 Subject: [PATCH 008/336] work around GCC 6~11 ADL bug see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51577 ADL seems to work properly when we do the SFINAE check via the return type, but not when using a dummy template parameter fix #3992 --- googletest/include/gtest/gtest-printers.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h index 8e4d29534..19c3e0b69 100644 --- a/googletest/include/gtest/gtest-printers.h +++ b/googletest/include/gtest/gtest-printers.h @@ -205,12 +205,13 @@ struct StreamPrinter { // Don't accept member pointers here. We'd print them via implicit // conversion to bool, which isn't useful. typename = typename std::enable_if< - !std::is_member_pointer::value>::type, - // Only accept types for which we can find a streaming operator via - // ADL (possibly involving implicit conversions). - typename = decltype(std::declval() - << std::declval())> - static void PrintValue(const T& value, ::std::ostream* os) { + !std::is_member_pointer::value>::type> + // Only accept types for which we can find a streaming operator via + // 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)) { // Call streaming operator found by ADL, possibly with implicit conversions // of the arguments. *os << value; From 05cc575c65924b83535b6d35fc39a1981b458bef Mon Sep 17 00:00:00 2001 From: John Hinnegan <426690+softwaregravy@users.noreply.github.com> Date: Sun, 18 Sep 2022 10:54:36 -0400 Subject: [PATCH 009/336] Update link to Bazel installation guide The Bazel docs have moved! --- docs/quickstart-bazel.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/quickstart-bazel.md b/docs/quickstart-bazel.md index c187e729e..853139a9d 100644 --- a/docs/quickstart-bazel.md +++ b/docs/quickstart-bazel.md @@ -17,7 +17,7 @@ See [Supported Platforms](platforms.md) for more information about platforms compatible with GoogleTest. If you don't already have Bazel installed, see the -[Bazel installation guide](https://docs.bazel.build/versions/main/install.html). +[Bazel installation guide](https://bazel.build/install). {: .callout .note} Note: The terminal commands in this tutorial show a Unix shell prompt, but the From 7a3abfec0aa5255f0ecf246987422493e9ca6a75 Mon Sep 17 00:00:00 2001 From: Marat Dukhan Date: Tue, 20 Sep 2022 23:07:33 -0700 Subject: [PATCH 010/336] Port GoogleTest to QuRT (Hexagon RTOS) --- googlemock/src/gmock-spec-builders.cc | 7 ++++++ .../include/gtest/internal/gtest-port-arch.h | 2 ++ .../include/gtest/internal/gtest-port.h | 25 +++++++++++++------ googletest/src/gtest-filepath.cc | 4 +-- googletest/src/gtest_main.cc | 12 +++++++++ 5 files changed, 40 insertions(+), 10 deletions(-) diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index 1771e4036..b333e53da 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -51,6 +51,9 @@ #if GTEST_OS_CYGWIN || GTEST_OS_LINUX || GTEST_OS_MAC #include // NOLINT #endif +#if GTEST_OS_QURT +#include +#endif // Silence C4800 (C4800: 'int *const ': forcing value // to bool 'true' or 'false') for MSVC 15 @@ -519,8 +522,12 @@ class MockObjectRegistry { // RUN_ALL_TESTS() has already returned when this destructor is // called. Therefore we cannot use the normal Google Test // failure reporting mechanism. +#if GTEST_OS_QURT + qurt_exception_raise_fatal(); +#else _exit(1); // We cannot call exit() as it is not reentrant and // may already have been called. +#endif } } diff --git a/googletest/include/gtest/internal/gtest-port-arch.h b/googletest/include/gtest/internal/gtest-port-arch.h index f025db76a..04064606f 100644 --- a/googletest/include/gtest/internal/gtest-port-arch.h +++ b/googletest/include/gtest/internal/gtest-port-arch.h @@ -111,6 +111,8 @@ #define GTEST_OS_ESP32 1 #elif defined(__XTENSA__) #define GTEST_OS_XTENSA 1 +#elif defined(__hexagon__) +#define GTEST_OS_QURT 1 #endif // __CYGWIN__ #endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_ diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index c9e1f3246..025d3d47b 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -385,7 +385,8 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // On Android, is only available starting with Gingerbread. #define GTEST_HAS_POSIX_RE (__ANDROID_API__ >= 9) #else -#define GTEST_HAS_POSIX_RE (!GTEST_OS_WINDOWS && !GTEST_OS_XTENSA) +#define GTEST_HAS_POSIX_RE \ + !(GTEST_OS_WINDOWS || GTEST_OS_XTENSA || GTEST_OS_QURT) #endif #endif @@ -457,7 +458,8 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // no support for it at least as recent as Froyo (2.2). #define GTEST_HAS_STD_WSTRING \ (!(GTEST_OS_LINUX_ANDROID || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \ - GTEST_OS_HAIKU || GTEST_OS_ESP32 || GTEST_OS_ESP8266 || GTEST_OS_XTENSA)) + GTEST_OS_HAIKU || GTEST_OS_ESP32 || GTEST_OS_ESP8266 || \ + GTEST_OS_XTENSA || GTEST_OS_QURT)) #endif // GTEST_HAS_STD_WSTRING @@ -578,9 +580,9 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // output correctness and to implement death tests. #ifndef GTEST_HAS_STREAM_REDIRECTION // By default, we assume that stream redirection is supported on all -// platforms except known mobile ones. +// platforms except known mobile / embedded ones. #if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || \ - GTEST_OS_WINDOWS_RT || GTEST_OS_ESP8266 || GTEST_OS_XTENSA + GTEST_OS_WINDOWS_RT || GTEST_OS_ESP8266 || GTEST_OS_XTENSA || GTEST_OS_QURT #define GTEST_HAS_STREAM_REDIRECTION 0 #else #define GTEST_HAS_STREAM_REDIRECTION 1 @@ -2019,7 +2021,12 @@ inline int StrCaseCmp(const char* s1, const char* s2) { return strcasecmp(s1, s2); } inline char* StrDup(const char* src) { return strdup(src); } +#if GTEST_OS_QURT +// QuRT doesn't support any directory functions, including rmdir +inline int RmDir(const char* dir GTEST_ATTRIBUTE_UNUSED_) { return 0; } +#else inline int RmDir(const char* dir) { return rmdir(dir); } +#endif inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); } #endif // GTEST_OS_WINDOWS @@ -2044,7 +2051,8 @@ GTEST_DISABLE_MSC_DEPRECATED_PUSH_() // defined there. #if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && \ - !GTEST_OS_WINDOWS_RT && !GTEST_OS_ESP8266 && !GTEST_OS_XTENSA + !GTEST_OS_WINDOWS_RT && !GTEST_OS_ESP8266 && !GTEST_OS_XTENSA && \ + !GTEST_OS_QURT inline int ChDir(const char* dir) { return chdir(dir); } #endif inline FILE* FOpen(const char* path, const char* mode) { @@ -2058,14 +2066,14 @@ inline FILE* FOpen(const char* path, const char* mode) { return fopen(path, mode); #endif // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW } -#if !GTEST_OS_WINDOWS_MOBILE +#if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT inline FILE* FReopen(const char* path, const char* mode, FILE* stream) { return freopen(path, mode, stream); } inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); } #endif inline int FClose(FILE* fp) { return fclose(fp); } -#if !GTEST_OS_WINDOWS_MOBILE +#if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT inline int Read(int fd, void* buf, unsigned int count) { return static_cast(read(fd, buf, count)); } @@ -2077,7 +2085,8 @@ inline const char* StrError(int errnum) { return strerror(errnum); } #endif inline const char* GetEnv(const char* name) { #if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || \ - GTEST_OS_WINDOWS_RT || GTEST_OS_ESP8266 || GTEST_OS_XTENSA + GTEST_OS_WINDOWS_RT || GTEST_OS_ESP8266 || GTEST_OS_XTENSA || \ + GTEST_OS_QURT // We are on an embedded platform, which has no environment variables. static_cast(name); // To prevent 'unused argument' warning. return nullptr; diff --git a/googletest/src/gtest-filepath.cc b/googletest/src/gtest-filepath.cc index f6ee90cdb..6767db0d7 100644 --- a/googletest/src/gtest-filepath.cc +++ b/googletest/src/gtest-filepath.cc @@ -96,7 +96,7 @@ static bool IsPathSeparator(char c) { FilePath FilePath::GetCurrentDir() { #if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || \ GTEST_OS_WINDOWS_RT || GTEST_OS_ESP8266 || GTEST_OS_ESP32 || \ - GTEST_OS_XTENSA + GTEST_OS_XTENSA || GTEST_OS_QURT // These platforms do not have a current directory, so we just return // something reasonable. return FilePath(kCurrentDirectoryString); @@ -323,7 +323,7 @@ bool FilePath::CreateFolder() const { delete[] unicode; #elif GTEST_OS_WINDOWS int result = _mkdir(pathname_.c_str()); -#elif GTEST_OS_ESP8266 || GTEST_OS_XTENSA +#elif GTEST_OS_ESP8266 || GTEST_OS_XTENSA || GTEST_OS_QURT // do nothing int result = 0; #else diff --git a/googletest/src/gtest_main.cc b/googletest/src/gtest_main.cc index 44976375c..d22604883 100644 --- a/googletest/src/gtest_main.cc +++ b/googletest/src/gtest_main.cc @@ -32,9 +32,12 @@ #include "gtest/gtest.h" #if GTEST_OS_ESP8266 || GTEST_OS_ESP32 +// Aduino-like platforms: program entry points are setup/loop instead of main. + #if GTEST_OS_ESP8266 extern "C" { #endif + void setup() { testing::InitGoogleTest(); } void loop() { RUN_ALL_TESTS(); } @@ -43,7 +46,16 @@ void loop() { RUN_ALL_TESTS(); } } #endif +#elif GTEST_OS_QURT +// QuRT: program entry point is main, but argc/argv are unusable. + +GTEST_API_ int main() { + printf("Running main() from %s\n", __FILE__); + testing::InitGoogleTest(); + return RUN_ALL_TESTS(); +} #else +// Normal platforms: program entry point is main, argc/argv are initialized. GTEST_API_ int main(int argc, char **argv) { printf("Running main() from %s\n", __FILE__); From 83bd792e36db826f869f30ded6c6acc82c4fe672 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 27 Sep 2022 12:44:59 +0200 Subject: [PATCH 011/336] Upgrade GitHub Actions Checkout https://github.com/actions/checkout/releases --- .github/workflows/gtest-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/gtest-ci.yml b/.github/workflows/gtest-ci.yml index bcef926b2..7ace9509c 100644 --- a/.github/workflows/gtest-ci.yml +++ b/.github/workflows/gtest-ci.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 @@ -23,7 +23,7 @@ jobs: runs-on: macos-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 @@ -35,7 +35,7 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 From 9836817d8256faf4829e2046c4a391df4b7cc54c Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 27 Sep 2022 12:47:32 +0200 Subject: [PATCH 012/336] Branding: macOS --- .github/workflows/gtest-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gtest-ci.yml b/.github/workflows/gtest-ci.yml index 7ace9509c..03a8cc5e2 100644 --- a/.github/workflows/gtest-ci.yml +++ b/.github/workflows/gtest-ci.yml @@ -19,7 +19,7 @@ jobs: - name: Tests run: bazel test --cxxopt=-std=c++14 --features=external_include_paths --test_output=errors ... - MacOs: + macOS: runs-on: macos-latest steps: From dfa67352364e00452360e1fa5d59677459712ee7 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Tue, 27 Sep 2022 12:08:58 -0700 Subject: [PATCH 013/336] Add GoogleTest workaround for MSVC crash with Address Sanitizer (ASAN) on version 17.3.3 PiperOrigin-RevId: 477240422 Change-Id: I894037850617252e462783c0885e30fc8e7ad122 --- googletest/src/gtest.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 81409a339..43e8723ba 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -2713,7 +2713,8 @@ TestInfo::TestInfo(const std::string& a_test_suite_name, internal::TypeId fixture_class_id, internal::TestFactoryBase* factory) : test_suite_name_(a_test_suite_name), - name_(a_name), + // begin()/end() is MSVC 17.3.3 ASAN crash workaround (GitHub issue #3997) + name_(a_name.begin(), a_name.end()), type_param_(a_type_param ? new std::string(a_type_param) : nullptr), value_param_(a_value_param ? new std::string(a_value_param) : nullptr), location_(a_code_location), From 4924e0610a89dcd58077a691a2e3702b0d6e58ed Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 28 Sep 2022 11:55:06 -0700 Subject: [PATCH 014/336] Moves boilerplate disabling copy constructor/assignment from GoogleTest's TEST_P macro into a header file to avoid triggering warnings in user code. Fixes #4015 PiperOrigin-RevId: 477513399 Change-Id: Ia21928ee12e85946b4c8db86835d225cb257eecc --- googletest/include/gtest/gtest-param-test.h | 7 +------ googletest/include/gtest/gtest.h | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/googletest/include/gtest/gtest-param-test.h b/googletest/include/gtest/gtest-param-test.h index b55119ac6..19238ae4d 100644 --- a/googletest/include/gtest/gtest-param-test.h +++ b/googletest/include/gtest/gtest-param-test.h @@ -409,7 +409,7 @@ internal::CartesianProductHolder Combine(const Generator&... g) { #define TEST_P(test_suite_name, test_name) \ class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \ - : public test_suite_name { \ + : public ::testing::internal::UserTestSuite { \ public: \ GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() {} \ void TestBody() override; \ @@ -429,11 +429,6 @@ internal::CartesianProductHolder Combine(const Generator&... g) { return 0; \ } \ static int gtest_registering_dummy_ GTEST_ATTRIBUTE_UNUSED_; \ - GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \ - (const GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) &) = delete; \ - GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) & operator=( \ - const GTEST_TEST_CLASS_NAME_(test_suite_name, \ - test_name) &) = delete; /* NOLINT */ \ }; \ int GTEST_TEST_CLASS_NAME_(test_suite_name, \ test_name)::gtest_registering_dummy_ = \ diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index d19a587a1..6ff2774f5 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -190,6 +190,21 @@ void ReportFailureInUnknownLocation(TestPartResult::Type result_type, const std::string& message); std::set* GetIgnoredParameterizedTestSuites(); +// Mix-in class for user tests. +// This allows us to add/delete members to/from test suites without having to +// modify the test macros themselves. +// This makes the code easier to read and maintain, as well making it easier +// for users to suppress any warnings originating from these members, as the +// members are now declared in an external header instead of in user code. +template +class UserTestSuite : public TestClass { + public: + UserTestSuite() = default; + UserTestSuite(const UserTestSuite &) = delete; + UserTestSuite &operator=(const UserTestSuite &) = delete; + virtual ~UserTestSuite() = default; +}; + } // namespace internal // The friend relationship of some of these classes is cyclic. From c43b916a9623e052860f59e52f71de1974ed8823 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 28 Sep 2022 14:14:25 -0700 Subject: [PATCH 015/336] Uses a simpler mechanism to disable the copying of GoogleTest test suites. PiperOrigin-RevId: 477549427 Change-Id: I6421ca09f0f1296cebdc3e54565049f1542dfa8a --- googletest/include/gtest/gtest-param-test.h | 2 +- googletest/include/gtest/gtest.h | 17 +++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/googletest/include/gtest/gtest-param-test.h b/googletest/include/gtest/gtest-param-test.h index 19238ae4d..2dbac48e6 100644 --- a/googletest/include/gtest/gtest-param-test.h +++ b/googletest/include/gtest/gtest-param-test.h @@ -409,7 +409,7 @@ internal::CartesianProductHolder Combine(const Generator&... g) { #define TEST_P(test_suite_name, test_name) \ class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \ - : public ::testing::internal::UserTestSuite { \ + : public test_suite_name, private ::testing::internal::NonCopyable { \ public: \ GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() {} \ void TestBody() override; \ diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index 6ff2774f5..4f037ad7a 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -190,19 +190,12 @@ void ReportFailureInUnknownLocation(TestPartResult::Type result_type, const std::string& message); std::set* GetIgnoredParameterizedTestSuites(); -// Mix-in class for user tests. -// This allows us to add/delete members to/from test suites without having to -// modify the test macros themselves. -// This makes the code easier to read and maintain, as well making it easier -// for users to suppress any warnings originating from these members, as the -// members are now declared in an external header instead of in user code. -template -class UserTestSuite : public TestClass { +class NonCopyable { public: - UserTestSuite() = default; - UserTestSuite(const UserTestSuite &) = delete; - UserTestSuite &operator=(const UserTestSuite &) = delete; - virtual ~UserTestSuite() = default; + NonCopyable() = default; + NonCopyable(const NonCopyable &) = delete; + NonCopyable &operator=(const NonCopyable &) = delete; + ~NonCopyable() = default; }; } // namespace internal From 19387c9dd5b153a6bdef6f1fc4fb2391fdb122d0 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 28 Sep 2022 14:58:29 -0700 Subject: [PATCH 016/336] Rollback: Uses a simpler mechanism to disable the copying of GoogleTest test suites. PiperOrigin-RevId: 477560280 Change-Id: I1c1f5a1d6645859ec38cb1a75cd267816d2aff35 --- googletest/include/gtest/gtest-param-test.h | 2 +- googletest/include/gtest/gtest.h | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/googletest/include/gtest/gtest-param-test.h b/googletest/include/gtest/gtest-param-test.h index 2dbac48e6..19238ae4d 100644 --- a/googletest/include/gtest/gtest-param-test.h +++ b/googletest/include/gtest/gtest-param-test.h @@ -409,7 +409,7 @@ internal::CartesianProductHolder Combine(const Generator&... g) { #define TEST_P(test_suite_name, test_name) \ class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \ - : public test_suite_name, private ::testing::internal::NonCopyable { \ + : public ::testing::internal::UserTestSuite { \ public: \ GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() {} \ void TestBody() override; \ diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index 4f037ad7a..6ff2774f5 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -190,12 +190,19 @@ void ReportFailureInUnknownLocation(TestPartResult::Type result_type, const std::string& message); std::set* GetIgnoredParameterizedTestSuites(); -class NonCopyable { +// Mix-in class for user tests. +// This allows us to add/delete members to/from test suites without having to +// modify the test macros themselves. +// This makes the code easier to read and maintain, as well making it easier +// for users to suppress any warnings originating from these members, as the +// members are now declared in an external header instead of in user code. +template +class UserTestSuite : public TestClass { public: - NonCopyable() = default; - NonCopyable(const NonCopyable &) = delete; - NonCopyable &operator=(const NonCopyable &) = delete; - ~NonCopyable() = default; + UserTestSuite() = default; + UserTestSuite(const UserTestSuite &) = delete; + UserTestSuite &operator=(const UserTestSuite &) = delete; + virtual ~UserTestSuite() = default; }; } // namespace internal From d1a0039b97291dd1dc14f123b906bb7622ffe07c Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 28 Sep 2022 15:24:12 -0700 Subject: [PATCH 017/336] Rollback: Moves boilerplate disabling copy constructor/assignment from GoogleTest's TEST_P macro into a header file to avoid triggering warnings in user code. PiperOrigin-RevId: 477566426 Change-Id: Ia417e295d839f43be6e61a5699457866108f2a01 --- googletest/include/gtest/gtest-param-test.h | 7 ++++++- googletest/include/gtest/gtest.h | 15 --------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/googletest/include/gtest/gtest-param-test.h b/googletest/include/gtest/gtest-param-test.h index 19238ae4d..b55119ac6 100644 --- a/googletest/include/gtest/gtest-param-test.h +++ b/googletest/include/gtest/gtest-param-test.h @@ -409,7 +409,7 @@ internal::CartesianProductHolder Combine(const Generator&... g) { #define TEST_P(test_suite_name, test_name) \ class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \ - : public ::testing::internal::UserTestSuite { \ + : public test_suite_name { \ public: \ GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() {} \ void TestBody() override; \ @@ -429,6 +429,11 @@ internal::CartesianProductHolder Combine(const Generator&... g) { return 0; \ } \ static int gtest_registering_dummy_ GTEST_ATTRIBUTE_UNUSED_; \ + GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \ + (const GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) &) = delete; \ + GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) & operator=( \ + const GTEST_TEST_CLASS_NAME_(test_suite_name, \ + test_name) &) = delete; /* NOLINT */ \ }; \ int GTEST_TEST_CLASS_NAME_(test_suite_name, \ test_name)::gtest_registering_dummy_ = \ diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index 6ff2774f5..d19a587a1 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -190,21 +190,6 @@ void ReportFailureInUnknownLocation(TestPartResult::Type result_type, const std::string& message); std::set* GetIgnoredParameterizedTestSuites(); -// Mix-in class for user tests. -// This allows us to add/delete members to/from test suites without having to -// modify the test macros themselves. -// This makes the code easier to read and maintain, as well making it easier -// for users to suppress any warnings originating from these members, as the -// members are now declared in an external header instead of in user code. -template -class UserTestSuite : public TestClass { - public: - UserTestSuite() = default; - UserTestSuite(const UserTestSuite &) = delete; - UserTestSuite &operator=(const UserTestSuite &) = delete; - virtual ~UserTestSuite() = default; -}; - } // namespace internal // The friend relationship of some of these classes is cyclic. From 93f08be653c36ddc6943e9513fc14c7292b4d007 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Fri, 30 Sep 2022 10:54:41 -0700 Subject: [PATCH 018/336] Uses a simpler mechanism to disable the copying of GoogleTest test suites, to move code out of the TEST_P macro. PiperOrigin-RevId: 478031678 Change-Id: I45f0ce17a4add526c86b8212d836d98d63b3a193 --- googletest/include/gtest/gtest-param-test.h | 7 +------ googletest/include/gtest/gtest.h | 11 +++++++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/googletest/include/gtest/gtest-param-test.h b/googletest/include/gtest/gtest-param-test.h index b55119ac6..2d38b96c0 100644 --- a/googletest/include/gtest/gtest-param-test.h +++ b/googletest/include/gtest/gtest-param-test.h @@ -409,7 +409,7 @@ internal::CartesianProductHolder Combine(const Generator&... g) { #define TEST_P(test_suite_name, test_name) \ class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \ - : public test_suite_name { \ + : public test_suite_name, private ::testing::internal::GTestNonCopyable {\ public: \ GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() {} \ void TestBody() override; \ @@ -429,11 +429,6 @@ internal::CartesianProductHolder Combine(const Generator&... g) { return 0; \ } \ static int gtest_registering_dummy_ GTEST_ATTRIBUTE_UNUSED_; \ - GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \ - (const GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) &) = delete; \ - GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) & operator=( \ - const GTEST_TEST_CLASS_NAME_(test_suite_name, \ - test_name) &) = delete; /* NOLINT */ \ }; \ int GTEST_TEST_CLASS_NAME_(test_suite_name, \ test_name)::gtest_registering_dummy_ = \ diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index d19a587a1..81e124fad 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -190,6 +190,17 @@ void ReportFailureInUnknownLocation(TestPartResult::Type result_type, const std::string& message); std::set* GetIgnoredParameterizedTestSuites(); +// A base class that prevents subclasses from being copyable. +// We do this instead of using '= delete' so as to avoid triggering warnings +// inside user code regarding any of our declarations. +class GTestNonCopyable { + public: + GTestNonCopyable() = default; + GTestNonCopyable(const GTestNonCopyable &) = delete; + GTestNonCopyable &operator=(const GTestNonCopyable &) = delete; + ~GTestNonCopyable() = default; +}; + } // namespace internal // The friend relationship of some of these classes is cyclic. From 08935483cb22749b3c3774e9bcd5ef35b5a1a7b7 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 5 Oct 2022 12:26:54 -0700 Subject: [PATCH 019/336] Makes Clang compilations via Ninja on Windows define _DLL only for shared CRT builds, as one would already expect from MSVC builds. (Previously, static Clang/Ninja builds on Windows also implicitly defined _DLL, which was problematic.) PiperOrigin-RevId: 479113168 Change-Id: I252d9be90fd33df75dab922e62b197208830d124 --- googletest/cmake/internal_utils.cmake | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index 6f7fdc2ca..41405587f 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -21,8 +21,9 @@ endif (POLICY CMP0054) # This must be a macro(), as inside a function string() can only # update variables in the function scope. macro(fix_default_compiler_settings_) - if (MSVC) - # For MSVC, CMake sets certain flags to defaults we want to override. + if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC|Clang") + # For MSVC and Clang, CMake sets certain flags to defaults we want to + # override. # This replacement code is taken from sample in the CMake Wiki at # https://gitlab.kitware.com/cmake/community/wikis/FAQ#dynamic-replace. foreach (flag_var @@ -39,6 +40,10 @@ macro(fix_default_compiler_settings_) # on CRT DLLs being available. CMake always defaults to using shared # CRT libraries, so we override that default here. string(REPLACE "/MD" "-MT" ${flag_var} "${${flag_var}}") + + # When using Ninja with Clang, static builds pass -D_DLL on Windows. + # This is incorrect and should not happen, so we fix that here. + string(REPLACE "-D_DLL" "" ${flag_var} "${${flag_var}}") endif() # We prefer more strict warning checking for building Google Test. From 67e264834a45c3d543aa2fa11bcc41c4ba90316b Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Thu, 6 Oct 2022 11:21:49 -0700 Subject: [PATCH 020/336] [fuchsia] Use __builtin_trap to trigger gunit_break_on_failure on non-x86 arch In developing tests for the fuchsia debugger, it was found that in addition to catching gtest failures (which are implemented as software breakpoints) we also see PageFault exceptions, caused by this nullptr dereference. PiperOrigin-RevId: 479365782 Change-Id: I84d805d94c2e46b6f3c982ca1ae49c6ac3ed3430 --- googletest/src/gtest.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 43e8723ba..638d53bb4 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -143,6 +143,14 @@ #include "absl/strings/str_replace.h" #endif // GTEST_HAS_ABSL +// Checks builtin compiler feature |x| while avoiding an extra layer of #ifdefs +// at the callsite. +#if defined(__has_builtin) +#define GTEST_HAS_BUILTIN(x) __has_builtin(x) +#else +#define GTEST_HAS_BUILTIN(x) 0 +#endif // defined(__has_builtin) + namespace testing { using internal::CountIf; @@ -5331,6 +5339,10 @@ void UnitTest::AddTestPartResult(TestPartResult::Type result_type, (defined(__x86_64__) || defined(__i386__))) // with clang/gcc we can achieve the same effect on x86 by invoking int3 asm("int3"); +#elif GTEST_HAS_BUILTIN(__builtin_trap) + __builtin_trap(); +#elif defined(SIGTRAP) + raise(SIGTRAP); #else // Dereference nullptr through a volatile pointer to prevent the compiler // from removing. We use this rather than abort() or __builtin_trap() for From 9fbb6575035e3ac97ad9547d042c026a1296c705 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Fri, 7 Oct 2022 14:20:15 -0700 Subject: [PATCH 021/336] Update the POSIX Extended section of the Regular Expression Wikipedia page PiperOrigin-RevId: 479667644 Change-Id: I4ab03bd5f0520f8586667de8bd1b9443f241337a --- docs/advanced.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/advanced.md b/docs/advanced.md index bce983c69..c3c546145 100644 --- a/docs/advanced.md +++ b/docs/advanced.md @@ -487,7 +487,7 @@ When built with Bazel and using Abseil, googletest uses the systems (Linux, Cygwin, Mac), googletest uses the [POSIX extended regular expression](http://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](http://en.wikipedia.org/wiki/Regular_expression#POSIX_Extended_Regular_Expressions). +[Wikipedia entry](http://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 From 0231584a608bda1101c5f50ae03805c518ece93b Mon Sep 17 00:00:00 2001 From: Vertexwahn Date: Sat, 8 Oct 2022 13:33:18 +0200 Subject: [PATCH 022/336] Update rules_python, bazel_skylib and platfroms --- WORKSPACE | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 4d7b3988a..7e371b901 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -20,20 +20,25 @@ http_archive( http_archive( name = "rules_python", - sha256 = "0b460f17771258341528753b1679335b629d1d25e3af28eda47d009c103a6e15", - strip_prefix = "rules_python-aef17ad72919d184e5edb7abf61509eb78e57eda", - urls = ["https://github.com/bazelbuild/rules_python/archive/aef17ad72919d184e5edb7abf61509eb78e57eda.zip"], # 2022-06-21T23:44:47Z + sha256 = "8c8fe44ef0a9afc256d1e75ad5f448bb59b81aba149b8958f02f7b3a98f5d9b4", + strip_prefix = "rules_python-0.13.0", + url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.13.0.tar.gz", ) http_archive( name = "bazel_skylib", - urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.2.1/bazel-skylib-1.2.1.tar.gz"], - sha256 = "f7be3474d42aae265405a592bb7da8e171919d74c16f082a5457840f06054728", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz", + "https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz", + ], + sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506", ) http_archive( name = "platforms", - sha256 = "a879ea428c6d56ab0ec18224f976515948822451473a80d06c2e50af0bbe5121", - strip_prefix = "platforms-da5541f26b7de1dc8e04c075c99df5351742a4a2", - urls = ["https://github.com/bazelbuild/platforms/archive/da5541f26b7de1dc8e04c075c99df5351742a4a2.zip"], # 2022-05-27 + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz", + "https://github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz", + ], + sha256 = "5308fc1d8865406a49427ba24a9ab53087f17f5266a7aabbfc28823f3916e1ca", ) From 671cfb7dbf26363ea0fc11b7e813cda7c2a2912e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferenc=20G=C3=A9czi?= Date: Fri, 7 Oct 2022 00:00:00 +0000 Subject: [PATCH 023/336] Suggests a release with fixed CMakeLists.txt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ferenc Géczi --- googletest/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/README.md b/googletest/README.md index 75b3d5262..3a82b1dfb 100644 --- a/googletest/README.md +++ b/googletest/README.md @@ -25,7 +25,7 @@ When building GoogleTest as a standalone project, the typical workflow starts with ``` -git clone https://github.com/google/googletest.git -b release-1.12.0 +git clone https://github.com/google/googletest.git -b release-1.12.1 cd googletest # Main directory of the cloned repository. mkdir build # Create a directory to hold the build output. cd build From 1d505b8e40db0204fd0515673fa97137680cb8ac Mon Sep 17 00:00:00 2001 From: Denis Hananein Date: Tue, 11 Oct 2022 12:11:46 +0200 Subject: [PATCH 024/336] Fix JSON output format #3884 --- googletest/src/gtest.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 638d53bb4..385945284 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -4829,6 +4829,9 @@ void JsonUnitTestResultPrinter::PrintJsonUnitTest(std::ostream* stream, // If there was a test failure outside of one of the test suites (like in a // test environment) include that in the output. if (unit_test.ad_hoc_test_result().Failed()) { + if (comma) { + *stream << ",\n"; + } OutputJsonTestSuiteForTestResult(stream, unit_test.ad_hoc_test_result()); } From d29b143bda80baad6fd3f5b523ed54f10eb0eea3 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 12 Oct 2022 10:30:15 -0700 Subject: [PATCH 025/336] Workaround for Visual C++ error C2039 with std::tuple_element_t. Fixes #3931 PiperOrigin-RevId: 480659507 Change-Id: I6fabef63b1285189a06375227273d9de2456e37a --- googlemock/include/gmock/gmock-actions.h | 12 ++++++++---- .../include/gmock/internal/gmock-internal-utils.h | 7 +++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h index 7e78c09a9..aad07d51c 100644 --- a/googlemock/include/gmock/gmock-actions.h +++ b/googlemock/include/gmock/gmock-actions.h @@ -1428,8 +1428,10 @@ struct WithArgsAction { // MSVC complains about the I parameter pack not being // expanded (error C3520) despite it being expanded in the // type alias. - OnceAction>::type...)>>::value, + // TupleElement is also an MSVC workaround. + // See its definition for details. + OnceAction>...)>>::value, int>::type = 0> operator OnceAction() && { // NOLINT struct OA { @@ -1453,8 +1455,10 @@ struct WithArgsAction { // MSVC complains about the I parameter pack not being // expanded (error C3520) despite it being expanded in the // type alias. - Action>::type...)>>::value, + // TupleElement is also an MSVC workaround. + // See its definition for details. + Action>...)>>::value, int>::type = 0> operator Action() const { // NOLINT Action> converted(inner_action); diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h index 92d8eb9de..2678920b0 100644 --- a/googlemock/include/gmock/internal/gmock-internal-utils.h +++ b/googlemock/include/gmock/internal/gmock-internal-utils.h @@ -453,6 +453,13 @@ struct Function { template constexpr size_t Function::ArgumentCount; +// Workaround for MSVC error C2039: 'type': is not a member of 'std' +// when std::tuple_element is used. +// See: https://github.com/google/googletest/issues/3931 +// Can be replaced with std::tuple_element_t in C++14. +template +using TupleElement = typename std::tuple_element::type; + bool Base64Unescape(const std::string& encoded, std::string* decoded); #ifdef _MSC_VER From a41c3d0fb80c4558aa3799f262a7cfd67f32c468 Mon Sep 17 00:00:00 2001 From: Jan Date: Fri, 14 Oct 2022 09:12:51 +0200 Subject: [PATCH 026/336] Fix table markup in testing.md --- docs/reference/testing.md | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/docs/reference/testing.md b/docs/reference/testing.md index dd0b982ce..d983301e3 100644 --- a/docs/reference/testing.md +++ b/docs/reference/testing.md @@ -101,23 +101,14 @@ functions that generate the test parameters, all defined in the `::testing` namespace: - -| Parameter Generator | Behavior | -| ---------------------------- | -------------------------------------------- | -| `Range(begin, end [, step])` | Yields values `{begin, begin+step, | -: : begin+step+step, ...}`. The values do not : -: : include `end`. `step` defaults to 1. : -| `Values(v1, v2, ..., vN)` | Yields values `{v1, v2, ..., vN}`. | -| `ValuesIn(container)` or | Yields values from a C-style array, an | -: `ValuesIn(begin,end)` : STL-style container, or an iterator range : -: : `[begin, end)`. : -| `Bool()` | Yields sequence `{false, true}`. | -| `Combine(g1, g2, ..., gN)` | Yields as `std::tuple` *n*-tuples all | -: : combinations (Cartesian product) of the : -: : values generated by the given *n* generators : -: : `g1`, `g2`, ..., `gN`. : -| `ConvertGenerator(g)` | Yields values generated by generator `g`, | -: : `static_cast` to `T`. : +| Parameter Generator | Behavior | +| ------------------- | ---------------------------------------------------- | +| `Range(begin, end [, step])` | Yields values `{begin, begin+step, begin+step+step, ...}`. The values do not include `end`. `step` defaults to 1. | +| `Values(v1, v2, ..., vN)` | Yields values `{v1, v2, ..., vN}`. | +| `ValuesIn(container)` or `ValuesIn(begin,end)` | Yields values from a C-style array, an STL-style container, or an iterator range `[begin, end)`. | +| `Bool()` | Yields sequence `{false, true}`. | +| `Combine(g1, g2, ..., gN)` | Yields as `std::tuple` *n*-tuples all combinations (Cartesian product) of the values generated by the given *n* generators `g1`, `g2`, ..., `gN`. | +| `ConvertGenerator(g)` | Yields values generated by generator `g`, `static_cast` to `T`. | The optional last argument *`name_generator`* is a function or functor that generates custom test name suffixes based on the test parameters. The function From 137b6e2770deb44aacd229c20507413120655b22 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Fri, 14 Oct 2022 10:32:14 -0700 Subject: [PATCH 027/336] Terse printing of std::reference_wrapper hides pointer This matches the intention and documentation of terse printing which generally avoids printing the pointer. PiperOrigin-RevId: 481178950 Change-Id: I27039dac1870934d2d5b212e2cc7e97ab82c5b34 --- googletest/include/gtest/gtest-printers.h | 7 +++++++ googletest/test/googletest-printers-test.cc | 23 +++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h index 8e4d29534..89215e620 100644 --- a/googletest/include/gtest/gtest-printers.h +++ b/googletest/include/gtest/gtest-printers.h @@ -891,6 +891,13 @@ class UniversalTersePrinter { UniversalPrint(value, os); } }; +template +class UniversalTersePrinter> { + public: + static void Print(std::reference_wrapper value, ::std::ostream* os) { + UniversalTersePrinter::Print(value.get(), os); + } +}; template class UniversalTersePrinter { public: diff --git a/googletest/test/googletest-printers-test.cc b/googletest/test/googletest-printers-test.cc index acfecf97b..d2d88a522 100644 --- a/googletest/test/googletest-printers-test.cc +++ b/googletest/test/googletest-printers-test.cc @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -193,6 +194,11 @@ OutputStream& operator<<(OutputStream& os, return os; } +struct StreamableInLocal {}; +void operator<<(::std::ostream& os, const StreamableInLocal& /* x */) { + os << "StreamableInLocal"; +} + // A user-defined streamable but recursively-defined container type in // a user namespace, it mimics therefore std::filesystem::path or // boost::filesystem::path. @@ -1604,6 +1610,23 @@ TEST(PrintToStringTest, ContainsNonLatin) { "\n As Text: \"From ä — ẑ\""); } +TEST(PrintToStringTest, PrintStreamableInLocal) { + EXPECT_STREQ("StreamableInLocal", + PrintToString(foo::StreamableInLocal()).c_str()); +} + +TEST(PrintToStringTest, PrintReferenceToStreamableInLocal) { + foo::StreamableInLocal s; + std::reference_wrapper r(s); + EXPECT_STREQ("StreamableInLocal", PrintToString(r).c_str()); +} + +TEST(PrintToStringTest, PrintReferenceToStreamableInGlobal) { + StreamableInGlobal s; + std::reference_wrapper r(s); + EXPECT_STREQ("StreamableInGlobal", PrintToString(r).c_str()); +} + TEST(IsValidUTF8Test, IllFormedUTF8) { // The following test strings are ill-formed UTF-8 and are printed // as hex only (or ASCII, in case of ASCII bytes) because IsValidUTF8() is From a9b2f0495cabb1ff01b51bcd0625cb1fd82da4ce Mon Sep 17 00:00:00 2001 From: Derek Mauro Date: Fri, 14 Oct 2022 11:00:07 -0700 Subject: [PATCH 028/336] Use attribute testing to simplify portable attribute macros Fixes #4025 PiperOrigin-RevId: 481186097 Change-Id: Id7d09e4626e5ccf564e8cfaa65581c1cd827918d --- .../include/gtest/internal/gtest-port.h | 85 ++++++++----------- 1 file changed, 37 insertions(+), 48 deletions(-) diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 3556fdb96..50d4c41f9 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -642,6 +642,22 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; default: // NOLINT #endif +// GTEST_HAVE_ATTRIBUTE_ +// +// A function-like feature checking macro that is a wrapper around +// `__has_attribute`, which is defined by GCC 5+ and Clang and evaluates to a +// nonzero constant integer if the attribute is supported or 0 if not. +// +// It evaluates to zero if `__has_attribute` is not defined by the compiler. +// +// GCC: https://gcc.gnu.org/gcc-5/changes.html +// Clang: https://clang.llvm.org/docs/LanguageExtensions.html +#ifdef __has_attribute +#define GTEST_HAVE_ATTRIBUTE_(x) __has_attribute(x) +#else +#define GTEST_HAVE_ATTRIBUTE_(x) 0 +#endif + // Use this annotation at the end of a struct/class definition to // prevent the compiler from optimizing away instances that are never // used. This is useful when all interesting logic happens inside the @@ -653,30 +669,22 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // // Also use it after a variable or parameter declaration to tell the // compiler the variable/parameter does not have to be used. -#if defined(__GNUC__) && !defined(COMPILER_ICC) +#if GTEST_HAVE_ATTRIBUTE_(unused) #define GTEST_ATTRIBUTE_UNUSED_ __attribute__((unused)) -#elif defined(__clang__) -#if __has_attribute(unused) -#define GTEST_ATTRIBUTE_UNUSED_ __attribute__((unused)) -#endif -#endif -#ifndef GTEST_ATTRIBUTE_UNUSED_ +#else #define GTEST_ATTRIBUTE_UNUSED_ #endif // Use this annotation before a function that takes a printf format string. -#if (defined(__GNUC__) || defined(__clang__)) && !defined(COMPILER_ICC) -#if defined(__MINGW_PRINTF_FORMAT) +#if GTEST_HAVE_ATTRIBUTE_(format) && defined(__MINGW_PRINTF_FORMAT) // MinGW has two different printf implementations. Ensure the format macro // matches the selected implementation. See // https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/. #define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \ - __attribute__(( \ - __format__(__MINGW_PRINTF_FORMAT, string_index, first_to_check))) -#else -#define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \ - __attribute__((__format__(__printf__, string_index, first_to_check))) -#endif + __attribute__((format(__MINGW_PRINTF_FORMAT, string_index, first_to_check))) +#elif GTEST_HAVE_ATTRIBUTE_(format) +#define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \ + __attribute__((format(printf, string_index, first_to_check))) #else #define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) #endif @@ -686,11 +694,11 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // following the argument list: // // Sprocket* AllocateSprocket() GTEST_MUST_USE_RESULT_; -#if defined(__GNUC__) && !defined(COMPILER_ICC) +#if GTEST_HAVE_ATTRIBUTE_(warn_unused_result) #define GTEST_MUST_USE_RESULT_ __attribute__((warn_unused_result)) #else #define GTEST_MUST_USE_RESULT_ -#endif // __GNUC__ && !COMPILER_ICC +#endif // MS C++ compiler emits warning when a conditional expression is compile time // constant. In some contexts this warning is false positive and needs to be @@ -746,7 +754,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #elif GTEST_CREATE_SHARED_LIBRARY #define GTEST_API_ __declspec(dllexport) #endif -#elif __GNUC__ >= 4 || defined(__clang__) +#elif GTEST_HAVE_ATTRIBUTE_(visibility) #define GTEST_API_ __attribute__((visibility("default"))) #endif // _MSC_VER @@ -760,20 +768,17 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #define GTEST_DEFAULT_DEATH_TEST_STYLE "fast" #endif // GTEST_DEFAULT_DEATH_TEST_STYLE -#ifdef __GNUC__ +#if GTEST_HAVE_ATTRIBUTE_(noinline) // Ask the compiler to never inline a given function. #define GTEST_NO_INLINE_ __attribute__((noinline)) #else #define GTEST_NO_INLINE_ #endif -#if defined(__clang__) -// Nested ifs to avoid triggering MSVC warning. -#if __has_attribute(disable_tail_calls) +#if GTEST_HAVE_ATTRIBUTE_(disable_tail_calls) // Ask the compiler not to perform tail call optimization inside // the marked function. #define GTEST_NO_TAIL_CALL_ __attribute__((disable_tail_calls)) -#endif #elif __GNUC__ #define GTEST_NO_TAIL_CALL_ \ __attribute__((optimize("no-optimize-sibling-calls"))) @@ -792,50 +797,34 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // A function level attribute to disable checking for use of uninitialized // memory when built with MemorySanitizer. -#if defined(__clang__) -#if __has_feature(memory_sanitizer) +#if GTEST_HAVE_ATTRIBUTE_(no_sanitize_memory) #define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ __attribute__((no_sanitize_memory)) #else #define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ -#endif // __has_feature(memory_sanitizer) -#else -#define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_ -#endif // __clang__ +#endif // A function level attribute to disable AddressSanitizer instrumentation. -#if defined(__clang__) -#if __has_feature(address_sanitizer) +#if GTEST_HAVE_ATTRIBUTE_(no_sanitize_address) #define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ \ __attribute__((no_sanitize_address)) #else #define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ -#endif // __has_feature(address_sanitizer) -#else -#define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ -#endif // __clang__ +#endif // A function level attribute to disable HWAddressSanitizer instrumentation. -#if defined(__clang__) -#if __has_feature(hwaddress_sanitizer) +#if GTEST_HAVE_ATTRIBUTE_(no_sanitize) #define GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_ \ __attribute__((no_sanitize("hwaddress"))) #else #define GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_ -#endif // __has_feature(hwaddress_sanitizer) -#else -#define GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_ -#endif // __clang__ +#endif // A function level attribute to disable ThreadSanitizer instrumentation. -#if defined(__clang__) -#if __has_feature(thread_sanitizer) -#define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ __attribute__((no_sanitize_thread)) +#if GTEST_HAVE_ATTRIBUTE_(no_sanitize_thread) +#define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ __attribute((no_sanitize_thread)) #else #define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ -#endif // __has_feature(thread_sanitizer) -#else -#define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_ -#endif // __clang__ +#endif namespace testing { From 6f149520a19c0bfd6a70075a733a69cd8b03ae94 Mon Sep 17 00:00:00 2001 From: Denis Hananein Date: Sun, 16 Oct 2022 01:57:22 +0200 Subject: [PATCH 029/336] Add return for GTEST_FAIL_AT --- googletest/include/gtest/gtest.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index 7963e8c7a..8a7d173c1 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -1735,8 +1735,8 @@ class TestWithParam : public Test, public WithParamInterface {}; // Like GTEST_FAIL(), but at the given source file location. #define GTEST_FAIL_AT(file, line) \ - GTEST_MESSAGE_AT_(file, line, "Failed", \ - ::testing::TestPartResult::kFatalFailure) + return GTEST_MESSAGE_AT_(file, line, "Failed", \ + ::testing::TestPartResult::kFatalFailure) // Define this macro to 1 to omit the definition of FAIL(), which is a // generic name and clashes with some other libraries. From 88c59752c05d74475c3d487b28c5e82ad0b129b8 Mon Sep 17 00:00:00 2001 From: Dino Radakovic Date: Mon, 17 Oct 2022 10:39:12 -0700 Subject: [PATCH 030/336] Add Windows CI script PiperOrigin-RevId: 481680362 Change-Id: I87b2b71427a8ad2603f5445d6ef794c3fa84746e --- ci/windows-presubmit.bat | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 ci/windows-presubmit.bat diff --git a/ci/windows-presubmit.bat b/ci/windows-presubmit.bat new file mode 100644 index 000000000..8668ff359 --- /dev/null +++ b/ci/windows-presubmit.bat @@ -0,0 +1,56 @@ +SETLOCAL ENABLEDELAYEDEXPANSION + +SET BAZEL_EXE=%KOKORO_GFILE_DIR%\bazel-5.1.1-windows-x86_64.exe + +SET PATH=C:\Python37;%PATH% +SET BAZEL_PYTHON=C:\python37\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 CTEST_OUTPUT_ON_FAILURE=1 + +IF EXIST git\googletest ( + CD git\googletest +) ELSE IF EXIST github\googletest ( + CD github\googletest +) + +IF %errorlevel% neq 0 EXIT /B 1 + +:: ---------------------------------------------------------------------------- +:: CMake Visual Studio 15 2017 Win64 +MKDIR cmake_msvc2017 +CD cmake_msvc2017 + +%CMAKE_BIN% .. ^ + -G "Visual Studio 15 2017 Win64" ^ + -DPYTHON_EXECUTABLE:FILEPATH=c:\python37\python.exe ^ + -DPYTHON_INCLUDE_DIR:PATH=c:\python37\include ^ + -DPYTHON_LIBRARY:FILEPATH=c:\python37\lib\site-packages\pip ^ + -Dgtest_build_samples=ON ^ + -Dgtest_build_tests=ON ^ + -Dgmock_build_tests=ON +IF %errorlevel% neq 0 EXIT /B 1 + +%CMAKE_BIN% --build . --target ALL_BUILD --config Debug -- -maxcpucount +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 + +:: ---------------------------------------------------------------------------- +:: Bazel Visual Studio 15 2017 Win64 + +SET BAZEL_VC=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC +%BAZEL_EXE% test ... ^ + --compilation_mode=dbg ^ + --copt=/std:c++14 ^ + --copt=/WX ^ + --features=external_include_paths ^ + --keep_going ^ + --test_output=errors ^ + --test_tag_filters=-no_test_msvc2017 +IF %errorlevel% neq 0 EXIT /B 1 From 26d3ab54422257b65452d5feeb080c015eabf5e8 Mon Sep 17 00:00:00 2001 From: Derek Mauro Date: Mon, 17 Oct 2022 16:15:24 -0700 Subject: [PATCH 031/336] Fix detection of the no_sanitize("hwaddress") attribute PiperOrigin-RevId: 481765573 Change-Id: I1ba829c3cbf364a51d3ba383ee3b474c0e109578 --- googletest/include/gtest/internal/gtest-port.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 50d4c41f9..005a0c0dd 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -658,6 +658,16 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #define GTEST_HAVE_ATTRIBUTE_(x) 0 #endif +// GTEST_HAVE_FEATURE_ +// +// A function-like feature checking macro that is a wrapper around +// `__has_feature`. +#ifdef __has_feature +#define GTEST_HAVE_FEATURE_(x) __has_feature(x) +#else +#define GTEST_HAVE_FEATURE_(x) 0 +#endif + // Use this annotation at the end of a struct/class definition to // prevent the compiler from optimizing away instances that are never // used. This is useful when all interesting logic happens inside the @@ -812,7 +822,8 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #endif // A function level attribute to disable HWAddressSanitizer instrumentation. -#if GTEST_HAVE_ATTRIBUTE_(no_sanitize) +#if GTEST_HAVE_FEATURE_(hwaddress_sanitizer) && \ + GTEST_HAVE_ATTRIBUTE_(no_sanitize) #define GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_ \ __attribute__((no_sanitize("hwaddress"))) #else From f372c760264ad5fe672a96994d4a44190201e5c1 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Tue, 18 Oct 2022 08:51:57 -0700 Subject: [PATCH 032/336] Adds Win32 UNC path support to FilePath::IsAbsolutePath() and FilePath::IsRootDirectory() in GoogleTest Fixes: #3025 PiperOrigin-RevId: 481932601 Change-Id: I90fcb5b3d189aea79a0fd18735bad038b3511270 --- .../include/gtest/internal/gtest-filepath.h | 10 +++ googletest/src/gtest-filepath.cc | 75 ++++++++++++++----- googletest/test/googletest-filepath-test.cc | 18 +++++ 3 files changed, 85 insertions(+), 18 deletions(-) diff --git a/googletest/include/gtest/internal/gtest-filepath.h b/googletest/include/gtest/internal/gtest-filepath.h index a2a60a962..dd7a3a49a 100644 --- a/googletest/include/gtest/internal/gtest-filepath.h +++ b/googletest/include/gtest/internal/gtest-filepath.h @@ -199,6 +199,16 @@ class GTEST_API_ FilePath { // separators. Returns NULL if no path separator was found. const char* FindLastPathSeparator() const; + // Returns the length of the path root, including the directory separator at + // the end of the prefix. Returns zero by definition if the path is relative. + // Examples: + // - [Windows] "..\Sibling" => 0 + // - [Windows] "\Windows" => 1 + // - [Windows] "C:/Windows\Notepad.exe" => 3 + // - [Windows] "\\Host\Share\C$/Windows" => 13 + // - [UNIX] "/bin" => 1 + size_t CalculateRootLength() const; + std::string pathname_; }; // class FilePath diff --git a/googletest/src/gtest-filepath.cc b/googletest/src/gtest-filepath.cc index 6767db0d7..bec587009 100644 --- a/googletest/src/gtest-filepath.cc +++ b/googletest/src/gtest-filepath.cc @@ -145,6 +145,45 @@ const char* FilePath::FindLastPathSeparator() const { return last_sep; } +size_t FilePath::CalculateRootLength() const { + const auto &path = pathname_; + auto s = path.begin(); + auto end = path.end(); +#if GTEST_OS_WINDOWS + if (end - s >= 2 && s[1] == ':' && + (end - s == 2 || IsPathSeparator(s[2])) && + (('A' <= s[0] && s[0] <= 'Z') || ('a' <= s[0] && s[0] <= 'z'))) { + // A typical absolute path like "C:\Windows" or "D:" + s += 2; + if (s != end) { + ++s; + } + } else if (end - s >= 3 && IsPathSeparator(*s) && IsPathSeparator(*(s + 1)) + && !IsPathSeparator(*(s + 2))) { + // Move past the "\\" prefix in a UNC path like "\\Server\Share\Folder" + s += 2; + // Skip 2 components and their following separators ("Server\" and "Share\") + for (int i = 0; i < 2; ++i) { + while (s != end) { + bool stop = IsPathSeparator(*s); + ++s; + if (stop) { + break; + } + } + } + } else if (s != end && IsPathSeparator(*s)) { + // A drive-rooted path like "\Windows" + ++s; + } +#else + if (s != end && IsPathSeparator(*s)) { + ++s; + } +#endif + return static_cast(s - path.begin()); +} + // Returns a copy of the FilePath with the directory part removed. // Example: FilePath("path/to/file").RemoveDirectoryName() returns // FilePath("file"). If there is no directory part ("just_a_file"), it returns @@ -246,26 +285,16 @@ bool FilePath::DirectoryExists() const { } // Returns true if pathname describes a root directory. (Windows has one -// root directory per disk drive.) +// root directory per disk drive. UNC share roots are also included.) bool FilePath::IsRootDirectory() const { -#if GTEST_OS_WINDOWS - return pathname_.length() == 3 && IsAbsolutePath(); -#else - return pathname_.length() == 1 && IsPathSeparator(pathname_.c_str()[0]); -#endif + size_t root_length = CalculateRootLength(); + return root_length > 0 && root_length == pathname_.size() && + IsPathSeparator(pathname_[root_length - 1]); } // Returns true if pathname describes an absolute path. bool FilePath::IsAbsolutePath() const { - const char* const name = pathname_.c_str(); -#if GTEST_OS_WINDOWS - return pathname_.length() >= 3 && - ((name[0] >= 'a' && name[0] <= 'z') || - (name[0] >= 'A' && name[0] <= 'Z')) && - name[1] == ':' && IsPathSeparator(name[2]); -#else - return IsPathSeparator(name[0]); -#endif + return CalculateRootLength() > 0; } // Returns a pathname for a file that does not currently exist. The pathname @@ -347,17 +376,27 @@ FilePath FilePath::RemoveTrailingPathSeparator() const { // Removes any redundant separators that might be in the pathname. // For example, "bar///foo" becomes "bar/foo". Does not eliminate other // redundancies that might be in a pathname involving "." or "..". +// Note that "\\Host\Share" does not contain a redundancy on Windows! void FilePath::Normalize() { auto out = pathname_.begin(); - for (const char character : pathname_) { + auto i = pathname_.cbegin(); +#if GTEST_OS_WINDOWS + // UNC paths are treated specially + if (pathname_.end() - i >= 3 && IsPathSeparator(*i) && + IsPathSeparator(*(i + 1)) && !IsPathSeparator(*(i + 2))) { + *(out++) = kPathSeparator; + *(out++) = kPathSeparator; + } +#endif + while (i != pathname_.end()) { + const char character = *i; if (!IsPathSeparator(character)) { *(out++) = character; } else if (out == pathname_.begin() || *std::prev(out) != kPathSeparator) { *(out++) = kPathSeparator; - } else { - continue; } + ++i; } pathname_.erase(out, pathname_.end()); diff --git a/googletest/test/googletest-filepath-test.cc b/googletest/test/googletest-filepath-test.cc index fe53f848f..1e2cc4aaf 100644 --- a/googletest/test/googletest-filepath-test.cc +++ b/googletest/test/googletest-filepath-test.cc @@ -421,8 +421,13 @@ TEST(NormalizeTest, MultipleConsecutiveSeparatorsInMidstring) { // "/bar" == //bar" == "///bar" TEST(NormalizeTest, MultipleConsecutiveSeparatorsAtStringStart) { EXPECT_EQ(GTEST_PATH_SEP_ "bar", FilePath(GTEST_PATH_SEP_ "bar").string()); +#if GTEST_OS_WINDOWS + EXPECT_EQ(GTEST_PATH_SEP_ GTEST_PATH_SEP_ "bar", + FilePath(GTEST_PATH_SEP_ GTEST_PATH_SEP_ "bar").string()); +#else EXPECT_EQ(GTEST_PATH_SEP_ "bar", FilePath(GTEST_PATH_SEP_ GTEST_PATH_SEP_ "bar").string()); +#endif EXPECT_EQ( GTEST_PATH_SEP_ "bar", FilePath(GTEST_PATH_SEP_ GTEST_PATH_SEP_ GTEST_PATH_SEP_ "bar").string()); @@ -621,6 +626,9 @@ TEST(FilePathTest, IsAbsolutePath) { EXPECT_TRUE( FilePath("c:/" GTEST_PATH_SEP_ "is_not" GTEST_PATH_SEP_ "relative") .IsAbsolutePath()); + EXPECT_TRUE(FilePath("d:/Windows").IsAbsolutePath()); + EXPECT_TRUE(FilePath("\\\\Host\\Share").IsAbsolutePath()); + EXPECT_TRUE(FilePath("\\\\Host\\Share\\Folder").IsAbsolutePath()); #else EXPECT_TRUE(FilePath(GTEST_PATH_SEP_ "is_not" GTEST_PATH_SEP_ "relative") .IsAbsolutePath()); @@ -637,6 +645,16 @@ TEST(FilePathTest, IsRootDirectory) { EXPECT_FALSE(FilePath("b:a").IsRootDirectory()); EXPECT_FALSE(FilePath("8:/").IsRootDirectory()); EXPECT_FALSE(FilePath("c|/").IsRootDirectory()); + EXPECT_TRUE(FilePath("c:/").IsRootDirectory()); + EXPECT_FALSE(FilePath("d:/Windows").IsRootDirectory()); + + // This is for backward compatibility, since callers (even in this library) + // have assumed IsRootDirectory() implies a trailing directory separator. + EXPECT_FALSE(FilePath("\\\\Host\\Share").IsRootDirectory()); + + EXPECT_TRUE(FilePath("\\\\Host\\Share\\").IsRootDirectory()); + EXPECT_FALSE(FilePath("\\\\Host\\Share\\.").IsRootDirectory()); + EXPECT_FALSE(FilePath("\\\\Host\\Share\\C$\\").IsRootDirectory()); #else EXPECT_TRUE(FilePath("/").IsRootDirectory()); EXPECT_TRUE(FilePath("//").IsRootDirectory()); From 6bad847991e663f2e2cc0fac1e72765763ab616b Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Tue, 18 Oct 2022 21:39:44 -0700 Subject: [PATCH 033/336] CMake: Add GTEST_HAS_ABSL build option for using Absl PiperOrigin-RevId: 482101793 Change-Id: I1bd140fd6a325f573c8a0c464e4dccd4acd0d0a3 --- CMakeLists.txt | 1 + googletest/CMakeLists.txt | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 725d67072..4210622b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,7 @@ include(GNUInstallDirs) #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(BUILD_GMOCK) add_subdirectory( googlemock ) diff --git a/googletest/CMakeLists.txt b/googletest/CMakeLists.txt index aa00a5f3d..95bfa4420 100644 --- a/googletest/CMakeLists.txt +++ b/googletest/CMakeLists.txt @@ -125,6 +125,22 @@ include_directories(${gtest_build_include_dirs}) # aggressive about warnings. cxx_library(gtest "${cxx_strict}" src/gtest-all.cc) set_target_properties(gtest PROPERTIES VERSION ${GOOGLETEST_VERSION}) +if(GTEST_HAS_ABSL) + target_compile_definitions(gtest PUBLIC GTEST_HAS_ABSL=1) + target_link_libraries(gtest PUBLIC + absl::failure_signal_handler + absl::stacktrace + absl::symbolize + absl::flags_parse + absl::flags_reflection + absl::flags_usage + absl::strings + absl::any + absl::optional + absl::variant + re2::re2 + ) +endif() cxx_library(gtest_main "${cxx_strict}" src/gtest_main.cc) set_target_properties(gtest_main PROPERTIES VERSION ${GOOGLETEST_VERSION}) # If the CMake version supports it, attach header directory information From f3eb2b7e38e132402f8f67e86feb97813714c3d7 Mon Sep 17 00:00:00 2001 From: Denis Hananein Date: Thu, 20 Oct 2022 23:13:06 +0200 Subject: [PATCH 034/336] Allow naming expectations #3970 Signed-off-by: Denis Hananein --- .../include/gmock/gmock-spec-builders.h | 23 +++++++++++++++++-- googlemock/src/gmock-spec-builders.cc | 10 ++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/googlemock/include/gmock/gmock-spec-builders.h b/googlemock/include/gmock/gmock-spec-builders.h index 45cc60518..1d706758c 100644 --- a/googlemock/include/gmock/gmock-spec-builders.h +++ b/googlemock/include/gmock/gmock-spec-builders.h @@ -772,6 +772,10 @@ class GTEST_API_ ExpectationBase { retired_ = true; } + void SetName(std::string name) { name_ = std::move(name); } + + const std::string& GetName() const { return name_; } + // Returns true if and only if this expectation is satisfied. bool IsSatisfied() const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { g_gmock_mutex.AssertHeld(); @@ -831,6 +835,7 @@ class GTEST_API_ ExpectationBase { const char* file_; // The file that contains the expectation. int line_; // The line number of the expectation. const std::string source_text_; // The EXPECT_CALL(...) source text. + std::string name_; // True if and only if the cardinality is specified explicitly. bool cardinality_specified_; Cardinality cardinality_; // The cardinality of the expectation. @@ -909,6 +914,11 @@ class TypedExpectation : public ExpectationBase { return *this; } + TypedExpectation& Name(std::string name) { + SetName(std::move(name)); + return *this; + } + // Implements the .Times() clause. TypedExpectation& Times(const Cardinality& a_cardinality) { ExpectationBase::UntypedTimes(a_cardinality); @@ -1199,10 +1209,15 @@ class TypedExpectation : public ExpectationBase { ::std::ostream* why) GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { g_gmock_mutex.AssertHeld(); + const ::std::string& expectation_name = GetName(); if (IsSaturated()) { // We have an excessive call. IncrementCallCount(); - *what << "Mock function called more times than expected - "; + *what << "Mock function "; + if (!expectation_name.empty()) { + *what << "with name \"" << expectation_name << "\" "; + } + *what << "called more times than expected - "; mocker->DescribeDefaultActionTo(args, what); DescribeCallCountTo(why); @@ -1217,7 +1232,11 @@ class TypedExpectation : public ExpectationBase { } // Must be done after IncrementCount()! - *what << "Mock function call matches " << source_text() << "...\n"; + *what << "Mock function "; + if (!expectation_name.empty()) { + *what << "with name \"" << expectation_name << "\" "; + } + *what << "call matches " << source_text() << "...\n"; return &(GetCurrentAction(mocker, args)); } diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index b333e53da..e5f4609fa 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -409,8 +409,14 @@ bool UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked() } else if (!untyped_expectation->IsSatisfied()) { expectations_met = false; ::std::stringstream ss; - ss << "Actual function call count doesn't match " - << untyped_expectation->source_text() << "...\n"; + + const ::std::string& expectation_name = untyped_expectation->GetName(); + ss << "Actual function"; + if (!expectation_name.empty()) { + ss << " with name \"" << expectation_name << "\""; + } + ss << " call count doesn't match " << untyped_expectation->source_text() + << "...\n"; // No need to show the source file location of the expectation // in the description, as the Expect() call that follows already // takes care of it. From 0d263789198e021b688942c55d483ad670c66f22 Mon Sep 17 00:00:00 2001 From: Denis Hananein Date: Fri, 21 Oct 2022 14:03:45 +0200 Subject: [PATCH 035/336] Change messages Signed-off-by: Denis Hananein --- googlemock/include/gmock/gmock-spec-builders.h | 12 ++++++------ googlemock/src/gmock-spec-builders.cc | 7 +++---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/googlemock/include/gmock/gmock-spec-builders.h b/googlemock/include/gmock/gmock-spec-builders.h index 1d706758c..1168d22db 100644 --- a/googlemock/include/gmock/gmock-spec-builders.h +++ b/googlemock/include/gmock/gmock-spec-builders.h @@ -1213,11 +1213,11 @@ class TypedExpectation : public ExpectationBase { if (IsSaturated()) { // We have an excessive call. IncrementCallCount(); - *what << "Mock function "; + *what << "Mock function called more times than expected "; if (!expectation_name.empty()) { - *what << "with name \"" << expectation_name << "\" "; + *what << "for \"" << expectation_name << "\" "; } - *what << "called more times than expected - "; + *what << " - "; mocker->DescribeDefaultActionTo(args, what); DescribeCallCountTo(why); @@ -1232,11 +1232,11 @@ class TypedExpectation : public ExpectationBase { } // Must be done after IncrementCount()! - *what << "Mock function "; + *what << "Mock function call matches "; if (!expectation_name.empty()) { - *what << "with name \"" << expectation_name << "\" "; + *what << "\"" << expectation_name << "\" "; } - *what << "call matches " << source_text() << "...\n"; + *what << source_text() << "...\n"; return &(GetCurrentAction(mocker, args)); } diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index e5f4609fa..66fb434b2 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -411,12 +411,11 @@ bool UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked() ::std::stringstream ss; const ::std::string& expectation_name = untyped_expectation->GetName(); - ss << "Actual function"; + ss << "Actual function call count doesn't match "; if (!expectation_name.empty()) { - ss << " with name \"" << expectation_name << "\""; + ss << "\"" << expectation_name << "\""; } - ss << " call count doesn't match " << untyped_expectation->source_text() - << "...\n"; + ss << untyped_expectation->source_text() << "...\n"; // No need to show the source file location of the expectation // in the description, as the Expect() call that follows already // takes care of it. From 09e1c64f86634dd3a38bff59f3c24c5b8ad6675a Mon Sep 17 00:00:00 2001 From: Denis Hananein Date: Fri, 21 Oct 2022 15:37:38 +0200 Subject: [PATCH 036/336] Fix format without expectation name Signed-off-by: Denis Hananein --- googlemock/include/gmock/gmock-spec-builders.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/googlemock/include/gmock/gmock-spec-builders.h b/googlemock/include/gmock/gmock-spec-builders.h index 1168d22db..f6a5eadcb 100644 --- a/googlemock/include/gmock/gmock-spec-builders.h +++ b/googlemock/include/gmock/gmock-spec-builders.h @@ -1213,9 +1213,9 @@ class TypedExpectation : public ExpectationBase { if (IsSaturated()) { // We have an excessive call. IncrementCallCount(); - *what << "Mock function called more times than expected "; + *what << "Mock function called more times than expected"; if (!expectation_name.empty()) { - *what << "for \"" << expectation_name << "\" "; + *what << " for \"" << expectation_name << "\""; } *what << " - "; mocker->DescribeDefaultActionTo(args, what); From 03597a01ee50ed33e9dfd640b249b4be3799d395 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Mon, 24 Oct 2022 09:01:26 -0700 Subject: [PATCH 037/336] Clarify that parameter generator does not evaluate immediately This aims to avoid confusion as to what kinds of computations are valid inside a parameter generator expression, calling out flags as a supported use case. PiperOrigin-RevId: 483397027 Change-Id: I2d036fae95120d617f30a5566ea7498ce1f9bfb6 --- docs/advanced.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/advanced.md b/docs/advanced.md index c3c546145..59251706e 100644 --- a/docs/advanced.md +++ b/docs/advanced.md @@ -1095,6 +1095,11 @@ instantiation of the test suite. The next argument is the name of the test pattern, and the last is the [parameter generator](reference/testing.md#param-generators). +The parameter generator expression is not evaluated until GoogleTest is +initialized (via `InitGoogleTest()`). Any prior initialization done in the +`main` function will be accessible from the parameter generator, for example, +the results of flag parsing. + You can instantiate a test pattern more than once, so to distinguish different instances of the pattern, the instantiation name is added as a prefix to the actual test suite name. Remember to pick unique prefixes for different From 90171d106135fc03db211fcfe928527f3cb74a5e Mon Sep 17 00:00:00 2001 From: Dino Radakovic Date: Tue, 25 Oct 2022 06:28:58 -0700 Subject: [PATCH 038/336] Use git commit hash in CMake quickstart Commit hashes reflect GoogleTest's live-at-head stance. Credits to @shinfd. Fixes #4000 PiperOrigin-RevId: 483655943 Change-Id: Ieeb162859348dbe3657e18f283bac81412f2585d --- docs/quickstart-cmake.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/quickstart-cmake.md b/docs/quickstart-cmake.md index 2988761bf..5abe50441 100644 --- a/docs/quickstart-cmake.md +++ b/docs/quickstart-cmake.md @@ -58,8 +58,7 @@ set(CMAKE_CXX_STANDARD 14) include(FetchContent) FetchContent_Declare( googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG release-1.12.1 + URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip ) # For Windows: Prevent overriding the parent project's compiler/linker settings set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) @@ -67,7 +66,7 @@ FetchContent_MakeAvailable(googletest) ``` The above configuration declares a dependency on GoogleTest which is downloaded -from GitHub. In the above example, `609281088cfefc76f9d0ce82e1ff6c30cc3591e5` is +from GitHub. In the above example, `03597a01ee50ed33e9dfd640b249b4be3799d395` is the Git commit hash of the GoogleTest version to use; we recommend updating the hash often to point to the latest version. From 66366cea569337c53c7ef1c72f84b566746e465e Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Thu, 3 Nov 2022 09:34:43 -0700 Subject: [PATCH 039/336] Add documentation for `--gunit_recreate_environments_when_repeating`. PiperOrigin-RevId: 485895339 Change-Id: I09b0f535941531ef7bcb74593d385891d56b3e32 --- docs/advanced.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/advanced.md b/docs/advanced.md index 59251706e..f16382fe0 100644 --- a/docs/advanced.md +++ b/docs/advanced.md @@ -1913,8 +1913,12 @@ Repeat the tests whose name matches the filter 1000 times. If your test program contains [global set-up/tear-down](#global-set-up-and-tear-down) code, it will be -repeated in each iteration as well, as the flakiness may be in it. You can also -specify the repeat count by setting the `GTEST_REPEAT` environment variable. +repeated in each iteration as well, as the flakiness may be in it. To avoid +repeating global set-up/tear-down, specify +`--gtest_recreate_environments_when_repeating=false`{.nowrap}. + +You can also specify the repeat count by setting the `GTEST_REPEAT` environment +variable. ### Shuffling the Tests From a4f02ef38981350c9d673b9909559c7a86420d7a Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Sat, 5 Nov 2022 01:07:00 -0700 Subject: [PATCH 040/336] Fix typo in documentation of ConvertGenerator() PiperOrigin-RevId: 486316328 Change-Id: I91d5d5ba1aaf4a4ab14019c8963e7fe181722f95 --- googletest/include/gtest/gtest-param-test.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/include/gtest/gtest-param-test.h b/googletest/include/gtest/gtest-param-test.h index 10d6a079a..1adb9a725 100644 --- a/googletest/include/gtest/gtest-param-test.h +++ b/googletest/include/gtest/gtest-param-test.h @@ -407,7 +407,7 @@ internal::CartesianProductHolder Combine(const Generator&... g) { return internal::CartesianProductHolder(g...); } -// ConvertGenerator() wraps a parameter generator in order to cast each prduced +// ConvertGenerator() wraps a parameter generator in order to cast each produced // value through a known type before supplying it to the test suite // // Synopsis: From 386c7665f5cf1f772f5877cdb32070d8052041a9 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Mon, 7 Nov 2022 09:36:17 -0800 Subject: [PATCH 041/336] RecordProperty serializes ints and 64-bit ints, including size_ts PiperOrigin-RevId: 486685761 Change-Id: I164d2646e65670d341dbf437ee571953c456677a --- googletest/include/gtest/gtest.h | 3 ++- googletest/src/gtest.cc | 10 ++++------ googletest/test/gtest_xml_outfile2_test_.cc | 4 +++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index 7963e8c7a..55fdc6019 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -50,6 +50,7 @@ #define GOOGLETEST_INCLUDE_GTEST_GTEST_H_ #include +#include #include #include #include @@ -296,7 +297,7 @@ class GTEST_API_ Test { // SetUp/TearDown method of Environment objects registered with Google // Test) will be output as attributes of the element. static void RecordProperty(const std::string& key, const std::string& value); - static void RecordProperty(const std::string& key, int value); + static void RecordProperty(const std::string& key, int64_t value); protected: // Creates a Test object. diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 385945284..2276d0778 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -2444,12 +2444,10 @@ void Test::TearDown() {} void Test::RecordProperty(const std::string& key, const std::string& value) { UnitTest::GetInstance()->RecordProperty(key, value); } - -// Allows user supplied key value pairs to be recorded for later output. -void Test::RecordProperty(const std::string& key, int value) { - Message value_message; - value_message << value; - RecordProperty(key, value_message.GetString().c_str()); +// We do not define a customary serialization except for integers, +// but other values could be logged in this way. +void Test::RecordProperty(const std::string& key, int64_t value) { + RecordProperty(key, (Message() << value).GetString()); } namespace internal { diff --git a/googletest/test/gtest_xml_outfile2_test_.cc b/googletest/test/gtest_xml_outfile2_test_.cc index f9a2a6e98..f743b31b7 100644 --- a/googletest/test/gtest_xml_outfile2_test_.cc +++ b/googletest/test/gtest_xml_outfile2_test_.cc @@ -39,5 +39,7 @@ class PropertyTwo : public testing::Test { }; TEST_F(PropertyTwo, TestSomeProperties) { - RecordProperty("TestSomeProperty", 2); + // Validate we can write an unsigned size_t as a property + size_t prop_two = 2; + RecordProperty("TestSomeProperty", prop_two); } From 6b63c98ac43efc992122f1da12aaf0a0e0658206 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Tue, 8 Nov 2022 07:57:31 -0800 Subject: [PATCH 042/336] Remove incorrect GTEST_ATTRIBUTE_UNUSED_ from InSequence class. Fixes: #4048 PiperOrigin-RevId: 486951561 Change-Id: I4fae101b5ac5ed4f46c32aba8c36519e1f784db1 --- googlemock/include/gmock/gmock-spec-builders.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googlemock/include/gmock/gmock-spec-builders.h b/googlemock/include/gmock/gmock-spec-builders.h index ef199ab86..c1b725b3d 100644 --- a/googlemock/include/gmock/gmock-spec-builders.h +++ b/googlemock/include/gmock/gmock-spec-builders.h @@ -656,7 +656,7 @@ class GTEST_API_ InSequence { InSequence(const InSequence&) = delete; InSequence& operator=(const InSequence&) = delete; -} GTEST_ATTRIBUTE_UNUSED_; +}; namespace internal { From 4b7f9453c5fbb0614cec13565ff98ab87aa83fbe Mon Sep 17 00:00:00 2001 From: Denis Hananein Date: Thu, 10 Nov 2022 17:08:48 +0100 Subject: [PATCH 043/336] Support kitty TERM Signed-off-by: Denis Hananein --- googletest/src/gtest.cc | 1 + googletest/test/googletest-color-test.py | 1 + googletest/test/gtest_unittest.cc | 3 +++ 3 files changed, 5 insertions(+) diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 385945284..cc56752a5 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -3257,6 +3257,7 @@ bool ShouldUseColor(bool stdout_is_tty) { const bool term_supports_color = term != nullptr && ( String::CStringEquals(term, "xterm") || String::CStringEquals(term, "xterm-color") || + String::CStringEquals(term, "xterm-kitty") || String::CStringEquals(term, "screen") || String::CStringEquals(term, "tmux") || String::CStringEquals(term, "rxvt-unicode") || diff --git a/googletest/test/googletest-color-test.py b/googletest/test/googletest-color-test.py index c22752db8..f08edf707 100755 --- a/googletest/test/googletest-color-test.py +++ b/googletest/test/googletest-color-test.py @@ -78,6 +78,7 @@ class GTestColorTest(gtest_test_utils.TestCase): self.assert_(UsesColor('cygwin', None, None)) self.assert_(UsesColor('xterm', None, None)) self.assert_(UsesColor('xterm-color', None, None)) + self.assert_(UsesColor('xterm-kitty', None, None)) self.assert_(UsesColor('xterm-256color', None, None)) def testFlagOnly(self): diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index 329ca5466..8bd21be98 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -6636,6 +6636,9 @@ TEST(ColoredOutputTest, UsesColorsWhenTermSupportsColors) { SetEnv("TERM", "xterm-color"); // TERM supports colors. EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY. + SetEnv("TERM", "xterm-kitty"); // TERM supports colors. + EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY. + SetEnv("TERM", "xterm-256color"); // TERM supports colors. EXPECT_TRUE(ShouldUseColor(true)); // Stdout is a TTY. From 912db742531bf82efb01194bc08140416e3b3467 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Fri, 11 Nov 2022 12:58:35 -0800 Subject: [PATCH 044/336] Defined a testing::SrcDir() function that returns the name of a directory where ancillary data files can be found. PiperOrigin-RevId: 487896836 Change-Id: Ie6b1ba734e900fa33872b63090879ee6efe33411 --- googletest/include/gtest/gtest.h | 11 +++- googletest/src/gtest.cc | 43 ++++++++++--- googletest/test/gtest_dirs_test.cc | 97 ++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+), 11 deletions(-) create mode 100644 googletest/test/gtest_dirs_test.cc diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index ffff87662..1184337a8 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -2201,10 +2201,17 @@ constexpr bool StaticAssertTypeEq() noexcept { #define TEST_F(test_fixture, test_name) GTEST_TEST_F(test_fixture, test_name) #endif -// Returns a path to temporary directory. -// Tries to determine an appropriate directory for the platform. +// Returns a path to a temporary directory, which should be writable. It is +// implementation-dependent whether or not the path is terminated by the +// directory-separator character. GTEST_API_ std::string TempDir(); +// Returns a path to a directory that contains ancillary data files that might +// be used by tests. It is implementation dependent whether or not the path is +// terminated by the directory-separator character. The directory and the files +// in it should be considered read-only. +GTEST_API_ std::string SrcDir(); + #ifdef _MSC_VER #pragma warning(pop) #endif diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 2276d0778..7669d2287 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -6754,12 +6754,13 @@ void InitGoogleTest() { #endif // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_) } -#if !defined(GTEST_CUSTOM_TEMPDIR_FUNCTION_) -// Return value of first environment variable that is set and contains -// a non-empty string. If there are none, return the "fallback" string. -// Since we like the temporary directory to have a directory separator suffix, -// add it if not provided in the environment variable value. -static std::string GetTempDirFromEnv( +#if !defined(GTEST_CUSTOM_TEMPDIR_FUNCTION_) || \ + !defined(GTEST_CUSTOM_SRCDIR_FUNCTION_) +// Returns the value of the first environment variable that is set and contains +// a non-empty string. If there are none, returns the "fallback" string. Adds +// the director-separator character as a suffix if not provided in the +// environment variable value. +static std::string GetDirFromEnv( std::initializer_list environment_variables, const char* fallback, char separator) { for (const char* variable_name : environment_variables) { @@ -6779,11 +6780,35 @@ std::string TempDir() { #if defined(GTEST_CUSTOM_TEMPDIR_FUNCTION_) return GTEST_CUSTOM_TEMPDIR_FUNCTION_(); #elif GTEST_OS_WINDOWS || GTEST_OS_WINDOWS_MOBILE - return GetTempDirFromEnv({"TEST_TMPDIR", "TEMP"}, "\\temp\\", '\\'); + return GetDirFromEnv({"TEST_TMPDIR", "TEMP"}, "\\temp\\", '\\'); #elif GTEST_OS_LINUX_ANDROID - return GetTempDirFromEnv({"TEST_TMPDIR", "TMPDIR"}, "/data/local/tmp/", '/'); + return GetDirFromEnv({"TEST_TMPDIR", "TMPDIR"}, "/data/local/tmp/", '/'); #else - return GetTempDirFromEnv({"TEST_TMPDIR", "TMPDIR"}, "/tmp/", '/'); + return GetDirFromEnv({"TEST_TMPDIR", "TMPDIR"}, "/tmp/", '/'); +#endif +} + +#if !defined(GTEST_CUSTOM_SRCDIR_FUNCTION_) +// Returns the directory path (including terminating separator) of the current +// executable as derived from argv[0]. +static std::string GetCurrentExecutableDirectory() { + internal::FilePath argv_0(internal::GetArgvs()[0]); + return argv_0.RemoveFileName().string(); +} +#endif + +std::string SrcDir() { +#if defined(GTEST_CUSTOM_SRCDIR_FUNCTION_) + return GTEST_CUSTOM_SRCDIR_FUNCTION_(); +#elif GTEST_OS_WINDOWS || GTEST_OS_WINDOWS_MOBILE + return GetDirFromEnv({"TEST_SRCDIR"}, GetCurrentExecutableDirectory().c_str(), + '\\'); +#elif GTEST_OS_LINUX_ANDROID + return GetDirFromEnv({"TEST_SRCDIR"}, GetCurrentExecutableDirectory().c_str(), + '/'); +#else + return GetDirFromEnv({"TEST_SRCDIR"}, GetCurrentExecutableDirectory().c_str(), + '/'); #endif } diff --git a/googletest/test/gtest_dirs_test.cc b/googletest/test/gtest_dirs_test.cc new file mode 100644 index 000000000..c0da9ac46 --- /dev/null +++ b/googletest/test/gtest_dirs_test.cc @@ -0,0 +1,97 @@ +#include + +#include +#include +#include + +#include "gtest/gtest.h" +#include "gtest/internal/gtest-port.h" + +namespace { + +class SetEnv { + public: + // Sets the environment value with name `name` to `value`, unless `value` is + // nullptr, in which case it unsets it. Restores the original value on + // destruction. + SetEnv(const char* name, const char* value) : name_(name) { + const char* old_value = getenv(name); + if (old_value != nullptr) { + saved_value_ = old_value; + have_saved_value_ = true; + } + if (value == nullptr) { + GTEST_CHECK_POSIX_SUCCESS_(unsetenv(name)); + } else { + GTEST_CHECK_POSIX_SUCCESS_(setenv(name, value, 1 /*overwrite*/)); + } + } + + ~SetEnv() { + if (have_saved_value_) { + GTEST_CHECK_POSIX_SUCCESS_( + setenv(name_.c_str(), saved_value_.c_str(), 1 /*overwrite*/)); + } else { + GTEST_CHECK_POSIX_SUCCESS_(unsetenv(name_.c_str())); + } + } + + private: + std::string name_; + bool have_saved_value_ = false; + std::string saved_value_; +}; + +class MakeTempDir { + public: + // Creates a directory with a unique name including `testname`. + // The destructor removes it. + explicit MakeTempDir(const std::string& testname) { + // mkdtemp requires that the last 6 characters of the input pattern + // are Xs, and the string is modified by replacing those characters. + std::string pattern = "/tmp/" + testname + "_XXXXXX"; + GTEST_CHECK_(mkdtemp(pattern.data()) != nullptr); + dirname_ = pattern; + } + + ~MakeTempDir() { GTEST_CHECK_POSIX_SUCCESS_(rmdir(dirname_.c_str())); } + + const char* DirName() const { return dirname_.c_str(); } + + private: + std::string dirname_; +}; + +bool StartsWith(const std::string& str, const std::string& prefix) { + return str.substr(0, prefix.size()) == prefix; +} + +TEST(TempDirTest, InEnvironment) { + // Since the test infrastructure might be verifying directory existence or + // even creating subdirectories, we need to be careful that the directories we + // specify are actually valid. + MakeTempDir temp_dir("TempDirTest_InEnvironment"); + SetEnv set_env("TEST_TMPDIR", temp_dir.DirName()); + EXPECT_TRUE(StartsWith(testing::TempDir(), temp_dir.DirName())); +} + +TEST(TempDirTest, NotInEnvironment) { + SetEnv set_env("TEST_TMPDIR", nullptr); + EXPECT_NE(testing::TempDir(), ""); +} + +TEST(SrcDirTest, InEnvironment) { + // Since the test infrastructure might be verifying directory existence or + // even creating subdirectories, we need to be careful that the directories we + // specify are actually valid. + MakeTempDir temp_dir("SrcDirTest_InEnvironment"); + SetEnv set_env("TEST_SRCDIR", temp_dir.DirName()); + EXPECT_TRUE(StartsWith(testing::SrcDir(), temp_dir.DirName())); +} + +TEST(SrcDirTest, NotInEnvironment) { + SetEnv set_env("TEST_SRCDIR", nullptr); + EXPECT_NE(testing::SrcDir(), ""); +} + +} // namespace From 9c990a7b1e9a1f888aaf16bd38eb52ba16827582 Mon Sep 17 00:00:00 2001 From: RerEngineer Date: Sat, 12 Nov 2022 15:12:00 +0000 Subject: [PATCH 045/336] fixing gcc.gnu domain redirection --- googletest/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/README.md b/googletest/README.md index 3a82b1dfb..4e76520dc 100644 --- a/googletest/README.md +++ b/googletest/README.md @@ -186,7 +186,7 @@ to the compiler flags. Note: while the above steps aren't technically necessary today when using some compilers (e.g. GCC), they may become necessary in the future, if we decide to improve the speed of loading the library (see - for details). Therefore you are recommended + for details). Therefore you are recommended to always add the above flags when using GoogleTest as a shared library. Otherwise a future release of GoogleTest may break your build script. From 148ab827cacc7a879832f40313bda87a65b1e8a3 Mon Sep 17 00:00:00 2001 From: RerEngineer Date: Sat, 12 Nov 2022 15:21:28 +0000 Subject: [PATCH 046/336] From 4408a0288b24fbe9156a9b14bbecd148ea64f40f Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Tue, 15 Nov 2022 12:00:32 -0800 Subject: [PATCH 047/336] Remove incorrect usage of GTEST_ATTRIBUTE_UNUSED_ on classes. Fixes: #4054 PiperOrigin-RevId: 488721587 Change-Id: I8742d8475376635c83edcf524796a6107042e89b --- googletest/include/gtest/gtest.h | 4 +--- .../gtest/internal/gtest-death-test-internal.h | 2 +- googletest/include/gtest/internal/gtest-port.h | 14 ++++---------- googletest/src/gtest-internal-inl.h | 2 +- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index 1184337a8..fcad3ae25 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -2075,9 +2075,7 @@ class GTEST_API_ ScopedTrace { ScopedTrace(const ScopedTrace&) = delete; ScopedTrace& operator=(const ScopedTrace&) = delete; -} GTEST_ATTRIBUTE_UNUSED_; // A ScopedTrace object does its job in its - // c'tor and d'tor. Therefore it doesn't - // need to be used otherwise. +}; // Causes a trace (including the source file path, the current line // number, and the given message) to be included in every test failure diff --git a/googletest/include/gtest/internal/gtest-death-test-internal.h b/googletest/include/gtest/internal/gtest-death-test-internal.h index 45580ae80..347821708 100644 --- a/googletest/include/gtest/internal/gtest-death-test-internal.h +++ b/googletest/include/gtest/internal/gtest-death-test-internal.h @@ -99,7 +99,7 @@ class GTEST_API_ DeathTest { DeathTest* const test_; ReturnSentinel(const ReturnSentinel&) = delete; ReturnSentinel& operator=(const ReturnSentinel&) = delete; - } GTEST_ATTRIBUTE_UNUSED_; + }; // An enumeration of possible roles that may be taken when a death // test is encountered. EXECUTE means that the death test logic should diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 005a0c0dd..c3b131f50 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -668,17 +668,11 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #define GTEST_HAVE_FEATURE_(x) 0 #endif -// Use this annotation at the end of a struct/class definition to -// prevent the compiler from optimizing away instances that are never -// used. This is useful when all interesting logic happens inside the -// c'tor and / or d'tor. Example: -// -// struct Foo { -// Foo() { ... } -// } GTEST_ATTRIBUTE_UNUSED_; -// -// Also use it after a variable or parameter declaration to tell the +// Use this annotation after a variable or parameter declaration to tell the // compiler the variable/parameter does not have to be used. +// Example: +// +// GTEST_ATTRIBUTE_UNUSED_ int foo = bar(); #if GTEST_HAVE_ATTRIBUTE_(unused) #define GTEST_ATTRIBUTE_UNUSED_ __attribute__((unused)) #else diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h index 8c650e0c3..517cc13a3 100644 --- a/googletest/src/gtest-internal-inl.h +++ b/googletest/src/gtest-internal-inl.h @@ -212,7 +212,7 @@ class GTestFlagSaver { int32_t stack_trace_depth_; std::string stream_result_to_; bool throw_on_failure_; -} GTEST_ATTRIBUTE_UNUSED_; +}; // Converts a Unicode code point to a narrow string in UTF-8 encoding. // code_point parameter is of type UInt32 because wchar_t may not be From 9c332145b71c36a5bad9688312c79184f98601ff Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 16 Nov 2022 09:17:58 -0800 Subject: [PATCH 048/336] When printing floating-point numbers, print full precision by default. To make debug output readable, we still use the faster 6-digit precision sometimes, but only if it will round-trip. This way, when a test fails due to a very small difference in floating-point numbers, users will have enough digits to see the difference. PiperOrigin-RevId: 488958311 Change-Id: Ibcac43f48a97006d89217530c69386cc4fa2735c --- googletest/include/gtest/gtest-printers.h | 75 +++++++++++++++++++++ googletest/test/googletest-printers-test.cc | 10 ++- 2 files changed, 84 insertions(+), 1 deletion(-) diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h index 89215e620..eeaef04e0 100644 --- a/googletest/include/gtest/gtest-printers.h +++ b/googletest/include/gtest/gtest-printers.h @@ -484,6 +484,81 @@ GTEST_API_ void PrintTo(__uint128_t v, ::std::ostream* os); GTEST_API_ void PrintTo(__int128_t v, ::std::ostream* os); #endif // __SIZEOF_INT128__ +// The default resolution used to print floating-point values uses only +// 6 digits, which can be confusing if a test compares two values whose +// difference lies in the 7th digit. So we'd like to print out numbers +// in full precision. +// However if the value is something simple like 1.1, full will print a +// long string like 1.100000001 due to floating-point numbers not using +// a base of 10. This routiune returns an appropriate resolution for a +// given floating-point number, that is, 6 if it will be accurate, or a +// max_digits10 value (full precision) if it won't, for values between +// 0.0001 and one million. +// It does this by computing what those digits would be (by multiplying +// by an appropriate power of 10), then dividing by that power again to +// see if gets the original value back. +// A similar algorithm applies for values larger than one million; note +// that for those values, we must divide to get a six-digit number, and +// then multiply to possibly get the original value again. +template +int AppropriateResolution(FloatType val) { + int full = std::numeric_limits::max_digits10; + if (val < 0) val = -val; + + if (val < 1000000) { + FloatType mulfor6 = 1e10; + if (val >= 100000.0) { // 100,000 to 999,999 + mulfor6 = 1.0; + } else if (val >= 10000.0) { + mulfor6 = 1e1; + } else if (val >= 1000.0) { + mulfor6 = 1e2; + } else if (val >= 100.0) { + mulfor6 = 1e3; + } else if (val >= 10.0) { + mulfor6 = 1e4; + } else if (val >= 1.0) { + mulfor6 = 1e5; + } else if (val >= 0.1) { + mulfor6 = 1e6; + } else if (val >= 0.01) { + mulfor6 = 1e7; + } else if (val >= 0.001) { + mulfor6 = 1e8; + } else if (val >= 0.0001) { + mulfor6 = 1e9; + } + if (static_cast(val * mulfor6 + 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 + divfor6 = 10000; + } else if (val >= 1e8) { // 100,000,000 to 999,999,999 + divfor6 = 1000; + } else if (val >= 1e7) { // 10,000,000 to 99,999,999 + divfor6 = 100; + } else if (val >= 1e6) { // 1,000,000 to 9,999,999 + divfor6 = 10; + } + if (static_cast(val / divfor6 + 0.5) * divfor6 == val) return 6; + } + return full; +} + +inline void PrintTo(float f, ::std::ostream* os) { + auto old_precision = os->precision(); + os->precision(AppropriateResolution(f)); + *os << f; + os->precision(old_precision); +} + +inline void PrintTo(double d, ::std::ostream* os) { + auto old_precision = os->precision(); + os->precision(AppropriateResolution(d)); + *os << d; + os->precision(old_precision); +} + // Overloads for C strings. GTEST_API_ void PrintTo(const char* s, ::std::ostream* os); inline void PrintTo(char* s, ::std::ostream* os) { diff --git a/googletest/test/googletest-printers-test.cc b/googletest/test/googletest-printers-test.cc index d2d88a522..8a7db25b0 100644 --- a/googletest/test/googletest-printers-test.cc +++ b/googletest/test/googletest-printers-test.cc @@ -458,7 +458,15 @@ TEST(PrintBuiltInTypeTest, Int128) { // Floating-points. TEST(PrintBuiltInTypeTest, FloatingPoints) { - EXPECT_EQ("1.5", Print(1.5f)); // float + // float (32-bit precision) + EXPECT_EQ("1.5", Print(1.5f)); + + EXPECT_EQ("1.0999999", Print(1.09999990f)); + EXPECT_EQ("1.1", Print(1.10000002f)); + EXPECT_EQ("1.10000014", Print(1.10000014f)); + EXPECT_EQ("9e+09", Print(9e9f)); + + // double EXPECT_EQ("-2.5", Print(-2.5)); // double } From 834698cc9b19fc6e327db1b8b7e434e18b5cef38 Mon Sep 17 00:00:00 2001 From: Denis Hananein Date: Sun, 20 Nov 2022 15:08:43 +0100 Subject: [PATCH 049/336] Change MakeUnique -> std::make_unique in docs --- docs/gmock_cheat_sheet.md | 2 +- docs/gmock_cook_book.md | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/gmock_cheat_sheet.md b/docs/gmock_cheat_sheet.md index 67d075dd9..2fb0403e6 100644 --- a/docs/gmock_cheat_sheet.md +++ b/docs/gmock_cheat_sheet.md @@ -140,7 +140,7 @@ To customize the default action for functions with return type `T`, use // Sets the default action for return type std::unique_ptr to // creating a new Buzz every time. DefaultValue>::SetFactory( - [] { return MakeUnique(AccessLevel::kInternal); }); + [] { return std::make_unique(AccessLevel::kInternal); }); // When this fires, the default action of MakeBuzz() will run, which // will return a new Buzz object. diff --git a/docs/gmock_cook_book.md b/docs/gmock_cook_book.md index 5be298d3e..693201e45 100644 --- a/docs/gmock_cook_book.md +++ b/docs/gmock_cook_book.md @@ -2784,7 +2784,7 @@ If you just need to return a pre-defined move-only value, you can use the // When this fires, the unique_ptr<> specified by ByMove(...) will // be returned. EXPECT_CALL(mock_buzzer_, MakeBuzz("world")) - .WillOnce(Return(ByMove(MakeUnique(AccessLevel::kInternal)))); + .WillOnce(Return(ByMove(std::make_unique(AccessLevel::kInternal)))); EXPECT_NE(nullptr, mock_buzzer_.MakeBuzz("world")); ``` @@ -2805,7 +2805,7 @@ pretty much anything you want: ```cpp EXPECT_CALL(mock_buzzer_, MakeBuzz("x")) .WillRepeatedly([](StringPiece text) { - return MakeUnique(AccessLevel::kInternal); + return std::make_unique(AccessLevel::kInternal); }); EXPECT_NE(nullptr, mock_buzzer_.MakeBuzz("x")); @@ -2824,7 +2824,7 @@ can always use `Return`, or a [lambda or functor](#FunctionsAsActions): using ::testing::Unused; EXPECT_CALL(mock_buzzer_, ShareBuzz(NotNull(), _)).WillOnce(Return(true)); - EXPECT_TRUE(mock_buzzer_.ShareBuzz(MakeUnique(AccessLevel::kInternal)), + EXPECT_TRUE(mock_buzzer_.ShareBuzz(std::make_unique(AccessLevel::kInternal)), 0); EXPECT_CALL(mock_buzzer_, ShareBuzz(_, _)).WillOnce( @@ -2868,7 +2868,7 @@ method: // When one calls ShareBuzz() on the MockBuzzer like this, the call is // forwarded to DoShareBuzz(), which is mocked. Therefore this statement // will trigger the above EXPECT_CALL. - mock_buzzer_.ShareBuzz(MakeUnique(AccessLevel::kInternal), 0); + mock_buzzer_.ShareBuzz(std::make_unique(AccessLevel::kInternal), 0); ``` ### Making the Compilation Faster From e68764c147ea0dac1e8811925c531d937396878e Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 23 Nov 2022 15:57:21 -0800 Subject: [PATCH 050/336] This commit fixes a minor verb conjugation error in gmock_cook_book.md. PiperOrigin-RevId: 490601453 Change-Id: I733b2ed8740b1c809dddb166a42993b869198469 --- docs/gmock_cook_book.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/gmock_cook_book.md b/docs/gmock_cook_book.md index 693201e45..59aa9fc3d 100644 --- a/docs/gmock_cook_book.md +++ b/docs/gmock_cook_book.md @@ -1904,7 +1904,7 @@ using testing::ReturnPointee; ### Combining Actions Want to do more than one thing when a function is called? That's fine. `DoAll()` -allow you to do sequence of actions every time. Only the return value of the +allows you to do a sequence of actions every time. Only the return value of the last action in the sequence will be used. ```cpp From a16bfcfda1ea994c1abec23cca8f530953042dfa Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Tue, 29 Nov 2022 08:43:37 -0800 Subject: [PATCH 051/336] Disables `-Wunused-member-function` and `-Wused-but-marked-unused` that trigger via `MOCK_METHOD()` and `EXPECT_THAT()` macros. Fixes: #4052, #4055 PiperOrigin-RevId: 491647393 Change-Id: I8e2ad838156fa8c7e9dccd1740af797e694992b6 --- .../include/gmock/gmock-function-mocker.h | 7 +++++-- googlemock/include/gmock/gmock-matchers.h | 8 +++++++- .../gmock/internal/gmock-internal-utils.h | 18 ++++++++++++++++++ googlemock/test/gmock-function-mocker_test.cc | 15 +++++++++++++++ googlemock/test/gmock-matchers-misc_test.cc | 14 ++++++++++++++ 5 files changed, 59 insertions(+), 3 deletions(-) diff --git a/googlemock/include/gmock/gmock-function-mocker.h b/googlemock/include/gmock/gmock-function-mocker.h index b568aefe4..73065493b 100644 --- a/googlemock/include/gmock/gmock-function-mocker.h +++ b/googlemock/include/gmock/gmock-function-mocker.h @@ -108,8 +108,11 @@ constexpr bool ValidateSpec(const char (&spec)[N]) { using internal::FunctionMocker; } // namespace testing -#define MOCK_METHOD(...) \ - GMOCK_PP_VARIADIC_CALL(GMOCK_INTERNAL_MOCK_METHOD_ARG_, __VA_ARGS__) +#define MOCK_METHOD(...) \ + GMOCK_INTERNAL_WARNING_PUSH() \ + GMOCK_INTERNAL_WARNING_CLANG(ignored, "-Wunused-member-function") \ + GMOCK_PP_VARIADIC_CALL(GMOCK_INTERNAL_MOCK_METHOD_ARG_, __VA_ARGS__) \ + GMOCK_INTERNAL_WARNING_POP() #define GMOCK_INTERNAL_MOCK_METHOD_ARG_1(...) \ GMOCK_INTERNAL_WRONG_ARITY(__VA_ARGS__) diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index 5faf8dc95..9ade92733 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -5482,7 +5482,13 @@ PolymorphicMatcher> ThrowsMessage( } \ }; \ }; \ - GTEST_ATTRIBUTE_UNUSED_ inline name##Matcher name() { return {}; } \ + inline name##Matcher GMOCK_INTERNAL_WARNING_PUSH() \ + GMOCK_INTERNAL_WARNING_CLANG(ignored, "-Wunused-function") \ + GMOCK_INTERNAL_WARNING_CLANG(ignored, "-Wunused-member-function") \ + name \ + GMOCK_INTERNAL_WARNING_POP()() { \ + return {}; \ + } \ template \ bool name##Matcher::gmock_Impl::MatchAndExplain( \ const arg_type& arg, \ diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h index 2678920b0..36ab8e26a 100644 --- a/googlemock/include/gmock/internal/gmock-internal-utils.h +++ b/googlemock/include/gmock/internal/gmock-internal-utils.h @@ -95,6 +95,24 @@ inline Element* GetRawPointer(Element* p) { return p; } +// Default definitions for all compilers. +// NOTE: If you implement support for other compilers, make sure to avoid +// unexpected overlaps. +// (e.g., Clang also processes #pragma GCC, and clang-cl also handles _MSC_VER.) +#define GMOCK_INTERNAL_WARNING_PUSH() +#define GMOCK_INTERNAL_WARNING_CLANG(Level, Name) +#define GMOCK_INTERNAL_WARNING_POP() + +#if defined(__clang__) +#undef GMOCK_INTERNAL_WARNING_PUSH +#define GMOCK_INTERNAL_WARNING_PUSH() _Pragma("clang diagnostic push") +#undef GMOCK_INTERNAL_WARNING_CLANG +#define GMOCK_INTERNAL_WARNING_CLANG(Level, Warning) \ + _Pragma(GMOCK_PP_INTERNAL_STRINGIZE(clang diagnostic Level Warning)) +#undef GMOCK_INTERNAL_WARNING_POP +#define GMOCK_INTERNAL_WARNING_POP() _Pragma("clang diagnostic pop") +#endif + // MSVC treats wchar_t as a native type usually, but treats it as the // same as unsigned short when the compiler option /Zc:wchar_t- is // specified. It defines _NATIVE_WCHAR_T_DEFINED symbol when wchar_t diff --git a/googlemock/test/gmock-function-mocker_test.cc b/googlemock/test/gmock-function-mocker_test.cc index 286115fef..1d15a2993 100644 --- a/googlemock/test/gmock-function-mocker_test.cc +++ b/googlemock/test/gmock-function-mocker_test.cc @@ -958,6 +958,21 @@ TEST(MockMethodMockFunctionTest, MockMethodSizeOverhead) { EXPECT_EQ(sizeof(LegacyMockMethodSizes0), sizeof(MockMethodSizes0)); } +TEST(MockMethodMockFunctionTest, EnsureNoUnusedMemberFunction) { +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic error "-Wunused-member-function" +#endif + // https://github.com/google/googletest/issues/4052 + struct Foo { + MOCK_METHOD(void, foo, ()); + }; + EXPECT_CALL(Foo(), foo()).Times(0); +#ifdef __clang__ +#pragma clang diagnostic pop +#endif +} + void hasTwoParams(int, int); void MaybeThrows(); void DoesntThrow() noexcept; diff --git a/googlemock/test/gmock-matchers-misc_test.cc b/googlemock/test/gmock-matchers-misc_test.cc index 53f4962b9..42a0e44d7 100644 --- a/googlemock/test/gmock-matchers-misc_test.cc +++ b/googlemock/test/gmock-matchers-misc_test.cc @@ -1615,6 +1615,20 @@ TEST(MatcherPMacroTest, WorksOnMoveOnlyType) { EXPECT_THAT(p, Not(UniquePointee(2))); } +MATCHER(EnsureNoUnusedButMarkedUnusedWarning, "") { return (arg % 2) == 0; } + +TEST(MockMethodMockFunctionTest, EnsureNoUnusedButMarkedUnusedWarning) { +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic error "-Wused-but-marked-unused" +#endif + // https://github.com/google/googletest/issues/4055 + EXPECT_THAT(0, EnsureNoUnusedButMarkedUnusedWarning()); +#ifdef __clang__ +#pragma clang diagnostic pop +#endif +} + #if GTEST_HAS_EXCEPTIONS // std::function is used below for compatibility with older copies of From 1f643f71d4151c3b364c0e9302042f7a6debd439 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 30 Nov 2022 14:41:44 -0800 Subject: [PATCH 052/336] Make SizeIsMatcher::Impl conform to the contract of MatcherDescriberInterface. MatcherDescriberInterface specifies that DescribeTo "should print a verb phrase", but "size ..." is not a verb phrase. Currently, ElementsAre(SizeIs(9)) is described as "has 1 element that size is equal to 9". With this change, it will be described as "has 1 element that has a size that is equal to 9". PiperOrigin-RevId: 492022324 Change-Id: I4083335f2419462464957521c1e033643b53b763 --- googlemock/include/gmock/gmock-matchers.h | 4 ++-- googlemock/test/gmock-matchers-containers_test.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index 9ade92733..901c109c0 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -2309,11 +2309,11 @@ class SizeIsMatcher { : size_matcher_(MatcherCast(size_matcher)) {} void DescribeTo(::std::ostream* os) const override { - *os << "size "; + *os << "has a size that "; size_matcher_.DescribeTo(os); } void DescribeNegationTo(::std::ostream* os) const override { - *os << "size "; + *os << "has a size that "; size_matcher_.DescribeNegationTo(os); } diff --git a/googlemock/test/gmock-matchers-containers_test.cc b/googlemock/test/gmock-matchers-containers_test.cc index f50159f80..98787f25e 100644 --- a/googlemock/test/gmock-matchers-containers_test.cc +++ b/googlemock/test/gmock-matchers-containers_test.cc @@ -1182,8 +1182,8 @@ TEST(SizeIsTest, WorksWithMinimalistCustomType) { TEST(SizeIsTest, CanDescribeSelf) { Matcher> m = SizeIs(2); - EXPECT_EQ("size is equal to 2", Describe(m)); - EXPECT_EQ("size isn't equal to 2", DescribeNegation(m)); + EXPECT_EQ("has a size that is equal to 2", Describe(m)); + EXPECT_EQ("has a size that isn't equal to 2", DescribeNegation(m)); } TEST(SizeIsTest, ExplainsResult) { From 97459e54ec4f1882d219c413c929f719d9741ada Mon Sep 17 00:00:00 2001 From: Derek Mauro Date: Mon, 5 Dec 2022 17:38:46 -0800 Subject: [PATCH 053/336] Remove the unused class TestNameIs Fixes #4076 PiperOrigin-RevId: 493158910 Change-Id: Id66c0443a6f5f4d167ae39ac79766b32cf95a383 --- googletest/src/gtest.cc | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index d01cbd586..281d93315 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -2784,37 +2784,6 @@ void ReportInvalidTestSuiteType(const char* test_suite_name, code_location.line) << " " << errors.GetString(); } -} // namespace internal - -namespace { - -// A predicate that checks the test name of a TestInfo against a known -// value. -// -// This is used for implementation of the TestSuite class only. We put -// it in the anonymous namespace to prevent polluting the outer -// namespace. -// -// TestNameIs is copyable. -class TestNameIs { - public: - // Constructor. - // - // TestNameIs has NO default constructor. - explicit TestNameIs(const char* name) : name_(name) {} - - // Returns true if and only if the test name of test_info matches name_. - bool operator()(const TestInfo* test_info) const { - return test_info && test_info->name() == name_; - } - - private: - std::string name_; -}; - -} // namespace - -namespace internal { // This method expands all parameterized tests registered with macros TEST_P // and INSTANTIATE_TEST_SUITE_P into regular tests and registers those. From d454936a0c0ee999a3512d2494f06f888532fc45 Mon Sep 17 00:00:00 2001 From: Derek Mauro Date: Wed, 7 Dec 2022 09:55:11 -0800 Subject: [PATCH 054/336] Migrate GoogleTest to a bug report template and add a link to the discussion forum for non-bugs PiperOrigin-RevId: 493632811 Change-Id: I7e02c3c479c2a925b7971f6a55e1e95a5a6f2d0a --- .github/ISSUE_TEMPLATE/00-bug_report.md | 43 ------------------- .github/ISSUE_TEMPLATE/00-bug_report.yml | 53 ++++++++++++++++++++++++ .github/ISSUE_TEMPLATE/config.yml | 4 ++ 3 files changed, 57 insertions(+), 43 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/00-bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/00-bug_report.yml diff --git a/.github/ISSUE_TEMPLATE/00-bug_report.md b/.github/ISSUE_TEMPLATE/00-bug_report.md deleted file mode 100644 index 0f7e8b532..000000000 --- a/.github/ISSUE_TEMPLATE/00-bug_report.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: 'bug' -assignees: '' ---- - -**Describe the bug** - -Include a clear and concise description of what the problem is, including what -you expected to happen, and what actually happened. - -**Steps to reproduce the bug** - -It's important that we are able to reproduce the problem that you are -experiencing. Please provide all code and relevant steps to reproduce the -problem, including your `BUILD`/`CMakeLists.txt` file and build commands. Links -to a GitHub branch or [godbolt.org](https://godbolt.org/) that demonstrate the -problem are also helpful. - -**Does the bug persist in the most recent commit?** - -We recommend using the latest commit in the master branch in your projects. - -**What operating system and version are you using?** - -If you are using a Linux distribution please include the name and version of the -distribution as well. - -**What compiler and version are you using?** - -Please include the output of `gcc -v` or `clang -v`, or the equivalent for your -compiler. - -**What build system are you using?** - -Please include the output of `bazel --version` or `cmake --version`, or the -equivalent for your build system. - -**Additional context** - -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/00-bug_report.yml b/.github/ISSUE_TEMPLATE/00-bug_report.yml new file mode 100644 index 000000000..586779ad2 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/00-bug_report.yml @@ -0,0 +1,53 @@ +name: Bug Report +description: Let us know that something does not work as expected. +title: "[Bug]: Please title this bug report" +body: + - type: textarea + id: what-happened + attributes: + label: Describe the issue + description: What happened, and what did you expect to happen? + validations: + required: true + - type: textarea + id: steps + attributes: + label: Steps to reproduce the problem + description: It is important that we are able to reproduce the problem that you are experiencing. Please provide all code and relevant steps to reproduce the problem, including your `BUILD`/`CMakeLists.txt` file and build commands. Links to a GitHub branch or [godbolt.org](https://godbolt.org/) that demonstrate the problem are also helpful. + validations: + required: true + - type: textarea + id: version + attributes: + label: What version of GoogleTest are you using? + description: Please include the output of `git rev-parse HEAD` or the GoogleTest release version number that you are using. + validations: + required: true + - type: textarea + id: os + attributes: + label: What operating system and version are you using? + description: If you are using a Linux distribution please include the name and version of the distribution as well. + validations: + required: true + - type: textarea + id: compiler + attributes: + label: What compiler and version are you using? + description: Please include the output of `gcc -v` or `clang -v`, or the equivalent for your compiler. + validations: + required: true + - type: textarea + id: buildsystem + attributes: + label: What build system are you using? + description: Please include the output of `bazel --version` or `cmake --version`, or the equivalent for your build system. + validations: + required: true + - type: textarea + id: additional + attributes: + label: Additional context + description: Add any other context about the problem here. + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 3ba13e0ce..65170d10a 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1 +1,5 @@ blank_issues_enabled: false +contact_links: + - name: Get Help + url: https://github.com/google/googletest/discussions + about: Please ask and answer questions here. From 516940f16d6b35d9c90b20eceb6d1f511407845e Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 8 Dec 2022 09:33:22 -0800 Subject: [PATCH 055/336] Fall back to the system clock when building with newlib on a system without a monotonic clock. PiperOrigin-RevId: 493917905 Change-Id: I20137cfcda3671ffc8edcda2b6554aa392e3a00a --- googletest/src/gtest.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 281d93315..51de00e8e 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -1123,17 +1123,24 @@ std::string UnitTestImpl::CurrentOsStackTraceExceptTop(int skip_count) { // A helper class for measuring elapsed times. class Timer { public: - Timer() : start_(std::chrono::steady_clock::now()) {} + Timer() : start_(clock::now()) {} // Return time elapsed in milliseconds since the timer was created. TimeInMillis Elapsed() { return std::chrono::duration_cast( - std::chrono::steady_clock::now() - start_) + clock::now() - start_) .count(); } private: - std::chrono::steady_clock::time_point start_; + // Fall back to the system_clock when building with newlib on a system + // without a monotonic clock. +#if defined(_NEWLIB_VERSION) && !defined(CLOCK_MONOTONIC) + using clock = std::chrono::system_clock; +#else + using clock = std::chrono::steady_clock; +#endif + clock::time_point start_; }; // Returns a timestamp as milliseconds since the epoch. Note this time may jump From b0846aaf37a271d56019b42121ebcea0ac42e8c1 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Mon, 12 Dec 2022 09:33:33 -0800 Subject: [PATCH 056/336] Introduces a new porting flag (GTEST_HAS_FILE_SYSTEM) to indicate whether a platform supports filesystem operations. PiperOrigin-RevId: 494751986 Change-Id: I07f73bdf478a73934b8f1a69c1ab4abda1b231ae --- .../include/gtest/internal/gtest-filepath.h | 5 + .../include/gtest/internal/gtest-port.h | 103 +++++++++++------- googletest/src/gtest-filepath.cc | 4 + googletest/src/gtest-internal-inl.h | 4 + googletest/src/gtest.cc | 41 ++++++- 5 files changed, 116 insertions(+), 41 deletions(-) diff --git a/googletest/include/gtest/internal/gtest-filepath.h b/googletest/include/gtest/internal/gtest-filepath.h index dd7a3a49a..ceba8f200 100644 --- a/googletest/include/gtest/internal/gtest-filepath.h +++ b/googletest/include/gtest/internal/gtest-filepath.h @@ -42,11 +42,14 @@ #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_ #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_ +#include "gtest/internal/gtest-port.h" #include "gtest/internal/gtest-string.h" GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ /* class A needs to have dll-interface to be used by clients of class B */) +#if GTEST_HAS_FILE_SYSTEM + namespace testing { namespace internal { @@ -217,4 +220,6 @@ class GTEST_API_ FilePath { GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 +#endif // GTEST_HAS_FILE_SYSTEM + #endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_ diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index c3b131f50..01bfd1f13 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -83,6 +83,8 @@ // GTEST_HAS_STD_WSTRING - Define it to 1/0 to indicate that // std::wstring does/doesn't work (Google Test can // be used where std::wstring is unavailable). +// GTEST_HAS_FILE_SYSTEM - Define it to 1/0 to indicate whether or not a +// file system is/isn't available. // GTEST_HAS_SEH - Define it to 1/0 to indicate whether the // compiler supports Microsoft's "Structured // Exception Handling". @@ -463,6 +465,11 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #endif // GTEST_HAS_STD_WSTRING +#ifndef GTEST_HAS_FILE_SYSTEM +// Most platforms support a file system. +#define GTEST_HAS_FILE_SYSTEM 1 +#endif // GTEST_HAS_FILE_SYSTEM + // Determines whether RTTI is available. #ifndef GTEST_HAS_RTTI // The user didn't tell us whether RTTI is enabled, so we need to @@ -580,10 +587,11 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // output correctness and to implement death tests. #ifndef GTEST_HAS_STREAM_REDIRECTION // By default, we assume that stream redirection is supported on all -// platforms except known mobile / embedded ones. +// platforms except known mobile / embedded ones. Also, if the port doesn't have +// a file system, stream redirection is not supported. #if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || \ GTEST_OS_WINDOWS_RT || GTEST_OS_ESP8266 || GTEST_OS_XTENSA || \ - GTEST_OS_QURT + GTEST_OS_QURT || !GTEST_HAS_FILE_SYSTEM #define GTEST_HAS_STREAM_REDIRECTION 0 #else #define GTEST_HAS_STREAM_REDIRECTION 1 @@ -599,7 +607,10 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; GTEST_OS_FREEBSD || GTEST_OS_NETBSD || GTEST_OS_FUCHSIA || \ GTEST_OS_DRAGONFLY || GTEST_OS_GNU_KFREEBSD || GTEST_OS_HAIKU || \ GTEST_OS_GNU_HURD) +// Death tests require a file system to work properly. +#if GTEST_HAS_FILE_SYSTEM #define GTEST_HAS_DEATH_TEST 1 +#endif // GTEST_HAS_FILE_SYSTEM #endif // Determines whether to support type-driven tests. @@ -1953,12 +1964,55 @@ inline std::string StripTrailingSpaces(std::string str) { namespace posix { -// Functions with a different name on Windows. - +// File system porting. +#if GTEST_HAS_FILE_SYSTEM #if GTEST_OS_WINDOWS typedef struct _stat StatStruct; +#if GTEST_OS_WINDOWS_MOBILE +inline int FileNo(FILE* file) { return reinterpret_cast(_fileno(file)); } +// Stat(), RmDir(), and IsDir() are not needed on Windows CE at this +// time and thus not defined there. +#else +inline int FileNo(FILE* file) { return _fileno(file); } +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 // GTEST_OS_WINDOWS_MOBILE + +#elif GTEST_OS_ESP8266 +typedef struct stat StatStruct; + +inline int FileNo(FILE* file) { return fileno(file); } +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); } + +#else + +typedef struct stat StatStruct; + +inline int FileNo(FILE* file) { return fileno(file); } +inline int Stat(const char* path, StatStruct* buf) { return stat(path, buf); } +#if GTEST_OS_QURT +// QuRT doesn't support any directory functions, including rmdir +inline int RmDir(const char*) { return 0; } +#else +inline int RmDir(const char* dir) { return rmdir(dir); } +#endif +inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); } + +#endif // GTEST_OS_WINDOWS +#endif // GTEST_HAS_FILE_SYSTEM + +// Other functions with a different name on Windows. + +#if GTEST_OS_WINDOWS + #ifdef __BORLANDC__ inline int DoIsATTY(int fd) { return isatty(fd); } inline int StrCaseCmp(const char* s1, const char* s2) { @@ -1978,51 +2032,21 @@ inline int StrCaseCmp(const char* s1, const char* s2) { inline char* StrDup(const char* src) { return _strdup(src); } #endif // __BORLANDC__ -#if GTEST_OS_WINDOWS_MOBILE -inline int FileNo(FILE* file) { return reinterpret_cast(_fileno(file)); } -// Stat(), RmDir(), and IsDir() are not needed on Windows CE at this -// time and thus not defined there. -#else -inline int FileNo(FILE* file) { return _fileno(file); } -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 // GTEST_OS_WINDOWS_MOBILE - #elif GTEST_OS_ESP8266 -typedef struct stat StatStruct; -inline int FileNo(FILE* file) { return fileno(file); } inline int DoIsATTY(int fd) { return isatty(fd); } -inline int Stat(const char* path, StatStruct* buf) { - // stat function not implemented on ESP8266 - return 0; -} inline int StrCaseCmp(const char* s1, const char* s2) { return strcasecmp(s1, s2); } inline char* StrDup(const char* src) { return strdup(src); } -inline int RmDir(const char* dir) { return rmdir(dir); } -inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); } #else -typedef struct stat StatStruct; - -inline int FileNo(FILE* file) { return fileno(file); } inline int DoIsATTY(int fd) { return isatty(fd); } -inline int Stat(const char* path, StatStruct* buf) { return stat(path, buf); } inline int StrCaseCmp(const char* s1, const char* s2) { return strcasecmp(s1, s2); } inline char* StrDup(const char* src) { return strdup(src); } -#if GTEST_OS_QURT -// QuRT doesn't support any directory functions, including rmdir -inline int RmDir(const char*) { return 0; } -#else -inline int RmDir(const char* dir) { return rmdir(dir); } -#endif -inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); } #endif // GTEST_OS_WINDOWS @@ -2044,7 +2068,7 @@ GTEST_DISABLE_MSC_DEPRECATED_PUSH_() // ChDir(), FReopen(), FDOpen(), Read(), Write(), Close(), and // StrError() aren't needed on Windows CE at this time and thus not // defined there. - +#if GTEST_HAS_FILE_SYSTEM #if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && \ !GTEST_OS_WINDOWS_RT && !GTEST_OS_ESP8266 && !GTEST_OS_XTENSA && \ !GTEST_OS_QURT @@ -2066,7 +2090,7 @@ inline FILE* FReopen(const char* path, const char* mode, FILE* stream) { return freopen(path, mode, stream); } inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); } -#endif +#endif // !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT inline int FClose(FILE* fp) { return fclose(fp); } #if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT inline int Read(int fd, void* buf, unsigned int count) { @@ -2076,8 +2100,13 @@ inline int Write(int fd, const void* buf, unsigned int count) { return static_cast(write(fd, buf, count)); } inline int Close(int fd) { return close(fd); } +#endif // !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT +#endif // GTEST_HAS_FILE_SYSTEM + +#if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT inline const char* StrError(int errnum) { return strerror(errnum); } -#endif +#endif // !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT + inline const char* GetEnv(const char* name) { #if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || \ GTEST_OS_WINDOWS_RT || GTEST_OS_ESP8266 || GTEST_OS_XTENSA || \ diff --git a/googletest/src/gtest-filepath.cc b/googletest/src/gtest-filepath.cc index bec587009..9d79ea49d 100644 --- a/googletest/src/gtest-filepath.cc +++ b/googletest/src/gtest-filepath.cc @@ -57,6 +57,8 @@ #define GTEST_PATH_MAX_ _POSIX_PATH_MAX #endif // GTEST_OS_WINDOWS +#if GTEST_HAS_FILE_SYSTEM + namespace testing { namespace internal { @@ -404,3 +406,5 @@ void FilePath::Normalize() { } // namespace internal } // namespace testing + +#endif // GTEST_HAS_FILE_SYSTEM diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h index 517cc13a3..ddef4bbdb 100644 --- a/googletest/src/gtest-internal-inl.h +++ b/googletest/src/gtest-internal-inl.h @@ -396,9 +396,11 @@ class GTEST_API_ UnitTestOptions { static bool MatchesFilter(const std::string& name, const char* filter); }; +#if GTEST_HAS_FILE_SYSTEM // Returns the current application's name, removing directory path if that // is present. Used by UnitTestOptions::GetOutputFile. GTEST_API_ FilePath GetCurrentExecutableName(); +#endif // GTEST_HAS_FILE_SYSTEM // The role interface for getting the OS stack trace as a string. class OsStackTraceGetterInterface { @@ -840,9 +842,11 @@ class GTEST_API_ UnitTestImpl { // The UnitTest object that owns this implementation object. UnitTest* const parent_; +#if GTEST_HAS_FILE_SYSTEM // The working directory when the first TEST() or TEST_F() was // executed. internal::FilePath original_working_dir_; +#endif // GTEST_HAS_FILE_SYSTEM // The default test part result reporters. DefaultGlobalTestPartResultReporter default_global_test_part_result_reporter_; diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 51de00e8e..0803cf32d 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -58,6 +58,7 @@ #include "gtest/gtest-assertion-result.h" #include "gtest/gtest-spi.h" #include "gtest/internal/custom/gtest.h" +#include "gtest/internal/gtest-port.h" #if GTEST_OS_LINUX @@ -194,6 +195,7 @@ const char kStackTraceMarker[] = "\nStack trace:\n"; // is specified on the command line. bool g_help_flag = false; +#if GTEST_HAS_FILE_SYSTEM // Utility function to Open File for Writing static FILE* OpenFileForWriting(const std::string& output_file) { FILE* fileout = nullptr; @@ -208,6 +210,7 @@ static FILE* OpenFileForWriting(const std::string& output_file) { } return fileout; } +#endif // GTEST_HAS_FILE_SYSTEM } // namespace internal @@ -620,6 +623,7 @@ static ::std::vector g_argvs; #endif // defined(GTEST_CUSTOM_GET_ARGVS_) } +#if GTEST_HAS_FILE_SYSTEM // Returns the current application's name, removing directory path if that // is present. FilePath GetCurrentExecutableName() { @@ -633,6 +637,7 @@ FilePath GetCurrentExecutableName() { return result.RemoveDirectoryName(); } +#endif // GTEST_HAS_FILE_SYSTEM // Functions for processing the gtest_output flag. @@ -647,6 +652,7 @@ std::string UnitTestOptions::GetOutputFormat() { static_cast(colon - gtest_output_flag)); } +#if GTEST_HAS_FILE_SYSTEM // Returns the name of the requested output file, or the default if none // was explicitly specified. std::string UnitTestOptions::GetAbsolutePathToOutputFile() { @@ -677,6 +683,7 @@ std::string UnitTestOptions::GetAbsolutePathToOutputFile() { GetOutputFormat().c_str())); return result.string(); } +#endif // GTEST_HAS_FILE_SYSTEM // Returns true if and only if the wildcard pattern matches the string. Each // pattern consists of regular characters, single-character wildcards (?), and @@ -3262,7 +3269,12 @@ static void ColoredPrintf(GTestColor color, const char* fmt, ...) { va_start(args, fmt); static const bool in_color_mode = +#if GTEST_HAS_FILE_SYSTEM ShouldUseColor(posix::IsATTY(posix::FileNo(stdout)) != 0); +#else + false; +#endif // GTEST_HAS_FILE_SYSTEM + const bool use_color = in_color_mode && (color != GTestColor::kDefault); if (!use_color) { @@ -3867,6 +3879,7 @@ void TestEventRepeater::OnTestIterationEnd(const UnitTest& unit_test, // End TestEventRepeater +#if GTEST_HAS_FILE_SYSTEM // This class generates an XML output file. class XmlUnitTestResultPrinter : public EmptyTestEventListener { public: @@ -4414,7 +4427,9 @@ void XmlUnitTestResultPrinter::OutputXmlTestProperties( } // End XmlUnitTestResultPrinter +#endif // GTEST_HAS_FILE_SYSTEM +#if GTEST_HAS_FILE_SYSTEM // This class generates an JSON output file. class JsonUnitTestResultPrinter : public EmptyTestEventListener { public: @@ -4855,6 +4870,7 @@ std::string JsonUnitTestResultPrinter::TestPropertiesAsJson( } // End JsonUnitTestResultPrinter +#endif // GTEST_HAS_FILE_SYSTEM #if GTEST_CAN_STREAM_RESULTS_ @@ -4993,6 +5009,7 @@ void OsStackTraceGetter::UponLeavingGTest() GTEST_LOCK_EXCLUDED_(mutex_) { #endif // GTEST_HAS_ABSL } +#if GTEST_HAS_DEATH_TEST // A helper class that creates the premature-exit file in its // constructor and deletes the file in its destructor. class ScopedPrematureExitFile { @@ -5030,6 +5047,7 @@ class ScopedPrematureExitFile { ScopedPrematureExitFile(const ScopedPrematureExitFile&) = delete; ScopedPrematureExitFile& operator=(const ScopedPrematureExitFile&) = delete; }; +#endif // GTEST_HAS_DEATH_TEST } // namespace internal @@ -5355,6 +5373,7 @@ void UnitTest::RecordProperty(const std::string& key, // We don't protect this under mutex_, as we only support calling it // from the main thread. int UnitTest::Run() { +#if GTEST_HAS_DEATH_TEST const bool in_death_test_child_process = GTEST_FLAG_GET(internal_run_death_test).length() > 0; @@ -5383,6 +5402,7 @@ int UnitTest::Run() { in_death_test_child_process ? nullptr : internal::posix::GetEnv("TEST_PREMATURE_EXIT_FILE")); +#endif // GTEST_HAS_DEATH_TEST // Captures the value of GTEST_FLAG(catch_exceptions). This value will be // used for the duration of the program. @@ -5438,11 +5458,13 @@ int UnitTest::Run() { : 1; } +#if GTEST_HAS_FILE_SYSTEM // Returns the working directory when the first TEST() or TEST_F() was // executed. const char* UnitTest::original_working_dir() const { return impl_->original_working_dir_.c_str(); } +#endif // GTEST_HAS_FILE_SYSTEM // Returns the TestSuite object for the test that's currently running, // or NULL if no test is running. @@ -5575,6 +5597,7 @@ void UnitTestImpl::SuppressTestEventsIfInSubprocess() { // UnitTestOptions. Must not be called before InitGoogleTest. void UnitTestImpl::ConfigureXmlOutput() { const std::string& output_format = UnitTestOptions::GetOutputFormat(); +#if GTEST_HAS_FILE_SYSTEM if (output_format == "xml") { listeners()->SetDefaultXmlGenerator(new XmlUnitTestResultPrinter( UnitTestOptions::GetAbsolutePathToOutputFile().c_str())); @@ -5585,6 +5608,10 @@ void UnitTestImpl::ConfigureXmlOutput() { GTEST_LOG_(WARNING) << "WARNING: unrecognized output format \"" << output_format << "\" ignored."; } +#else + GTEST_LOG_(ERROR) << "ERROR: alternative output formats require " + << "GTEST_HAS_FILE_SYSTEM to be enabled"; +#endif // GTEST_HAS_FILE_SYSTEM } #if GTEST_CAN_STREAM_RESULTS_ @@ -5747,10 +5774,12 @@ bool UnitTestImpl::RunAllTests() { // user didn't call InitGoogleTest. PostFlagParsingInit(); +#if GTEST_HAS_FILE_SYSTEM // Even if sharding is not on, test runners may want to use the // GTEST_SHARD_STATUS_FILE to query whether the test supports the sharding // protocol. internal::WriteToShardStatusFileIfNeeded(); +#endif // GTEST_HAS_FILE_SYSTEM // True if and only if we are in a subprocess for running a thread-safe-style // death test. @@ -5930,6 +5959,7 @@ bool UnitTestImpl::RunAllTests() { return !failed; } +#if GTEST_HAS_FILE_SYSTEM // Reads the GTEST_SHARD_STATUS_FILE environment variable, and creates the file // if the variable is present. If a file already exists at this location, this // function will write over it. If the variable is present, but the file cannot @@ -5949,6 +5979,7 @@ void WriteToShardStatusFileIfNeeded() { fclose(file); } } +#endif // GTEST_HAS_FILE_SYSTEM // Checks whether sharding is enabled by examining the relevant // environment variable values. If the variables are present, @@ -6140,6 +6171,7 @@ void UnitTestImpl::ListTestsMatchingFilter() { } } fflush(stdout); + #if GTEST_HAS_FILE_SYSTEM const std::string& output_format = UnitTestOptions::GetOutputFormat(); if (output_format == "xml" || output_format == "json") { FILE* fileout = OpenFileForWriting( @@ -6157,6 +6189,7 @@ void UnitTestImpl::ListTestsMatchingFilter() { fprintf(fileout, "%s", StringStreamToString(&stream).c_str()); fclose(fileout); } +#endif // GTEST_HAS_FILE_SYSTEM } // Sets the OS stack trace getter. @@ -6545,7 +6578,7 @@ static bool ParseGoogleTestFlag(const char* const arg) { return false; } -#if GTEST_USE_OWN_FLAGFILE_FLAG_ +#if GTEST_USE_OWN_FLAGFILE_FLAG_ && GTEST_HAS_FILE_SYSTEM static void LoadFlagsFromFile(const std::string& path) { FILE* flagfile = posix::FOpen(path.c_str(), "r"); if (!flagfile) { @@ -6561,7 +6594,7 @@ static void LoadFlagsFromFile(const std::string& path) { if (!ParseGoogleTestFlag(lines[i].c_str())) g_help_flag = true; } } -#endif // GTEST_USE_OWN_FLAGFILE_FLAG_ +#endif // GTEST_USE_OWN_FLAGFILE_FLAG_ && GTEST_HAS_FILE_SYSTEM // Parses the command line for Google Test flags, without initializing // other parts of Google Test. The type parameter CharType can be @@ -6578,12 +6611,12 @@ void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) { bool remove_flag = false; if (ParseGoogleTestFlag(arg)) { remove_flag = true; -#if GTEST_USE_OWN_FLAGFILE_FLAG_ +#if GTEST_USE_OWN_FLAGFILE_FLAG_ && GTEST_HAS_FILE_SYSTEM } else if (ParseFlag(arg, "flagfile", &flagfile_value)) { GTEST_FLAG_SET(flagfile, flagfile_value); LoadFlagsFromFile(flagfile_value); remove_flag = true; -#endif // GTEST_USE_OWN_FLAGFILE_FLAG_ +#endif // GTEST_USE_OWN_FLAGFILE_FLAG_ && GTEST_HAS_FILE_SYSTEM } else if (arg_string == "--help" || HasGoogleTestFlagPrefix(arg)) { // Both help flag and unrecognized Google Test flags (excluding // internal ones) trigger help display. From ad54e90f57199b91ac40e1344eb0c75e8670b21b Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Mon, 12 Dec 2022 11:51:21 -0800 Subject: [PATCH 057/336] Refactor matrix verification into VerifyMatchMatrix. PiperOrigin-RevId: 494786543 Change-Id: I7769558dd2ca046d8957bf352dc04cfb48ff7c3a --- googlemock/include/gmock/gmock-matchers.h | 17 ----------------- googlemock/src/gmock-matchers.cc | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index 901c109c0..26fe8d2ea 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -3644,23 +3644,6 @@ class UnorderedElementsAreMatcherImpl AnalyzeElements(stl_container.begin(), stl_container.end(), &element_printouts, listener); - if (matrix.LhsSize() == 0 && matrix.RhsSize() == 0) { - return true; - } - - if (match_flags() == UnorderedMatcherRequire::ExactMatch) { - if (matrix.LhsSize() != matrix.RhsSize()) { - // The element count doesn't match. If the container is empty, - // there's no need to explain anything as Google Mock already - // prints the empty container. Otherwise we just need to show - // how many elements there actually are. - if (matrix.LhsSize() != 0 && listener->IsInterested()) { - *listener << "which has " << Elements(matrix.LhsSize()); - } - return false; - } - } - return VerifyMatchMatrix(element_printouts, matrix, listener) && FindPairing(matrix, listener); } diff --git a/googlemock/src/gmock-matchers.cc b/googlemock/src/gmock-matchers.cc index a8d04a6da..5810b6aa3 100644 --- a/googlemock/src/gmock-matchers.cc +++ b/googlemock/src/gmock-matchers.cc @@ -370,6 +370,23 @@ void UnorderedElementsAreMatcherImplBase::DescribeNegationToImpl( bool UnorderedElementsAreMatcherImplBase::VerifyMatchMatrix( const ::std::vector& element_printouts, const MatchMatrix& matrix, MatchResultListener* listener) const { + if (matrix.LhsSize() == 0 && matrix.RhsSize() == 0) { + return true; + } + + if (match_flags() == UnorderedMatcherRequire::ExactMatch) { + if (matrix.LhsSize() != matrix.RhsSize()) { + // The element count doesn't match. If the container is empty, + // there's no need to explain anything as Google Mock already + // prints the empty container. Otherwise we just need to show + // how many elements there actually are. + if (matrix.LhsSize() != 0 && listener->IsInterested()) { + *listener << "which has " << Elements(matrix.LhsSize()); + } + return false; + } + } + bool result = true; ::std::vector element_matched(matrix.LhsSize(), 0); ::std::vector matcher_matched(matrix.RhsSize(), 0); From e38ef3be887afc0089005e394c5001002e313960 Mon Sep 17 00:00:00 2001 From: Derek Mauro Date: Mon, 12 Dec 2022 13:54:59 -0800 Subject: [PATCH 058/336] Convert feature requests to a form PiperOrigin-RevId: 494820396 Change-Id: I1aa0a5a0f4796fde8d0424093370fd89ebd2592e --- .github/ISSUE_TEMPLATE/10-feature_request.md | 24 -------------- .github/ISSUE_TEMPLATE/10-feature_request.yml | 33 +++++++++++++++++++ 2 files changed, 33 insertions(+), 24 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/10-feature_request.md create mode 100644 .github/ISSUE_TEMPLATE/10-feature_request.yml diff --git a/.github/ISSUE_TEMPLATE/10-feature_request.md b/.github/ISSUE_TEMPLATE/10-feature_request.md deleted file mode 100644 index 70a3a2099..000000000 --- a/.github/ISSUE_TEMPLATE/10-feature_request.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -name: Feature request -about: Propose a new feature -title: '' -labels: 'enhancement' -assignees: '' ---- - -**Does the feature exist in the most recent commit?** - -We recommend using the latest commit from GitHub in your projects. - -**Why do we need this feature?** - -Ideally, explain why a combination of existing features cannot be used instead. - -**Describe the proposal** - -Include a detailed description of the feature, with usage examples. - -**Is the feature specific to an operating system, compiler, or build system version?** - -If it is, please specify which versions. - diff --git a/.github/ISSUE_TEMPLATE/10-feature_request.yml b/.github/ISSUE_TEMPLATE/10-feature_request.yml new file mode 100644 index 000000000..91ad04177 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/10-feature_request.yml @@ -0,0 +1,33 @@ +name: Feature request +description: Propose a new feature. +title: "[FR]: Please title this feature request" +labels: "enhancement" +body: + - type: textarea + id: version + attributes: + label: Does the feature exist in the most recent commit? + description: We recommend using the latest commit from GitHub in your projects. + validations: + required: true + - 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 + id: proposal + attributes: + label: Describe the proposal. + description: Include a detailed description of the feature, with usage examples. + validations: + required: true + - type: textarea + id: platform + attributes: + label: Is the feature specific to an operating system, compiler, or build system version? + description: If it is, please specify which versions. + validations: + required: true From 41fe6be7d738237d1ca53070bd6ddebb73190b58 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 14 Dec 2022 15:05:05 -0800 Subject: [PATCH 059/336] Fix a typo in the gMock sample code for Defining a Custom Matcher Class. EXPECT_CALL doesn't seem to make much sense here. I think the intent was to use EXPECT_THAT instead. PiperOrigin-RevId: 495427663 Change-Id: I39a16ea37282729d34017c6bcd331a60cedf1fbe --- docs/gmock_cook_book.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/gmock_cook_book.md b/docs/gmock_cook_book.md index 59aa9fc3d..6a795ec01 100644 --- a/docs/gmock_cook_book.md +++ b/docs/gmock_cook_book.md @@ -1345,7 +1345,7 @@ class BarPlusBazEqMatcher { ... Foo foo; - EXPECT_CALL(foo, BarPlusBazEq(5))...; + EXPECT_THAT(foo, BarPlusBazEq(5))...; ``` ### Matching Containers From 3fa7f983c69f780378b4d1ad44d36030ca951ba6 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Thu, 15 Dec 2022 11:50:08 -0800 Subject: [PATCH 060/336] Shut up a Clang warning. Clang warns on this pattern because it looks like the author might have meant to use the value of the first part of the comma operator, so it warns that it isn't being used. The cast here signals to Clang that this behavior is intentional. This was discovered while updating gmock in Android. Clang's -Wcomma warning is on by default with either -Wall or -Werror, so users of gmock with those on in combination with -Werror are unable to build without this fix. PiperOrigin-RevId: 495655990 Change-Id: Iaf27e2199669f5b6185a877738234e551b6b6556 --- googlemock/include/gmock/gmock-matchers.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index 26fe8d2ea..73be7c997 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -4098,7 +4098,12 @@ class ArgsMatcherImpl : public MatcherInterface { const char* sep = ""; // Workaround spurious C4189 on MSVC<=15.7 when k is empty. (void)sep; - const char* dummy[] = {"", (*os << sep << "#" << k, sep = ", ")...}; + // The static_cast to void is needed to silence Clang's -Wcomma warning. + // This pattern looks suspiciously like we may have mismatched parentheses + // and may have been trying to use the first operation of the comma operator + // as a member of the array, so Clang warns that we may have made a mistake. + const char* dummy[] = { + "", (static_cast(*os << sep << "#" << k), sep = ", ")...}; (void)dummy; *os << ") "; } From a4e0be898bc81cdbf96731336cb41ff03a6b1cc5 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Mon, 19 Dec 2022 08:27:30 -0800 Subject: [PATCH 061/336] Specify a name for a `Property` in a code example. It is good practice to specify a name for the `testing::Property` matcher's use in diagnostics, and we should do so in our examples. PiperOrigin-RevId: 496406309 Change-Id: Ibb4d1ba63771b5d6855442b91564027cda8ddaca --- docs/gmock_cook_book.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/gmock_cook_book.md b/docs/gmock_cook_book.md index 6a795ec01..7672457c1 100644 --- a/docs/gmock_cook_book.md +++ b/docs/gmock_cook_book.md @@ -904,7 +904,7 @@ using ::testing::Contains; using ::testing::Property; inline constexpr auto HasFoo = [](const auto& f) { - return Property(&MyClass::foo, Contains(f)); + return Property("foo", &MyClass::foo, Contains(f)); }; ... EXPECT_THAT(x, HasFoo("blah")); From b3bfebd796a5875360ee1c90237931e8e0bae9f5 Mon Sep 17 00:00:00 2001 From: Dino Radakovic Date: Tue, 20 Dec 2022 06:11:31 -0800 Subject: [PATCH 062/336] Comment that q0_ in primer should remain empty PiperOrigin-RevId: 496642643 Change-Id: I178efeda76cbf46e5f4bb91454c205b9a060a4ea --- docs/primer.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/primer.md b/docs/primer.md index aecc368b0..2ffbf53bc 100644 --- a/docs/primer.md +++ b/docs/primer.md @@ -274,6 +274,7 @@ First, define a fixture class. By convention, you should give it the name class QueueTest : public ::testing::Test { protected: void SetUp() override { + // q0_ remains empty q1_.Enqueue(1); q2_.Enqueue(2); q2_.Enqueue(3); From 5ab508a01f9eb089207ee87fd547d290da39d015 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Tue, 20 Dec 2022 09:25:53 -0800 Subject: [PATCH 063/336] Fix a typo in the documentation for "Using Predicates as Matchers". PiperOrigin-RevId: 496679950 Change-Id: I2842050902876231d49a142165bcbb88d737505d --- docs/gmock_cook_book.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/gmock_cook_book.md b/docs/gmock_cook_book.md index 7672457c1..fc7db35b8 100644 --- a/docs/gmock_cook_book.md +++ b/docs/gmock_cook_book.md @@ -1158,7 +1158,7 @@ int IsEven(int n) { return (n % 2) == 0 ? 1 : 0; } ``` Note that the predicate function / functor doesn't have to return `bool`. It -works as long as the return value can be used as the condition in in statement +works as long as the return value can be used as the condition in the statement `if (condition) ...`. ### Matching Arguments that Are Not Copyable From 71140c3ca7a87bb1b5b9c9f1500fea8858cce344 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Thu, 22 Dec 2022 09:30:51 -0800 Subject: [PATCH 064/336] Use a more recent commit of googletest that uses OS constraints from @platforms//os:* instead of from @build_tools//platforms:* See https://github.com/bazelbuild/bazel/issues/8622 Necessary to fix #4096 Also need the fix for #4098 PiperOrigin-RevId: 497182073 Change-Id: Ifd568b088d2f779755dd20264edfd5dad12ca9cc --- docs/quickstart-bazel.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/docs/quickstart-bazel.md b/docs/quickstart-bazel.md index 853139a9d..15c27a22e 100644 --- a/docs/quickstart-bazel.md +++ b/docs/quickstart-bazel.md @@ -19,9 +19,8 @@ compatible with GoogleTest. If you don't already have Bazel installed, see the [Bazel installation guide](https://bazel.build/install). -{: .callout .note} -Note: The terminal commands in this tutorial show a Unix shell prompt, but the -commands work on the Windows command line as well. +{: .callout .note} Note: The terminal commands in this tutorial show a Unix +shell prompt, but the commands work on the Windows command line as well. ## Set up a Bazel workspace @@ -51,16 +50,16 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "com_google_googletest", - urls = ["https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip"], - strip_prefix = "googletest-609281088cfefc76f9d0ce82e1ff6c30cc3591e5", + urls = ["https://github.com/google/googletest/archive/5ab508a01f9eb089207ee87fd547d290da39d015.zip"], + strip_prefix = "googletest-5ab508a01f9eb089207ee87fd547d290da39d015", ) ``` The above configuration declares a dependency on GoogleTest which is downloaded as a ZIP archive from GitHub. In the above example, -`609281088cfefc76f9d0ce82e1ff6c30cc3591e5` is the Git commit hash of the +`5ab508a01f9eb089207ee87fd547d290da39d015` is the Git commit hash of the GoogleTest version to use; we recommend updating the hash often to point to the -latest version. +latest version. Use a recent hash on the `main` branch. Now you're ready to build C++ code that uses GoogleTest. From ab669cad0eea4cbe59faf9a421ab01db30ebc13c Mon Sep 17 00:00:00 2001 From: Gonzalo Brito Gadeschi Date: Wed, 28 Dec 2022 06:00:31 -0800 Subject: [PATCH 065/336] Fix warnings with nvc++ as the compiler Closes #3849. --- googletest/include/gtest/internal/gtest-port.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 01bfd1f13..77549e849 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -794,7 +794,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // Ask the compiler not to perform tail call optimization inside // the marked function. #define GTEST_NO_TAIL_CALL_ __attribute__((disable_tail_calls)) -#elif __GNUC__ +#elif __GNUC__ && !defined(__NVCOMPILER) #define GTEST_NO_TAIL_CALL_ \ __attribute__((optimize("no-optimize-sibling-calls"))) #else From 3a99ab6d8326c845af0672a0cd64dd05ad7734fe Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 4 Jan 2023 06:40:19 -0800 Subject: [PATCH 066/336] Fix _MSC_VER check Use "#if defined(_MSC_VER)" instead of "#if _MSC_VER" to be consistent with other usages in the file and to work with the "-Wundef" warning. PiperOrigin-RevId: 499471290 Change-Id: I34a9442eecf266afd74d4332cab7d39766df4ed9 --- googletest/include/gtest/internal/gtest-port.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 01bfd1f13..d427f7120 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -2142,7 +2142,7 @@ GTEST_DISABLE_MSC_DEPRECATED_POP_() // MSVC-based platforms. We map the GTEST_SNPRINTF_ macro to the appropriate // function in order to achieve that. We use macro definition here because // snprintf is a variadic function. -#if _MSC_VER && !GTEST_OS_WINDOWS_MOBILE +#if defined(_MSC_VER) && !GTEST_OS_WINDOWS_MOBILE // MSVC 2005 and above support variadic macros. #define GTEST_SNPRINTF_(buffer, size, format, ...) \ _snprintf_s(buffer, size, size, format, __VA_ARGS__) From 64e0945546ec8c331af27ebffcca44a4006e9e35 Mon Sep 17 00:00:00 2001 From: SunBlack Date: Wed, 4 Jan 2023 17:24:07 +0100 Subject: [PATCH 067/336] Fix typos found by codespell --- googlemock/test/gmock-matchers-comparisons_test.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/googlemock/test/gmock-matchers-comparisons_test.cc b/googlemock/test/gmock-matchers-comparisons_test.cc index 0cf731ff0..83242d648 100644 --- a/googlemock/test/gmock-matchers-comparisons_test.cc +++ b/googlemock/test/gmock-matchers-comparisons_test.cc @@ -864,7 +864,7 @@ struct Type { }; TEST(TypedEqTest, HasSpecifiedType) { - // Verfies that the type of TypedEq(v) is Matcher. + // Verifies that the type of TypedEq(v) is Matcher. Type>::IsTypeOf(TypedEq(5)); Type>::IsTypeOf(TypedEq(5)); } @@ -1530,7 +1530,7 @@ TEST(PairTest, MatchesCorrectly) { EXPECT_THAT(p, Pair(25, "foo")); EXPECT_THAT(p, Pair(Ge(20), HasSubstr("o"))); - // 'first' doesnt' match, but 'second' matches. + // 'first' doesn't match, but 'second' matches. EXPECT_THAT(p, Not(Pair(42, "foo"))); EXPECT_THAT(p, Not(Pair(Lt(25), "foo"))); From 0296d7d37007ec54441cb9f8cd001da6ac58eea8 Mon Sep 17 00:00:00 2001 From: Derek Mauro Date: Wed, 4 Jan 2023 12:49:23 -0800 Subject: [PATCH 068/336] Workaround for GCC12 bug illustrated by https://godbolt.org/z/Pe5aE59xG Fixes #4108 PiperOrigin-RevId: 499556061 Change-Id: I1cb1564f9b77e1825fddc9236965f4a3b661d96a --- googletest/src/gtest.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 0803cf32d..08eaefbda 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -4888,7 +4888,8 @@ std::string StreamingListener::UrlEncode(const char* str) { case '=': case '&': case '\n': - result.append("%" + String::FormatByte(static_cast(ch))); + result.push_back('%'); + result.append(String::FormatByte(static_cast(ch))); break; default: result.push_back(ch); From e5e46b09a10cf0f575dbab2702b72f2460e31964 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 5 Jan 2023 08:43:19 -0800 Subject: [PATCH 069/336] IWYU: Add missing std includes PiperOrigin-RevId: 499893032 Change-Id: I33304802b7c82ae2d008f3ee89df38866e5f57ba --- googlemock/include/gmock/gmock-matchers.h | 1 + googlemock/include/gmock/gmock-spec-builders.h | 1 + googletest/include/gtest/gtest-message.h | 2 ++ googletest/include/gtest/gtest-printers.h | 1 + googletest/include/gtest/gtest-spi.h | 2 ++ googletest/include/gtest/gtest-test-part.h | 2 ++ googletest/include/gtest/gtest.h | 4 ++++ googletest/include/gtest/internal/gtest-death-test-internal.h | 1 + googletest/include/gtest/internal/gtest-filepath.h | 2 ++ googletest/include/gtest/internal/gtest-internal.h | 1 + googletest/include/gtest/internal/gtest-param-util.h | 3 +++ googletest/include/gtest/internal/gtest-port.h | 1 + googletest/include/gtest/internal/gtest-string.h | 1 + googletest/include/gtest/internal/gtest-type-util.h | 4 ++++ googletest/src/gtest-internal-inl.h | 1 + googletest/test/googletest-filepath-test.cc | 2 ++ googletest/test/googletest-message-test.cc | 3 +++ googletest/test/googletest-options-test.cc | 2 ++ googletest/test/googletest-port-test.cc | 1 + googletest/test/gtest-typed-test_test.cc | 1 + googletest/test/gtest_pred_impl_unittest.cc | 1 + googletest/test/gtest_unittest.cc | 1 + 22 files changed, 38 insertions(+) diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index 73be7c997..9e634f7f1 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -258,6 +258,7 @@ #include #include #include +#include #include #include #include diff --git a/googlemock/include/gmock/gmock-spec-builders.h b/googlemock/include/gmock/gmock-spec-builders.h index c1b725b3d..4e498d8f5 100644 --- a/googlemock/include/gmock/gmock-spec-builders.h +++ b/googlemock/include/gmock/gmock-spec-builders.h @@ -65,6 +65,7 @@ #include #include #include +#include #include #include #include diff --git a/googletest/include/gtest/gtest-message.h b/googletest/include/gtest/gtest-message.h index 6c8bf9000..4d4b152b1 100644 --- a/googletest/include/gtest/gtest-message.h +++ b/googletest/include/gtest/gtest-message.h @@ -50,7 +50,9 @@ #include #include +#include #include +#include #include "gtest/internal/gtest-port.h" diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h index eeaef04e0..0055e37ff 100644 --- a/googletest/include/gtest/gtest-printers.h +++ b/googletest/include/gtest/gtest-printers.h @@ -108,6 +108,7 @@ #include #include #include +#include #include #include diff --git a/googletest/include/gtest/gtest-spi.h b/googletest/include/gtest/gtest-spi.h index bec8c4810..c0613b695 100644 --- a/googletest/include/gtest/gtest-spi.h +++ b/googletest/include/gtest/gtest-spi.h @@ -33,6 +33,8 @@ #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_SPI_H_ #define GOOGLETEST_INCLUDE_GTEST_GTEST_SPI_H_ +#include + #include "gtest/gtest.h" GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ diff --git a/googletest/include/gtest/gtest-test-part.h b/googletest/include/gtest/gtest-test-part.h index 09cc8c34f..8290b4d65 100644 --- a/googletest/include/gtest/gtest-test-part.h +++ b/googletest/include/gtest/gtest-test-part.h @@ -35,6 +35,8 @@ #define GOOGLETEST_INCLUDE_GTEST_GTEST_TEST_PART_H_ #include +#include +#include #include #include "gtest/internal/gtest-internal.h" diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index fcad3ae25..3e452a503 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -51,9 +51,13 @@ #include #include +#include #include #include #include +#include +#include +#include #include #include diff --git a/googletest/include/gtest/internal/gtest-death-test-internal.h b/googletest/include/gtest/internal/gtest-death-test-internal.h index 347821708..4687dae2b 100644 --- a/googletest/include/gtest/internal/gtest-death-test-internal.h +++ b/googletest/include/gtest/internal/gtest-death-test-internal.h @@ -42,6 +42,7 @@ #include #include +#include #include "gtest/gtest-matchers.h" #include "gtest/internal/gtest-internal.h" diff --git a/googletest/include/gtest/internal/gtest-filepath.h b/googletest/include/gtest/internal/gtest-filepath.h index ceba8f200..5189c81da 100644 --- a/googletest/include/gtest/internal/gtest-filepath.h +++ b/googletest/include/gtest/internal/gtest-filepath.h @@ -42,6 +42,8 @@ #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_ #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_ +#include + #include "gtest/internal/gtest-port.h" #include "gtest/internal/gtest-string.h" diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h index e9c2441ac..3121d428b 100644 --- a/googletest/include/gtest/internal/gtest-internal.h +++ b/googletest/include/gtest/internal/gtest-internal.h @@ -64,6 +64,7 @@ #include #include #include +#include #include #include "gtest/gtest-message.h" diff --git a/googletest/include/gtest/internal/gtest-param-util.h b/googletest/include/gtest/internal/gtest-param-util.h index fb989e0ba..7092d10e6 100644 --- a/googletest/include/gtest/internal/gtest-param-util.h +++ b/googletest/include/gtest/internal/gtest-param-util.h @@ -40,8 +40,11 @@ #include #include +#include #include +#include #include +#include #include #include #include diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index d427f7120..5d81adb35 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -270,6 +270,7 @@ #include #include #include +#include #include // #include // Guarded by GTEST_IS_THREADSAFE below #include diff --git a/googletest/include/gtest/internal/gtest-string.h b/googletest/include/gtest/internal/gtest-string.h index cca2e1f2a..cc0dd7529 100644 --- a/googletest/include/gtest/internal/gtest-string.h +++ b/googletest/include/gtest/internal/gtest-string.h @@ -51,6 +51,7 @@ #include #include +#include #include #include "gtest/internal/gtest-port.h" diff --git a/googletest/include/gtest/internal/gtest-type-util.h b/googletest/include/gtest/internal/gtest-type-util.h index 6bc02a7de..17a470b62 100644 --- a/googletest/include/gtest/internal/gtest-type-util.h +++ b/googletest/include/gtest/internal/gtest-type-util.h @@ -37,6 +37,10 @@ #ifndef GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_ #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_ +#include +#include +#include + #include "gtest/internal/gtest-port.h" // #ifdef __GNUC__ is too general here. It is possible to use gcc without using diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h index ddef4bbdb..2c9db4f20 100644 --- a/googletest/src/gtest-internal-inl.h +++ b/googletest/src/gtest-internal-inl.h @@ -44,6 +44,7 @@ #include #include #include +#include #include #include diff --git a/googletest/test/googletest-filepath-test.cc b/googletest/test/googletest-filepath-test.cc index 1e2cc4aaf..5f0c9c2fb 100644 --- a/googletest/test/googletest-filepath-test.cc +++ b/googletest/test/googletest-filepath-test.cc @@ -35,6 +35,8 @@ // This file is #included from gtest-internal.h. // Do not #include this file anywhere else! +#include + #include "gtest/gtest.h" #include "gtest/internal/gtest-filepath.h" #include "src/gtest-internal-inl.h" diff --git a/googletest/test/googletest-message-test.cc b/googletest/test/googletest-message-test.cc index 252a86197..54e9d43c9 100644 --- a/googletest/test/googletest-message-test.cc +++ b/googletest/test/googletest-message-test.cc @@ -30,6 +30,9 @@ // // Tests for the Message class. +#include +#include + #include "gtest/gtest-message.h" #include "gtest/gtest.h" diff --git a/googletest/test/googletest-options-test.cc b/googletest/test/googletest-options-test.cc index 1265c2251..874632098 100644 --- a/googletest/test/googletest-options-test.cc +++ b/googletest/test/googletest-options-test.cc @@ -36,6 +36,8 @@ // make-files on Windows and other platforms. Do not #include this file // anywhere else! +#include + #include "gtest/gtest.h" #if GTEST_OS_WINDOWS_MOBILE diff --git a/googletest/test/googletest-port-test.cc b/googletest/test/googletest-port-test.cc index c20dfa4c4..bb536ac54 100644 --- a/googletest/test/googletest-port-test.cc +++ b/googletest/test/googletest-port-test.cc @@ -39,6 +39,7 @@ #include // NOLINT #include #include +#include #include // NOLINT #include // For std::pair and std::make_pair. #include diff --git a/googletest/test/gtest-typed-test_test.cc b/googletest/test/gtest-typed-test_test.cc index af23f86d1..4b1c23ddb 100644 --- a/googletest/test/gtest-typed-test_test.cc +++ b/googletest/test/gtest-typed-test_test.cc @@ -30,6 +30,7 @@ #include "test/gtest-typed-test_test.h" #include +#include #include #include diff --git a/googletest/test/gtest_pred_impl_unittest.cc b/googletest/test/gtest_pred_impl_unittest.cc index 3d4366537..033e2d9f6 100644 --- a/googletest/test/gtest_pred_impl_unittest.cc +++ b/googletest/test/gtest_pred_impl_unittest.cc @@ -45,6 +45,7 @@ // stand-alone regression test. #include +#include #include "gtest/gtest-spi.h" #include "gtest/gtest.h" diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index 8bd21be98..e66e66b95 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -61,6 +61,7 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) { #include #include #include +#include #include #include #include From 934542165899c786cb5d8a710529c37184730183 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 5 Jan 2023 11:14:51 -0800 Subject: [PATCH 070/336] Fix GTEST_OS_ESP8266 check Everywhere else in the code, we check the value of GTEST_OS_ESP8266, not just whether it is defined. PiperOrigin-RevId: 499946909 Change-Id: I86f7e8947abb4e928fc24d1416d8237987b27845 --- googletest/src/gtest.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 08eaefbda..a64e887c9 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -5030,7 +5030,7 @@ class ScopedPrematureExitFile { } ~ScopedPrematureExitFile() { -#if !defined GTEST_OS_ESP8266 +#if !GTEST_OS_ESP8266 if (!premature_exit_filepath_.empty()) { int retval = remove(premature_exit_filepath_.c_str()); if (retval) { From a652ae05755c5d95e9b11ef0c4bc0b715e4332d4 Mon Sep 17 00:00:00 2001 From: Derek Mauro Date: Wed, 11 Jan 2023 07:56:30 -0800 Subject: [PATCH 071/336] Update GoogleTest dependencies PiperOrigin-RevId: 501282034 Change-Id: I0314ac566dc5e117db5a06c97d303e5cf8822d61 --- WORKSPACE | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 7e371b901..0f10a6a9a 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -3,42 +3,38 @@ workspace(name = "com_google_googletest") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( - name = "com_google_absl", - sha256 = "1a1745b5ee81392f5ea4371a4ca41e55d446eeaee122903b2eaffbd8a3b67a2b", - strip_prefix = "abseil-cpp-01cc6567cff77738e416a7ddc17de2d435a780ce", - urls = ["https://github.com/abseil/abseil-cpp/archive/01cc6567cff77738e416a7ddc17de2d435a780ce.zip"], # 2022-06-21T19:28:27Z + 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"], ) # 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", - sha256 = "0a890c2aa0bb05b2ce906a15efb520d0f5ad4c7d37b8db959c43772802991887", - strip_prefix = "re2-a427f10b9fb4622dd6d8643032600aa1b50fbd12", - urls = ["https://github.com/google/re2/archive/a427f10b9fb4622dd6d8643032600aa1b50fbd12.zip"], # 2022-06-09 + 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"], ) http_archive( - name = "rules_python", - sha256 = "8c8fe44ef0a9afc256d1e75ad5f448bb59b81aba149b8958f02f7b3a98f5d9b4", - strip_prefix = "rules_python-0.13.0", - url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.13.0.tar.gz", + 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"], ) http_archive( - name = "bazel_skylib", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz", - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz", - ], - sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506", + 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"], ) http_archive( - name = "platforms", - urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz", - "https://github.com/bazelbuild/platforms/releases/download/0.0.6/platforms-0.0.6.tar.gz", - ], - sha256 = "5308fc1d8865406a49427ba24a9ab53087f17f5266a7aabbfc28823f3916e1ca", + name = "platforms", # 2022-11-09T19:18:22Z + sha256 = "b4a3b45dc4202e2b3e34e3bc49d2b5b37295fc23ea58d88fb9e01f3642ad9b55", + strip_prefix = "platforms-3fbc687756043fb58a407c2ea8c944bc2fe1d922", + urls = ["https://github.com/bazelbuild/platforms/archive/3fbc687756043fb58a407c2ea8c944bc2fe1d922.zip"], ) From b5401fef68794d93b7fcd933bc3692211e8ebad1 Mon Sep 17 00:00:00 2001 From: Derek Mauro Date: Thu, 12 Jan 2023 08:09:49 -0800 Subject: [PATCH 072/336] Add an explicit #error that C++ versions less than C++14 are not supported PiperOrigin-RevId: 501568410 Change-Id: I0f78cd96dc9204c8ec97a1cdd09a9d63a613cc5b --- googletest/include/gtest/internal/gtest-port.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 5d81adb35..6db191b7a 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -257,6 +257,19 @@ // deprecated; calling a marked function // should generate a compiler warning +// The definition of GTEST_INTERNAL_CPLUSPLUS_LANG comes first because it can +// potentially be used as an #include guard. +#if defined(_MSVC_LANG) +#define GTEST_INTERNAL_CPLUSPLUS_LANG _MSVC_LANG +#elif defined(__cplusplus) +#define GTEST_INTERNAL_CPLUSPLUS_LANG __cplusplus +#endif + +#if !defined(GTEST_INTERNAL_CPLUSPLUS_LANG) || \ + GTEST_INTERNAL_CPLUSPLUS_LANG < 201402L +#error C++ versions less than C++14 are not supported. +#endif + #include // for isspace, etc #include // for ptrdiff_t #include From 356fc301251378e0f6fa6aa794d73714202887ac Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 12 Jan 2023 09:03:40 -0800 Subject: [PATCH 073/336] Fix -Wshadow warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ../googlemock/test/gmock-actions_test.cc:687:36: warning: declaration of ‘v’ shadows a member of ‘testing::{anonymous}::ReturnTest_SupportsReferenceLikeReturnType_Test::TestBody()::Result’ [-Wshadow] 687 | Result(const std::vector& v) : v(&v) {} // NOLINT | ~~~~~~~~~~~~~~~~~~~~~~~~^ ../googlemock/test/gmock-actions_test.cc:686:29: note: shadowed declaration is here 686 | const std::vector* v; | ^ ../googlemock/test/gmock-actions_test.cc: In constructor ‘testing::{anonymous}::ReturnTest_PrefersConversionOperator_Test::TestBody()::Out::Out(int)’: ../googlemock/test/gmock-actions_test.cc:720:28: warning: declaration of ‘x’ shadows a member of ‘testing::{anonymous}::ReturnTest_PrefersConversionOperator_Test::TestBody()::Out’ [-Wshadow] 720 | explicit Out(const int x) : x(x) {} | ~~~~~~~~~~^ ../googlemock/test/gmock-actions_test.cc:718:9: note: shadowed declaration is here 718 | int x; | ^ PiperOrigin-RevId: 501580618 Change-Id: I584710fbbe440ec724f88746e51f3be5653c32d5 --- googlemock/test/gmock-actions_test.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc index e5a7ae132..510d15c8d 100644 --- a/googlemock/test/gmock-actions_test.cc +++ b/googlemock/test/gmock-actions_test.cc @@ -684,7 +684,7 @@ TEST(ReturnTest, SupportsReferenceLikeReturnType) { // A reference wrapper for std::vector, implicitly convertible from it. struct Result { const std::vector* v; - Result(const std::vector& v) : v(&v) {} // NOLINT + Result(const std::vector& vec) : v(&vec) {} // NOLINT }; // Set up an action for a mock function that returns the reference wrapper @@ -717,7 +717,7 @@ TEST(ReturnTest, PrefersConversionOperator) { struct Out { int x; - explicit Out(const int x) : x(x) {} + explicit Out(const int val) : x(val) {} explicit Out(const In&) : x(0) {} }; From ac7a126f39d5bcd909b78c9e69900c76659b1bbb Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Tue, 17 Jan 2023 07:12:03 -0800 Subject: [PATCH 074/336] gmock_output_test: normalize golden file output to unix line endings When checked out on Windows, the repo might use \r\n line endings, and so the golden output has them. Adjust for that. PiperOrigin-RevId: 502577222 Change-Id: Iabfe537f6d95a49bf6bdcb934e855d28c65f6f89 --- googlemock/test/gmock_output_test.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/googlemock/test/gmock_output_test.py b/googlemock/test/gmock_output_test.py index 6b4ab9015..d7c3f27e8 100755 --- a/googlemock/test/gmock_output_test.py +++ b/googlemock/test/gmock_output_test.py @@ -159,6 +159,9 @@ class GMockOutputTest(gmock_test_utils.TestCase): golden_file = open(GOLDEN_PATH, 'rb') golden = golden_file.read().decode('utf-8') golden_file.close() + # On Windows the repository might have been checked out with \r\n line + # endings, so normalize it here. + golden = ToUnixLineEnding(golden) # The normalized output should match the golden file. self.assertEqual(golden, output) From b796f7d44681514f58a683a3a71ff17c94edb0c1 Mon Sep 17 00:00:00 2001 From: Derek Mauro Date: Tue, 17 Jan 2023 10:36:00 -0800 Subject: [PATCH 075/336] Bump version to 1.13.0 in preparation for release PiperOrigin-RevId: 502626077 Change-Id: I3aad27a8b725cf73163e52ef2e28e6cdfc13082b --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4210622b5..6af414371 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ if (POLICY CMP0077) endif (POLICY CMP0077) project(googletest-distribution) -set(GOOGLETEST_VERSION 1.12.1) +set(GOOGLETEST_VERSION 1.13.0) if(NOT CYGWIN AND NOT MSYS AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL QNX) set(CMAKE_CXX_EXTENSIONS OFF) From 9d697cc81cafa7e6c35d056cd8a31eac725a96ea Mon Sep 17 00:00:00 2001 From: Derek Mauro Date: Tue, 17 Jan 2023 11:37:18 -0800 Subject: [PATCH 076/336] Update documentation for v1.13.0 PiperOrigin-RevId: 502644180 Change-Id: Id20b5e4eec22035da278f1767002657f66dbe79c --- README.md | 9 ++++----- googletest/README.md | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index cd89abb2d..9d72c0499 100644 --- a/README.md +++ b/README.md @@ -15,13 +15,12 @@ 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.12.1 +#### Release 1.13.0 -[Release 1.12.1](https://github.com/google/googletest/releases/tag/release-1.12.1) -is now available. +[Release 1.13.0](https://github.com/google/googletest/releases/tag/v1.13.0) is +now available. -The 1.12.x branch will be the last to support C++11. Future releases will -require at least C++14. +The 1.13.x branch requires at least C++14. #### Coming Soon diff --git a/googletest/README.md b/googletest/README.md index 9bdbcec04..ae2fce140 100644 --- a/googletest/README.md +++ b/googletest/README.md @@ -25,7 +25,7 @@ When building GoogleTest as a standalone project, the typical workflow starts with ``` -git clone https://github.com/google/googletest.git -b release-1.12.1 +git clone https://github.com/google/googletest.git -b v1.13.0 cd googletest # Main directory of the cloned repository. mkdir build # Create a directory to hold the build output. cd build From 5cd81a7848203d3df6959c148eb91f1a4ff32c1d Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 17 Jan 2023 11:44:04 -0800 Subject: [PATCH 077/336] Fix -Wimplicit-int-float-conversion warning We're intentionally losing precision in this case, so add a cast. googletest/googletest/include/gtest/gtest-printers.h:532:9: error: implicit conversion from 'int32_t' (aka 'int') to 'float' may lose precision [-Werror,-Wimplicit-int-float-conversion] if (static_cast(val * mulfor6 + 0.5) / mulfor6 == val) return 6; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ googletest/googletest/include/gtest/gtest-printers.h:544:9: error: implicit conversion from 'int32_t' (aka 'int') to 'float' may lose precision [-Werror,-Wimplicit-int-float-conversion] if (static_cast(val / divfor6 + 0.5) * divfor6 == val) return 6; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ PiperOrigin-RevId: 502646042 Change-Id: I05989ee42675b531a9907616c9582a5a7c77bed6 --- googletest/include/gtest/gtest-printers.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h index 0055e37ff..7d7e77c19 100644 --- a/googletest/include/gtest/gtest-printers.h +++ b/googletest/include/gtest/gtest-printers.h @@ -529,7 +529,10 @@ int AppropriateResolution(FloatType val) { } else if (val >= 0.0001) { mulfor6 = 1e9; } - if (static_cast(val * mulfor6 + 0.5) / mulfor6 == val) return 6; + if (static_cast(static_cast(val * mulfor6 + 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 @@ -541,7 +544,10 @@ int AppropriateResolution(FloatType val) { } else if (val >= 1e6) { // 1,000,000 to 9,999,999 divfor6 = 10; } - if (static_cast(val / divfor6 + 0.5) * divfor6 == val) return 6; + if (static_cast(static_cast(val / divfor6 + 0.5)) * + divfor6 == + val) + return 6; } return full; } From bba28fa8b2ef2d9725302ab8da0ca7c1a4a81715 Mon Sep 17 00:00:00 2001 From: Dino Radakovic Date: Tue, 17 Jan 2023 12:13:58 -0800 Subject: [PATCH 078/336] Announce that GitHub actions are not GoogleTest's canonical CI PiperOrigin-RevId: 502654465 Change-Id: I51269e8c389ad63f3737132feec1b6d20dc4c314 --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 9d72c0499..23eb5026d 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,13 @@ now available. The 1.13.x branch requires at least C++14. +#### 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. + #### Coming Soon * We are planning to take a dependency on From bdb3b0a4939228f28fcb38e786cc29b79db463ab Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 17 Jan 2023 12:15:50 -0800 Subject: [PATCH 079/336] Replace deprecated python calls assert_ -> assertTrue/assertFalse/assertIn/assertNotIn assertEquals -> assertEqual PiperOrigin-RevId: 502654909 Change-Id: I25d30095a83c3806606cb80d676b3c979495e6bd --- CONTRIBUTING.md | 2 +- googlemock/test/gmock_leak_test.py | 4 +- .../googletest-break-on-failure-unittest.py | 2 +- .../test/googletest-catch-exceptions-test.py | 79 ++++++++++++------- googletest/test/googletest-color-test.py | 68 ++++++++-------- googletest/test/googletest-filter-unittest.py | 24 +++--- .../test/googletest-json-outfiles-test.py | 10 ++- .../test/googletest-json-output-unittest.py | 38 +++++---- .../test/googletest-list-tests-unittest.py | 23 ++++-- googletest/test/googletest-shuffle-test.py | 76 +++++++++++------- .../test/googletest-throw-on-failure-test.py | 2 +- googletest/test/gtest_testbridge_test.py | 2 +- googletest/test/gtest_xml_outfiles_test.py | 10 ++- googletest/test/gtest_xml_output_unittest.py | 38 +++++---- googletest/test/gtest_xml_test_utils.py | 78 +++++++++++------- 15 files changed, 271 insertions(+), 185 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index de14c8159..423b06751 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -88,7 +88,7 @@ check your formatting. If you plan to contribute a patch, you need to build Google Test, Google Mock, and their own tests from a git checkout, which has further requirements: -* [Python](https://www.python.org/) v2.3 or newer (for running some of the +* [Python](https://www.python.org/) v3.6 or newer (for running some of the tests and re-generating certain source files from templates) * [CMake](https://cmake.org/) v2.8.12 or newer diff --git a/googlemock/test/gmock_leak_test.py b/googlemock/test/gmock_leak_test.py index 4f41c7bbd..9d142d34b 100755 --- a/googlemock/test/gmock_leak_test.py +++ b/googlemock/test/gmock_leak_test.py @@ -62,12 +62,12 @@ class GMockLeakTest(gmock_test_utils.TestCase): env=environ).exit_code) def testDoesNotCatchLeakedMockWhenDisabled(self): - self.assertEquals( + self.assertEqual( 0, gmock_test_utils.Subprocess(TEST_WITH_EXPECT_CALL + ['--gmock_catch_leaked_mocks=0'], env=environ).exit_code) - self.assertEquals( + self.assertEqual( 0, gmock_test_utils.Subprocess(TEST_WITH_ON_CALL + ['--gmock_catch_leaked_mocks=0'], diff --git a/googletest/test/googletest-break-on-failure-unittest.py b/googletest/test/googletest-break-on-failure-unittest.py index 4eafba3e6..c5c0b1571 100755 --- a/googletest/test/googletest-break-on-failure-unittest.py +++ b/googletest/test/googletest-break-on-failure-unittest.py @@ -135,7 +135,7 @@ class GTestBreakOnFailureUnitTest(gtest_test_utils.TestCase): msg = ('when %s%s, an assertion failure in "%s" %s cause a seg-fault.' % (BREAK_ON_FAILURE_ENV_VAR, env_var_value_msg, ' '.join(command), should_or_not)) - self.assert_(has_seg_fault == expect_seg_fault, msg) + self.assertTrue(has_seg_fault == expect_seg_fault, msg) def testDefaultBehavior(self): """Tests the behavior of the default mode.""" diff --git a/googletest/test/googletest-catch-exceptions-test.py b/googletest/test/googletest-catch-exceptions-test.py index d38d91a62..07f15826b 100755 --- a/googletest/test/googletest-catch-exceptions-test.py +++ b/googletest/test/googletest-catch-exceptions-test.py @@ -81,24 +81,37 @@ if SUPPORTS_SEH_EXCEPTIONS: class CatchSehExceptionsTest(gtest_test_utils.TestCase): """Tests exception-catching behavior.""" - def TestSehExceptions(self, test_output): - self.assert_('SEH exception with code 0x2a thrown ' - 'in the test fixture\'s constructor' - in test_output) - self.assert_('SEH exception with code 0x2a thrown ' - 'in the test fixture\'s destructor' - in test_output) - self.assert_('SEH exception with code 0x2a thrown in SetUpTestSuite()' - in test_output) - self.assert_('SEH exception with code 0x2a thrown in TearDownTestSuite()' - in test_output) - self.assert_('SEH exception with code 0x2a thrown in SetUp()' - in test_output) - self.assert_('SEH exception with code 0x2a thrown in TearDown()' - in test_output) - self.assert_('SEH exception with code 0x2a thrown in the test body' - in test_output) + self.assertIn( + ( + 'SEH exception with code 0x2a thrown ' + "in the test fixture's constructor" + ), + test_output, + ) + self.assertIn( + ( + 'SEH exception with code 0x2a thrown ' + "in the test fixture's destructor" + ), + test_output, + ) + self.assertIn( + 'SEH exception with code 0x2a thrown in SetUpTestSuite()', test_output + ) + self.assertIn( + 'SEH exception with code 0x2a thrown in TearDownTestSuite()', + test_output, + ) + self.assertIn( + 'SEH exception with code 0x2a thrown in SetUp()', test_output + ) + self.assertIn( + 'SEH exception with code 0x2a thrown in TearDown()', test_output + ) + self.assertIn( + 'SEH exception with code 0x2a thrown in the test body', test_output + ) def testCatchesSehExceptionsWithCxxExceptionsEnabled(self): self.TestSehExceptions(EX_BINARY_OUTPUT) @@ -122,10 +135,14 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase): '"Standard C++ exception" thrown ' 'in the test fixture\'s constructor' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT) - self.assert_('unexpected' not in EX_BINARY_OUTPUT, - 'This failure belongs in this test only if ' - '"CxxExceptionInConstructorTest" (no quotes) ' - 'appears on the same line as words "called unexpectedly"') + self.assertTrue( + 'unexpected' not in EX_BINARY_OUTPUT, + ( + 'This failure belongs in this test only if ' + '"CxxExceptionInConstructorTest" (no quotes) ' + 'appears on the same line as words "called unexpectedly"' + ), + ) if ('CxxExceptionInDestructorTest.ThrowsExceptionInDestructor' in EX_BINARY_OUTPUT): @@ -181,10 +198,14 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase): self.assertTrue( 'CxxExceptionInSetUpTest::TearDown() ' 'called as expected.' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT) - self.assert_('unexpected' not in EX_BINARY_OUTPUT, - 'This failure belongs in this test only if ' - '"CxxExceptionInSetUpTest" (no quotes) ' - 'appears on the same line as words "called unexpectedly"') + self.assertTrue( + 'unexpected' not in EX_BINARY_OUTPUT, + ( + 'This failure belongs in this test only if ' + '"CxxExceptionInSetUpTest" (no quotes) ' + 'appears on the same line as words "called unexpectedly"' + ), + ) def testCatchesCxxExceptionsInTearDown(self): self.assertTrue( @@ -227,9 +248,11 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase): FITLER_OUT_SEH_TESTS_FLAG], env=environ).output - self.assert_('Unhandled C++ exception terminating the program' - in uncaught_exceptions_ex_binary_output) - self.assert_('unexpected' not in uncaught_exceptions_ex_binary_output) + self.assertIn( + 'Unhandled C++ exception terminating the program', + uncaught_exceptions_ex_binary_output, + ) + self.assertNotIn('unexpected', uncaught_exceptions_ex_binary_output) if __name__ == '__main__': diff --git a/googletest/test/googletest-color-test.py b/googletest/test/googletest-color-test.py index f08edf707..32dafccca 100755 --- a/googletest/test/googletest-color-test.py +++ b/googletest/test/googletest-color-test.py @@ -69,59 +69,59 @@ class GTestColorTest(gtest_test_utils.TestCase): """Tests the case when there's neither GTEST_COLOR nor --gtest_color.""" if not IS_WINDOWS: - self.assert_(not UsesColor('dumb', None, None)) - self.assert_(not UsesColor('emacs', None, None)) - self.assert_(not UsesColor('xterm-mono', None, None)) - self.assert_(not UsesColor('unknown', None, None)) - self.assert_(not UsesColor(None, None, None)) - self.assert_(UsesColor('linux', None, None)) - self.assert_(UsesColor('cygwin', None, None)) - self.assert_(UsesColor('xterm', None, None)) - self.assert_(UsesColor('xterm-color', None, None)) - self.assert_(UsesColor('xterm-kitty', None, None)) - self.assert_(UsesColor('xterm-256color', None, None)) + self.assertTrue(not UsesColor('dumb', None, None)) + self.assertTrue(not UsesColor('emacs', None, None)) + self.assertTrue(not UsesColor('xterm-mono', None, None)) + self.assertTrue(not UsesColor('unknown', None, None)) + self.assertTrue(not UsesColor(None, None, None)) + self.assertTrue(UsesColor('linux', None, None)) + self.assertTrue(UsesColor('cygwin', None, None)) + self.assertTrue(UsesColor('xterm', None, None)) + self.assertTrue(UsesColor('xterm-color', None, None)) + self.assertTrue(UsesColor('xterm-kitty', None, None)) + self.assertTrue(UsesColor('xterm-256color', None, None)) def testFlagOnly(self): """Tests the case when there's --gtest_color but not GTEST_COLOR.""" - self.assert_(not UsesColor('dumb', None, 'no')) - self.assert_(not UsesColor('xterm-color', None, 'no')) + self.assertTrue(not UsesColor('dumb', None, 'no')) + self.assertTrue(not UsesColor('xterm-color', None, 'no')) if not IS_WINDOWS: - self.assert_(not UsesColor('emacs', None, 'auto')) - self.assert_(UsesColor('xterm', None, 'auto')) - self.assert_(UsesColor('dumb', None, 'yes')) - self.assert_(UsesColor('xterm', None, 'yes')) + self.assertTrue(not UsesColor('emacs', None, 'auto')) + self.assertTrue(UsesColor('xterm', None, 'auto')) + self.assertTrue(UsesColor('dumb', None, 'yes')) + self.assertTrue(UsesColor('xterm', None, 'yes')) def testEnvVarOnly(self): """Tests the case when there's GTEST_COLOR but not --gtest_color.""" - self.assert_(not UsesColor('dumb', 'no', None)) - self.assert_(not UsesColor('xterm-color', 'no', None)) + self.assertTrue(not UsesColor('dumb', 'no', None)) + self.assertTrue(not UsesColor('xterm-color', 'no', None)) if not IS_WINDOWS: - self.assert_(not UsesColor('dumb', 'auto', None)) - self.assert_(UsesColor('xterm-color', 'auto', None)) - self.assert_(UsesColor('dumb', 'yes', None)) - self.assert_(UsesColor('xterm-color', 'yes', None)) + self.assertTrue(not UsesColor('dumb', 'auto', None)) + self.assertTrue(UsesColor('xterm-color', 'auto', None)) + self.assertTrue(UsesColor('dumb', 'yes', None)) + self.assertTrue(UsesColor('xterm-color', 'yes', None)) def testEnvVarAndFlag(self): """Tests the case when there are both GTEST_COLOR and --gtest_color.""" - self.assert_(not UsesColor('xterm-color', 'no', 'no')) - self.assert_(UsesColor('dumb', 'no', 'yes')) - self.assert_(UsesColor('xterm-color', 'no', 'auto')) + self.assertTrue(not UsesColor('xterm-color', 'no', 'no')) + self.assertTrue(UsesColor('dumb', 'no', 'yes')) + self.assertTrue(UsesColor('xterm-color', 'no', 'auto')) def testAliasesOfYesAndNo(self): """Tests using aliases in specifying --gtest_color.""" - self.assert_(UsesColor('dumb', None, 'true')) - self.assert_(UsesColor('dumb', None, 'YES')) - self.assert_(UsesColor('dumb', None, 'T')) - self.assert_(UsesColor('dumb', None, '1')) + self.assertTrue(UsesColor('dumb', None, 'true')) + self.assertTrue(UsesColor('dumb', None, 'YES')) + self.assertTrue(UsesColor('dumb', None, 'T')) + self.assertTrue(UsesColor('dumb', None, '1')) - self.assert_(not UsesColor('xterm', None, 'f')) - self.assert_(not UsesColor('xterm', None, 'false')) - self.assert_(not UsesColor('xterm', None, '0')) - self.assert_(not UsesColor('xterm', None, 'unknown')) + self.assertTrue(not UsesColor('xterm', None, 'f')) + self.assertTrue(not UsesColor('xterm', None, 'false')) + self.assertTrue(not UsesColor('xterm', None, '0')) + self.assertTrue(not UsesColor('xterm', None, 'unknown')) if __name__ == '__main__': diff --git a/googletest/test/googletest-filter-unittest.py b/googletest/test/googletest-filter-unittest.py index 2c4a1b18a..02fd1dfba 100755 --- a/googletest/test/googletest-filter-unittest.py +++ b/googletest/test/googletest-filter-unittest.py @@ -250,10 +250,10 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase): """Asserts that two sets are equal.""" for elem in lhs: - self.assert_(elem in rhs, '%s in %s' % (elem, rhs)) + self.assertTrue(elem in rhs, '%s in %s' % (elem, rhs)) for elem in rhs: - self.assert_(elem in lhs, '%s in %s' % (elem, lhs)) + self.assertTrue(elem in lhs, '%s in %s' % (elem, lhs)) def AssertPartitionIsValid(self, set_var, list_of_sets): """Asserts that list_of_sets is a valid partition of set_var.""" @@ -595,13 +595,13 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase): shard_status_file = os.path.join(gtest_test_utils.GetTempDir(), 'shard_status_file') - self.assert_(not os.path.exists(shard_status_file)) + self.assertTrue(not os.path.exists(shard_status_file)) extra_env = {SHARD_STATUS_FILE_ENV_VAR: shard_status_file} try: InvokeWithModifiedEnv(extra_env, RunAndReturnOutput) finally: - self.assert_(os.path.exists(shard_status_file)) + self.assertTrue(os.path.exists(shard_status_file)) os.remove(shard_status_file) def testShardStatusFileIsCreatedWithListTests(self): @@ -609,7 +609,7 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase): shard_status_file = os.path.join(gtest_test_utils.GetTempDir(), 'shard_status_file2') - self.assert_(not os.path.exists(shard_status_file)) + self.assertTrue(not os.path.exists(shard_status_file)) extra_env = {SHARD_STATUS_FILE_ENV_VAR: shard_status_file} try: @@ -619,12 +619,16 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase): finally: # This assertion ensures that Google Test enumerated the tests as # opposed to running them. - self.assert_('[==========]' not in output, - 'Unexpected output during test enumeration.\n' - 'Please ensure that LIST_TESTS_FLAG is assigned the\n' - 'correct flag value for listing Google Test tests.') + self.assertTrue( + '[==========]' not in output, + ( + 'Unexpected output during test enumeration.\n' + 'Please ensure that LIST_TESTS_FLAG is assigned the\n' + 'correct flag value for listing Google Test tests.' + ), + ) - self.assert_(os.path.exists(shard_status_file)) + self.assertTrue(os.path.exists(shard_status_file)) os.remove(shard_status_file) def testDisabledBanner(self): diff --git a/googletest/test/googletest-json-outfiles-test.py b/googletest/test/googletest-json-outfiles-test.py index 179283b85..3abf355d4 100644 --- a/googletest/test/googletest-json-outfiles-test.py +++ b/googletest/test/googletest-json-outfiles-test.py @@ -171,15 +171,17 @@ class GTestJsonOutFilesTest(gtest_test_utils.TestCase): command = [gtest_prog_path, '--gtest_output=json:%s' % self.output_dir_] p = gtest_test_utils.Subprocess(command, working_dir=gtest_test_utils.GetTempDir()) - self.assert_(p.exited) - self.assertEquals(0, p.exit_code) + self.assertTrue(p.exited) + self.assertEqual(0, p.exit_code) output_file_name1 = test_name + '.json' output_file1 = os.path.join(self.output_dir_, output_file_name1) output_file_name2 = 'lt-' + output_file_name1 output_file2 = os.path.join(self.output_dir_, output_file_name2) - self.assert_(os.path.isfile(output_file1) or os.path.isfile(output_file2), - output_file1) + self.assertTrue( + os.path.isfile(output_file1) or os.path.isfile(output_file2), + output_file1, + ) if os.path.isfile(output_file1): with open(output_file1) as f: diff --git a/googletest/test/googletest-json-output-unittest.py b/googletest/test/googletest-json-output-unittest.py index e0fbe4650..c8915b2f3 100644 --- a/googletest/test/googletest-json-output-unittest.py +++ b/googletest/test/googletest-json-output-unittest.py @@ -806,9 +806,9 @@ class GTestJsonOutputUnitTest(gtest_test_utils.TestCase): p = gtest_test_utils.Subprocess( [gtest_prog_path, '%s=json' % GTEST_OUTPUT_FLAG], working_dir=gtest_test_utils.GetTempDir()) - self.assert_(p.exited) - self.assertEquals(0, p.exit_code) - self.assert_(os.path.isfile(output_file)) + self.assertTrue(p.exited) + self.assertEqual(0, p.exit_code) + self.assertTrue(os.path.isfile(output_file)) def testSuppressedJsonOutput(self): """Verifies that no JSON output is generated. @@ -832,13 +832,15 @@ class GTestJsonOutputUnitTest(gtest_test_utils.TestCase): p.terminated_by_signal, '%s was killed by signal %d' % (GTEST_PROGRAM_NAME, p.signal)) else: - self.assert_(p.exited) - self.assertEquals(1, p.exit_code, - "'%s' exited with code %s, which doesn't match " - 'the expected exit code %s.' - % (command, p.exit_code, 1)) + self.assertTrue(p.exited) + self.assertEqual( + 1, + p.exit_code, + "'%s' exited with code %s, which doesn't match " + 'the expected exit code %s.' % (command, p.exit_code, 1), + ) - self.assert_(not os.path.isfile(json_path)) + self.assertTrue(not os.path.isfile(json_path)) def testFilteredTestJsonOutput(self): """Verifies JSON output when a filter is applied. @@ -870,14 +872,18 @@ class GTestJsonOutputUnitTest(gtest_test_utils.TestCase): ) p = gtest_test_utils.Subprocess(command) if p.terminated_by_signal: - self.assert_(False, - '%s was killed by signal %d' % (gtest_prog_name, p.signal)) + self.assertTrue( + False, '%s was killed by signal %d' % (gtest_prog_name, p.signal) + ) else: - self.assert_(p.exited) - self.assertEquals(expected_exit_code, p.exit_code, - "'%s' exited with code %s, which doesn't match " - 'the expected exit code %s.' - % (command, p.exit_code, expected_exit_code)) + self.assertTrue(p.exited) + self.assertEqual( + expected_exit_code, + p.exit_code, + "'%s' exited with code %s, which doesn't match " + 'the expected exit code %s.' + % (command, p.exit_code, expected_exit_code), + ) with open(json_path) as f: actual = json.load(f) return actual diff --git a/googletest/test/googletest-list-tests-unittest.py b/googletest/test/googletest-list-tests-unittest.py index 9d56883d7..485150ddf 100755 --- a/googletest/test/googletest-list-tests-unittest.py +++ b/googletest/test/googletest-list-tests-unittest.py @@ -156,17 +156,24 @@ class GTestListTestsUnitTest(gtest_test_utils.TestCase): output = Run(args) if expected_output_re: - self.assert_( + self.assertTrue( expected_output_re.match(output), - ('when %s is %s, the output of "%s" is "%s",\n' - 'which does not match regex "%s"' % - (LIST_TESTS_FLAG, flag_expression, ' '.join(args), output, - expected_output_re.pattern))) + 'when %s is %s, the output of "%s" is "%s",\n' + 'which does not match regex "%s"' + % ( + LIST_TESTS_FLAG, + flag_expression, + ' '.join(args), + output, + expected_output_re.pattern, + ), + ) else: - self.assert_( + self.assertTrue( not EXPECTED_OUTPUT_NO_FILTER_RE.match(output), - ('when %s is %s, the output of "%s" is "%s"'% - (LIST_TESTS_FLAG, flag_expression, ' '.join(args), output))) + 'when %s is %s, the output of "%s" is "%s"' + % (LIST_TESTS_FLAG, flag_expression, ' '.join(args), output), + ) def testDefaultBehavior(self): """Tests the behavior of the default mode.""" diff --git a/googletest/test/googletest-shuffle-test.py b/googletest/test/googletest-shuffle-test.py index 9d2adc128..61e25932f 100755 --- a/googletest/test/googletest-shuffle-test.py +++ b/googletest/test/googletest-shuffle-test.py @@ -177,25 +177,34 @@ class GTestShuffleUnitTest(gtest_test_utils.TestCase): self.assertEqual(len(SHARDED_TESTS), len(SHUFFLED_SHARDED_TESTS)) def testShuffleChangesTestOrder(self): - self.assert_(SHUFFLED_ALL_TESTS != ALL_TESTS, SHUFFLED_ALL_TESTS) - self.assert_(SHUFFLED_ACTIVE_TESTS != ACTIVE_TESTS, SHUFFLED_ACTIVE_TESTS) - self.assert_(SHUFFLED_FILTERED_TESTS != FILTERED_TESTS, - SHUFFLED_FILTERED_TESTS) - self.assert_(SHUFFLED_SHARDED_TESTS != SHARDED_TESTS, - SHUFFLED_SHARDED_TESTS) + self.assertTrue(SHUFFLED_ALL_TESTS != ALL_TESTS, SHUFFLED_ALL_TESTS) + self.assertTrue( + SHUFFLED_ACTIVE_TESTS != ACTIVE_TESTS, SHUFFLED_ACTIVE_TESTS + ) + self.assertTrue( + SHUFFLED_FILTERED_TESTS != FILTERED_TESTS, SHUFFLED_FILTERED_TESTS + ) + self.assertTrue( + SHUFFLED_SHARDED_TESTS != SHARDED_TESTS, SHUFFLED_SHARDED_TESTS + ) def testShuffleChangesTestCaseOrder(self): - self.assert_(GetTestCases(SHUFFLED_ALL_TESTS) != GetTestCases(ALL_TESTS), - GetTestCases(SHUFFLED_ALL_TESTS)) - self.assert_( + self.assertTrue( + GetTestCases(SHUFFLED_ALL_TESTS) != GetTestCases(ALL_TESTS), + GetTestCases(SHUFFLED_ALL_TESTS), + ) + self.assertTrue( GetTestCases(SHUFFLED_ACTIVE_TESTS) != GetTestCases(ACTIVE_TESTS), - GetTestCases(SHUFFLED_ACTIVE_TESTS)) - self.assert_( + GetTestCases(SHUFFLED_ACTIVE_TESTS), + ) + self.assertTrue( GetTestCases(SHUFFLED_FILTERED_TESTS) != GetTestCases(FILTERED_TESTS), - GetTestCases(SHUFFLED_FILTERED_TESTS)) - self.assert_( + GetTestCases(SHUFFLED_FILTERED_TESTS), + ) + self.assertTrue( GetTestCases(SHUFFLED_SHARDED_TESTS) != GetTestCases(SHARDED_TESTS), - GetTestCases(SHUFFLED_SHARDED_TESTS)) + GetTestCases(SHUFFLED_SHARDED_TESTS), + ) def testShuffleDoesNotRepeatTest(self): for test in SHUFFLED_ALL_TESTS: @@ -213,30 +222,34 @@ class GTestShuffleUnitTest(gtest_test_utils.TestCase): def testShuffleDoesNotCreateNewTest(self): for test in SHUFFLED_ALL_TESTS: - self.assert_(test in ALL_TESTS, '%s is an invalid test' % (test,)) + self.assertTrue(test in ALL_TESTS, '%s is an invalid test' % (test,)) for test in SHUFFLED_ACTIVE_TESTS: - self.assert_(test in ACTIVE_TESTS, '%s is an invalid test' % (test,)) + self.assertTrue(test in ACTIVE_TESTS, '%s is an invalid test' % (test,)) for test in SHUFFLED_FILTERED_TESTS: - self.assert_(test in FILTERED_TESTS, '%s is an invalid test' % (test,)) + self.assertTrue(test in FILTERED_TESTS, '%s is an invalid test' % (test,)) for test in SHUFFLED_SHARDED_TESTS: - self.assert_(test in SHARDED_TESTS, '%s is an invalid test' % (test,)) + self.assertTrue(test in SHARDED_TESTS, '%s is an invalid test' % (test,)) def testShuffleIncludesAllTests(self): for test in ALL_TESTS: - self.assert_(test in SHUFFLED_ALL_TESTS, '%s is missing' % (test,)) + self.assertTrue(test in SHUFFLED_ALL_TESTS, '%s is missing' % (test,)) for test in ACTIVE_TESTS: - self.assert_(test in SHUFFLED_ACTIVE_TESTS, '%s is missing' % (test,)) + self.assertTrue(test in SHUFFLED_ACTIVE_TESTS, '%s is missing' % (test,)) for test in FILTERED_TESTS: - self.assert_(test in SHUFFLED_FILTERED_TESTS, '%s is missing' % (test,)) + self.assertTrue( + test in SHUFFLED_FILTERED_TESTS, '%s is missing' % (test,) + ) for test in SHARDED_TESTS: - self.assert_(test in SHUFFLED_SHARDED_TESTS, '%s is missing' % (test,)) + self.assertTrue(test in SHUFFLED_SHARDED_TESTS, '%s is missing' % (test,)) def testShuffleLeavesDeathTestsAtFront(self): non_death_test_found = False for test in SHUFFLED_ACTIVE_TESTS: if 'DeathTest.' in test: - self.assert_(not non_death_test_found, - '%s appears after a non-death test' % (test,)) + self.assertTrue( + not non_death_test_found, + '%s appears after a non-death test' % (test,), + ) else: non_death_test_found = True @@ -293,12 +306,15 @@ class GTestShuffleUnitTest(gtest_test_utils.TestCase): GetTestsForAllIterations( {}, [ShuffleFlag(), RandomSeedFlag(1), RepeatFlag(3)])) - self.assert_(tests_in_iteration1 != tests_in_iteration2, - tests_in_iteration1) - self.assert_(tests_in_iteration1 != tests_in_iteration3, - tests_in_iteration1) - self.assert_(tests_in_iteration2 != tests_in_iteration3, - tests_in_iteration2) + self.assertTrue( + tests_in_iteration1 != tests_in_iteration2, tests_in_iteration1 + ) + self.assertTrue( + tests_in_iteration1 != tests_in_iteration3, tests_in_iteration1 + ) + self.assertTrue( + tests_in_iteration2 != tests_in_iteration3, tests_in_iteration2 + ) def testShuffleShardedTestsPreservesPartition(self): # If we run M tests on N shards, the same M tests should be run in diff --git a/googletest/test/googletest-throw-on-failure-test.py b/googletest/test/googletest-throw-on-failure-test.py index 772bbc5f3..8fc4f54f6 100755 --- a/googletest/test/googletest-throw-on-failure-test.py +++ b/googletest/test/googletest-throw-on-failure-test.py @@ -120,7 +120,7 @@ class ThrowOnFailureTest(gtest_test_utils.TestCase): 'exit code.' % (THROW_ON_FAILURE, env_var_value_msg, ' '.join(command), should_or_not)) - self.assert_(failed == should_fail, msg) + self.assertTrue(failed == should_fail, msg) def testDefaultBehavior(self): """Tests the behavior of the default mode.""" diff --git a/googletest/test/gtest_testbridge_test.py b/googletest/test/gtest_testbridge_test.py index 1c2a303a8..0d58758b0 100755 --- a/googletest/test/gtest_testbridge_test.py +++ b/googletest/test/gtest_testbridge_test.py @@ -52,7 +52,7 @@ class GTestTestFilterTest(gtest_test_utils.TestCase): subprocess_env[TESTBRIDGE_NAME] = '*.TestThatSucceeds' p = gtest_test_utils.Subprocess(COMMAND, env=subprocess_env) - self.assertEquals(0, p.exit_code) + self.assertEqual(0, p.exit_code) Assert('filter = *.TestThatSucceeds' in p.output) Assert('[ OK ] TestFilterTest.TestThatSucceeds' in p.output) diff --git a/googletest/test/gtest_xml_outfiles_test.py b/googletest/test/gtest_xml_outfiles_test.py index c129e64b9..73fb2b31d 100755 --- a/googletest/test/gtest_xml_outfiles_test.py +++ b/googletest/test/gtest_xml_outfiles_test.py @@ -108,15 +108,17 @@ class GTestXMLOutFilesTest(gtest_xml_test_utils.GTestXMLTestCase): command = [gtest_prog_path, "--gtest_output=xml:%s" % self.output_dir_] p = gtest_test_utils.Subprocess(command, working_dir=gtest_test_utils.GetTempDir()) - self.assert_(p.exited) - self.assertEquals(0, p.exit_code) + self.assertTrue(p.exited) + self.assertEqual(0, p.exit_code) output_file_name1 = test_name + ".xml" output_file1 = os.path.join(self.output_dir_, output_file_name1) output_file_name2 = 'lt-' + output_file_name1 output_file2 = os.path.join(self.output_dir_, output_file_name2) - self.assert_(os.path.isfile(output_file1) or os.path.isfile(output_file2), - output_file1) + self.assertTrue( + os.path.isfile(output_file1) or os.path.isfile(output_file2), + output_file1, + ) expected = minidom.parseString(expected_xml) if os.path.isfile(output_file1): diff --git a/googletest/test/gtest_xml_output_unittest.py b/googletest/test/gtest_xml_output_unittest.py index e1b7f1fc8..29fbc41f6 100755 --- a/googletest/test/gtest_xml_output_unittest.py +++ b/googletest/test/gtest_xml_output_unittest.py @@ -305,9 +305,9 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): p = gtest_test_utils.Subprocess( [gtest_prog_path, '%s=xml' % GTEST_OUTPUT_FLAG], working_dir=gtest_test_utils.GetTempDir()) - self.assert_(p.exited) - self.assertEquals(0, p.exit_code) - self.assert_(os.path.isfile(output_file)) + self.assertTrue(p.exited) + self.assertEqual(0, p.exit_code) + self.assertTrue(os.path.isfile(output_file)) def testSuppressedXmlOutput(self): """ @@ -330,13 +330,15 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): p.terminated_by_signal, '%s was killed by signal %d' % (GTEST_PROGRAM_NAME, p.signal)) else: - self.assert_(p.exited) - self.assertEquals(1, p.exit_code, - "'%s' exited with code %s, which doesn't match " - 'the expected exit code %s.' - % (command, p.exit_code, 1)) + self.assertTrue(p.exited) + self.assertEqual( + 1, + p.exit_code, + "'%s' exited with code %s, which doesn't match " + 'the expected exit code %s.' % (command, p.exit_code, 1), + ) - self.assert_(not os.path.isfile(xml_path)) + self.assertFalse(os.path.isfile(xml_path)) def testFilteredTestXmlOutput(self): """Verifies XML output when a filter is applied. @@ -380,14 +382,18 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): p = gtest_test_utils.Subprocess(command, env=environ_copy) if p.terminated_by_signal: - self.assert_(False, - '%s was killed by signal %d' % (gtest_prog_name, p.signal)) + self.assertTrue( + False, '%s was killed by signal %d' % (gtest_prog_name, p.signal) + ) else: - self.assert_(p.exited) - self.assertEquals(expected_exit_code, p.exit_code, - "'%s' exited with code %s, which doesn't match " - 'the expected exit code %s.' - % (command, p.exit_code, expected_exit_code)) + self.assertTrue(p.exited) + self.assertEqual( + expected_exit_code, + p.exit_code, + "'%s' exited with code %s, which doesn't match " + 'the expected exit code %s.' + % (command, p.exit_code, expected_exit_code), + ) actual = minidom.parse(xml_path) return actual diff --git a/googletest/test/gtest_xml_test_utils.py b/googletest/test/gtest_xml_test_utils.py index c6fb9f443..ae41bbad9 100755 --- a/googletest/test/gtest_xml_test_utils.py +++ b/googletest/test/gtest_xml_test_utils.py @@ -61,43 +61,59 @@ class GTestXMLTestCase(gtest_test_utils.TestCase): """ if expected_node.nodeType == Node.CDATA_SECTION_NODE: - self.assertEquals(Node.CDATA_SECTION_NODE, actual_node.nodeType) - self.assertEquals(expected_node.nodeValue, actual_node.nodeValue) + self.assertEqual(Node.CDATA_SECTION_NODE, actual_node.nodeType) + self.assertEqual(expected_node.nodeValue, actual_node.nodeValue) return - self.assertEquals(Node.ELEMENT_NODE, actual_node.nodeType) - self.assertEquals(Node.ELEMENT_NODE, expected_node.nodeType) - self.assertEquals(expected_node.tagName, actual_node.tagName) + self.assertEqual(Node.ELEMENT_NODE, actual_node.nodeType) + self.assertEqual(Node.ELEMENT_NODE, expected_node.nodeType) + self.assertEqual(expected_node.tagName, actual_node.tagName) expected_attributes = expected_node.attributes actual_attributes = actual_node.attributes - self.assertEquals( - expected_attributes.length, actual_attributes.length, - 'attribute numbers differ in element %s:\nExpected: %r\nActual: %r' % ( - actual_node.tagName, expected_attributes.keys(), - actual_attributes.keys())) + self.assertEqual( + expected_attributes.length, + actual_attributes.length, + 'attribute numbers differ in element %s:\nExpected: %r\nActual: %r' + % ( + actual_node.tagName, + expected_attributes.keys(), + actual_attributes.keys(), + ), + ) for i in range(expected_attributes.length): expected_attr = expected_attributes.item(i) actual_attr = actual_attributes.get(expected_attr.name) - self.assert_( + self.assertTrue( actual_attr is not None, - 'expected attribute %s not found in element %s' % - (expected_attr.name, actual_node.tagName)) - self.assertEquals( - expected_attr.value, actual_attr.value, - ' values of attribute %s in element %s differ: %s vs %s' % - (expected_attr.name, actual_node.tagName, - expected_attr.value, actual_attr.value)) + 'expected attribute %s not found in element %s' + % (expected_attr.name, actual_node.tagName), + ) + self.assertEqual( + expected_attr.value, + actual_attr.value, + ' values of attribute %s in element %s differ: %s vs %s' + % ( + expected_attr.name, + actual_node.tagName, + expected_attr.value, + actual_attr.value, + ), + ) expected_children = self._GetChildren(expected_node) actual_children = self._GetChildren(actual_node) - self.assertEquals( - len(expected_children), len(actual_children), - 'number of child elements differ in element ' + actual_node.tagName) + self.assertEqual( + len(expected_children), + len(actual_children), + 'number of child elements differ in element ' + actual_node.tagName, + ) for child_id, child in expected_children.items(): - self.assert_(child_id in actual_children, - '<%s> is not in <%s> (in element %s)' % - (child_id, actual_children, actual_node.tagName)) + self.assertTrue( + child_id in actual_children, + '<%s> is not in <%s> (in element %s)' + % (child_id, actual_children, actual_node.tagName), + ) self.AssertEquivalentNodes(child, actual_children[child_id]) identifying_attribute = { @@ -128,15 +144,19 @@ class GTestXMLTestCase(gtest_test_utils.TestCase): for child in element.childNodes: if child.nodeType == Node.ELEMENT_NODE: if child.tagName == 'properties': - self.assert_(child.parentNode is not None, - 'Encountered element without a parent') + self.assertTrue( + child.parentNode is not None, + 'Encountered element without a parent', + ) child_id = child.parentNode.getAttribute('name') + '-properties' else: - self.assert_(child.tagName in self.identifying_attribute, - 'Encountered unknown element <%s>' % child.tagName) + self.assertTrue( + child.tagName in self.identifying_attribute, + 'Encountered unknown element <%s>' % child.tagName, + ) child_id = child.getAttribute( self.identifying_attribute[child.tagName]) - self.assert_(child_id not in children) + self.assertNotIn(child_id, children) children[child_id] = child elif child.nodeType in [Node.TEXT_NODE, Node.CDATA_SECTION_NODE]: if 'detail' not in children: From ec25eea8f8237cf86c30703f59747e42f34b6f75 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 18 Jan 2023 09:43:14 -0800 Subject: [PATCH 080/336] Mention using MockFunction as a way to mock free functions. PiperOrigin-RevId: 502901538 Change-Id: I0cf351b9ad1411ae9c45e09550c24e006a24e179 --- docs/gmock_cook_book.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/gmock_cook_book.md b/docs/gmock_cook_book.md index fc7db35b8..d11282fa6 100644 --- a/docs/gmock_cook_book.md +++ b/docs/gmock_cook_book.md @@ -285,6 +285,10 @@ If you are concerned about the performance overhead incurred by virtual functions, and profiling confirms your concern, you can combine this with the recipe for [mocking non-virtual methods](#MockingNonVirtualMethods). +Alternatively, instead of introducing a new interface, you can rewrite your code +to accept a std::function instead of the free function, and then use +[MockFunction](#MockFunction) to mock the std::function. + ### Old-Style `MOCK_METHODn` Macros Before the generic `MOCK_METHOD` macro From 544c96ed5b0fb97ef867c38fbe204df2eaa02d2b Mon Sep 17 00:00:00 2001 From: Derek Mauro Date: Tue, 24 Jan 2023 08:40:51 -0800 Subject: [PATCH 081/336] Remove FloatingPoint::Max() in favor of std::numeric_limits::max() In #4113 a user says Max clashes with a macro. Since it is only used in a test, use std::numeric_limits::max() instead. Note that in headers, the macro issue can be mitigated with parenthesis like this: `(std::numeric_limits::max)()` PiperOrigin-RevId: 504284906 Change-Id: Ibf430caec1a6afdf6b303534fec6a4fd00a6373f --- googlemock/test/gmock-matchers-arithmetic_test.cc | 4 +++- googletest/include/gtest/internal/gtest-internal.h | 14 -------------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/googlemock/test/gmock-matchers-arithmetic_test.cc b/googlemock/test/gmock-matchers-arithmetic_test.cc index a4c1def6e..36c2bf027 100644 --- a/googlemock/test/gmock-matchers-arithmetic_test.cc +++ b/googlemock/test/gmock-matchers-arithmetic_test.cc @@ -41,6 +41,8 @@ #include "test/gmock-matchers_test.h" +#include + namespace testing { namespace gmock_matchers_test { namespace { @@ -1037,7 +1039,7 @@ class FloatingPointTest : public testing::Test { Floating::ReinterpretBits(infinity_bits_ - max_ulps_)), further_from_infinity_( Floating::ReinterpretBits(infinity_bits_ - max_ulps_ - 1)), - max_(Floating::Max()), + max_(std::numeric_limits::max()), nan1_(Floating::ReinterpretBits(Floating::kExponentBitMask | 1)), nan2_(Floating::ReinterpretBits(Floating::kExponentBitMask | 200)) {} diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h index 3121d428b..e1eb2b510 100644 --- a/googletest/include/gtest/internal/gtest-internal.h +++ b/googletest/include/gtest/internal/gtest-internal.h @@ -307,9 +307,6 @@ class FloatingPoint { // Returns the floating-point number that represent positive infinity. static RawType Infinity() { return ReinterpretBits(kExponentBitMask); } - // Returns the maximum representable finite floating-point number. - static RawType Max(); - // Non-static methods // Returns the bits that represents this number. @@ -390,17 +387,6 @@ class FloatingPoint { FloatingPointUnion u_; }; -// We cannot use std::numeric_limits::max() as it clashes with the max() -// macro defined by . -template <> -inline float FloatingPoint::Max() { - return FLT_MAX; -} -template <> -inline double FloatingPoint::Max() { - return DBL_MAX; -} - // Typedefs the instances of the FloatingPoint template class that we // care to use. typedef FloatingPoint Float; From 408471e20cfaa7ccd585fe5e1c6e7b6fba8ce06e Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 24 Jan 2023 10:12:28 -0800 Subject: [PATCH 082/336] Fix formatting of Markdown files PiperOrigin-RevId: 504308485 Change-Id: Ia4ae97b2173b44b89aa5d987ddefd6e0c1488386 --- CONTRIBUTING.md | 26 ++++++++++++++++++-------- googletest/README.md | 28 +++++++++++++++++++++------- 2 files changed, 39 insertions(+), 15 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 423b06751..8bed14b26 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -102,30 +102,40 @@ To make sure your changes work as intended and don't break existing functionality, you'll want to compile and run Google Test and GoogleMock's own tests. For that you can use CMake: - mkdir mybuild - cd mybuild - cmake -Dgtest_build_tests=ON -Dgmock_build_tests=ON ${GTEST_REPO_DIR} +``` +mkdir mybuild +cd mybuild +cmake -Dgtest_build_tests=ON -Dgmock_build_tests=ON ${GTEST_REPO_DIR} +``` To choose between building only Google Test or Google Mock, you may modify your cmake command to be one of each - cmake -Dgtest_build_tests=ON ${GTEST_DIR} # sets up Google Test tests - cmake -Dgmock_build_tests=ON ${GMOCK_DIR} # sets up Google Mock tests +``` +cmake -Dgtest_build_tests=ON ${GTEST_DIR} # sets up Google Test tests +cmake -Dgmock_build_tests=ON ${GMOCK_DIR} # sets up Google Mock tests +``` Make sure you have Python installed, as some of Google Test's tests are written in Python. If the cmake command complains about not being able to find Python (`Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE)`), try telling it explicitly where your Python executable can be found: - cmake -DPYTHON_EXECUTABLE=path/to/python ... +``` +cmake -DPYTHON_EXECUTABLE=path/to/python ... +``` Next, you can build Google Test and / or Google Mock and all desired tests. On \*nix, this is usually done by - make +``` +make +``` To run the tests, do - make test +``` +make test +``` All tests should pass. diff --git a/googletest/README.md b/googletest/README.md index ae2fce140..995834e46 100644 --- a/googletest/README.md +++ b/googletest/README.md @@ -152,11 +152,15 @@ GoogleTest is thread-safe where the pthread library is available. After If GoogleTest doesn't correctly detect whether pthread is available in your environment, you can force it with - -DGTEST_HAS_PTHREAD=1 +``` +-DGTEST_HAS_PTHREAD=1 +``` or - -DGTEST_HAS_PTHREAD=0 +``` +-DGTEST_HAS_PTHREAD=0 +``` When GoogleTest uses pthread, you may need to add flags to your compiler and/or linker to select the pthread library, or you'll get link errors. If you use the @@ -172,14 +176,18 @@ as a DLL on Windows) if you prefer. To compile *gtest* as a shared library, add - -DGTEST_CREATE_SHARED_LIBRARY=1 +``` +-DGTEST_CREATE_SHARED_LIBRARY=1 +``` to the compiler flags. You'll also need to tell the linker to produce a shared library instead - consult your linker's manual for how to do it. To compile your *tests* that use the gtest shared library, add - -DGTEST_LINKED_AS_SHARED_LIBRARY=1 +``` +-DGTEST_LINKED_AS_SHARED_LIBRARY=1 +``` to the compiler flags. @@ -200,7 +208,9 @@ rename its macro to avoid the conflict. Specifically, if both GoogleTest and some other code define macro FOO, you can add - -DGTEST_DONT_DEFINE_FOO=1 +``` +-DGTEST_DONT_DEFINE_FOO=1 +``` to the compiler flags to tell GoogleTest to change the macro's name from `FOO` to `GTEST_FOO`. Currently `FOO` can be `ASSERT_EQ`, `ASSERT_FALSE`, `ASSERT_GE`, @@ -208,10 +218,14 @@ to `GTEST_FOO`. Currently `FOO` can be `ASSERT_EQ`, `ASSERT_FALSE`, `ASSERT_GE`, `EXPECT_FALSE`, `EXPECT_TRUE`, `FAIL`, `SUCCEED`, `TEST`, or `TEST_F`. For example, with `-DGTEST_DONT_DEFINE_TEST=1`, you'll need to write - GTEST_TEST(SomeTest, DoesThis) { ... } +``` +GTEST_TEST(SomeTest, DoesThis) { ... } +``` instead of - TEST(SomeTest, DoesThis) { ... } +``` +TEST(SomeTest, DoesThis) { ... } +``` in order to define a test. From 2491710524094dc3b77cfa4e8eda2ba8edb0d91c Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 24 Jan 2023 11:09:35 -0800 Subject: [PATCH 083/336] Fix formatting of C++ files PiperOrigin-RevId: 504325204 Change-Id: Iaa1d6d0ab1dccaaeef26f9cb109d530835499240 --- googlemock/include/gmock/gmock-actions.h | 52 +++++++++---------- .../include/gmock/gmock-function-mocker.h | 5 +- googlemock/include/gmock/gmock-matchers.h | 7 ++- googlemock/include/gmock/gmock-more-actions.h | 21 ++++---- googlemock/test/gmock-actions_test.cc | 4 +- googlemock/test/gmock-matchers-misc_test.cc | 4 +- googlemock/test/gmock-matchers_test.h | 6 +-- googletest/include/gtest/gtest-param-test.h | 3 +- googletest/include/gtest/gtest-typed-test.h | 34 ++++++------ googletest/include/gtest/gtest.h | 4 +- .../include/gtest/internal/gtest-param-util.h | 2 +- .../include/gtest/internal/gtest-port.h | 2 +- googletest/src/gtest-filepath.cc | 13 ++--- googletest/src/gtest.cc | 6 +-- googletest/test/googletest-printers-test.cc | 6 +-- 15 files changed, 84 insertions(+), 85 deletions(-) diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h index aad07d51c..a6c2489f5 100644 --- a/googlemock/include/gmock/gmock-actions.h +++ b/googlemock/include/gmock/gmock-actions.h @@ -1420,19 +1420,19 @@ struct WithArgsAction { // providing a call operator because even with a particular set of arguments // they don't have a fixed return type. - template >...)>>::value, - int>::type = 0> + template < + typename R, typename... Args, + typename std::enable_if< + std::is_convertible>...)>>::value, + int>::type = 0> operator OnceAction() && { // NOLINT struct OA { OnceAction> inner_action; @@ -1447,19 +1447,19 @@ struct WithArgsAction { return OA{std::move(inner_action)}; } - template >...)>>::value, - int>::type = 0> + template < + typename R, typename... Args, + typename std::enable_if< + std::is_convertible>...)>>::value, + int>::type = 0> operator Action() const { // NOLINT Action> converted(inner_action); diff --git a/googlemock/include/gmock/gmock-function-mocker.h b/googlemock/include/gmock/gmock-function-mocker.h index 73065493b..1a1f126e4 100644 --- a/googlemock/include/gmock/gmock-function-mocker.h +++ b/googlemock/include/gmock/gmock-function-mocker.h @@ -180,8 +180,9 @@ using internal::FunctionMocker; _Signature)>::Result \ GMOCK_INTERNAL_EXPAND(_CallType) \ _MethodName(GMOCK_PP_REPEAT(GMOCK_INTERNAL_PARAMETER, _Signature, _N)) \ - GMOCK_PP_IF(_Constness, const, ) _RefSpec _NoexceptSpec \ - GMOCK_PP_IF(_Override, override, ) GMOCK_PP_IF(_Final, final, ) { \ + GMOCK_PP_IF(_Constness, const, ) \ + _RefSpec _NoexceptSpec GMOCK_PP_IF(_Override, override, ) \ + GMOCK_PP_IF(_Final, final, ) { \ GMOCK_MOCKER_(_N, _Constness, _MethodName) \ .SetOwnerAndName(this, #_MethodName); \ return GMOCK_MOCKER_(_N, _Constness, _MethodName) \ diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index 9e634f7f1..fc00c3560 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -3317,8 +3317,8 @@ class FieldsAreMatcherImpl> std::vector inner_listener(sizeof...(I)); VariadicExpand( - {failed_pos == ~size_t{}&& !std::get(matchers_).MatchAndExplain( - std::get(tuple), &inner_listener[I]) + {failed_pos == ~size_t{} && !std::get(matchers_).MatchAndExplain( + std::get(tuple), &inner_listener[I]) ? failed_pos = I : 0 ...}); if (failed_pos != ~size_t{}) { @@ -5474,8 +5474,7 @@ PolymorphicMatcher> ThrowsMessage( inline name##Matcher GMOCK_INTERNAL_WARNING_PUSH() \ GMOCK_INTERNAL_WARNING_CLANG(ignored, "-Wunused-function") \ GMOCK_INTERNAL_WARNING_CLANG(ignored, "-Wunused-member-function") \ - name \ - GMOCK_INTERNAL_WARNING_POP()() { \ + name GMOCK_INTERNAL_WARNING_POP()() { \ return {}; \ } \ template \ diff --git a/googlemock/include/gmock/gmock-more-actions.h b/googlemock/include/gmock/gmock-more-actions.h index 148ac0172..78169b1d0 100644 --- a/googlemock/include/gmock/gmock-more-actions.h +++ b/googlemock/include/gmock/gmock-more-actions.h @@ -526,9 +526,10 @@ GMOCK_INTERNAL_LIST_##value_params)){}) \ GMOCK_ACTION_CLASS_(name, value_params)(const GMOCK_ACTION_CLASS_( \ name, value_params) &) noexcept GMOCK_INTERNAL_DEFN_COPY_ \ - ##value_params GMOCK_ACTION_CLASS_(name, value_params)( \ - GMOCK_ACTION_CLASS_(name, value_params) &&) noexcept \ - GMOCK_INTERNAL_DEFN_COPY_##value_params template \ + ##value_params \ + GMOCK_ACTION_CLASS_(name, value_params)(GMOCK_ACTION_CLASS_( \ + name, value_params) &&) noexcept GMOCK_INTERNAL_DEFN_COPY_ \ + ##value_params template \ operator ::testing::Action() const { \ return GMOCK_PP_IF( \ GMOCK_PP_IS_EMPTY(GMOCK_INTERNAL_COUNT_##value_params), \ @@ -602,13 +603,13 @@ template struct InvokeArgumentAction { template ::type> - auto operator()(Args&&... args) const -> decltype(internal::InvokeArgument( + auto operator()(Args &&...args) const -> decltype(internal::InvokeArgument( std::get(std::forward_as_tuple(std::forward(args)...)), - std::declval()...)) { - internal::FlatTuple args_tuple(FlatTupleConstructTag{}, - std::forward(args)...); - return params.Apply([&](const Params&... unpacked_params) { - auto&& callable = args_tuple.template Get(); + std::declval()...)) { + internal::FlatTuple args_tuple(FlatTupleConstructTag{}, + std::forward(args)...); + return params.Apply([&](const Params &...unpacked_params) { + auto &&callable = args_tuple.template Get(); return internal::InvokeArgument( std::forward(callable), unpacked_params...); }); @@ -648,7 +649,7 @@ struct InvokeArgumentAction { // later. template internal::InvokeArgumentAction::type...> -InvokeArgument(Params&&... params) { +InvokeArgument(Params &&...params) { return {internal::FlatTuple::type...>( internal::FlatTupleConstructTag{}, std::forward(params)...)}; } diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc index 510d15c8d..295470ec1 100644 --- a/googlemock/test/gmock-actions_test.cc +++ b/googlemock/test/gmock-actions_test.cc @@ -1410,7 +1410,7 @@ TEST(DoAll, ProvidesLvalueReferencesToInitialActions) { void operator()(Obj&&) const { FAIL() << "Unexpected call"; } }; - MockFunction mock; + MockFunction mock; EXPECT_CALL(mock, Call) .WillOnce(DoAll(InitialAction{}, InitialAction{}, [](Obj&&) {})) .WillRepeatedly(DoAll(InitialAction{}, InitialAction{}, [](Obj&&) {})); @@ -1438,7 +1438,7 @@ TEST(DoAll, ProvidesLvalueReferencesToInitialActions) { void operator()(Obj&) && {} }; - MockFunction mock; + MockFunction mock; EXPECT_CALL(mock, Call) .WillOnce(DoAll(InitialAction{}, InitialAction{}, [](Obj&&) {})); diff --git a/googlemock/test/gmock-matchers-misc_test.cc b/googlemock/test/gmock-matchers-misc_test.cc index 42a0e44d7..f99bbf4f1 100644 --- a/googlemock/test/gmock-matchers-misc_test.cc +++ b/googlemock/test/gmock-matchers-misc_test.cc @@ -1792,8 +1792,8 @@ TEST(ThrowsPredicateCompilesTest, ExceptionMatcherAcceptsBroadType) { { Matcher inner = Eq(10); Matcher> matcher = Throws(inner); - EXPECT_TRUE(matcher.Matches([]() { throw(uint32_t) 10; })); - EXPECT_FALSE(matcher.Matches([]() { throw(uint32_t) 11; })); + EXPECT_TRUE(matcher.Matches([]() { throw (uint32_t)10; })); + EXPECT_FALSE(matcher.Matches([]() { throw (uint32_t)11; })); } } diff --git a/googlemock/test/gmock-matchers_test.h b/googlemock/test/gmock-matchers_test.h index 6c986e9ff..56956076d 100644 --- a/googlemock/test/gmock-matchers_test.h +++ b/googlemock/test/gmock-matchers_test.h @@ -148,9 +148,9 @@ class GreaterThanMatcher : public MatcherInterface { }; // Names and instantiates a new instance of GTestMatcherTestP. -#define INSTANTIATE_GTEST_MATCHER_TEST_P(TestSuite) \ - using TestSuite##P = GTestMatcherTestP; \ - INSTANTIATE_TEST_SUITE_P(MatcherInterface, TestSuite##P, Values(false)); \ +#define INSTANTIATE_GTEST_MATCHER_TEST_P(TestSuite) \ + using TestSuite##P = GTestMatcherTestP; \ + INSTANTIATE_TEST_SUITE_P(MatcherInterface, TestSuite##P, Values(false)); \ INSTANTIATE_TEST_SUITE_P(GtestMatcher, TestSuite##P, Values(true)) class GTestMatcherTestP : public testing::TestWithParam { diff --git a/googletest/include/gtest/gtest-param-test.h b/googletest/include/gtest/gtest-param-test.h index 1adb9a725..49a47ead0 100644 --- a/googletest/include/gtest/gtest-param-test.h +++ b/googletest/include/gtest/gtest-param-test.h @@ -449,7 +449,8 @@ internal::ParamConverterGenerator ConvertGenerator( #define TEST_P(test_suite_name, test_name) \ class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \ - : public test_suite_name, private ::testing::internal::GTestNonCopyable {\ + : public test_suite_name, \ + private ::testing::internal::GTestNonCopyable { \ public: \ GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() {} \ void TestBody() override; \ diff --git a/googletest/include/gtest/gtest-typed-test.h b/googletest/include/gtest/gtest-typed-test.h index bd35a3266..72de536bc 100644 --- a/googletest/include/gtest/gtest-typed-test.h +++ b/googletest/include/gtest/gtest-typed-test.h @@ -267,28 +267,28 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes); TYPED_TEST_SUITE_P #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ -#define TYPED_TEST_P(SuiteName, TestName) \ - namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \ - template \ - class TestName : public SuiteName { \ - private: \ - typedef SuiteName TestFixture; \ - typedef gtest_TypeParam_ TypeParam; \ - void TestBody() override; \ - }; \ - static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \ - GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).AddTestName( \ - __FILE__, __LINE__, GTEST_STRINGIFY_(SuiteName), \ - GTEST_STRINGIFY_(TestName)); \ - } \ - template \ - void GTEST_SUITE_NAMESPACE_( \ +#define TYPED_TEST_P(SuiteName, TestName) \ + namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \ + template \ + class TestName : public SuiteName { \ + private: \ + typedef SuiteName TestFixture; \ + typedef gtest_TypeParam_ TypeParam; \ + void TestBody() override; \ + }; \ + static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \ + GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).AddTestName( \ + __FILE__, __LINE__, GTEST_STRINGIFY_(SuiteName), \ + GTEST_STRINGIFY_(TestName)); \ + } \ + template \ + void GTEST_SUITE_NAMESPACE_( \ SuiteName)::TestName::TestBody() // Note: this won't work correctly if the trailing arguments are macros. #define REGISTER_TYPED_TEST_SUITE_P(SuiteName, ...) \ namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \ - typedef ::testing::internal::Templates<__VA_ARGS__> gtest_AllTests_; \ + typedef ::testing::internal::Templates<__VA_ARGS__> gtest_AllTests_; \ } \ static const char* const GTEST_REGISTERED_TEST_NAMES_( \ SuiteName) GTEST_ATTRIBUTE_UNUSED_ = \ diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index 3e452a503..c4e01adf9 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -201,8 +201,8 @@ std::set* GetIgnoredParameterizedTestSuites(); class GTestNonCopyable { public: GTestNonCopyable() = default; - GTestNonCopyable(const GTestNonCopyable &) = delete; - GTestNonCopyable &operator=(const GTestNonCopyable &) = delete; + GTestNonCopyable(const GTestNonCopyable&) = delete; + GTestNonCopyable& operator=(const GTestNonCopyable&) = delete; ~GTestNonCopyable() = default; }; diff --git a/googletest/include/gtest/internal/gtest-param-util.h b/googletest/include/gtest/internal/gtest-param-util.h index 7092d10e6..358ef72c7 100644 --- a/googletest/include/gtest/internal/gtest-param-util.h +++ b/googletest/include/gtest/internal/gtest-param-util.h @@ -956,7 +956,7 @@ class CartesianProductHolder { template class ParamGeneratorConverter : public ParamGeneratorInterface { public: - ParamGeneratorConverter(ParamGenerator gen) // NOLINT + ParamGeneratorConverter(ParamGenerator gen) // NOLINT : generator_(std::move(gen)) {} ParamIteratorInterface* Begin() const override { diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 6db191b7a..b4fa3f07e 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -712,7 +712,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \ __attribute__((format(__MINGW_PRINTF_FORMAT, string_index, first_to_check))) #elif GTEST_HAVE_ATTRIBUTE_(format) -#define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \ +#define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) \ __attribute__((format(printf, string_index, first_to_check))) #else #define GTEST_ATTRIBUTE_PRINTF_(string_index, first_to_check) diff --git a/googletest/src/gtest-filepath.cc b/googletest/src/gtest-filepath.cc index 9d79ea49d..940585db9 100644 --- a/googletest/src/gtest-filepath.cc +++ b/googletest/src/gtest-filepath.cc @@ -148,20 +148,19 @@ const char* FilePath::FindLastPathSeparator() const { } size_t FilePath::CalculateRootLength() const { - const auto &path = pathname_; + const auto& path = pathname_; auto s = path.begin(); auto end = path.end(); #if GTEST_OS_WINDOWS - if (end - s >= 2 && s[1] == ':' && - (end - s == 2 || IsPathSeparator(s[2])) && + if (end - s >= 2 && s[1] == ':' && (end - s == 2 || IsPathSeparator(s[2])) && (('A' <= s[0] && s[0] <= 'Z') || ('a' <= s[0] && s[0] <= 'z'))) { // A typical absolute path like "C:\Windows" or "D:" s += 2; if (s != end) { ++s; } - } else if (end - s >= 3 && IsPathSeparator(*s) && IsPathSeparator(*(s + 1)) - && !IsPathSeparator(*(s + 2))) { + } else if (end - s >= 3 && IsPathSeparator(*s) && IsPathSeparator(*(s + 1)) && + !IsPathSeparator(*(s + 2))) { // Move past the "\\" prefix in a UNC path like "\\Server\Share\Folder" s += 2; // Skip 2 components and their following separators ("Server\" and "Share\") @@ -295,9 +294,7 @@ bool FilePath::IsRootDirectory() const { } // Returns true if pathname describes an absolute path. -bool FilePath::IsAbsolutePath() const { - return CalculateRootLength() > 0; -} +bool FilePath::IsAbsolutePath() const { return CalculateRootLength() > 0; } // Returns a pathname for a file that does not currently exist. The pathname // will be directory/base_name.extension or diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index a64e887c9..19acb1cc7 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -1134,8 +1134,8 @@ class Timer { // Return time elapsed in milliseconds since the timer was created. TimeInMillis Elapsed() { - return std::chrono::duration_cast( - clock::now() - start_) + return std::chrono::duration_cast(clock::now() - + start_) .count(); } @@ -6172,7 +6172,7 @@ void UnitTestImpl::ListTestsMatchingFilter() { } } fflush(stdout); - #if GTEST_HAS_FILE_SYSTEM +#if GTEST_HAS_FILE_SYSTEM const std::string& output_format = UnitTestOptions::GetOutputFormat(); if (output_format == "xml" || output_format == "json") { FILE* fileout = OpenFileForWriting( diff --git a/googletest/test/googletest-printers-test.cc b/googletest/test/googletest-printers-test.cc index 8a7db25b0..34aa92457 100644 --- a/googletest/test/googletest-printers-test.cc +++ b/googletest/test/googletest-printers-test.cc @@ -461,10 +461,10 @@ TEST(PrintBuiltInTypeTest, FloatingPoints) { // float (32-bit precision) EXPECT_EQ("1.5", Print(1.5f)); - EXPECT_EQ("1.0999999", Print(1.09999990f)); - EXPECT_EQ("1.1", Print(1.10000002f)); + EXPECT_EQ("1.0999999", Print(1.09999990f)); + EXPECT_EQ("1.1", Print(1.10000002f)); EXPECT_EQ("1.10000014", Print(1.10000014f)); - EXPECT_EQ("9e+09", Print(9e9f)); + EXPECT_EQ("9e+09", Print(9e9f)); // double EXPECT_EQ("-2.5", Print(-2.5)); // double From 6c65a1ca359052e9fd671b550fe748056be74af6 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 25 Jan 2023 08:31:33 -0800 Subject: [PATCH 084/336] Replace numeric lints with their string equivalent PiperOrigin-RevId: 504570278 Change-Id: Iab9c988b3a781eaafbdd97c924a74c2269125799 --- googletest/test/googletest-filter-unittest.py | 8 ++++---- googletest/test/gtest_test_utils.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/googletest/test/googletest-filter-unittest.py b/googletest/test/googletest-filter-unittest.py index 02fd1dfba..6b2351812 100755 --- a/googletest/test/googletest-filter-unittest.py +++ b/googletest/test/googletest-filter-unittest.py @@ -285,13 +285,13 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase): # into a process using the environment variable. However, we can still # test the case when the variable is not supplied (i.e., gtest_filter is # None). - # pylint: disable-msg=C6403 + # pylint: disable=g-explicit-bool-comparison if CAN_TEST_EMPTY_FILTER or gtest_filter != '': SetEnvVar(FILTER_ENV_VAR, gtest_filter) tests_run = RunAndExtractTestList()[0] SetEnvVar(FILTER_ENV_VAR, None) self.AssertSetEqual(tests_run, tests_to_run) - # pylint: enable-msg=C6403 + # pylint: enable=g-explicit-bool-comparison # Next, tests using the command line flag. @@ -328,7 +328,7 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase): # into a process using the environment variable. However, we can still # test the case when the variable is not supplied (i.e., gtest_filter is # None). - # pylint: disable-msg=C6403 + # pylint: disable=g-explicit-bool-comparison if CAN_TEST_EMPTY_FILTER or gtest_filter != '': SetEnvVar(FILTER_ENV_VAR, gtest_filter) partition = [] @@ -340,7 +340,7 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase): self.AssertPartitionIsValid(tests_to_run, partition) SetEnvVar(FILTER_ENV_VAR, None) - # pylint: enable-msg=C6403 + # pylint: enable=g-explicit-bool-comparison def RunAndVerifyAllowingDisabled(self, gtest_filter, tests_to_run): """Checks that the binary runs correct set of tests for the given filter. diff --git a/googletest/test/gtest_test_utils.py b/googletest/test/gtest_test_utils.py index eecc53346..459f9ea32 100755 --- a/googletest/test/gtest_test_utils.py +++ b/googletest/test/gtest_test_utils.py @@ -29,7 +29,7 @@ """Unit test utilities for Google C++ Testing and Mocking Framework.""" # Suppresses the 'Import not at the top of the file' lint complaint. -# pylint: disable-msg=C6204 +# pylint: disable=g-import-not-at-top import os import subprocess @@ -43,7 +43,7 @@ import atexit import shutil import tempfile import unittest as _test_module -# pylint: enable-msg=C6204 +# pylint: enable=g-import-not-at-top GTEST_OUTPUT_VAR_NAME = 'GTEST_OUTPUT' From d1ad27e0a4ba67161f554da25c5f281ec1e94c44 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 25 Jan 2023 09:13:35 -0800 Subject: [PATCH 085/336] Fix formatting in subset of Python files These files were formatted with automated tools. The remaining Python files require some manual fix ups, so they will be fixed separately. PiperOrigin-RevId: 504579820 Change-Id: I3923bd414bffe3ded6163ec496cd09ace3951928 --- googlemock/test/gmock_leak_test.py | 55 +- googlemock/test/gmock_output_test.py | 12 +- .../googletest-break-on-failure-unittest.py | 67 +- .../test/googletest-catch-exceptions-test.py | 162 ++- googletest/test/googletest-color-test.py | 1 + googletest/test/googletest-env-var-test.py | 2 +- .../test/googletest-failfast-unittest.py | 197 ++- googletest/test/googletest-filter-unittest.py | 376 +++-- .../googletest-global-environment-unittest.py | 87 +- .../test/googletest-json-outfiles-test.py | 146 +- .../test/googletest-json-output-unittest.py | 1294 ++++++++--------- .../test/googletest-list-tests-unittest.py | 69 +- googletest/test/googletest-output-test.py | 164 ++- ...oogletest-param-test-invalid-name1-test.py | 2 +- ...oogletest-param-test-invalid-name2-test.py | 3 +- .../test/googletest-setuptestsuite-test.py | 16 +- .../test/googletest-throw-on-failure-test.py | 54 +- .../test/googletest-uninitialized-test.py | 7 +- googletest/test/gtest_help_test.py | 54 +- googletest/test/gtest_json_test_utils.py | 2 + googletest/test/gtest_list_output_unittest.py | 27 +- .../test/gtest_skip_check_output_test.py | 3 +- ...test_skip_environment_check_output_test.py | 3 +- googletest/test/gtest_xml_outfiles_test.py | 15 +- 24 files changed, 1475 insertions(+), 1343 deletions(-) diff --git a/googlemock/test/gmock_leak_test.py b/googlemock/test/gmock_leak_test.py index 9d142d34b..8b02bc465 100755 --- a/googlemock/test/gmock_leak_test.py +++ b/googlemock/test/gmock_leak_test.py @@ -54,50 +54,59 @@ class GMockLeakTest(gmock_test_utils.TestCase): def testCatchesLeakedMockByDefault(self): self.assertNotEqual( 0, - gmock_test_utils.Subprocess(TEST_WITH_EXPECT_CALL, - env=environ).exit_code) + gmock_test_utils.Subprocess( + TEST_WITH_EXPECT_CALL, env=environ + ).exit_code, + ) self.assertNotEqual( - 0, - gmock_test_utils.Subprocess(TEST_WITH_ON_CALL, - env=environ).exit_code) + 0, gmock_test_utils.Subprocess(TEST_WITH_ON_CALL, env=environ).exit_code + ) def testDoesNotCatchLeakedMockWhenDisabled(self): self.assertEqual( 0, - gmock_test_utils.Subprocess(TEST_WITH_EXPECT_CALL + - ['--gmock_catch_leaked_mocks=0'], - env=environ).exit_code) + gmock_test_utils.Subprocess( + TEST_WITH_EXPECT_CALL + ['--gmock_catch_leaked_mocks=0'], + env=environ, + ).exit_code, + ) self.assertEqual( 0, - gmock_test_utils.Subprocess(TEST_WITH_ON_CALL + - ['--gmock_catch_leaked_mocks=0'], - env=environ).exit_code) + gmock_test_utils.Subprocess( + TEST_WITH_ON_CALL + ['--gmock_catch_leaked_mocks=0'], env=environ + ).exit_code, + ) def testCatchesLeakedMockWhenEnabled(self): self.assertNotEqual( 0, - gmock_test_utils.Subprocess(TEST_WITH_EXPECT_CALL + - ['--gmock_catch_leaked_mocks'], - env=environ).exit_code) + gmock_test_utils.Subprocess( + TEST_WITH_EXPECT_CALL + ['--gmock_catch_leaked_mocks'], env=environ + ).exit_code, + ) self.assertNotEqual( 0, - gmock_test_utils.Subprocess(TEST_WITH_ON_CALL + - ['--gmock_catch_leaked_mocks'], - env=environ).exit_code) + gmock_test_utils.Subprocess( + TEST_WITH_ON_CALL + ['--gmock_catch_leaked_mocks'], env=environ + ).exit_code, + ) def testCatchesLeakedMockWhenEnabledWithExplictFlagValue(self): self.assertNotEqual( 0, - gmock_test_utils.Subprocess(TEST_WITH_EXPECT_CALL + - ['--gmock_catch_leaked_mocks=1'], - env=environ).exit_code) + gmock_test_utils.Subprocess( + TEST_WITH_EXPECT_CALL + ['--gmock_catch_leaked_mocks=1'], + env=environ, + ).exit_code, + ) def testCatchesMultipleLeakedMocks(self): self.assertNotEqual( 0, - gmock_test_utils.Subprocess(TEST_MULTIPLE_LEAKS + - ['--gmock_catch_leaked_mocks'], - env=environ).exit_code) + gmock_test_utils.Subprocess( + TEST_MULTIPLE_LEAKS + ['--gmock_catch_leaked_mocks'], env=environ + ).exit_code, + ) if __name__ == '__main__': diff --git a/googlemock/test/gmock_output_test.py b/googlemock/test/gmock_output_test.py index d7c3f27e8..7c24d6832 100755 --- a/googlemock/test/gmock_output_test.py +++ b/googlemock/test/gmock_output_test.py @@ -39,7 +39,7 @@ gmock_output_test.py """ -from io import open # pylint: disable=redefined-builtin, g-importing-member +from io import open # pylint: disable=redefined-builtin, g-importing-member import os import re import sys @@ -168,9 +168,13 @@ class GMockOutputTest(gmock_test_utils.TestCase): # The raw output should contain 2 leaked mock object errors for # test GMockOutputTest.CatchesLeakedMocks. - self.assertEqual(['GMockOutputTest.CatchesLeakedMocks', - 'GMockOutputTest.CatchesLeakedMocks'], - leaky_tests) + self.assertEqual( + [ + 'GMockOutputTest.CatchesLeakedMocks', + 'GMockOutputTest.CatchesLeakedMocks', + ], + leaky_tests, + ) if __name__ == '__main__': diff --git a/googletest/test/googletest-break-on-failure-unittest.py b/googletest/test/googletest-break-on-failure-unittest.py index c5c0b1571..3f65812be 100755 --- a/googletest/test/googletest-break-on-failure-unittest.py +++ b/googletest/test/googletest-break-on-failure-unittest.py @@ -59,7 +59,8 @@ CATCH_EXCEPTIONS_ENV_VAR = 'GTEST_CATCH_EXCEPTIONS' # Path to the googletest-break-on-failure-unittest_ program. EXE_PATH = gtest_test_utils.GetTestExecutablePath( - 'googletest-break-on-failure-unittest_') + 'googletest-break-on-failure-unittest_' +) environ = gtest_test_utils.environ @@ -98,11 +99,11 @@ class GTestBreakOnFailureUnitTest(gtest_test_utils.TestCase): Args: env_var_value: value of the GTEST_BREAK_ON_FAILURE environment - variable; None if the variable should be unset. - flag_value: value of the --gtest_break_on_failure flag; - None if the flag should not be present. - expect_seg_fault: 1 if the program is expected to generate a seg-fault; - 0 otherwise. + variable; None if the variable should be unset. + flag_value: value of the --gtest_break_on_failure flag; None if the + flag should not be present. + expect_seg_fault: 1 if the program is expected to generate a seg-fault; 0 + otherwise. """ SetEnvVar(BREAK_ON_FAILURE_ENV_VAR, env_var_value) @@ -132,74 +133,56 @@ class GTestBreakOnFailureUnitTest(gtest_test_utils.TestCase): SetEnvVar(BREAK_ON_FAILURE_ENV_VAR, None) - msg = ('when %s%s, an assertion failure in "%s" %s cause a seg-fault.' % - (BREAK_ON_FAILURE_ENV_VAR, env_var_value_msg, ' '.join(command), - should_or_not)) + msg = 'when %s%s, an assertion failure in "%s" %s cause a seg-fault.' % ( + BREAK_ON_FAILURE_ENV_VAR, + env_var_value_msg, + ' '.join(command), + should_or_not, + ) self.assertTrue(has_seg_fault == expect_seg_fault, msg) def testDefaultBehavior(self): """Tests the behavior of the default mode.""" - self.RunAndVerify(env_var_value=None, - flag_value=None, - expect_seg_fault=0) + self.RunAndVerify(env_var_value=None, flag_value=None, expect_seg_fault=0) def testEnvVar(self): """Tests using the GTEST_BREAK_ON_FAILURE environment variable.""" - self.RunAndVerify(env_var_value='0', - flag_value=None, - expect_seg_fault=0) - self.RunAndVerify(env_var_value='1', - flag_value=None, - expect_seg_fault=1) + self.RunAndVerify(env_var_value='0', flag_value=None, expect_seg_fault=0) + self.RunAndVerify(env_var_value='1', flag_value=None, expect_seg_fault=1) def testFlag(self): """Tests using the --gtest_break_on_failure flag.""" - self.RunAndVerify(env_var_value=None, - flag_value='0', - expect_seg_fault=0) - self.RunAndVerify(env_var_value=None, - flag_value='1', - expect_seg_fault=1) + self.RunAndVerify(env_var_value=None, flag_value='0', expect_seg_fault=0) + self.RunAndVerify(env_var_value=None, flag_value='1', expect_seg_fault=1) def testFlagOverridesEnvVar(self): """Tests that the flag overrides the environment variable.""" - self.RunAndVerify(env_var_value='0', - flag_value='0', - expect_seg_fault=0) - self.RunAndVerify(env_var_value='0', - flag_value='1', - expect_seg_fault=1) - self.RunAndVerify(env_var_value='1', - flag_value='0', - expect_seg_fault=0) - self.RunAndVerify(env_var_value='1', - flag_value='1', - expect_seg_fault=1) + self.RunAndVerify(env_var_value='0', flag_value='0', expect_seg_fault=0) + self.RunAndVerify(env_var_value='0', flag_value='1', expect_seg_fault=1) + self.RunAndVerify(env_var_value='1', flag_value='0', expect_seg_fault=0) + self.RunAndVerify(env_var_value='1', flag_value='1', expect_seg_fault=1) def testBreakOnFailureOverridesThrowOnFailure(self): """Tests that gtest_break_on_failure overrides gtest_throw_on_failure.""" SetEnvVar(THROW_ON_FAILURE_ENV_VAR, '1') try: - self.RunAndVerify(env_var_value=None, - flag_value='1', - expect_seg_fault=1) + self.RunAndVerify(env_var_value=None, flag_value='1', expect_seg_fault=1) finally: SetEnvVar(THROW_ON_FAILURE_ENV_VAR, None) if IS_WINDOWS: + def testCatchExceptionsDoesNotInterfere(self): """Tests that gtest_catch_exceptions doesn't interfere.""" SetEnvVar(CATCH_EXCEPTIONS_ENV_VAR, '1') try: - self.RunAndVerify(env_var_value='1', - flag_value='1', - expect_seg_fault=1) + self.RunAndVerify(env_var_value='1', flag_value='1', expect_seg_fault=1) finally: SetEnvVar(CATCH_EXCEPTIONS_ENV_VAR, None) diff --git a/googletest/test/googletest-catch-exceptions-test.py b/googletest/test/googletest-catch-exceptions-test.py index 07f15826b..a850ea4a7 100755 --- a/googletest/test/googletest-catch-exceptions-test.py +++ b/googletest/test/googletest-catch-exceptions-test.py @@ -46,12 +46,14 @@ FILTER_FLAG = FLAG_PREFIX + 'filter' # Path to the googletest-catch-exceptions-ex-test_ binary, compiled with # exceptions enabled. EX_EXE_PATH = gtest_test_utils.GetTestExecutablePath( - 'googletest-catch-exceptions-ex-test_') + 'googletest-catch-exceptions-ex-test_' +) # Path to the googletest-catch-exceptions-test_ binary, compiled with # exceptions disabled. EXE_PATH = gtest_test_utils.GetTestExecutablePath( - 'googletest-catch-exceptions-no-ex-test_') + 'googletest-catch-exceptions-no-ex-test_' +) environ = gtest_test_utils.environ SetEnvVar = gtest_test_utils.SetEnvVar @@ -64,7 +66,8 @@ SetEnvVar = gtest_test_utils.SetEnvVar SetEnvVar(gtest_test_utils.PREMATURE_EXIT_FILE_ENV_VAR, None) TEST_LIST = gtest_test_utils.Subprocess( - [EXE_PATH, LIST_TESTS_FLAG], env=environ).output + [EXE_PATH, LIST_TESTS_FLAG], env=environ +).output SUPPORTS_SEH_EXCEPTIONS = 'ThrowsSehException' in TEST_LIST @@ -72,7 +75,8 @@ if SUPPORTS_SEH_EXCEPTIONS: BINARY_OUTPUT = gtest_test_utils.Subprocess([EXE_PATH], env=environ).output EX_BINARY_OUTPUT = gtest_test_utils.Subprocess( - [EX_EXE_PATH], env=environ).output + [EX_EXE_PATH], env=environ +).output # The tests. @@ -123,18 +127,20 @@ if SUPPORTS_SEH_EXCEPTIONS: class CatchCxxExceptionsTest(gtest_test_utils.TestCase): """Tests C++ exception-catching behavior. - Tests in this test case verify that: - * C++ exceptions are caught and logged as C++ (not SEH) exceptions - * Exception thrown affect the remainder of the test work flow in the - expected manner. + Tests in this test case verify that: + * C++ exceptions are caught and logged as C++ (not SEH) exceptions + * Exception thrown affect the remainder of the test work flow in the + expected manner. """ def testCatchesCxxExceptionsInFixtureConstructor(self): self.assertTrue( 'C++ exception with description ' '"Standard C++ exception" thrown ' - 'in the test fixture\'s constructor' in EX_BINARY_OUTPUT, - EX_BINARY_OUTPUT) + "in the test fixture's constructor" + in EX_BINARY_OUTPUT, + EX_BINARY_OUTPUT, + ) self.assertTrue( 'unexpected' not in EX_BINARY_OUTPUT, ( @@ -144,60 +150,94 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase): ), ) - if ('CxxExceptionInDestructorTest.ThrowsExceptionInDestructor' in - EX_BINARY_OUTPUT): + if ( + 'CxxExceptionInDestructorTest.ThrowsExceptionInDestructor' + in EX_BINARY_OUTPUT + ): def testCatchesCxxExceptionsInFixtureDestructor(self): self.assertTrue( 'C++ exception with description ' '"Standard C++ exception" thrown ' - 'in the test fixture\'s destructor' in EX_BINARY_OUTPUT, - EX_BINARY_OUTPUT) + "in the test fixture's destructor" + in EX_BINARY_OUTPUT, + EX_BINARY_OUTPUT, + ) self.assertTrue( 'CxxExceptionInDestructorTest::TearDownTestSuite() ' - 'called as expected.' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT) + 'called as expected.' + in EX_BINARY_OUTPUT, + EX_BINARY_OUTPUT, + ) def testCatchesCxxExceptionsInSetUpTestCase(self): self.assertTrue( 'C++ exception with description "Standard C++ exception"' - ' thrown in SetUpTestSuite()' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT) + ' thrown in SetUpTestSuite()' + in EX_BINARY_OUTPUT, + EX_BINARY_OUTPUT, + ) self.assertTrue( - 'CxxExceptionInConstructorTest::TearDownTestSuite() ' - 'called as expected.' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT) + 'CxxExceptionInConstructorTest::TearDownTestSuite() called as expected.' + in EX_BINARY_OUTPUT, + EX_BINARY_OUTPUT, + ) self.assertFalse( - 'CxxExceptionInSetUpTestSuiteTest constructor ' - 'called as expected.' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT) + 'CxxExceptionInSetUpTestSuiteTest constructor called as expected.' + in EX_BINARY_OUTPUT, + EX_BINARY_OUTPUT, + ) self.assertFalse( - 'CxxExceptionInSetUpTestSuiteTest destructor ' - 'called as expected.' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT) + 'CxxExceptionInSetUpTestSuiteTest destructor called as expected.' + in EX_BINARY_OUTPUT, + EX_BINARY_OUTPUT, + ) self.assertFalse( - 'CxxExceptionInSetUpTestSuiteTest::SetUp() ' - 'called as expected.' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT) + 'CxxExceptionInSetUpTestSuiteTest::SetUp() called as expected.' + in EX_BINARY_OUTPUT, + EX_BINARY_OUTPUT, + ) self.assertFalse( - 'CxxExceptionInSetUpTestSuiteTest::TearDown() ' - 'called as expected.' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT) + 'CxxExceptionInSetUpTestSuiteTest::TearDown() called as expected.' + in EX_BINARY_OUTPUT, + EX_BINARY_OUTPUT, + ) self.assertFalse( - 'CxxExceptionInSetUpTestSuiteTest test body ' - 'called as expected.' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT) + 'CxxExceptionInSetUpTestSuiteTest test body called as expected.' + in EX_BINARY_OUTPUT, + EX_BINARY_OUTPUT, + ) def testCatchesCxxExceptionsInTearDownTestCase(self): self.assertTrue( 'C++ exception with description "Standard C++ exception"' - ' thrown in TearDownTestSuite()' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT) + ' thrown in TearDownTestSuite()' + in EX_BINARY_OUTPUT, + EX_BINARY_OUTPUT, + ) def testCatchesCxxExceptionsInSetUp(self): self.assertTrue( 'C++ exception with description "Standard C++ exception"' - ' thrown in SetUp()' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT) + ' thrown in SetUp()' + in EX_BINARY_OUTPUT, + EX_BINARY_OUTPUT, + ) self.assertTrue( - 'CxxExceptionInSetUpTest::TearDownTestSuite() ' - 'called as expected.' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT) + 'CxxExceptionInSetUpTest::TearDownTestSuite() called as expected.' + in EX_BINARY_OUTPUT, + EX_BINARY_OUTPUT, + ) self.assertTrue( - 'CxxExceptionInSetUpTest destructor ' - 'called as expected.' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT) + 'CxxExceptionInSetUpTest destructor called as expected.' + in EX_BINARY_OUTPUT, + EX_BINARY_OUTPUT, + ) self.assertTrue( - 'CxxExceptionInSetUpTest::TearDown() ' - 'called as expected.' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT) + 'CxxExceptionInSetUpTest::TearDown() called as expected.' + in EX_BINARY_OUTPUT, + EX_BINARY_OUTPUT, + ) self.assertTrue( 'unexpected' not in EX_BINARY_OUTPUT, ( @@ -210,32 +250,49 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase): def testCatchesCxxExceptionsInTearDown(self): self.assertTrue( 'C++ exception with description "Standard C++ exception"' - ' thrown in TearDown()' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT) + ' thrown in TearDown()' + in EX_BINARY_OUTPUT, + EX_BINARY_OUTPUT, + ) self.assertTrue( - 'CxxExceptionInTearDownTest::TearDownTestSuite() ' - 'called as expected.' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT) + 'CxxExceptionInTearDownTest::TearDownTestSuite() called as expected.' + in EX_BINARY_OUTPUT, + EX_BINARY_OUTPUT, + ) self.assertTrue( - 'CxxExceptionInTearDownTest destructor ' - 'called as expected.' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT) + 'CxxExceptionInTearDownTest destructor called as expected.' + in EX_BINARY_OUTPUT, + EX_BINARY_OUTPUT, + ) def testCatchesCxxExceptionsInTestBody(self): self.assertTrue( 'C++ exception with description "Standard C++ exception"' - ' thrown in the test body' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT) + ' thrown in the test body' + in EX_BINARY_OUTPUT, + EX_BINARY_OUTPUT, + ) self.assertTrue( - 'CxxExceptionInTestBodyTest::TearDownTestSuite() ' - 'called as expected.' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT) + 'CxxExceptionInTestBodyTest::TearDownTestSuite() called as expected.' + in EX_BINARY_OUTPUT, + EX_BINARY_OUTPUT, + ) self.assertTrue( - 'CxxExceptionInTestBodyTest destructor ' - 'called as expected.' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT) + 'CxxExceptionInTestBodyTest destructor called as expected.' + in EX_BINARY_OUTPUT, + EX_BINARY_OUTPUT, + ) self.assertTrue( - 'CxxExceptionInTestBodyTest::TearDown() ' - 'called as expected.' in EX_BINARY_OUTPUT, EX_BINARY_OUTPUT) + 'CxxExceptionInTestBodyTest::TearDown() called as expected.' + in EX_BINARY_OUTPUT, + EX_BINARY_OUTPUT, + ) def testCatchesNonStdCxxExceptions(self): self.assertTrue( 'Unknown C++ exception thrown in the test body' in EX_BINARY_OUTPUT, - EX_BINARY_OUTPUT) + EX_BINARY_OUTPUT, + ) def testUnhandledCxxExceptionsAbortTheProgram(self): # Filters out SEH exception tests on Windows. Unhandled SEH exceptions @@ -243,10 +300,9 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase): FITLER_OUT_SEH_TESTS_FLAG = FILTER_FLAG + '=-*Seh*' # By default, Google Test doesn't catch the exceptions. uncaught_exceptions_ex_binary_output = gtest_test_utils.Subprocess( - [EX_EXE_PATH, - NO_CATCH_EXCEPTIONS_FLAG, - FITLER_OUT_SEH_TESTS_FLAG], - env=environ).output + [EX_EXE_PATH, NO_CATCH_EXCEPTIONS_FLAG, FITLER_OUT_SEH_TESTS_FLAG], + env=environ, + ).output self.assertIn( 'Unhandled C++ exception terminating the program', diff --git a/googletest/test/googletest-color-test.py b/googletest/test/googletest-color-test.py index 32dafccca..8926a4815 100755 --- a/googletest/test/googletest-color-test.py +++ b/googletest/test/googletest-color-test.py @@ -65,6 +65,7 @@ def UsesColor(term, color_env_var, color_flag): class GTestColorTest(gtest_test_utils.TestCase): + def testNoEnvVarNoFlag(self): """Tests the case when there's neither GTEST_COLOR nor --gtest_color.""" diff --git a/googletest/test/googletest-env-var-test.py b/googletest/test/googletest-env-var-test.py index bc4d87d93..24d8edbbf 100755 --- a/googletest/test/googletest-env-var-test.py +++ b/googletest/test/googletest-env-var-test.py @@ -101,7 +101,6 @@ class GTestEnvVarTest(gtest_test_utils.TestCase): TestFlag('death_test_use_fork', '1', '0') TestFlag('stack_trace_depth', '0', '100') - def testXmlOutputFile(self): """Tests that $XML_OUTPUT_FILE affects the output flag.""" @@ -116,5 +115,6 @@ class GTestEnvVarTest(gtest_test_utils.TestCase): SetEnvVar('XML_OUTPUT_FILE', 'tmp/bar.xml') AssertEq('xml:tmp/foo.xml', GetFlag('output')) + if __name__ == '__main__': gtest_test_utils.Main() diff --git a/googletest/test/googletest-failfast-unittest.py b/googletest/test/googletest-failfast-unittest.py index 1356d4f8b..cdbce0c5d 100755 --- a/googletest/test/googletest-failfast-unittest.py +++ b/googletest/test/googletest-failfast-unittest.py @@ -62,15 +62,18 @@ FILTER_FLAG = 'gtest_filter' # Command to run the googletest-failfast-unittest_ program. COMMAND = gtest_test_utils.GetTestExecutablePath( - 'googletest-failfast-unittest_') + 'googletest-failfast-unittest_' +) # The command line flag to tell Google Test to output the list of tests it # will run. LIST_TESTS_FLAG = '--gtest_list_tests' # Indicates whether Google Test supports death tests. -SUPPORTS_DEATH_TESTS = 'HasDeathTest' in gtest_test_utils.Subprocess( - [COMMAND, LIST_TESTS_FLAG]).output +SUPPORTS_DEATH_TESTS = ( + 'HasDeathTest' + in gtest_test_utils.Subprocess([COMMAND, LIST_TESTS_FLAG]).output +) # Utilities. @@ -90,8 +93,9 @@ def RunAndReturnOutput(test_suite=None, fail_fast=None, run_disabled=False): """Runs the test program and returns its output.""" args = [] - xml_path = os.path.join(gtest_test_utils.GetTempDir(), - '.GTestFailFastUnitTest.xml') + xml_path = os.path.join( + gtest_test_utils.GetTempDir(), '.GTestFailFastUnitTest.xml' + ) args += ['--gtest_output=xml:' + xml_path] if fail_fast is not None: if isinstance(fail_fast, str): @@ -188,49 +192,63 @@ class GTestFailFastUnitTest(gtest_test_utils.TestCase): txt, _ = RunAndReturnOutput(test_suite='HasSkipTest', fail_fast=True) self.assertIn('1 FAILED TEST', txt) self.assertIn('[ SKIPPED ] 3 tests', txt) - for expected_count, callback in [(1, 'OnTestSuiteStart'), - (5, 'OnTestStart'), - (5, 'OnTestEnd'), - (5, 'OnTestPartResult'), - (1, 'OnTestSuiteEnd')]: + for expected_count, callback in [ + (1, 'OnTestSuiteStart'), + (5, 'OnTestStart'), + (5, 'OnTestEnd'), + (5, 'OnTestPartResult'), + (1, 'OnTestSuiteEnd'), + ]: self.assertEqual( - expected_count, txt.count(callback), - 'Expected %d calls to callback %s match count on output: %s ' % - (expected_count, callback, txt)) + expected_count, + txt.count(callback), + 'Expected %d calls to callback %s match count on output: %s ' + % (expected_count, callback, txt), + ) txt, _ = RunAndReturnOutput(test_suite='HasSkipTest', fail_fast=False) self.assertIn('3 FAILED TEST', txt) self.assertIn('[ SKIPPED ] 1 test', txt) - for expected_count, callback in [(1, 'OnTestSuiteStart'), - (5, 'OnTestStart'), - (5, 'OnTestEnd'), - (5, 'OnTestPartResult'), - (1, 'OnTestSuiteEnd')]: + for expected_count, callback in [ + (1, 'OnTestSuiteStart'), + (5, 'OnTestStart'), + (5, 'OnTestEnd'), + (5, 'OnTestPartResult'), + (1, 'OnTestSuiteEnd'), + ]: self.assertEqual( - expected_count, txt.count(callback), - 'Expected %d calls to callback %s match count on output: %s ' % - (expected_count, callback, txt)) + expected_count, + txt.count(callback), + 'Expected %d calls to callback %s match count on output: %s ' + % (expected_count, callback, txt), + ) def assertXmlResultCount(self, result, count, xml): self.assertEqual( - count, xml.count('result="%s"' % result), - 'Expected \'result="%s"\' match count of %s: %s ' % - (result, count, xml)) + count, + xml.count('result="%s"' % result), + 'Expected \'result="%s"\' match count of %s: %s ' + % (result, count, xml), + ) def assertXmlStatusCount(self, status, count, xml): self.assertEqual( - count, xml.count('status="%s"' % status), - 'Expected \'status="%s"\' match count of %s: %s ' % - (status, count, xml)) + count, + xml.count('status="%s"' % status), + 'Expected \'status="%s"\' match count of %s: %s ' + % (status, count, xml), + ) - def assertFailFastXmlAndTxtOutput(self, - fail_fast, - test_suite, - passed_count, - failure_count, - skipped_count, - suppressed_count, - run_disabled=False): + def assertFailFastXmlAndTxtOutput( + self, + fail_fast, + test_suite, + passed_count, + failure_count, + skipped_count, + suppressed_count, + run_disabled=False, + ): """Assert XML and text output of a test execution.""" txt, xml = RunAndReturnOutput(test_suite, fail_fast, run_disabled) @@ -240,40 +258,57 @@ class GTestFailFastUnitTest(gtest_test_utils.TestCase): self.assertIn('%s DISABLED TEST' % suppressed_count, txt) if skipped_count > 0: self.assertIn('[ SKIPPED ] %s tests' % skipped_count, txt) - self.assertXmlStatusCount('run', - passed_count + failure_count + skipped_count, xml) + self.assertXmlStatusCount( + 'run', passed_count + failure_count + skipped_count, xml + ) self.assertXmlStatusCount('notrun', suppressed_count, xml) self.assertXmlResultCount('completed', passed_count + failure_count, xml) self.assertXmlResultCount('skipped', skipped_count, xml) self.assertXmlResultCount('suppressed', suppressed_count, xml) - def assertFailFastBehavior(self, - test_suite, - passed_count, - failure_count, - skipped_count, - suppressed_count, - run_disabled=False): + def assertFailFastBehavior( + self, + test_suite, + passed_count, + failure_count, + skipped_count, + suppressed_count, + run_disabled=False, + ): """Assert --fail_fast via flag.""" for fail_fast in ('true', '1', 't', True): - self.assertFailFastXmlAndTxtOutput(fail_fast, test_suite, passed_count, - failure_count, skipped_count, - suppressed_count, run_disabled) + self.assertFailFastXmlAndTxtOutput( + fail_fast, + test_suite, + passed_count, + failure_count, + skipped_count, + suppressed_count, + run_disabled, + ) - def assertNotFailFastBehavior(self, - test_suite, - passed_count, - failure_count, - skipped_count, - suppressed_count, - run_disabled=False): + def assertNotFailFastBehavior( + self, + test_suite, + passed_count, + failure_count, + skipped_count, + suppressed_count, + run_disabled=False, + ): """Assert --nofail_fast via flag.""" for fail_fast in ('false', '0', 'f', False): - self.assertFailFastXmlAndTxtOutput(fail_fast, test_suite, passed_count, - failure_count, skipped_count, - suppressed_count, run_disabled) + self.assertFailFastXmlAndTxtOutput( + fail_fast, + test_suite, + passed_count, + failure_count, + skipped_count, + suppressed_count, + run_disabled, + ) def testFlag_HasFixtureTest(self): """Tests the behavior of fail_fast and TEST_F.""" @@ -282,13 +317,15 @@ class GTestFailFastUnitTest(gtest_test_utils.TestCase): passed_count=1, failure_count=1, skipped_count=3, - suppressed_count=0) + suppressed_count=0, + ) self.assertNotFailFastBehavior( test_suite='HasFixtureTest', passed_count=1, failure_count=4, skipped_count=0, - suppressed_count=0) + suppressed_count=0, + ) def testFlag_HasSimpleTest(self): """Tests the behavior of fail_fast and TEST.""" @@ -297,13 +334,15 @@ class GTestFailFastUnitTest(gtest_test_utils.TestCase): passed_count=1, failure_count=1, skipped_count=3, - suppressed_count=0) + suppressed_count=0, + ) self.assertNotFailFastBehavior( test_suite='HasSimpleTest', passed_count=1, failure_count=4, skipped_count=0, - suppressed_count=0) + suppressed_count=0, + ) def testFlag_HasParametersTest(self): """Tests the behavior of fail_fast and TEST_P.""" @@ -312,13 +351,15 @@ class GTestFailFastUnitTest(gtest_test_utils.TestCase): passed_count=0, failure_count=1, skipped_count=3, - suppressed_count=0) + suppressed_count=0, + ) self.assertNotFailFastBehavior( test_suite='HasParametersSuite/HasParametersTest', passed_count=0, failure_count=4, skipped_count=0, - suppressed_count=0) + suppressed_count=0, + ) def testFlag_HasDisabledTest(self): """Tests the behavior of fail_fast and Disabled test cases.""" @@ -328,14 +369,16 @@ class GTestFailFastUnitTest(gtest_test_utils.TestCase): failure_count=1, skipped_count=2, suppressed_count=1, - run_disabled=False) + run_disabled=False, + ) self.assertNotFailFastBehavior( test_suite='HasDisabledTest', passed_count=1, failure_count=3, skipped_count=0, suppressed_count=1, - run_disabled=False) + run_disabled=False, + ) def testFlag_HasDisabledRunDisabledTest(self): """Tests the behavior of fail_fast and Disabled test cases enabled.""" @@ -345,14 +388,16 @@ class GTestFailFastUnitTest(gtest_test_utils.TestCase): failure_count=1, skipped_count=3, suppressed_count=0, - run_disabled=True) + run_disabled=True, + ) self.assertNotFailFastBehavior( test_suite='HasDisabledTest', passed_count=1, failure_count=4, skipped_count=0, suppressed_count=0, - run_disabled=True) + run_disabled=True, + ) def testFlag_HasDisabledSuiteTest(self): """Tests the behavior of fail_fast and Disabled test suites.""" @@ -362,14 +407,16 @@ class GTestFailFastUnitTest(gtest_test_utils.TestCase): failure_count=0, skipped_count=0, suppressed_count=5, - run_disabled=False) + run_disabled=False, + ) self.assertNotFailFastBehavior( test_suite='DISABLED_HasDisabledSuite', passed_count=0, failure_count=0, skipped_count=0, suppressed_count=5, - run_disabled=False) + run_disabled=False, + ) def testFlag_HasDisabledSuiteRunDisabledTest(self): """Tests the behavior of fail_fast and Disabled test suites enabled.""" @@ -379,14 +426,16 @@ class GTestFailFastUnitTest(gtest_test_utils.TestCase): failure_count=1, skipped_count=3, suppressed_count=0, - run_disabled=True) + run_disabled=True, + ) self.assertNotFailFastBehavior( test_suite='DISABLED_HasDisabledSuite', passed_count=1, failure_count=4, skipped_count=0, suppressed_count=0, - run_disabled=True) + run_disabled=True, + ) if SUPPORTS_DEATH_TESTS: @@ -397,13 +446,15 @@ class GTestFailFastUnitTest(gtest_test_utils.TestCase): passed_count=1, failure_count=1, skipped_count=3, - suppressed_count=0) + suppressed_count=0, + ) self.assertNotFailFastBehavior( test_suite='HasDeathTest', passed_count=1, failure_count=4, skipped_count=0, - suppressed_count=0) + suppressed_count=0, + ) if __name__ == '__main__': diff --git a/googletest/test/googletest-filter-unittest.py b/googletest/test/googletest-filter-unittest.py index 6b2351812..f1f3c7a51 100755 --- a/googletest/test/googletest-filter-unittest.py +++ b/googletest/test/googletest-filter-unittest.py @@ -42,6 +42,7 @@ we test that here also. import os import re + try: from sets import Set as set # For Python 2.3 compatibility except ImportError: @@ -60,7 +61,8 @@ CAN_PASS_EMPTY_ENV = False if sys.executable: os.environ['EMPTY_VAR'] = '' child = gtest_test_utils.Subprocess( - [sys.executable, '-c', 'import os; print(\'EMPTY_VAR\' in os.environ)']) + [sys.executable, '-c', "import os; print('EMPTY_VAR' in os.environ)"] + ) CAN_PASS_EMPTY_ENV = eval(child.output) @@ -75,8 +77,8 @@ if sys.executable: os.environ['UNSET_VAR'] = 'X' del os.environ['UNSET_VAR'] child = gtest_test_utils.Subprocess( - [sys.executable, '-c', 'import os; print(\'UNSET_VAR\' not in os.environ)' - ]) + [sys.executable, '-c', "import os; print('UNSET_VAR' not in os.environ)"] + ) CAN_UNSET_ENV = eval(child.output) @@ -84,7 +86,7 @@ if sys.executable: # make sense on platforms that cannot pass empty env variables (Win32) # and on platforms that cannot unset variables (since we cannot tell # the difference between "" and NULL -- Borland and Solaris < 5.10) -CAN_TEST_EMPTY_FILTER = (CAN_PASS_EMPTY_ENV and CAN_UNSET_ENV) +CAN_TEST_EMPTY_FILTER = CAN_PASS_EMPTY_ENV and CAN_UNSET_ENV # The environment variable for specifying the test filters. @@ -121,8 +123,10 @@ DISABLED_BANNER_REGEX = re.compile(r'^\[\s*DISABLED\s*\] (.*)') LIST_TESTS_FLAG = '--gtest_list_tests' # Indicates whether Google Test supports death tests. -SUPPORTS_DEATH_TESTS = 'HasDeathTest' in gtest_test_utils.Subprocess( - [COMMAND, LIST_TESTS_FLAG]).output +SUPPORTS_DEATH_TESTS = ( + 'HasDeathTest' + in gtest_test_utils.Subprocess([COMMAND, LIST_TESTS_FLAG]).output +) # Full names of all tests in googletest-filter-unittests_. PARAM_TESTS = [ @@ -134,7 +138,7 @@ PARAM_TESTS = [ 'SeqQ/ParamTest.TestX/1', 'SeqQ/ParamTest.TestY/0', 'SeqQ/ParamTest.TestY/1', - ] +] DISABLED_TESTS = [ 'BarTest.DISABLED_TestFour', @@ -143,29 +147,31 @@ DISABLED_TESTS = [ 'DISABLED_FoobarTest.Test1', 'DISABLED_FoobarTest.DISABLED_Test2', 'DISABLED_FoobarbazTest.TestA', - ] +] if SUPPORTS_DEATH_TESTS: DEATH_TESTS = [ - 'HasDeathTest.Test1', - 'HasDeathTest.Test2', - ] + 'HasDeathTest.Test1', + 'HasDeathTest.Test2', + ] else: DEATH_TESTS = [] # All the non-disabled tests. -ACTIVE_TESTS = [ - 'FooTest.Abc', - 'FooTest.Xyz', - - 'BarTest.TestOne', - 'BarTest.TestTwo', - 'BarTest.TestThree', - - 'BazTest.TestOne', - 'BazTest.TestA', - 'BazTest.TestB', - ] + DEATH_TESTS + PARAM_TESTS +ACTIVE_TESTS = ( + [ + 'FooTest.Abc', + 'FooTest.Xyz', + 'BarTest.TestOne', + 'BarTest.TestTwo', + 'BarTest.TestThree', + 'BazTest.TestOne', + 'BazTest.TestA', + 'BazTest.TestB', + ] + + DEATH_TESTS + + PARAM_TESTS +) param_tests_present = None @@ -183,14 +189,15 @@ def SetEnvVar(env_var, value): del environ[env_var] -def RunAndReturnOutput(args = None): +def RunAndReturnOutput(args=None): """Runs the test program and returns its output.""" - return gtest_test_utils.Subprocess([COMMAND] + (args or []), - env=environ).output + return gtest_test_utils.Subprocess( + [COMMAND] + (args or []), env=environ + ).output -def RunAndExtractTestList(args = None): +def RunAndExtractTestList(args=None): """Runs the test program and returns its exit code and a list of tests run.""" p = gtest_test_utils.Subprocess([COMMAND] + (args or []), env=environ) @@ -234,10 +241,13 @@ def InvokeWithModifiedEnv(extra_env, function, *args, **kwargs): def RunWithSharding(total_shards, shard_index, command): """Runs a test program shard and returns exit code and a list of tests run.""" - extra_env = {SHARD_INDEX_ENV_VAR: str(shard_index), - TOTAL_SHARDS_ENV_VAR: str(total_shards)} + extra_env = { + SHARD_INDEX_ENV_VAR: str(shard_index), + TOTAL_SHARDS_ENV_VAR: str(total_shards), + } return InvokeWithModifiedEnv(extra_env, RunAndExtractTestList, command) + # The unit test. @@ -303,8 +313,14 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase): tests_run = RunAndExtractTestList(args)[0] self.AssertSetEqual(tests_run, tests_to_run) - def RunAndVerifyWithSharding(self, gtest_filter, total_shards, tests_to_run, - args=None, check_exit_0=False): + def RunAndVerifyWithSharding( + self, + gtest_filter, + total_shards, + tests_to_run, + args=None, + check_exit_0=False, + ): """Checks that binary runs correct tests for the given filter and shard. Runs all shards of googletest-filter-unittest_ with the given filter, and @@ -316,9 +332,9 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase): gtest_filter: A filter to apply to the tests. total_shards: A total number of shards to split test run into. tests_to_run: A set of tests expected to run. - args : Arguments to pass to the to the test binary. - check_exit_0: When set to a true value, make sure that all shards - return 0. + args: Arguments to pass to the to the test binary. + check_exit_0: When set to a true value, make sure that all shards return + 0. """ tests_to_run = self.AdjustForParameterizedTests(tests_to_run) @@ -372,8 +388,9 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase): global param_tests_present if param_tests_present is None: - param_tests_present = PARAM_TEST_REGEX.search( - RunAndReturnOutput()) is not None + param_tests_present = ( + PARAM_TEST_REGEX.search(RunAndReturnOutput()) is not None + ) def testDefaultBehavior(self): """Tests the behavior of not specifying the filter.""" @@ -425,8 +442,9 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase): BAZ_TESTS = ['BazTest.TestOne', 'BazTest.TestA', 'BazTest.TestB'] self.RunAndVerify('BazTest.*', BAZ_TESTS) - self.RunAndVerifyAllowingDisabled('BazTest.*', - BAZ_TESTS + ['BazTest.DISABLED_TestC']) + self.RunAndVerifyAllowingDisabled( + 'BazTest.*', BAZ_TESTS + ['BazTest.DISABLED_TestC'] + ) def testFilterByTest(self): """Tests filtering by test name.""" @@ -437,38 +455,50 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase): """Select only the disabled tests to run.""" self.RunAndVerify('DISABLED_FoobarTest.Test1', []) - self.RunAndVerifyAllowingDisabled('DISABLED_FoobarTest.Test1', - ['DISABLED_FoobarTest.Test1']) + self.RunAndVerifyAllowingDisabled( + 'DISABLED_FoobarTest.Test1', ['DISABLED_FoobarTest.Test1'] + ) self.RunAndVerify('*DISABLED_*', []) self.RunAndVerifyAllowingDisabled('*DISABLED_*', DISABLED_TESTS) self.RunAndVerify('*.DISABLED_*', []) - self.RunAndVerifyAllowingDisabled('*.DISABLED_*', [ - 'BarTest.DISABLED_TestFour', - 'BarTest.DISABLED_TestFive', - 'BazTest.DISABLED_TestC', - 'DISABLED_FoobarTest.DISABLED_Test2', - ]) + self.RunAndVerifyAllowingDisabled( + '*.DISABLED_*', + [ + 'BarTest.DISABLED_TestFour', + 'BarTest.DISABLED_TestFive', + 'BazTest.DISABLED_TestC', + 'DISABLED_FoobarTest.DISABLED_Test2', + ], + ) self.RunAndVerify('DISABLED_*', []) - self.RunAndVerifyAllowingDisabled('DISABLED_*', [ - 'DISABLED_FoobarTest.Test1', - 'DISABLED_FoobarTest.DISABLED_Test2', - 'DISABLED_FoobarbazTest.TestA', - ]) + self.RunAndVerifyAllowingDisabled( + 'DISABLED_*', + [ + 'DISABLED_FoobarTest.Test1', + 'DISABLED_FoobarTest.DISABLED_Test2', + 'DISABLED_FoobarbazTest.TestA', + ], + ) def testWildcardInTestCaseName(self): """Tests using wildcard in the test case name.""" - self.RunAndVerify('*a*.*', [ - 'BarTest.TestOne', - 'BarTest.TestTwo', - 'BarTest.TestThree', - - 'BazTest.TestOne', - 'BazTest.TestA', - 'BazTest.TestB', ] + DEATH_TESTS + PARAM_TESTS) + self.RunAndVerify( + '*a*.*', + [ + 'BarTest.TestOne', + 'BarTest.TestTwo', + 'BarTest.TestThree', + 'BazTest.TestOne', + 'BazTest.TestA', + 'BazTest.TestB', + ] + + DEATH_TESTS + + PARAM_TESTS, + ) def testWildcardInTestName(self): """Tests using wildcard in the test name.""" @@ -478,23 +508,27 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase): def testFilterWithoutDot(self): """Tests a filter that has no '.' in it.""" - self.RunAndVerify('*z*', [ - 'FooTest.Xyz', - - 'BazTest.TestOne', - 'BazTest.TestA', - 'BazTest.TestB', - ]) + self.RunAndVerify( + '*z*', + [ + 'FooTest.Xyz', + 'BazTest.TestOne', + 'BazTest.TestA', + 'BazTest.TestB', + ], + ) def testTwoPatterns(self): """Tests filters that consist of two patterns.""" - self.RunAndVerify('Foo*.*:*A*', [ - 'FooTest.Abc', - 'FooTest.Xyz', - - 'BazTest.TestA', - ]) + self.RunAndVerify( + 'Foo*.*:*A*', + [ + 'FooTest.Abc', + 'FooTest.Xyz', + 'BazTest.TestA', + ], + ) # An empty pattern + a non-empty one self.RunAndVerify(':*A*', ['FooTest.Abc', 'BazTest.TestA']) @@ -502,83 +536,109 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase): def testThreePatterns(self): """Tests filters that consist of three patterns.""" - self.RunAndVerify('*oo*:*A*:*One', [ - 'FooTest.Abc', - 'FooTest.Xyz', - - 'BarTest.TestOne', - - 'BazTest.TestOne', - 'BazTest.TestA', - ]) + self.RunAndVerify( + '*oo*:*A*:*One', + [ + 'FooTest.Abc', + 'FooTest.Xyz', + 'BarTest.TestOne', + 'BazTest.TestOne', + 'BazTest.TestA', + ], + ) # The 2nd pattern is empty. - self.RunAndVerify('*oo*::*One', [ - 'FooTest.Abc', - 'FooTest.Xyz', - - 'BarTest.TestOne', - - 'BazTest.TestOne', - ]) + self.RunAndVerify( + '*oo*::*One', + [ + 'FooTest.Abc', + 'FooTest.Xyz', + 'BarTest.TestOne', + 'BazTest.TestOne', + ], + ) # The last 2 patterns are empty. - self.RunAndVerify('*oo*::', [ - 'FooTest.Abc', - 'FooTest.Xyz', - ]) + self.RunAndVerify( + '*oo*::', + [ + 'FooTest.Abc', + 'FooTest.Xyz', + ], + ) def testNegativeFilters(self): - self.RunAndVerify('*-BazTest.TestOne', [ - 'FooTest.Abc', - 'FooTest.Xyz', + self.RunAndVerify( + '*-BazTest.TestOne', + [ + 'FooTest.Abc', + 'FooTest.Xyz', + 'BarTest.TestOne', + 'BarTest.TestTwo', + 'BarTest.TestThree', + 'BazTest.TestA', + 'BazTest.TestB', + ] + + DEATH_TESTS + + PARAM_TESTS, + ) - 'BarTest.TestOne', - 'BarTest.TestTwo', - 'BarTest.TestThree', + self.RunAndVerify( + '*-FooTest.Abc:BazTest.*', + [ + 'FooTest.Xyz', + 'BarTest.TestOne', + 'BarTest.TestTwo', + 'BarTest.TestThree', + ] + + DEATH_TESTS + + PARAM_TESTS, + ) - 'BazTest.TestA', - 'BazTest.TestB', - ] + DEATH_TESTS + PARAM_TESTS) - - self.RunAndVerify('*-FooTest.Abc:BazTest.*', [ - 'FooTest.Xyz', - - 'BarTest.TestOne', - 'BarTest.TestTwo', - 'BarTest.TestThree', - ] + DEATH_TESTS + PARAM_TESTS) - - self.RunAndVerify('BarTest.*-BarTest.TestOne', [ - 'BarTest.TestTwo', - 'BarTest.TestThree', - ]) + self.RunAndVerify( + 'BarTest.*-BarTest.TestOne', + [ + 'BarTest.TestTwo', + 'BarTest.TestThree', + ], + ) # Tests without leading '*'. - self.RunAndVerify('-FooTest.Abc:FooTest.Xyz:BazTest.*', [ - 'BarTest.TestOne', - 'BarTest.TestTwo', - 'BarTest.TestThree', - ] + DEATH_TESTS + PARAM_TESTS) + self.RunAndVerify( + '-FooTest.Abc:FooTest.Xyz:BazTest.*', + [ + 'BarTest.TestOne', + 'BarTest.TestTwo', + 'BarTest.TestThree', + ] + + DEATH_TESTS + + PARAM_TESTS, + ) # Value parameterized tests. self.RunAndVerify('*/*', PARAM_TESTS) # Value parameterized tests filtering by the sequence name. - self.RunAndVerify('SeqP/*', [ - 'SeqP/ParamTest.TestX/0', - 'SeqP/ParamTest.TestX/1', - 'SeqP/ParamTest.TestY/0', - 'SeqP/ParamTest.TestY/1', - ]) + self.RunAndVerify( + 'SeqP/*', + [ + 'SeqP/ParamTest.TestX/0', + 'SeqP/ParamTest.TestX/1', + 'SeqP/ParamTest.TestY/0', + 'SeqP/ParamTest.TestY/1', + ], + ) # Value parameterized tests filtering by the test name. - self.RunAndVerify('*/0', [ - 'SeqP/ParamTest.TestX/0', - 'SeqP/ParamTest.TestY/0', - 'SeqQ/ParamTest.TestX/0', - 'SeqQ/ParamTest.TestY/0', - ]) + self.RunAndVerify( + '*/0', + [ + 'SeqP/ParamTest.TestX/0', + 'SeqP/ParamTest.TestY/0', + 'SeqQ/ParamTest.TestX/0', + 'SeqQ/ParamTest.TestY/0', + ], + ) def testFlagOverridesEnvVar(self): """Tests that the filter flag overrides the filtering env. variable.""" @@ -593,8 +653,9 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase): def testShardStatusFileIsCreated(self): """Tests that the shard file is created if specified in the environment.""" - shard_status_file = os.path.join(gtest_test_utils.GetTempDir(), - 'shard_status_file') + shard_status_file = os.path.join( + gtest_test_utils.GetTempDir(), 'shard_status_file' + ) self.assertTrue(not os.path.exists(shard_status_file)) extra_env = {SHARD_STATUS_FILE_ENV_VAR: shard_status_file} @@ -607,15 +668,16 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase): def testShardStatusFileIsCreatedWithListTests(self): """Tests that the shard file is created with the "list_tests" flag.""" - shard_status_file = os.path.join(gtest_test_utils.GetTempDir(), - 'shard_status_file2') + shard_status_file = os.path.join( + gtest_test_utils.GetTempDir(), 'shard_status_file2' + ) self.assertTrue(not os.path.exists(shard_status_file)) extra_env = {SHARD_STATUS_FILE_ENV_VAR: shard_status_file} try: - output = InvokeWithModifiedEnv(extra_env, - RunAndReturnOutput, - [LIST_TESTS_FLAG]) + output = InvokeWithModifiedEnv( + extra_env, RunAndReturnOutput, [LIST_TESTS_FLAG] + ) finally: # This assertion ensures that Google Test enumerated the tests as # opposed to running them. @@ -636,19 +698,25 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase): make_filter = lambda s: ['--%s=%s' % (FILTER_FLAG, s)] banners = RunAndExtractDisabledBannerList(make_filter('*')) - self.AssertSetEqual(banners, [ - 'BarTest.DISABLED_TestFour', 'BarTest.DISABLED_TestFive', - 'BazTest.DISABLED_TestC' - ]) + self.AssertSetEqual( + banners, + [ + 'BarTest.DISABLED_TestFour', + 'BarTest.DISABLED_TestFive', + 'BazTest.DISABLED_TestC', + ], + ) banners = RunAndExtractDisabledBannerList(make_filter('Bar*')) self.AssertSetEqual( - banners, ['BarTest.DISABLED_TestFour', 'BarTest.DISABLED_TestFive']) + banners, ['BarTest.DISABLED_TestFour', 'BarTest.DISABLED_TestFive'] + ) banners = RunAndExtractDisabledBannerList(make_filter('*-Bar*')) self.AssertSetEqual(banners, ['BazTest.DISABLED_TestC']) if SUPPORTS_DEATH_TESTS: + def testShardingWorksWithDeathTests(self): """Tests integration with death tests and sharding.""" @@ -656,19 +724,23 @@ class GTestFilterUnitTest(gtest_test_utils.TestCase): expected_tests = [ 'HasDeathTest.Test1', 'HasDeathTest.Test2', - 'SeqP/ParamTest.TestX/0', 'SeqP/ParamTest.TestX/1', 'SeqP/ParamTest.TestY/0', 'SeqP/ParamTest.TestY/1', - ] + ] + + for flag in [ + '--gtest_death_test_style=threadsafe', + '--gtest_death_test_style=fast', + ]: + self.RunAndVerifyWithSharding( + gtest_filter, 3, expected_tests, check_exit_0=True, args=[flag] + ) + self.RunAndVerifyWithSharding( + gtest_filter, 5, expected_tests, check_exit_0=True, args=[flag] + ) - for flag in ['--gtest_death_test_style=threadsafe', - '--gtest_death_test_style=fast']: - self.RunAndVerifyWithSharding(gtest_filter, 3, expected_tests, - check_exit_0=True, args=[flag]) - self.RunAndVerifyWithSharding(gtest_filter, 5, expected_tests, - check_exit_0=True, args=[flag]) if __name__ == '__main__': gtest_test_utils.Main() diff --git a/googletest/test/googletest-global-environment-unittest.py b/googletest/test/googletest-global-environment-unittest.py index 265793442..bd73a2e1d 100644 --- a/googletest/test/googletest-global-environment-unittest.py +++ b/googletest/test/googletest-global-environment-unittest.py @@ -42,10 +42,14 @@ from googletest.test import gtest_test_utils def RunAndReturnOutput(args=None): """Runs the test program and returns its output.""" - return gtest_test_utils.Subprocess([ - gtest_test_utils.GetTestExecutablePath( - 'googletest-global-environment-unittest_') - ] + (args or [])).output + return gtest_test_utils.Subprocess( + [ + gtest_test_utils.GetTestExecutablePath( + 'googletest-global-environment-unittest_' + ) + ] + + (args or []) + ).output class GTestGlobalEnvironmentUnitTest(gtest_test_utils.TestCase): @@ -78,23 +82,25 @@ class GTestGlobalEnvironmentUnitTest(gtest_test_utils.TestCase): '--gtest_recreate_environments_when_repeating=true', ]) - expected_pattern = ('(.|\n)*' - r'Repeating all tests \(iteration 1\)' - '(.|\n)*' - 'Global test environment set-up.' - '(.|\n)*' - 'SomeTest.DoesFoo' - '(.|\n)*' - 'Global test environment tear-down' - '(.|\n)*' - r'Repeating all tests \(iteration 2\)' - '(.|\n)*' - 'Global test environment set-up.' - '(.|\n)*' - 'SomeTest.DoesFoo' - '(.|\n)*' - 'Global test environment tear-down' - '(.|\n)*') + expected_pattern = ( + '(.|\n)*' + r'Repeating all tests \(iteration 1\)' + '(.|\n)*' + 'Global test environment set-up.' + '(.|\n)*' + 'SomeTest.DoesFoo' + '(.|\n)*' + 'Global test environment tear-down' + '(.|\n)*' + r'Repeating all tests \(iteration 2\)' + '(.|\n)*' + 'Global test environment set-up.' + '(.|\n)*' + 'SomeTest.DoesFoo' + '(.|\n)*' + 'Global test environment tear-down' + '(.|\n)*' + ) self.assertRegex(txt, expected_pattern) def testEnvironmentSetUpAndTornDownOnce(self): @@ -102,28 +108,33 @@ class GTestGlobalEnvironmentUnitTest(gtest_test_utils.TestCase): # By default the environment should only be set up and torn down once, at # the start and end of the test respectively. - txt = RunAndReturnOutput([ - '--gtest_repeat=2', - ]) + txt = RunAndReturnOutput( + [ + '--gtest_repeat=2', + ] + ) - expected_pattern = ('(.|\n)*' - r'Repeating all tests \(iteration 1\)' - '(.|\n)*' - 'Global test environment set-up.' - '(.|\n)*' - 'SomeTest.DoesFoo' - '(.|\n)*' - r'Repeating all tests \(iteration 2\)' - '(.|\n)*' - 'SomeTest.DoesFoo' - '(.|\n)*' - 'Global test environment tear-down' - '(.|\n)*') + expected_pattern = ( + '(.|\n)*' + r'Repeating all tests \(iteration 1\)' + '(.|\n)*' + 'Global test environment set-up.' + '(.|\n)*' + 'SomeTest.DoesFoo' + '(.|\n)*' + r'Repeating all tests \(iteration 2\)' + '(.|\n)*' + 'SomeTest.DoesFoo' + '(.|\n)*' + 'Global test environment tear-down' + '(.|\n)*' + ) self.assertRegex(txt, expected_pattern) self.assertEqual(len(re.findall('Global test environment set-up', txt)), 1) self.assertEqual( - len(re.findall('Global test environment tear-down', txt)), 1) + len(re.findall('Global test environment tear-down', txt)), 1 + ) if __name__ == '__main__': diff --git a/googletest/test/googletest-json-outfiles-test.py b/googletest/test/googletest-json-outfiles-test.py index 3abf355d4..bc17fe217 100644 --- a/googletest/test/googletest-json-outfiles-test.py +++ b/googletest/test/googletest-json-outfiles-test.py @@ -40,93 +40,65 @@ GTEST_OUTPUT_1_TEST = 'gtest_xml_outfile1_test_' GTEST_OUTPUT_2_TEST = 'gtest_xml_outfile2_test_' EXPECTED_1 = { - u'tests': - 1, - u'failures': - 0, - u'disabled': - 0, - u'errors': - 0, - u'time': - u'*', - u'timestamp': - u'*', - u'name': - u'AllTests', - u'testsuites': [{ - u'name': - u'PropertyOne', - u'tests': - 1, - u'failures': - 0, - u'disabled': - 0, - u'errors': - 0, - u'time': - u'*', - u'timestamp': - u'*', - u'testsuite': [{ - u'name': u'TestSomeProperties', - u'file': u'gtest_xml_outfile1_test_.cc', - u'line': 41, - u'status': u'RUN', - u'result': u'COMPLETED', - u'time': u'*', - u'timestamp': u'*', - u'classname': u'PropertyOne', - u'SetUpProp': u'1', - u'TestSomeProperty': u'1', - u'TearDownProp': u'1', + 'tests': 1, + 'failures': 0, + 'disabled': 0, + 'errors': 0, + 'time': '*', + 'timestamp': '*', + 'name': 'AllTests', + 'testsuites': [{ + 'name': 'PropertyOne', + 'tests': 1, + 'failures': 0, + 'disabled': 0, + 'errors': 0, + 'time': '*', + 'timestamp': '*', + 'testsuite': [{ + 'name': 'TestSomeProperties', + 'file': 'gtest_xml_outfile1_test_.cc', + 'line': 41, + 'status': 'RUN', + 'result': 'COMPLETED', + 'time': '*', + 'timestamp': '*', + 'classname': 'PropertyOne', + 'SetUpProp': '1', + 'TestSomeProperty': '1', + 'TearDownProp': '1', }], }], } EXPECTED_2 = { - u'tests': - 1, - u'failures': - 0, - u'disabled': - 0, - u'errors': - 0, - u'time': - u'*', - u'timestamp': - u'*', - u'name': - u'AllTests', - u'testsuites': [{ - u'name': - u'PropertyTwo', - u'tests': - 1, - u'failures': - 0, - u'disabled': - 0, - u'errors': - 0, - u'time': - u'*', - u'timestamp': - u'*', - u'testsuite': [{ - u'name': u'TestSomeProperties', - u'file': u'gtest_xml_outfile2_test_.cc', - u'line': 41, - u'status': u'RUN', - u'result': u'COMPLETED', - u'timestamp': u'*', - u'time': u'*', - u'classname': u'PropertyTwo', - u'SetUpProp': u'2', - u'TestSomeProperty': u'2', - u'TearDownProp': u'2', + 'tests': 1, + 'failures': 0, + 'disabled': 0, + 'errors': 0, + 'time': '*', + 'timestamp': '*', + 'name': 'AllTests', + 'testsuites': [{ + 'name': 'PropertyTwo', + 'tests': 1, + 'failures': 0, + 'disabled': 0, + 'errors': 0, + 'time': '*', + 'timestamp': '*', + 'testsuite': [{ + 'name': 'TestSomeProperties', + 'file': 'gtest_xml_outfile2_test_.cc', + 'line': 41, + 'status': 'RUN', + 'result': 'COMPLETED', + 'timestamp': '*', + 'time': '*', + 'classname': 'PropertyTwo', + 'SetUpProp': '2', + 'TestSomeProperty': '2', + 'TearDownProp': '2', }], }], } @@ -139,8 +111,9 @@ class GTestJsonOutFilesTest(gtest_test_utils.TestCase): # We want the trailing '/' that the last "" provides in os.path.join, for # telling Google Test to create an output directory instead of a single file # for xml output. - self.output_dir_ = os.path.join(gtest_test_utils.GetTempDir(), - GTEST_OUTPUT_SUBDIR, '') + self.output_dir_ = os.path.join( + gtest_test_utils.GetTempDir(), GTEST_OUTPUT_SUBDIR, '' + ) self.DeleteFilesAndDir() def tearDown(self): @@ -169,8 +142,9 @@ class GTestJsonOutFilesTest(gtest_test_utils.TestCase): def _TestOutFile(self, test_name, expected): gtest_prog_path = gtest_test_utils.GetTestExecutablePath(test_name) command = [gtest_prog_path, '--gtest_output=json:%s' % self.output_dir_] - p = gtest_test_utils.Subprocess(command, - working_dir=gtest_test_utils.GetTempDir()) + p = gtest_test_utils.Subprocess( + command, working_dir=gtest_test_utils.GetTempDir() + ) self.assertTrue(p.exited) self.assertEqual(0, p.exit_code) diff --git a/googletest/test/googletest-json-output-unittest.py b/googletest/test/googletest-json-output-unittest.py index c8915b2f3..b3a08deb1 100644 --- a/googletest/test/googletest-json-output-unittest.py +++ b/googletest/test/googletest-json-output-unittest.py @@ -57,689 +57,570 @@ else: STACK_TRACE_TEMPLATE = '' EXPECTED_NON_EMPTY = { - u'tests': - 26, - u'failures': - 5, - u'disabled': - 2, - u'errors': - 0, - u'timestamp': - u'*', - u'time': - u'*', - u'ad_hoc_property': - u'42', - u'name': - u'AllTests', - u'testsuites': [{ - u'name': - u'SuccessfulTest', - u'tests': - 1, - u'failures': - 0, - u'disabled': - 0, - u'errors': - 0, - u'time': - u'*', - u'timestamp': - u'*', - u'testsuite': [{ - u'name': u'Succeeds', - u'file': u'gtest_xml_output_unittest_.cc', - u'line': 51, - u'status': u'RUN', - u'result': u'COMPLETED', - u'time': u'*', - u'timestamp': u'*', - u'classname': u'SuccessfulTest' - }] - }, { - u'name': - u'FailedTest', - u'tests': - 1, - u'failures': - 1, - u'disabled': - 0, - u'errors': - 0, - u'time': - u'*', - u'timestamp': - u'*', - u'testsuite': [{ - u'name': - u'Fails', - u'file': - u'gtest_xml_output_unittest_.cc', - u'line': - 59, - u'status': - u'RUN', - u'result': - u'COMPLETED', - u'time': - u'*', - u'timestamp': - u'*', - u'classname': - u'FailedTest', - u'failures': [{ - u'failure': u'gtest_xml_output_unittest_.cc:*\n' - u'Expected equality of these values:\n' - u' 1\n 2' + STACK_TRACE_TEMPLATE, - u'type': u'' - }] - }] - }, { - u'name': - u'DisabledTest', - u'tests': - 1, - u'failures': - 0, - u'disabled': - 1, - u'errors': - 0, - u'time': - u'*', - u'timestamp': - u'*', - u'testsuite': [{ - u'name': u'DISABLED_test_not_run', - u'file': u'gtest_xml_output_unittest_.cc', - u'line': 66, - u'status': u'NOTRUN', - u'result': u'SUPPRESSED', - u'time': u'*', - u'timestamp': u'*', - u'classname': u'DisabledTest' - }] - }, { - u'name': - u'SkippedTest', - u'tests': - 3, - u'failures': - 1, - u'disabled': - 0, - u'errors': - 0, - u'time': - u'*', - u'timestamp': - u'*', - u'testsuite': [{ - u'name': u'Skipped', - u'file': 'gtest_xml_output_unittest_.cc', - u'line': 73, - u'status': u'RUN', - u'result': u'SKIPPED', - u'time': u'*', - u'timestamp': u'*', - u'classname': u'SkippedTest' - }, { - u'name': u'SkippedWithMessage', - u'file': 'gtest_xml_output_unittest_.cc', - u'line': 77, - u'status': u'RUN', - u'result': u'SKIPPED', - u'time': u'*', - u'timestamp': u'*', - u'classname': u'SkippedTest' - }, { - u'name': - u'SkippedAfterFailure', - u'file': - 'gtest_xml_output_unittest_.cc', - u'line': - 81, - u'status': - u'RUN', - u'result': - u'COMPLETED', - u'time': - u'*', - u'timestamp': - u'*', - u'classname': - u'SkippedTest', - u'failures': [{ - u'failure': u'gtest_xml_output_unittest_.cc:*\n' - u'Expected equality of these values:\n' - u' 1\n 2' + STACK_TRACE_TEMPLATE, - u'type': u'' - }] - }] - }, { - u'name': - u'MixedResultTest', - u'tests': - 3, - u'failures': - 1, - u'disabled': - 1, - u'errors': - 0, - u'time': - u'*', - u'timestamp': - u'*', - u'testsuite': [{ - u'name': u'Succeeds', - u'file': 'gtest_xml_output_unittest_.cc', - u'line': 86, - u'status': u'RUN', - u'result': u'COMPLETED', - u'time': u'*', - u'timestamp': u'*', - u'classname': u'MixedResultTest' - }, { - u'name': - u'Fails', - u'file': - u'gtest_xml_output_unittest_.cc', - u'line': - 91, - u'status': - u'RUN', - u'result': - u'COMPLETED', - u'time': - u'*', - u'timestamp': - u'*', - u'classname': - u'MixedResultTest', - u'failures': [{ - u'failure': u'gtest_xml_output_unittest_.cc:*\n' - u'Expected equality of these values:\n' - u' 1\n 2' + STACK_TRACE_TEMPLATE, - u'type': u'' - }, { - u'failure': u'gtest_xml_output_unittest_.cc:*\n' - u'Expected equality of these values:\n' - u' 2\n 3' + STACK_TRACE_TEMPLATE, - u'type': u'' - }] - }, { - u'name': u'DISABLED_test', - u'file': u'gtest_xml_output_unittest_.cc', - u'line': 96, - u'status': u'NOTRUN', - u'result': u'SUPPRESSED', - u'time': u'*', - u'timestamp': u'*', - u'classname': u'MixedResultTest' - }] - }, { - u'name': - u'XmlQuotingTest', - u'tests': - 1, - u'failures': - 1, - u'disabled': - 0, - u'errors': - 0, - u'time': - u'*', - u'timestamp': - u'*', - u'testsuite': [{ - u'name': - u'OutputsCData', - u'file': - u'gtest_xml_output_unittest_.cc', - u'line': - 100, - u'status': - u'RUN', - u'result': - u'COMPLETED', - u'time': - u'*', - u'timestamp': - u'*', - u'classname': - u'XmlQuotingTest', - u'failures': [{ - u'failure': u'gtest_xml_output_unittest_.cc:*\n' - u'Failed\nXML output: ' - u'' + - STACK_TRACE_TEMPLATE, - u'type': u'' - }] - }] - }, { - u'name': - u'InvalidCharactersTest', - u'tests': - 1, - u'failures': - 1, - u'disabled': - 0, - u'errors': - 0, - u'time': - u'*', - u'timestamp': - u'*', - u'testsuite': [{ - u'name': - u'InvalidCharactersInMessage', - u'file': - u'gtest_xml_output_unittest_.cc', - u'line': - 107, - u'status': - u'RUN', - u'result': - u'COMPLETED', - u'time': - u'*', - u'timestamp': - u'*', - u'classname': - u'InvalidCharactersTest', - u'failures': [{ - u'failure': u'gtest_xml_output_unittest_.cc:*\n' - u'Failed\nInvalid characters in brackets' - u' [\x01\x02]' + STACK_TRACE_TEMPLATE, - u'type': u'' - }] - }] - }, { - u'name': - u'PropertyRecordingTest', - u'tests': - 4, - u'failures': - 0, - u'disabled': - 0, - u'errors': - 0, - u'time': - u'*', - u'timestamp': - u'*', - u'SetUpTestSuite': - u'yes', - u'TearDownTestSuite': - u'aye', - u'testsuite': [{ - u'name': u'OneProperty', - u'file': u'gtest_xml_output_unittest_.cc', - u'line': 119, - u'status': u'RUN', - u'result': u'COMPLETED', - u'time': u'*', - u'timestamp': u'*', - u'classname': u'PropertyRecordingTest', - u'key_1': u'1' - }, { - u'name': u'IntValuedProperty', - u'file': u'gtest_xml_output_unittest_.cc', - u'line': 123, - u'status': u'RUN', - u'result': u'COMPLETED', - u'time': u'*', - u'timestamp': u'*', - u'classname': u'PropertyRecordingTest', - u'key_int': u'1' - }, { - u'name': u'ThreeProperties', - u'file': u'gtest_xml_output_unittest_.cc', - u'line': 127, - u'status': u'RUN', - u'result': u'COMPLETED', - u'time': u'*', - u'timestamp': u'*', - u'classname': u'PropertyRecordingTest', - u'key_1': u'1', - u'key_2': u'2', - u'key_3': u'3' - }, { - u'name': u'TwoValuesForOneKeyUsesLastValue', - u'file': u'gtest_xml_output_unittest_.cc', - u'line': 133, - u'status': u'RUN', - u'result': u'COMPLETED', - u'time': u'*', - u'timestamp': u'*', - u'classname': u'PropertyRecordingTest', - u'key_1': u'2' - }] - }, { - u'name': - u'NoFixtureTest', - u'tests': - 3, - u'failures': - 0, - u'disabled': - 0, - u'errors': - 0, - u'time': - u'*', - u'timestamp': - u'*', - u'testsuite': [{ - u'name': u'RecordProperty', - u'file': u'gtest_xml_output_unittest_.cc', - u'line': 138, - u'status': u'RUN', - u'result': u'COMPLETED', - u'time': u'*', - u'timestamp': u'*', - u'classname': u'NoFixtureTest', - u'key': u'1' - }, { - u'name': u'ExternalUtilityThatCallsRecordIntValuedProperty', - u'file': u'gtest_xml_output_unittest_.cc', - u'line': 151, - u'status': u'RUN', - u'result': u'COMPLETED', - u'time': u'*', - u'timestamp': u'*', - u'classname': u'NoFixtureTest', - u'key_for_utility_int': u'1' - }, { - u'name': u'ExternalUtilityThatCallsRecordStringValuedProperty', - u'file': u'gtest_xml_output_unittest_.cc', - u'line': 155, - u'status': u'RUN', - u'result': u'COMPLETED', - u'time': u'*', - u'timestamp': u'*', - u'classname': u'NoFixtureTest', - u'key_for_utility_string': u'1' - }] - }, { - u'name': - u'TypedTest/0', - u'tests': - 1, - u'failures': - 0, - u'disabled': - 0, - u'errors': - 0, - u'time': - u'*', - u'timestamp': - u'*', - u'testsuite': [{ - u'name': u'HasTypeParamAttribute', - u'type_param': u'int', - u'file': u'gtest_xml_output_unittest_.cc', - u'line': 171, - u'status': u'RUN', - u'result': u'COMPLETED', - u'time': u'*', - u'timestamp': u'*', - u'classname': u'TypedTest/0' - }] - }, { - u'name': - u'TypedTest/1', - u'tests': - 1, - u'failures': - 0, - u'disabled': - 0, - u'errors': - 0, - u'time': - u'*', - u'timestamp': - u'*', - u'testsuite': [{ - u'name': u'HasTypeParamAttribute', - u'type_param': u'long', - u'file': u'gtest_xml_output_unittest_.cc', - u'line': 171, - u'status': u'RUN', - u'result': u'COMPLETED', - u'time': u'*', - u'timestamp': u'*', - u'classname': u'TypedTest/1' - }] - }, { - u'name': - u'Single/TypeParameterizedTestSuite/0', - u'tests': - 1, - u'failures': - 0, - u'disabled': - 0, - u'errors': - 0, - u'time': - u'*', - u'timestamp': - u'*', - u'testsuite': [{ - u'name': u'HasTypeParamAttribute', - u'type_param': u'int', - u'file': u'gtest_xml_output_unittest_.cc', - u'line': 178, - u'status': u'RUN', - u'result': u'COMPLETED', - u'time': u'*', - u'timestamp': u'*', - u'classname': u'Single/TypeParameterizedTestSuite/0' - }] - }, { - u'name': - u'Single/TypeParameterizedTestSuite/1', - u'tests': - 1, - u'failures': - 0, - u'disabled': - 0, - u'errors': - 0, - u'time': - u'*', - u'timestamp': - u'*', - u'testsuite': [{ - u'name': u'HasTypeParamAttribute', - u'type_param': u'long', - u'file': u'gtest_xml_output_unittest_.cc', - u'line': 178, - u'status': u'RUN', - u'result': u'COMPLETED', - u'time': u'*', - u'timestamp': u'*', - u'classname': u'Single/TypeParameterizedTestSuite/1' - }] - }, { - u'name': - u'Single/ValueParamTest', - u'tests': - 4, - u'failures': - 0, - u'disabled': - 0, - u'errors': - 0, - u'time': - u'*', - u'timestamp': - u'*', - u'testsuite': [{ - u'name': u'HasValueParamAttribute/0', - u'value_param': u'33', - u'file': u'gtest_xml_output_unittest_.cc', - u'line': 162, - u'status': u'RUN', - u'result': u'COMPLETED', - u'time': u'*', - u'timestamp': u'*', - u'classname': u'Single/ValueParamTest' - }, { - u'name': u'HasValueParamAttribute/1', - u'value_param': u'42', - u'file': u'gtest_xml_output_unittest_.cc', - u'line': 162, - u'status': u'RUN', - u'result': u'COMPLETED', - u'time': u'*', - u'timestamp': u'*', - u'classname': u'Single/ValueParamTest' - }, { - u'name': u'AnotherTestThatHasValueParamAttribute/0', - u'value_param': u'33', - u'file': u'gtest_xml_output_unittest_.cc', - u'line': 163, - u'status': u'RUN', - u'result': u'COMPLETED', - u'time': u'*', - u'timestamp': u'*', - u'classname': u'Single/ValueParamTest' - }, { - u'name': u'AnotherTestThatHasValueParamAttribute/1', - u'value_param': u'42', - u'file': u'gtest_xml_output_unittest_.cc', - u'line': 163, - u'status': u'RUN', - u'result': u'COMPLETED', - u'time': u'*', - u'timestamp': u'*', - u'classname': u'Single/ValueParamTest' - }] - }] + 'tests': 26, + 'failures': 5, + 'disabled': 2, + 'errors': 0, + 'timestamp': '*', + 'time': '*', + 'ad_hoc_property': '42', + 'name': 'AllTests', + 'testsuites': [ + { + 'name': 'SuccessfulTest', + 'tests': 1, + 'failures': 0, + 'disabled': 0, + 'errors': 0, + 'time': '*', + 'timestamp': '*', + 'testsuite': [{ + 'name': 'Succeeds', + 'file': 'gtest_xml_output_unittest_.cc', + 'line': 51, + 'status': 'RUN', + 'result': 'COMPLETED', + 'time': '*', + 'timestamp': '*', + 'classname': 'SuccessfulTest', + }], + }, + { + 'name': 'FailedTest', + 'tests': 1, + 'failures': 1, + 'disabled': 0, + 'errors': 0, + 'time': '*', + 'timestamp': '*', + 'testsuite': [{ + 'name': 'Fails', + 'file': 'gtest_xml_output_unittest_.cc', + 'line': 59, + 'status': 'RUN', + 'result': 'COMPLETED', + 'time': '*', + 'timestamp': '*', + 'classname': 'FailedTest', + 'failures': [{ + 'failure': ( + 'gtest_xml_output_unittest_.cc:*\n' + 'Expected equality of these values:\n' + ' 1\n 2' + + STACK_TRACE_TEMPLATE + ), + 'type': '', + }], + }], + }, + { + 'name': 'DisabledTest', + 'tests': 1, + 'failures': 0, + 'disabled': 1, + 'errors': 0, + 'time': '*', + 'timestamp': '*', + 'testsuite': [{ + 'name': 'DISABLED_test_not_run', + 'file': 'gtest_xml_output_unittest_.cc', + 'line': 66, + 'status': 'NOTRUN', + 'result': 'SUPPRESSED', + 'time': '*', + 'timestamp': '*', + 'classname': 'DisabledTest', + }], + }, + { + 'name': 'SkippedTest', + 'tests': 3, + 'failures': 1, + 'disabled': 0, + 'errors': 0, + 'time': '*', + 'timestamp': '*', + 'testsuite': [ + { + 'name': 'Skipped', + 'file': 'gtest_xml_output_unittest_.cc', + 'line': 73, + 'status': 'RUN', + 'result': 'SKIPPED', + 'time': '*', + 'timestamp': '*', + 'classname': 'SkippedTest', + }, + { + 'name': 'SkippedWithMessage', + 'file': 'gtest_xml_output_unittest_.cc', + 'line': 77, + 'status': 'RUN', + 'result': 'SKIPPED', + 'time': '*', + 'timestamp': '*', + 'classname': 'SkippedTest', + }, + { + 'name': 'SkippedAfterFailure', + 'file': 'gtest_xml_output_unittest_.cc', + 'line': 81, + 'status': 'RUN', + 'result': 'COMPLETED', + 'time': '*', + 'timestamp': '*', + 'classname': 'SkippedTest', + 'failures': [{ + 'failure': ( + 'gtest_xml_output_unittest_.cc:*\n' + 'Expected equality of these values:\n' + ' 1\n 2' + + STACK_TRACE_TEMPLATE + ), + 'type': '', + }], + }, + ], + }, + { + 'name': 'MixedResultTest', + 'tests': 3, + 'failures': 1, + 'disabled': 1, + 'errors': 0, + 'time': '*', + 'timestamp': '*', + 'testsuite': [ + { + 'name': 'Succeeds', + 'file': 'gtest_xml_output_unittest_.cc', + 'line': 86, + 'status': 'RUN', + 'result': 'COMPLETED', + 'time': '*', + 'timestamp': '*', + 'classname': 'MixedResultTest', + }, + { + 'name': 'Fails', + 'file': 'gtest_xml_output_unittest_.cc', + 'line': 91, + 'status': 'RUN', + 'result': 'COMPLETED', + 'time': '*', + 'timestamp': '*', + 'classname': 'MixedResultTest', + 'failures': [ + { + 'failure': ( + 'gtest_xml_output_unittest_.cc:*\n' + 'Expected equality of these values:\n' + ' 1\n 2' + + STACK_TRACE_TEMPLATE + ), + 'type': '', + }, + { + 'failure': ( + 'gtest_xml_output_unittest_.cc:*\n' + 'Expected equality of these values:\n' + ' 2\n 3' + + STACK_TRACE_TEMPLATE + ), + 'type': '', + }, + ], + }, + { + 'name': 'DISABLED_test', + 'file': 'gtest_xml_output_unittest_.cc', + 'line': 96, + 'status': 'NOTRUN', + 'result': 'SUPPRESSED', + 'time': '*', + 'timestamp': '*', + 'classname': 'MixedResultTest', + }, + ], + }, + { + 'name': 'XmlQuotingTest', + 'tests': 1, + 'failures': 1, + 'disabled': 0, + 'errors': 0, + 'time': '*', + 'timestamp': '*', + 'testsuite': [{ + 'name': 'OutputsCData', + 'file': 'gtest_xml_output_unittest_.cc', + 'line': 100, + 'status': 'RUN', + 'result': 'COMPLETED', + 'time': '*', + 'timestamp': '*', + 'classname': 'XmlQuotingTest', + 'failures': [{ + 'failure': ( + 'gtest_xml_output_unittest_.cc:*\n' + 'Failed\nXML output: ' + '' + + STACK_TRACE_TEMPLATE + ), + 'type': '', + }], + }], + }, + { + 'name': 'InvalidCharactersTest', + 'tests': 1, + 'failures': 1, + 'disabled': 0, + 'errors': 0, + 'time': '*', + 'timestamp': '*', + 'testsuite': [{ + 'name': 'InvalidCharactersInMessage', + 'file': 'gtest_xml_output_unittest_.cc', + 'line': 107, + 'status': 'RUN', + 'result': 'COMPLETED', + 'time': '*', + 'timestamp': '*', + 'classname': 'InvalidCharactersTest', + 'failures': [{ + 'failure': ( + 'gtest_xml_output_unittest_.cc:*\n' + 'Failed\nInvalid characters in brackets' + ' [\x01\x02]' + + STACK_TRACE_TEMPLATE + ), + 'type': '', + }], + }], + }, + { + 'name': 'PropertyRecordingTest', + 'tests': 4, + 'failures': 0, + 'disabled': 0, + 'errors': 0, + 'time': '*', + 'timestamp': '*', + 'SetUpTestSuite': 'yes', + 'TearDownTestSuite': 'aye', + 'testsuite': [ + { + 'name': 'OneProperty', + 'file': 'gtest_xml_output_unittest_.cc', + 'line': 119, + 'status': 'RUN', + 'result': 'COMPLETED', + 'time': '*', + 'timestamp': '*', + 'classname': 'PropertyRecordingTest', + 'key_1': '1', + }, + { + 'name': 'IntValuedProperty', + 'file': 'gtest_xml_output_unittest_.cc', + 'line': 123, + 'status': 'RUN', + 'result': 'COMPLETED', + 'time': '*', + 'timestamp': '*', + 'classname': 'PropertyRecordingTest', + 'key_int': '1', + }, + { + 'name': 'ThreeProperties', + 'file': 'gtest_xml_output_unittest_.cc', + 'line': 127, + 'status': 'RUN', + 'result': 'COMPLETED', + 'time': '*', + 'timestamp': '*', + 'classname': 'PropertyRecordingTest', + 'key_1': '1', + 'key_2': '2', + 'key_3': '3', + }, + { + 'name': 'TwoValuesForOneKeyUsesLastValue', + 'file': 'gtest_xml_output_unittest_.cc', + 'line': 133, + 'status': 'RUN', + 'result': 'COMPLETED', + 'time': '*', + 'timestamp': '*', + 'classname': 'PropertyRecordingTest', + 'key_1': '2', + }, + ], + }, + { + 'name': 'NoFixtureTest', + 'tests': 3, + 'failures': 0, + 'disabled': 0, + 'errors': 0, + 'time': '*', + 'timestamp': '*', + 'testsuite': [ + { + 'name': 'RecordProperty', + 'file': 'gtest_xml_output_unittest_.cc', + 'line': 138, + 'status': 'RUN', + 'result': 'COMPLETED', + 'time': '*', + 'timestamp': '*', + 'classname': 'NoFixtureTest', + 'key': '1', + }, + { + 'name': 'ExternalUtilityThatCallsRecordIntValuedProperty', + 'file': 'gtest_xml_output_unittest_.cc', + 'line': 151, + 'status': 'RUN', + 'result': 'COMPLETED', + 'time': '*', + 'timestamp': '*', + 'classname': 'NoFixtureTest', + 'key_for_utility_int': '1', + }, + { + 'name': ( + 'ExternalUtilityThatCallsRecordStringValuedProperty' + ), + 'file': 'gtest_xml_output_unittest_.cc', + 'line': 155, + 'status': 'RUN', + 'result': 'COMPLETED', + 'time': '*', + 'timestamp': '*', + 'classname': 'NoFixtureTest', + 'key_for_utility_string': '1', + }, + ], + }, + { + 'name': 'TypedTest/0', + 'tests': 1, + 'failures': 0, + 'disabled': 0, + 'errors': 0, + 'time': '*', + 'timestamp': '*', + 'testsuite': [{ + 'name': 'HasTypeParamAttribute', + 'type_param': 'int', + 'file': 'gtest_xml_output_unittest_.cc', + 'line': 171, + 'status': 'RUN', + 'result': 'COMPLETED', + 'time': '*', + 'timestamp': '*', + 'classname': 'TypedTest/0', + }], + }, + { + 'name': 'TypedTest/1', + 'tests': 1, + 'failures': 0, + 'disabled': 0, + 'errors': 0, + 'time': '*', + 'timestamp': '*', + 'testsuite': [{ + 'name': 'HasTypeParamAttribute', + 'type_param': 'long', + 'file': 'gtest_xml_output_unittest_.cc', + 'line': 171, + 'status': 'RUN', + 'result': 'COMPLETED', + 'time': '*', + 'timestamp': '*', + 'classname': 'TypedTest/1', + }], + }, + { + 'name': 'Single/TypeParameterizedTestSuite/0', + 'tests': 1, + 'failures': 0, + 'disabled': 0, + 'errors': 0, + 'time': '*', + 'timestamp': '*', + 'testsuite': [{ + 'name': 'HasTypeParamAttribute', + 'type_param': 'int', + 'file': 'gtest_xml_output_unittest_.cc', + 'line': 178, + 'status': 'RUN', + 'result': 'COMPLETED', + 'time': '*', + 'timestamp': '*', + 'classname': 'Single/TypeParameterizedTestSuite/0', + }], + }, + { + 'name': 'Single/TypeParameterizedTestSuite/1', + 'tests': 1, + 'failures': 0, + 'disabled': 0, + 'errors': 0, + 'time': '*', + 'timestamp': '*', + 'testsuite': [{ + 'name': 'HasTypeParamAttribute', + 'type_param': 'long', + 'file': 'gtest_xml_output_unittest_.cc', + 'line': 178, + 'status': 'RUN', + 'result': 'COMPLETED', + 'time': '*', + 'timestamp': '*', + 'classname': 'Single/TypeParameterizedTestSuite/1', + }], + }, + { + 'name': 'Single/ValueParamTest', + 'tests': 4, + 'failures': 0, + 'disabled': 0, + 'errors': 0, + 'time': '*', + 'timestamp': '*', + 'testsuite': [ + { + 'name': 'HasValueParamAttribute/0', + 'value_param': '33', + 'file': 'gtest_xml_output_unittest_.cc', + 'line': 162, + 'status': 'RUN', + 'result': 'COMPLETED', + 'time': '*', + 'timestamp': '*', + 'classname': 'Single/ValueParamTest', + }, + { + 'name': 'HasValueParamAttribute/1', + 'value_param': '42', + 'file': 'gtest_xml_output_unittest_.cc', + 'line': 162, + 'status': 'RUN', + 'result': 'COMPLETED', + 'time': '*', + 'timestamp': '*', + 'classname': 'Single/ValueParamTest', + }, + { + 'name': 'AnotherTestThatHasValueParamAttribute/0', + 'value_param': '33', + 'file': 'gtest_xml_output_unittest_.cc', + 'line': 163, + 'status': 'RUN', + 'result': 'COMPLETED', + 'time': '*', + 'timestamp': '*', + 'classname': 'Single/ValueParamTest', + }, + { + 'name': 'AnotherTestThatHasValueParamAttribute/1', + 'value_param': '42', + 'file': 'gtest_xml_output_unittest_.cc', + 'line': 163, + 'status': 'RUN', + 'result': 'COMPLETED', + 'time': '*', + 'timestamp': '*', + 'classname': 'Single/ValueParamTest', + }, + ], + }, + ], } EXPECTED_FILTERED = { - u'tests': - 1, - u'failures': - 0, - u'disabled': - 0, - u'errors': - 0, - u'time': - u'*', - u'timestamp': - u'*', - u'name': - u'AllTests', - u'ad_hoc_property': - u'42', - u'testsuites': [{ - u'name': - u'SuccessfulTest', - u'tests': - 1, - u'failures': - 0, - u'disabled': - 0, - u'errors': - 0, - u'time': - u'*', - u'timestamp': - u'*', - u'testsuite': [{ - u'name': u'Succeeds', - u'file': u'gtest_xml_output_unittest_.cc', - u'line': 51, - u'status': u'RUN', - u'result': u'COMPLETED', - u'time': u'*', - u'timestamp': u'*', - u'classname': u'SuccessfulTest', - }] + 'tests': 1, + 'failures': 0, + 'disabled': 0, + 'errors': 0, + 'time': '*', + 'timestamp': '*', + 'name': 'AllTests', + 'ad_hoc_property': '42', + 'testsuites': [{ + 'name': 'SuccessfulTest', + 'tests': 1, + 'failures': 0, + 'disabled': 0, + 'errors': 0, + 'time': '*', + 'timestamp': '*', + 'testsuite': [{ + 'name': 'Succeeds', + 'file': 'gtest_xml_output_unittest_.cc', + 'line': 51, + 'status': 'RUN', + 'result': 'COMPLETED', + 'time': '*', + 'timestamp': '*', + 'classname': 'SuccessfulTest', + }], }], } EXPECTED_NO_TEST = { - u'tests': - 0, - u'failures': - 0, - u'disabled': - 0, - u'errors': - 0, - u'time': - u'*', - u'timestamp': - u'*', - u'name': - u'AllTests', - u'testsuites': [{ - u'name': - u'NonTestSuiteFailure', - u'tests': - 1, - u'failures': - 1, - u'disabled': - 0, - u'skipped': - 0, - u'errors': - 0, - u'time': - u'*', - u'timestamp': - u'*', - u'testsuite': [{ - u'name': - u'', - u'status': - u'RUN', - u'result': - u'COMPLETED', - u'time': - u'*', - u'timestamp': - u'*', - u'classname': - u'', - u'failures': [{ - u'failure': u'gtest_no_test_unittest.cc:*\n' - u'Expected equality of these values:\n' - u' 1\n 2' + STACK_TRACE_TEMPLATE, - u'type': u'', - }] - }] + 'tests': 0, + 'failures': 0, + 'disabled': 0, + 'errors': 0, + 'time': '*', + 'timestamp': '*', + 'name': 'AllTests', + 'testsuites': [{ + 'name': 'NonTestSuiteFailure', + 'tests': 1, + 'failures': 1, + 'disabled': 0, + 'skipped': 0, + 'errors': 0, + 'time': '*', + 'timestamp': '*', + 'testsuite': [{ + 'name': '', + 'status': 'RUN', + 'result': 'COMPLETED', + 'time': '*', + 'timestamp': '*', + 'classname': '', + 'failures': [{ + 'failure': ( + 'gtest_no_test_unittest.cc:*\n' + 'Expected equality of these values:\n' + ' 1\n 2' + + STACK_TRACE_TEMPLATE + ), + 'type': '', + }], + }], }], } GTEST_PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath(GTEST_PROGRAM_NAME) -SUPPORTS_TYPED_TESTS = 'TypedTest' in gtest_test_utils.Subprocess( - [GTEST_PROGRAM_PATH, GTEST_LIST_TESTS_FLAG], capture_stderr=False).output +SUPPORTS_TYPED_TESTS = ( + 'TypedTest' + in gtest_test_utils.Subprocess( + [GTEST_PROGRAM_PATH, GTEST_LIST_TESTS_FLAG], capture_stderr=False + ).output +) class GTestJsonOutputUnitTest(gtest_test_utils.TestCase): - """Unit test for Google Test's JSON output functionality. - """ + """Unit test for Google Test's JSON output functionality.""" # This test currently breaks on platforms that do not support typed and # type-parameterized tests, so we don't run it under them. @@ -775,16 +656,23 @@ class GTestJsonOutputUnitTest(gtest_test_utils.TestCase): match = re.match(r'(\d+)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)', date_time_str) self.assertTrue( re.match, - 'JSON datettime string %s has incorrect format' % date_time_str) + 'JSON datettime string %s has incorrect format' % date_time_str, + ) date_time_from_json = datetime.datetime( - year=int(match.group(1)), month=int(match.group(2)), - day=int(match.group(3)), hour=int(match.group(4)), - minute=int(match.group(5)), second=int(match.group(6))) + year=int(match.group(1)), + month=int(match.group(2)), + day=int(match.group(3)), + hour=int(match.group(4)), + minute=int(match.group(5)), + second=int(match.group(6)), + ) time_delta = abs(datetime.datetime.now() - date_time_from_json) # timestamp value should be near the current local time - self.assertTrue(time_delta < datetime.timedelta(seconds=600), - 'time_delta is %s' % time_delta) + self.assertTrue( + time_delta < datetime.timedelta(seconds=600), + 'time_delta is %s' % time_delta, + ) def testDefaultOutputFile(self): """Verifies the default output file name. @@ -792,10 +680,12 @@ class GTestJsonOutputUnitTest(gtest_test_utils.TestCase): Confirms that Google Test produces an JSON output file with the expected default name if no name is explicitly specified. """ - output_file = os.path.join(gtest_test_utils.GetTempDir(), - GTEST_DEFAULT_OUTPUT_FILE) + output_file = os.path.join( + gtest_test_utils.GetTempDir(), GTEST_DEFAULT_OUTPUT_FILE + ) gtest_prog_path = gtest_test_utils.GetTestExecutablePath( - 'gtest_no_test_unittest') + 'gtest_no_test_unittest' + ) try: os.remove(output_file) except OSError: @@ -805,7 +695,8 @@ class GTestJsonOutputUnitTest(gtest_test_utils.TestCase): p = gtest_test_utils.Subprocess( [gtest_prog_path, '%s=json' % GTEST_OUTPUT_FLAG], - working_dir=gtest_test_utils.GetTempDir()) + working_dir=gtest_test_utils.GetTempDir(), + ) self.assertTrue(p.exited) self.assertEqual(0, p.exit_code) self.assertTrue(os.path.isfile(output_file)) @@ -817,20 +708,24 @@ class GTestJsonOutputUnitTest(gtest_test_utils.TestCase): shut down before RUN_ALL_TESTS is invoked. """ - json_path = os.path.join(gtest_test_utils.GetTempDir(), - GTEST_PROGRAM_NAME + 'out.json') + json_path = os.path.join( + gtest_test_utils.GetTempDir(), GTEST_PROGRAM_NAME + 'out.json' + ) if os.path.isfile(json_path): os.remove(json_path) - command = [GTEST_PROGRAM_PATH, - '%s=json:%s' % (GTEST_OUTPUT_FLAG, json_path), - '--shut_down_xml'] + command = [ + GTEST_PROGRAM_PATH, + '%s=json:%s' % (GTEST_OUTPUT_FLAG, json_path), + '--shut_down_xml', + ] p = gtest_test_utils.Subprocess(command) if p.terminated_by_signal: # p.signal is available only if p.terminated_by_signal is True. self.assertFalse( p.terminated_by_signal, - '%s was killed by signal %d' % (GTEST_PROGRAM_NAME, p.signal)) + '%s was killed by signal %d' % (GTEST_PROGRAM_NAME, p.signal), + ) else: self.assertTrue(p.exited) self.assertEqual( @@ -849,8 +744,12 @@ class GTestJsonOutputUnitTest(gtest_test_utils.TestCase): non-selected tests do not show up in the JSON output. """ - self._TestJsonOutput(GTEST_PROGRAM_NAME, EXPECTED_FILTERED, 0, - extra_args=['%s=SuccessfulTest.*' % GTEST_FILTER_FLAG]) + self._TestJsonOutput( + GTEST_PROGRAM_NAME, + EXPECTED_FILTERED, + 0, + extra_args=['%s=SuccessfulTest.*' % GTEST_FILTER_FLAG], + ) def _GetJsonOutput(self, gtest_prog_name, extra_args, expected_exit_code): """Returns the JSON output generated by running the program gtest_prog_name. @@ -862,14 +761,15 @@ class GTestJsonOutputUnitTest(gtest_test_utils.TestCase): extra_args: extra arguments to binary invocation. expected_exit_code: program's exit code. """ - json_path = os.path.join(gtest_test_utils.GetTempDir(), - gtest_prog_name + 'out.json') + json_path = os.path.join( + gtest_test_utils.GetTempDir(), gtest_prog_name + 'out.json' + ) gtest_prog_path = gtest_test_utils.GetTestExecutablePath(gtest_prog_name) - command = ( - [gtest_prog_path, '%s=json:%s' % (GTEST_OUTPUT_FLAG, json_path)] + - extra_args - ) + command = [ + gtest_prog_path, + '%s=json:%s' % (GTEST_OUTPUT_FLAG, json_path), + ] + extra_args p = gtest_test_utils.Subprocess(command) if p.terminated_by_signal: self.assertTrue( @@ -888,8 +788,9 @@ class GTestJsonOutputUnitTest(gtest_test_utils.TestCase): actual = json.load(f) return actual - def _TestJsonOutput(self, gtest_prog_name, expected, - expected_exit_code, extra_args=None): + def _TestJsonOutput( + self, gtest_prog_name, expected, expected_exit_code, extra_args=None + ): """Checks the JSON output generated by the Google Test binary. Asserts that the JSON document generated by running the program @@ -904,8 +805,9 @@ class GTestJsonOutputUnitTest(gtest_test_utils.TestCase): extra_args: extra arguments to binary invocation. """ - actual = self._GetJsonOutput(gtest_prog_name, extra_args or [], - expected_exit_code) + actual = self._GetJsonOutput( + gtest_prog_name, extra_args or [], expected_exit_code + ) self.assertEqual(expected, gtest_json_test_utils.normalize(actual)) diff --git a/googletest/test/googletest-list-tests-unittest.py b/googletest/test/googletest-list-tests-unittest.py index 485150ddf..f59fca011 100755 --- a/googletest/test/googletest-list-tests-unittest.py +++ b/googletest/test/googletest-list-tests-unittest.py @@ -46,11 +46,14 @@ from googletest.test import gtest_test_utils LIST_TESTS_FLAG = 'gtest_list_tests' # Path to the googletest-list-tests-unittest_ program. -EXE_PATH = gtest_test_utils.GetTestExecutablePath('googletest-list-tests-unittest_') +EXE_PATH = gtest_test_utils.GetTestExecutablePath( + 'googletest-list-tests-unittest_' +) # The expected output when running googletest-list-tests-unittest_ with # --gtest_list_tests -EXPECTED_OUTPUT_NO_FILTER_RE = re.compile(r"""FooDeathTest\. +EXPECTED_OUTPUT_NO_FILTER_RE = re.compile( + r"""FooDeathTest\. Test1 Foo\. Bar1 @@ -90,11 +93,13 @@ MyInstantiation/ValueParamTest\. TestB/0 # GetParam\(\) = one line TestB/1 # GetParam\(\) = two\\nlines TestB/2 # GetParam\(\) = a very\\nlo{241}\.\.\. -""") +""" +) # The expected output when running googletest-list-tests-unittest_ with # --gtest_list_tests and --gtest_filter=Foo*. -EXPECTED_OUTPUT_FILTER_FOO_RE = re.compile(r"""FooDeathTest\. +EXPECTED_OUTPUT_FILTER_FOO_RE = re.compile( + r"""FooDeathTest\. Test1 Foo\. Bar1 @@ -106,7 +111,8 @@ FooTest\. Test1 DISABLED_Test2 Test3 -""") +""" +) # Utilities. @@ -114,8 +120,9 @@ FooTest\. def Run(args): """Runs googletest-list-tests-unittest_ and returns the list of tests printed.""" - return gtest_test_utils.Subprocess([EXE_PATH] + args, - capture_stderr=False).output + return gtest_test_utils.Subprocess( + [EXE_PATH] + args, capture_stderr=False + ).output # The unit test. @@ -129,13 +136,12 @@ class GTestListTestsUnitTest(gtest_test_utils.TestCase): the correct tests. Args: - flag_value: value of the --gtest_list_tests flag; - None if the flag should not be present. - expected_output_re: regular expression that matches the expected - output after running command; - other_flag: a different flag to be passed to command - along with gtest_list_tests; - None if the flag should not be present. + flag_value: value of the --gtest_list_tests flag; None if the flag + should not be present. + expected_output_re: regular expression that matches the expected output + after running command; + other_flag: a different flag to be passed to command along with + gtest_list_tests; None if the flag should not be present. """ if flag_value is None: @@ -178,34 +184,37 @@ class GTestListTestsUnitTest(gtest_test_utils.TestCase): def testDefaultBehavior(self): """Tests the behavior of the default mode.""" - self.RunAndVerify(flag_value=None, - expected_output_re=None, - other_flag=None) + self.RunAndVerify(flag_value=None, expected_output_re=None, other_flag=None) def testFlag(self): """Tests using the --gtest_list_tests flag.""" - self.RunAndVerify(flag_value='0', - expected_output_re=None, - other_flag=None) - self.RunAndVerify(flag_value='1', - expected_output_re=EXPECTED_OUTPUT_NO_FILTER_RE, - other_flag=None) + self.RunAndVerify(flag_value='0', expected_output_re=None, other_flag=None) + self.RunAndVerify( + flag_value='1', + expected_output_re=EXPECTED_OUTPUT_NO_FILTER_RE, + other_flag=None, + ) def testOverrideNonFilterFlags(self): """Tests that --gtest_list_tests overrides the non-filter flags.""" - self.RunAndVerify(flag_value='1', - expected_output_re=EXPECTED_OUTPUT_NO_FILTER_RE, - other_flag='--gtest_break_on_failure') + self.RunAndVerify( + flag_value='1', + expected_output_re=EXPECTED_OUTPUT_NO_FILTER_RE, + other_flag='--gtest_break_on_failure', + ) def testWithFilterFlags(self): """Tests that --gtest_list_tests takes into account the - --gtest_filter flag.""" + --gtest_filter flag. + """ - self.RunAndVerify(flag_value='1', - expected_output_re=EXPECTED_OUTPUT_FILTER_FOO_RE, - other_flag='--gtest_filter=Foo*') + self.RunAndVerify( + flag_value='1', + expected_output_re=EXPECTED_OUTPUT_FILTER_FOO_RE, + other_flag='--gtest_filter=Foo*', + ) if __name__ == '__main__': diff --git a/googletest/test/googletest-output-test.py b/googletest/test/googletest-output-test.py index ff4448333..5185ed975 100755 --- a/googletest/test/googletest-output-test.py +++ b/googletest/test/googletest-output-test.py @@ -63,20 +63,32 @@ PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath('googletest-output-test_') # 'internal_skip_environment_and_ad_hoc_tests' argument. COMMAND_LIST_TESTS = ({}, [PROGRAM_PATH, '--gtest_list_tests']) COMMAND_WITH_COLOR = ({}, [PROGRAM_PATH, '--gtest_color=yes']) -COMMAND_WITH_TIME = ({}, [PROGRAM_PATH, - '--gtest_print_time', - 'internal_skip_environment_and_ad_hoc_tests', - '--gtest_filter=FatalFailureTest.*:LoggingTest.*']) +COMMAND_WITH_TIME = ( + {}, + [ + PROGRAM_PATH, + '--gtest_print_time', + 'internal_skip_environment_and_ad_hoc_tests', + '--gtest_filter=FatalFailureTest.*:LoggingTest.*', + ], +) COMMAND_WITH_DISABLED = ( - {}, [PROGRAM_PATH, - '--gtest_also_run_disabled_tests', - 'internal_skip_environment_and_ad_hoc_tests', - '--gtest_filter=*DISABLED_*']) + {}, + [ + PROGRAM_PATH, + '--gtest_also_run_disabled_tests', + 'internal_skip_environment_and_ad_hoc_tests', + '--gtest_filter=*DISABLED_*', + ], +) COMMAND_WITH_SHARDING = ( {'GTEST_SHARD_INDEX': '1', 'GTEST_TOTAL_SHARDS': '2'}, - [PROGRAM_PATH, - 'internal_skip_environment_and_ad_hoc_tests', - '--gtest_filter=PassingTest.*']) + [ + PROGRAM_PATH, + 'internal_skip_environment_and_ad_hoc_tests', + '--gtest_filter=PassingTest.*', + ], +) GOLDEN_PATH = os.path.join(gtest_test_utils.GetSourceDir(), GOLDEN_NAME) @@ -100,16 +112,20 @@ def RemoveLocations(test_output): 'FILE_NAME:#: '. """ - return re.sub(r'.*[/\\]((googletest-output-test_|gtest).cc)(\:\d+|\(\d+\))\: ', - r'\1:#: ', test_output) + return re.sub( + r'.*[/\\]((googletest-output-test_|gtest).cc)(\:\d+|\(\d+\))\: ', + r'\1:#: ', + test_output, + ) def RemoveStackTraceDetails(output): """Removes all stack traces from a Google Test program's output.""" # *? means "find the shortest string that matches". - return re.sub(r'Stack trace:(.|\n)*?\n\n', - 'Stack trace: (omitted)\n\n', output) + return re.sub( + r'Stack trace:(.|\n)*?\n\n', 'Stack trace: (omitted)\n\n', output + ) def RemoveStackTraces(output): @@ -156,14 +172,12 @@ def NormalizeToCurrentPlatform(test_output): def RemoveTestCounts(output): """Removes test counts from a Google Test program's output.""" - output = re.sub(r'\d+ tests?, listed below', - '? tests, listed below', output) - output = re.sub(r'\d+ FAILED TESTS', - '? FAILED TESTS', output) - output = re.sub(r'\d+ tests? from \d+ test cases?', - '? tests from ? test cases', output) - output = re.sub(r'\d+ tests? from ([a-zA-Z_])', - r'? tests from \1', output) + output = re.sub(r'\d+ tests?, listed below', '? tests, listed below', output) + output = re.sub(r'\d+ FAILED TESTS', '? FAILED TESTS', output) + output = re.sub( + r'\d+ tests? from \d+ test cases?', '? tests from ? test cases', output + ) + output = re.sub(r'\d+ tests? from ([a-zA-Z_])', r'? tests from \1', output) return re.sub(r'\d+ tests?\.', '? tests.', output) @@ -175,18 +189,19 @@ def RemoveMatchingTests(test_output, pattern): Args: test_output: A string containing the test output. - pattern: A regex string that matches names of test cases or - tests to remove. + pattern: A regex string that matches names of test cases or tests + to remove. Returns: Contents of test_output with tests whose names match pattern removed. """ test_output = re.sub( - r'.*\[ RUN \] .*%s(.|\n)*?\[( FAILED | OK )\] .*%s.*\n' % ( - pattern, pattern), + r'.*\[ RUN \] .*%s(.|\n)*?\[( FAILED | OK )\] .*%s.*\n' + % (pattern, pattern), '', - test_output) + test_output, + ) return re.sub(r'.*%s.*\n' % pattern, '', test_output) @@ -205,8 +220,8 @@ def GetShellCommandOutput(env_cmd): Args: env_cmd: The shell command. A 2-tuple where element 0 is a dict of extra - environment variables to set, and element 1 is a string with - the command and any flags. + environment variables to set, and element 1 is a string with the command + and any flags. Returns: A string with the command's combined standard and diagnostic output. @@ -227,8 +242,8 @@ def GetCommandOutput(env_cmd): Args: env_cmd: The shell command. A 2-tuple where element 0 is a dict of extra - environment variables to set, and element 1 is a string with - the command and any flags. + environment variables to set, and element 1 is a string with the command + and any flags. """ # Disables exception pop-ups on Windows. @@ -241,10 +256,12 @@ def GetCommandOutput(env_cmd): def GetOutputOfAllCommands(): """Returns concatenated output from several representative commands.""" - return (GetCommandOutput(COMMAND_WITH_COLOR) + - GetCommandOutput(COMMAND_WITH_TIME) + - GetCommandOutput(COMMAND_WITH_DISABLED) + - GetCommandOutput(COMMAND_WITH_SHARDING)) + return ( + GetCommandOutput(COMMAND_WITH_COLOR) + + GetCommandOutput(COMMAND_WITH_TIME) + + GetCommandOutput(COMMAND_WITH_DISABLED) + + GetCommandOutput(COMMAND_WITH_SHARDING) + ) test_list = GetShellCommandOutput(COMMAND_LIST_TESTS) @@ -253,12 +270,16 @@ SUPPORTS_TYPED_TESTS = 'TypedTest' in test_list SUPPORTS_THREADS = 'ExpectFailureWithThreadsTest' in test_list SUPPORTS_STACK_TRACES = NO_STACKTRACE_SUPPORT_FLAG not in sys.argv -CAN_GENERATE_GOLDEN_FILE = (SUPPORTS_DEATH_TESTS and - SUPPORTS_TYPED_TESTS and - SUPPORTS_THREADS and - SUPPORTS_STACK_TRACES) +CAN_GENERATE_GOLDEN_FILE = ( + SUPPORTS_DEATH_TESTS + and SUPPORTS_TYPED_TESTS + and SUPPORTS_THREADS + and SUPPORTS_STACK_TRACES +) + class GTestOutputTest(gtest_test_utils.TestCase): + def RemoveUnsupportedTests(self, test_output): if not SUPPORTS_DEATH_TESTS: test_output = RemoveMatchingTests(test_output, 'DeathTest') @@ -267,12 +288,13 @@ class GTestOutputTest(gtest_test_utils.TestCase): test_output = RemoveMatchingTests(test_output, 'TypedDeathTest') test_output = RemoveMatchingTests(test_output, 'TypeParamDeathTest') if not SUPPORTS_THREADS: - test_output = RemoveMatchingTests(test_output, - 'ExpectFailureWithThreadsTest') - test_output = RemoveMatchingTests(test_output, - 'ScopedFakeTestPartResultReporterTest') - test_output = RemoveMatchingTests(test_output, - 'WorksConcurrently') + test_output = RemoveMatchingTests( + test_output, 'ExpectFailureWithThreadsTest' + ) + test_output = RemoveMatchingTests( + test_output, 'ScopedFakeTestPartResultReporterTest' + ) + test_output = RemoveMatchingTests(test_output, 'WorksConcurrently') if not SUPPORTS_STACK_TRACES: test_output = RemoveStackTraces(test_output) @@ -297,27 +319,42 @@ class GTestOutputTest(gtest_test_utils.TestCase): normalized_golden = RemoveTypeInfoDetails(golden) if CAN_GENERATE_GOLDEN_FILE: - self.assertEqual(normalized_golden, normalized_actual, - '\n'.join(difflib.unified_diff( - normalized_golden.split('\n'), - normalized_actual.split('\n'), - 'golden', 'actual'))) + self.assertEqual( + normalized_golden, + normalized_actual, + '\n'.join( + difflib.unified_diff( + normalized_golden.split('\n'), + normalized_actual.split('\n'), + 'golden', + 'actual', + ) + ), + ) else: normalized_actual = NormalizeToCurrentPlatform( - RemoveTestCounts(normalized_actual)) + RemoveTestCounts(normalized_actual) + ) normalized_golden = NormalizeToCurrentPlatform( - RemoveTestCounts(self.RemoveUnsupportedTests(normalized_golden))) + RemoveTestCounts(self.RemoveUnsupportedTests(normalized_golden)) + ) # This code is very handy when debugging golden file differences: if os.getenv('DEBUG_GTEST_OUTPUT_TEST'): - open(os.path.join( - gtest_test_utils.GetSourceDir(), - '_googletest-output-test_normalized_actual.txt'), 'wb').write( - normalized_actual) - open(os.path.join( - gtest_test_utils.GetSourceDir(), - '_googletest-output-test_normalized_golden.txt'), 'wb').write( - normalized_golden) + open( + os.path.join( + gtest_test_utils.GetSourceDir(), + '_googletest-output-test_normalized_actual.txt', + ), + 'wb', + ).write(normalized_actual) + open( + os.path.join( + gtest_test_utils.GetSourceDir(), + '_googletest-output-test_normalized_golden.txt', + ), + 'wb', + ).write(normalized_golden) self.assertEqual(normalized_golden, normalized_actual) @@ -334,11 +371,10 @@ if __name__ == '__main__': golden_file.write(output.encode()) golden_file.close() else: - message = ( - """Unable to write a golden file when compiled in an environment + message = """Unable to write a golden file when compiled in an environment that does not support all the required features (death tests, typed tests, stack traces, and multiple threads). -Please build this test and generate the golden file using Blaze on Linux.""") +Please build this test and generate the golden file using Blaze on Linux.""" sys.stderr.write(message) sys.exit(1) diff --git a/googletest/test/googletest-param-test-invalid-name1-test.py b/googletest/test/googletest-param-test-invalid-name1-test.py index b8d609a70..4886e49e8 100644 --- a/googletest/test/googletest-param-test-invalid-name1-test.py +++ b/googletest/test/googletest-param-test-invalid-name1-test.py @@ -44,7 +44,7 @@ def Assert(condition): def TestExitCodeAndOutput(command): """Runs the given command and verifies its exit code and output.""" - err = ('Parameterized test name \'"InvalidWithQuotes"\' is invalid') + err = 'Parameterized test name \'"InvalidWithQuotes"\' is invalid' p = gtest_test_utils.Subprocess(command) Assert(p.terminated_by_signal) diff --git a/googletest/test/googletest-param-test-invalid-name2-test.py b/googletest/test/googletest-param-test-invalid-name2-test.py index d92fa065a..bcd8ddf0e 100644 --- a/googletest/test/googletest-param-test-invalid-name2-test.py +++ b/googletest/test/googletest-param-test-invalid-name2-test.py @@ -44,7 +44,7 @@ def Assert(condition): def TestExitCodeAndOutput(command): """Runs the given command and verifies its exit code and output.""" - err = ('Duplicate parameterized test name \'a\'') + err = "Duplicate parameterized test name 'a'" p = gtest_test_utils.Subprocess(command) Assert(p.terminated_by_signal) @@ -58,5 +58,6 @@ class GTestParamTestInvalidName2Test(gtest_test_utils.TestCase): def testExitCodeAndOutput(self): TestExitCodeAndOutput(COMMAND) + if __name__ == '__main__': gtest_test_utils.Main() diff --git a/googletest/test/googletest-setuptestsuite-test.py b/googletest/test/googletest-setuptestsuite-test.py index 9d1fd0295..899531f32 100755 --- a/googletest/test/googletest-setuptestsuite-test.py +++ b/googletest/test/googletest-setuptestsuite-test.py @@ -34,7 +34,8 @@ from googletest.test import gtest_test_utils COMMAND = gtest_test_utils.GetTestExecutablePath( - 'googletest-setuptestsuite-test_') + 'googletest-setuptestsuite-test_' +) class GTestSetUpTestSuiteTest(gtest_test_utils.TestCase): @@ -44,11 +45,14 @@ class GTestSetUpTestSuiteTest(gtest_test_utils.TestCase): self.assertNotEqual(p.exit_code, 0, msg=p.output) self.assertIn( - '[ FAILED ] SetupFailTest: SetUpTestSuite or TearDownTestSuite\n' - '[ FAILED ] TearDownFailTest: SetUpTestSuite or TearDownTestSuite\n' - '\n' - ' 2 FAILED TEST SUITES\n', - p.output) + ( + '[ FAILED ] SetupFailTest: SetUpTestSuite or TearDownTestSuite\n[' + ' FAILED ] TearDownFailTest: SetUpTestSuite or' + ' TearDownTestSuite\n\n 2 FAILED TEST SUITES\n' + ), + p.output, + ) + if __name__ == '__main__': gtest_test_utils.Main() diff --git a/googletest/test/googletest-throw-on-failure-test.py b/googletest/test/googletest-throw-on-failure-test.py index 8fc4f54f6..282163bce 100755 --- a/googletest/test/googletest-throw-on-failure-test.py +++ b/googletest/test/googletest-throw-on-failure-test.py @@ -47,7 +47,8 @@ THROW_ON_FAILURE = 'gtest_throw_on_failure' # Path to the googletest-throw-on-failure-test_ program, compiled with # exceptions disabled. EXE_PATH = gtest_test_utils.GetTestExecutablePath( - 'googletest-throw-on-failure-test_') + 'googletest-throw-on-failure-test_' +) # Utilities. @@ -83,9 +84,9 @@ class ThrowOnFailureTest(gtest_test_utils.TestCase): Args: env_var_value: value of the GTEST_BREAK_ON_FAILURE environment - variable; None if the variable should be unset. - flag_value: value of the --gtest_break_on_failure flag; - None if the flag should not be present. + variable; None if the variable should be unset. + flag_value: value of the --gtest_break_on_failure flag; None if the + flag should not be present. should_fail: True if and only if the program is expected to fail. """ @@ -116,10 +117,15 @@ class ThrowOnFailureTest(gtest_test_utils.TestCase): SetEnvVar(THROW_ON_FAILURE, None) - msg = ('when %s%s, an assertion failure in "%s" %s cause a non-zero ' - 'exit code.' % - (THROW_ON_FAILURE, env_var_value_msg, ' '.join(command), - should_or_not)) + msg = ( + 'when %s%s, an assertion failure in "%s" %s cause a non-zero exit code.' + % ( + THROW_ON_FAILURE, + env_var_value_msg, + ' '.join(command), + should_or_not, + ) + ) self.assertTrue(failed == should_fail, msg) def testDefaultBehavior(self): @@ -130,38 +136,22 @@ class ThrowOnFailureTest(gtest_test_utils.TestCase): def testThrowOnFailureEnvVar(self): """Tests using the GTEST_THROW_ON_FAILURE environment variable.""" - self.RunAndVerify(env_var_value='0', - flag_value=None, - should_fail=False) - self.RunAndVerify(env_var_value='1', - flag_value=None, - should_fail=True) + self.RunAndVerify(env_var_value='0', flag_value=None, should_fail=False) + self.RunAndVerify(env_var_value='1', flag_value=None, should_fail=True) def testThrowOnFailureFlag(self): """Tests using the --gtest_throw_on_failure flag.""" - self.RunAndVerify(env_var_value=None, - flag_value='0', - should_fail=False) - self.RunAndVerify(env_var_value=None, - flag_value='1', - should_fail=True) + self.RunAndVerify(env_var_value=None, flag_value='0', should_fail=False) + self.RunAndVerify(env_var_value=None, flag_value='1', should_fail=True) def testThrowOnFailureFlagOverridesEnvVar(self): """Tests that --gtest_throw_on_failure overrides GTEST_THROW_ON_FAILURE.""" - self.RunAndVerify(env_var_value='0', - flag_value='0', - should_fail=False) - self.RunAndVerify(env_var_value='0', - flag_value='1', - should_fail=True) - self.RunAndVerify(env_var_value='1', - flag_value='0', - should_fail=False) - self.RunAndVerify(env_var_value='1', - flag_value='1', - should_fail=True) + self.RunAndVerify(env_var_value='0', flag_value='0', should_fail=False) + self.RunAndVerify(env_var_value='0', flag_value='1', should_fail=True) + self.RunAndVerify(env_var_value='1', flag_value='0', should_fail=False) + self.RunAndVerify(env_var_value='1', flag_value='1', should_fail=True) if __name__ == '__main__': diff --git a/googletest/test/googletest-uninitialized-test.py b/googletest/test/googletest-uninitialized-test.py index 73c91764a..e5af7c842 100755 --- a/googletest/test/googletest-uninitialized-test.py +++ b/googletest/test/googletest-uninitialized-test.py @@ -33,7 +33,9 @@ from googletest.test import gtest_test_utils -COMMAND = gtest_test_utils.GetTestExecutablePath('googletest-uninitialized-test_') +COMMAND = gtest_test_utils.GetTestExecutablePath( + 'googletest-uninitialized-test_' +) def Assert(condition): @@ -54,11 +56,12 @@ def TestExitCodeAndOutput(command): # Verifies that 'command' exits with code 1. p = gtest_test_utils.Subprocess(command) if p.exited and p.exit_code == 0: - Assert('IMPORTANT NOTICE' in p.output); + Assert('IMPORTANT NOTICE' in p.output) Assert('InitGoogleTest' in p.output) class GTestUninitializedTest(gtest_test_utils.TestCase): + def testExitCodeAndOutput(self): TestExitCodeAndOutput(COMMAND) diff --git a/googletest/test/gtest_help_test.py b/googletest/test/gtest_help_test.py index 642ab8650..1d6741586 100755 --- a/googletest/test/gtest_help_test.py +++ b/googletest/test/gtest_help_test.py @@ -57,27 +57,43 @@ UNKNOWN_GTEST_PREFIXED_FLAG = FLAG_PREFIX + 'unknown_flag_for_testing' LIST_TESTS_FLAG = FLAG_PREFIX + 'list_tests' INTERNAL_FLAG_FOR_TESTING = FLAG_PREFIX + 'internal_flag_for_testing' -SUPPORTS_DEATH_TESTS = "DeathTest" in gtest_test_utils.Subprocess( - [PROGRAM_PATH, LIST_TESTS_FLAG]).output +SUPPORTS_DEATH_TESTS = ( + 'DeathTest' + in gtest_test_utils.Subprocess([PROGRAM_PATH, LIST_TESTS_FLAG]).output +) HAS_ABSL_FLAGS = '--has_absl_flags' in sys.argv # The help message must match this regex. HELP_REGEX = re.compile( - FLAG_PREFIX + r'list_tests.*' + - FLAG_PREFIX + r'filter=.*' + - FLAG_PREFIX + r'also_run_disabled_tests.*' + - FLAG_PREFIX + r'repeat=.*' + - FLAG_PREFIX + r'shuffle.*' + - FLAG_PREFIX + r'random_seed=.*' + - FLAG_PREFIX + r'color=.*' + - FLAG_PREFIX + r'brief.*' + - FLAG_PREFIX + r'print_time.*' + - FLAG_PREFIX + r'output=.*' + - FLAG_PREFIX + r'break_on_failure.*' + - FLAG_PREFIX + r'throw_on_failure.*' + - FLAG_PREFIX + r'catch_exceptions=0.*', - re.DOTALL) + FLAG_PREFIX + + r'list_tests.*' + + FLAG_PREFIX + + r'filter=.*' + + FLAG_PREFIX + + r'also_run_disabled_tests.*' + + FLAG_PREFIX + + r'repeat=.*' + + FLAG_PREFIX + + r'shuffle.*' + + FLAG_PREFIX + + r'random_seed=.*' + + FLAG_PREFIX + + r'color=.*' + + FLAG_PREFIX + + r'brief.*' + + FLAG_PREFIX + + r'print_time.*' + + FLAG_PREFIX + + r'output=.*' + + FLAG_PREFIX + + r'break_on_failure.*' + + FLAG_PREFIX + + r'throw_on_failure.*' + + FLAG_PREFIX + + r'catch_exceptions=0.*', + re.DOTALL, +) def RunWithFlag(flag): @@ -172,13 +188,15 @@ class GTestHelpTest(gtest_test_utils.TestCase): def testRunsTestsWithoutHelpFlag(self): """Verifies that when no help flag is specified, the tests are run - and the help message is not printed.""" + and the help message is not printed. + """ self.TestNonHelpFlag(None) def testRunsTestsWithGtestInternalFlag(self): """Verifies that the tests are run and no help message is printed when - a flag starting with Google Test prefix and 'internal_' is supplied.""" + a flag starting with Google Test prefix and 'internal_' is supplied. + """ self.TestNonHelpFlag(INTERNAL_FLAG_FOR_TESTING) diff --git a/googletest/test/gtest_json_test_utils.py b/googletest/test/gtest_json_test_utils.py index f62896c92..86a5925b0 100644 --- a/googletest/test/gtest_json_test_utils.py +++ b/googletest/test/gtest_json_test_utils.py @@ -42,6 +42,7 @@ def normalize(obj): Normalized output without any references to transient information that may change from run to run. """ + def _normalize(key, value): if key == 'time': return re.sub(r'^\d+(\.\d+)?s$', '*', value) @@ -54,6 +55,7 @@ def normalize(obj): return re.sub(r'^.*[/\\](.*)', '\\1', value) else: return normalize(value) + if isinstance(obj, dict): return {k: _normalize(k, v) for k, v in obj.items()} if isinstance(obj, list): diff --git a/googletest/test/gtest_list_output_unittest.py b/googletest/test/gtest_list_output_unittest.py index faacf103c..afd521d2f 100644 --- a/googletest/test/gtest_list_output_unittest.py +++ b/googletest/test/gtest_list_output_unittest.py @@ -224,8 +224,7 @@ EXPECTED_JSON = """{ class GTestListTestsOutputUnitTest(gtest_test_utils.TestCase): - """Unit test for Google Test's list tests with output to file functionality. - """ + """Unit test for Google Test's list tests with output to file functionality.""" def testXml(self): """Verifies XML output for listing tests in a Google Test binary. @@ -244,19 +243,22 @@ class GTestListTestsOutputUnitTest(gtest_test_utils.TestCase): self._TestOutput('json', EXPECTED_JSON) def _GetOutput(self, out_format): - file_path = os.path.join(gtest_test_utils.GetTempDir(), - 'test_out.' + out_format) + file_path = os.path.join( + gtest_test_utils.GetTempDir(), 'test_out.' + out_format + ) gtest_prog_path = gtest_test_utils.GetTestExecutablePath( - 'gtest_list_output_unittest_') + 'gtest_list_output_unittest_' + ) - command = ([ + command = [ gtest_prog_path, '%s=%s:%s' % (GTEST_OUTPUT_FLAG, out_format, file_path), - '--gtest_list_tests' - ]) + '--gtest_list_tests', + ] environ_copy = os.environ.copy() p = gtest_test_utils.Subprocess( - command, env=environ_copy, working_dir=gtest_test_utils.GetTempDir()) + command, env=environ_copy, working_dir=gtest_test_utils.GetTempDir() + ) self.assertTrue(p.exited) self.assertEqual(0, p.exit_code) @@ -275,9 +277,10 @@ class GTestListTestsOutputUnitTest(gtest_test_utils.TestCase): expected_line_re = re.compile(expected_line.strip()) self.assertTrue( expected_line_re.match(actual_line.strip()), - ('actual output of "%s",\n' - 'which does not match expected regex of "%s"\n' - 'on line %d' % (actual, expected_output, line_count))) + 'actual output of "%s",\n' + 'which does not match expected regex of "%s"\n' + 'on line %d' % (actual, expected_output, line_count), + ) line_count = line_count + 1 diff --git a/googletest/test/gtest_skip_check_output_test.py b/googletest/test/gtest_skip_check_output_test.py index 1c87b44f0..b30a16504 100755 --- a/googletest/test/gtest_skip_check_output_test.py +++ b/googletest/test/gtest_skip_check_output_test.py @@ -51,7 +51,8 @@ class SkipEntireEnvironmentTest(gtest_test_utils.TestCase): skip_fixture = 'Skipped\nskipping all tests for this fixture\n' self.assertIsNotNone( re.search(skip_fixture + '.*' + skip_fixture, OUTPUT, flags=re.DOTALL), - repr(OUTPUT)) + repr(OUTPUT), + ) self.assertNotIn('FAILED', OUTPUT) diff --git a/googletest/test/gtest_skip_environment_check_output_test.py b/googletest/test/gtest_skip_environment_check_output_test.py index 6960b11a5..388a4e95f 100755 --- a/googletest/test/gtest_skip_environment_check_output_test.py +++ b/googletest/test/gtest_skip_environment_check_output_test.py @@ -37,7 +37,8 @@ from googletest.test import gtest_test_utils # Path to the gtest_skip_in_environment_setup_test binary EXE_PATH = gtest_test_utils.GetTestExecutablePath( - 'gtest_skip_in_environment_setup_test') + 'gtest_skip_in_environment_setup_test' +) OUTPUT = gtest_test_utils.Subprocess([EXE_PATH]).output diff --git a/googletest/test/gtest_xml_outfiles_test.py b/googletest/test/gtest_xml_outfiles_test.py index 73fb2b31d..b482f0253 100755 --- a/googletest/test/gtest_xml_outfiles_test.py +++ b/googletest/test/gtest_xml_outfiles_test.py @@ -76,8 +76,9 @@ class GTestXMLOutFilesTest(gtest_xml_test_utils.GTestXMLTestCase): # We want the trailing '/' that the last "" provides in os.path.join, for # telling Google Test to create an output directory instead of a single file # for xml output. - self.output_dir_ = os.path.join(gtest_test_utils.GetTempDir(), - GTEST_OUTPUT_SUBDIR, "") + self.output_dir_ = os.path.join( + gtest_test_utils.GetTempDir(), GTEST_OUTPUT_SUBDIR, "" + ) self.DeleteFilesAndDir() def tearDown(self): @@ -106,14 +107,15 @@ class GTestXMLOutFilesTest(gtest_xml_test_utils.GTestXMLTestCase): def _TestOutFile(self, test_name, expected_xml): gtest_prog_path = gtest_test_utils.GetTestExecutablePath(test_name) command = [gtest_prog_path, "--gtest_output=xml:%s" % self.output_dir_] - p = gtest_test_utils.Subprocess(command, - working_dir=gtest_test_utils.GetTempDir()) + p = gtest_test_utils.Subprocess( + command, working_dir=gtest_test_utils.GetTempDir() + ) self.assertTrue(p.exited) self.assertEqual(0, p.exit_code) output_file_name1 = test_name + ".xml" output_file1 = os.path.join(self.output_dir_, output_file_name1) - output_file_name2 = 'lt-' + output_file_name1 + output_file_name2 = "lt-" + output_file_name1 output_file2 = os.path.join(self.output_dir_, output_file_name2) self.assertTrue( os.path.isfile(output_file1) or os.path.isfile(output_file2), @@ -126,8 +128,7 @@ class GTestXMLOutFilesTest(gtest_xml_test_utils.GTestXMLTestCase): else: actual = minidom.parse(output_file2) self.NormalizeXml(actual.documentElement) - self.AssertEquivalentNodes(expected.documentElement, - actual.documentElement) + self.AssertEquivalentNodes(expected.documentElement, actual.documentElement) expected.unlink() actual.unlink() From 643862d8adb333eae9f3ff288895314dfcc87587 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 25 Jan 2023 10:03:30 -0800 Subject: [PATCH 086/336] Mention `DescribeMatcher` in matchers.md PiperOrigin-RevId: 504591836 Change-Id: I48c93490d0c3b7c6bfaceceb1cef5eedeacfe6c6 --- docs/reference/matchers.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/reference/matchers.md b/docs/reference/matchers.md index 9fb159275..be962819c 100644 --- a/docs/reference/matchers.md +++ b/docs/reference/matchers.md @@ -288,3 +288,15 @@ which must be a permanent callback. return ExplainMatchResult(matcher, arg.nested().property(), result_listener); } ``` + +5. You can use `DescribeMatcher<>` to describe another matcher. For example: + + ```cpp + MATCHER_P(XAndYThat, matcher, + "X that " + DescribeMatcher(matcher, negation) + + (negation ? " or" : " and") + " Y that " + + DescribeMatcher(matcher, negation)) { + return ExplainMatchResult(matcher, arg.x(), result_listener) && + ExplainMatchResult(matcher, arg.y(), result_listener); + } + ``` From 137dcd18cc20b49059d834a592fe7e200bc4aeee Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 25 Jan 2023 12:34:50 -0800 Subject: [PATCH 087/336] Remove pylint disable comments that no longer trigger warnings PiperOrigin-RevId: 504633130 Change-Id: I3fdbc83975fea97aa53f7325d323adead0a30e24 --- googlemock/test/gmock_test_utils.py | 5 ----- googletest/test/googletest-catch-exceptions-test.py | 1 - googletest/test/gtest_test_utils.py | 9 +++------ 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/googlemock/test/gmock_test_utils.py b/googlemock/test/gmock_test_utils.py index d7bc0974a..edad1f752 100755 --- a/googlemock/test/gmock_test_utils.py +++ b/googlemock/test/gmock_test_utils.py @@ -77,9 +77,6 @@ def GetExitStatus(exit_code): return -1 -# Suppresses the "Invalid const name" lint complaint -# pylint: disable-msg=C6409 - # Exposes utilities from gtest_test_utils. Subprocess = gtest_test_utils.Subprocess TestCase = gtest_test_utils.TestCase @@ -87,8 +84,6 @@ environ = gtest_test_utils.environ SetEnvVar = gtest_test_utils.SetEnvVar PREMATURE_EXIT_FILE_ENV_VAR = gtest_test_utils.PREMATURE_EXIT_FILE_ENV_VAR -# pylint: enable-msg=C6409 - def Main(): """Runs the unit test.""" diff --git a/googletest/test/googletest-catch-exceptions-test.py b/googletest/test/googletest-catch-exceptions-test.py index a850ea4a7..127584ffb 100755 --- a/googletest/test/googletest-catch-exceptions-test.py +++ b/googletest/test/googletest-catch-exceptions-test.py @@ -81,7 +81,6 @@ EX_BINARY_OUTPUT = gtest_test_utils.Subprocess( # The tests. if SUPPORTS_SEH_EXCEPTIONS: - # pylint:disable-msg=C6302 class CatchSehExceptionsTest(gtest_test_utils.TestCase): """Tests exception-catching behavior.""" diff --git a/googletest/test/gtest_test_utils.py b/googletest/test/gtest_test_utils.py index 459f9ea32..6fc39b57d 100755 --- a/googletest/test/gtest_test_utils.py +++ b/googletest/test/gtest_test_utils.py @@ -63,9 +63,8 @@ def SetEnvVar(env_var, value): # Here we expose a class from a particular module, depending on the -# environment. The comment suppresses the 'Invalid variable name' lint -# complaint. -TestCase = _test_module.TestCase # pylint: disable=C6409 +# environment. +TestCase = _test_module.TestCase # Initially maps a flag to its default value. After # _ParseAndStripGTestFlags() is called, maps a flag to its actual value. @@ -77,9 +76,7 @@ _gtest_flags_are_parsed = False def _ParseAndStripGTestFlags(argv): """Parses and strips Google Test flags from argv. This is idempotent.""" - # Suppresses the lint complaint about a global variable since we need it - # here to maintain module-wide state. - global _gtest_flags_are_parsed # pylint: disable=W0603 + global _gtest_flags_are_parsed if _gtest_flags_are_parsed: return From f47d75faf35019c5e39d785c9c77f510a9f17b2b Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 25 Jan 2023 13:02:49 -0800 Subject: [PATCH 088/336] Fix pylint warning Possible unbalanced tuple unpacking with sequence defined at line N: left side has 1 label(s), right side has 0 value(s) [unbalanced-tuple-unpacking] PiperOrigin-RevId: 504640001 Change-Id: If8d6038a9acf74a409cb6b6ee30cea7745b4b303 --- googletest/test/googletest-shuffle-test.py | 38 +++++++++++++--------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/googletest/test/googletest-shuffle-test.py b/googletest/test/googletest-shuffle-test.py index 61e25932f..d049badb6 100755 --- a/googletest/test/googletest-shuffle-test.py +++ b/googletest/test/googletest-shuffle-test.py @@ -275,33 +275,38 @@ class GTestShuffleUnitTest(gtest_test_utils.TestCase): # iteration, and this test depends on the current implementation # picking successive numbers. This dependency is not ideal, but # makes the test much easier to write. + # pylint: disable-next=unbalanced-tuple-unpacking [tests_in_iteration1, tests_in_iteration2, tests_in_iteration3] = ( GetTestsForAllIterations( {}, [ShuffleFlag(), RandomSeedFlag(1), RepeatFlag(3)])) # Make sure running the tests with random seed 1 gets the same # order as in iteration 1 above. - [tests_with_seed1] = GetTestsForAllIterations( - {}, [ShuffleFlag(), RandomSeedFlag(1)]) + tests_with_seed1 = GetTestsForAllIterations( + {}, [ShuffleFlag(), RandomSeedFlag(1)] + )[0] self.assertEqual(tests_in_iteration1, tests_with_seed1) # Make sure running the tests with random seed 2 gets the same # order as in iteration 2 above. Success means that Google Test # correctly restores the test order before re-shuffling at the # beginning of iteration 2. - [tests_with_seed2] = GetTestsForAllIterations( - {}, [ShuffleFlag(), RandomSeedFlag(2)]) + tests_with_seed2 = GetTestsForAllIterations( + {}, [ShuffleFlag(), RandomSeedFlag(2)] + )[0] self.assertEqual(tests_in_iteration2, tests_with_seed2) # Make sure running the tests with random seed 3 gets the same # order as in iteration 3 above. Success means that Google Test # correctly restores the test order before re-shuffling at the # beginning of iteration 3. - [tests_with_seed3] = GetTestsForAllIterations( - {}, [ShuffleFlag(), RandomSeedFlag(3)]) + tests_with_seed3 = GetTestsForAllIterations( + {}, [ShuffleFlag(), RandomSeedFlag(3)] + )[0] self.assertEqual(tests_in_iteration3, tests_with_seed3) def testShuffleGeneratesNewOrderInEachIteration(self): + # pylint: disable-next=unbalanced-tuple-unpacking [tests_in_iteration1, tests_in_iteration2, tests_in_iteration3] = ( GetTestsForAllIterations( {}, [ShuffleFlag(), RandomSeedFlag(1), RepeatFlag(3)])) @@ -319,15 +324,18 @@ class GTestShuffleUnitTest(gtest_test_utils.TestCase): def testShuffleShardedTestsPreservesPartition(self): # If we run M tests on N shards, the same M tests should be run in # total, regardless of the random seeds used by the shards. - [tests1] = GetTestsForAllIterations({TOTAL_SHARDS_ENV_VAR: '3', - SHARD_INDEX_ENV_VAR: '0'}, - [ShuffleFlag(), RandomSeedFlag(1)]) - [tests2] = GetTestsForAllIterations({TOTAL_SHARDS_ENV_VAR: '3', - SHARD_INDEX_ENV_VAR: '1'}, - [ShuffleFlag(), RandomSeedFlag(20)]) - [tests3] = GetTestsForAllIterations({TOTAL_SHARDS_ENV_VAR: '3', - SHARD_INDEX_ENV_VAR: '2'}, - [ShuffleFlag(), RandomSeedFlag(25)]) + tests1 = GetTestsForAllIterations( + {TOTAL_SHARDS_ENV_VAR: '3', SHARD_INDEX_ENV_VAR: '0'}, + [ShuffleFlag(), RandomSeedFlag(1)], + )[0] + tests2 = GetTestsForAllIterations( + {TOTAL_SHARDS_ENV_VAR: '3', SHARD_INDEX_ENV_VAR: '1'}, + [ShuffleFlag(), RandomSeedFlag(20)], + )[0] + tests3 = GetTestsForAllIterations( + {TOTAL_SHARDS_ENV_VAR: '3', SHARD_INDEX_ENV_VAR: '2'}, + [ShuffleFlag(), RandomSeedFlag(25)], + )[0] sorted_sharded_tests = tests1 + tests2 + tests3 sorted_sharded_tests.sort() sorted_active_tests = [] From b495f72f1f096135cf9cf8c7879b5b89250de50a Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 25 Jan 2023 15:00:39 -0800 Subject: [PATCH 089/336] Use more specific assertLess instead of assertTrue PiperOrigin-RevId: 504670738 Change-Id: Ib68b676403204098e89f536f9b8317f9f717c24d --- googletest/test/gtest_xml_output_unittest.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/googletest/test/gtest_xml_output_unittest.py b/googletest/test/gtest_xml_output_unittest.py index 29fbc41f6..d48d1af2e 100755 --- a/googletest/test/gtest_xml_output_unittest.py +++ b/googletest/test/gtest_xml_output_unittest.py @@ -282,8 +282,7 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): time_delta = abs(datetime.datetime.now() - date_time_from_xml) # timestamp value should be near the current local time - self.assertTrue(time_delta < datetime.timedelta(seconds=600), - 'time_delta is %s' % time_delta) + self.assertLess(time_delta, datetime.timedelta(seconds=600)) actual.unlink() def testDefaultOutputFile(self): From 4b4c56aff603c6a252801be71b3813b4b9eb90bb Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 25 Jan 2023 17:43:18 -0800 Subject: [PATCH 090/336] Make document and example code more clear in the caveat section for potential memory leak with `SetUpTestSuite`. PiperOrigin-RevId: 504706717 Change-Id: I5842a4569f81f6c0d636099b5cdaabe778996949 --- docs/advanced.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/advanced.md b/docs/advanced.md index f16382fe0..7d15dfdd7 100644 --- a/docs/advanced.md +++ b/docs/advanced.md @@ -896,7 +896,8 @@ Note that `SetUpTestSuite()` may be called multiple times for a test fixture class that has derived classes, so you should not expect code in the function body to be run only once. Also, derived classes still have access to shared resources defined as static members, so careful consideration is needed when -managing shared resources to avoid memory leaks. +managing shared resources to avoid memory leaks if shared resources are not +properly cleaned up in `TearDownTestSuite()`. Here's an example of per-test-suite set-up and tear-down: @@ -907,10 +908,15 @@ class FooTest : public testing::Test { // Called before the first test in this test suite. // Can be omitted if not needed. static void SetUpTestSuite() { - // Avoid reallocating static objects if called in subclasses of FooTest. - if (shared_resource_ == nullptr) { - shared_resource_ = new ...; - } + shared_resource_ = new ...; + + // If `shared_resource_` is **not deleted** in `TearDownTestSuite()`, + // reallocation should be prevented because `SetUpTestSuite()` may be called + // in subclasses of FooTest and lead to memory leak. + // + // if (shared_resource_ == nullptr) { + // shared_resource_ = new ...; + // } } // Per-test-suite tear-down. From 0194f90d0e7118d44f0e3b0750eb69035811e2b8 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 26 Jan 2023 09:04:01 -0800 Subject: [PATCH 091/336] Fix Python docstrings to match style guide https://google.github.io/styleguide/pyguide.html#s3.8.3-functions-and-methods PiperOrigin-RevId: 504857416 Change-Id: I7815ce27e454a120b3974ae7e2bea952108b836c --- .../googletest-break-on-failure-unittest.py | 8 +++- .../test/googletest-list-tests-unittest.py | 8 +++- googletest/test/googletest-output-test.py | 7 ++- .../test/googletest-throw-on-failure-test.py | 12 ++++- googletest/test/gtest_help_test.py | 8 +++- googletest/test/gtest_xml_output_unittest.py | 34 ++++++++++---- googletest/test/gtest_xml_test_utils.py | 44 ++++++++++++------- 7 files changed, 88 insertions(+), 33 deletions(-) diff --git a/googletest/test/googletest-break-on-failure-unittest.py b/googletest/test/googletest-break-on-failure-unittest.py index 3f65812be..e314b5ccd 100755 --- a/googletest/test/googletest-break-on-failure-unittest.py +++ b/googletest/test/googletest-break-on-failure-unittest.py @@ -88,13 +88,17 @@ def Run(command): class GTestBreakOnFailureUnitTest(gtest_test_utils.TestCase): - """Tests using the GTEST_BREAK_ON_FAILURE environment variable or + """Unit test for Google Test's break-on-failure mode. + + Tests using the GTEST_BREAK_ON_FAILURE environment variable or the --gtest_break_on_failure flag to turn assertion failures into segmentation faults. """ def RunAndVerify(self, env_var_value, flag_value, expect_seg_fault): - """Runs googletest-break-on-failure-unittest_ and verifies that it does + """Runs googletest-break-on-failure-unittest_ and verifies its behavior. + + Runs googletest-break-on-failure-unittest_ and verifies that it does (or does not) have a seg-fault. Args: diff --git a/googletest/test/googletest-list-tests-unittest.py b/googletest/test/googletest-list-tests-unittest.py index f59fca011..977e57f08 100755 --- a/googletest/test/googletest-list-tests-unittest.py +++ b/googletest/test/googletest-list-tests-unittest.py @@ -132,7 +132,9 @@ class GTestListTestsUnitTest(gtest_test_utils.TestCase): """Tests using the --gtest_list_tests flag to list all tests.""" def RunAndVerify(self, flag_value, expected_output_re, other_flag): - """Runs googletest-list-tests-unittest_ and verifies that it prints + """Run googletest-list-tests-unittest_ and verify the output. + + Runs googletest-list-tests-unittest_ and verifies that it prints the correct tests. Args: @@ -206,7 +208,9 @@ class GTestListTestsUnitTest(gtest_test_utils.TestCase): ) def testWithFilterFlags(self): - """Tests that --gtest_list_tests takes into account the + """Tests that --gtest_list_tests takes into account the filter flags. + + Tests that --gtest_list_tests takes into account the --gtest_filter flag. """ diff --git a/googletest/test/googletest-output-test.py b/googletest/test/googletest-output-test.py index 5185ed975..347b85461 100755 --- a/googletest/test/googletest-output-test.py +++ b/googletest/test/googletest-output-test.py @@ -237,13 +237,16 @@ def GetShellCommandOutput(env_cmd): def GetCommandOutput(env_cmd): - """Runs a command and returns its output with all file location - info stripped off. + """Runs a command and returns output with all file location info stripped off. Args: env_cmd: The shell command. A 2-tuple where element 0 is a dict of extra environment variables to set, and element 1 is a string with the command and any flags. + + Returns: + A string with the command's combined standard and diagnostic output. File + location info is stripped. """ # Disables exception pop-ups on Windows. diff --git a/googletest/test/googletest-throw-on-failure-test.py b/googletest/test/googletest-throw-on-failure-test.py index 282163bce..106b00442 100755 --- a/googletest/test/googletest-throw-on-failure-test.py +++ b/googletest/test/googletest-throw-on-failure-test.py @@ -55,8 +55,14 @@ EXE_PATH = gtest_test_utils.GetTestExecutablePath( def SetEnvVar(env_var, value): - """Sets an environment variable to a given value; unsets it when the + """Sets an environment variable. + + Sets an environment variable to a given value; unsets it when the given value is None. + + Args: + env_var: environment variable. + value: value to set. """ env_var = env_var.upper() @@ -79,7 +85,9 @@ class ThrowOnFailureTest(gtest_test_utils.TestCase): """Tests the throw-on-failure mode.""" def RunAndVerify(self, env_var_value, flag_value, should_fail): - """Runs googletest-throw-on-failure-test_ and verifies that it does + """Runs googletest-throw-on-failure-test_ and verifies its behavior. + + Runs googletest-throw-on-failure-test_ and verifies that it does (or does not) exit with a non-zero code. Args: diff --git a/googletest/test/gtest_help_test.py b/googletest/test/gtest_help_test.py index 1d6741586..fda40bffc 100755 --- a/googletest/test/gtest_help_test.py +++ b/googletest/test/gtest_help_test.py @@ -187,14 +187,18 @@ class GTestHelpTest(gtest_test_utils.TestCase): self.TestHelpFlag(UNKNOWN_GTEST_PREFIXED_FLAG) def testRunsTestsWithoutHelpFlag(self): - """Verifies that when no help flag is specified, the tests are run + """Verifies correct behavior when no help flag is specified. + + Verifies that when no help flag is specified, the tests are run and the help message is not printed. """ self.TestNonHelpFlag(None) def testRunsTestsWithGtestInternalFlag(self): - """Verifies that the tests are run and no help message is printed when + """Verifies correct behavior when internal testing flag is specified. + + Verifies that the tests are run and no help message is printed when a flag starting with Google Test prefix and 'internal_' is supplied. """ diff --git a/googletest/test/gtest_xml_output_unittest.py b/googletest/test/gtest_xml_output_unittest.py index d48d1af2e..e46ad3999 100755 --- a/googletest/test/gtest_xml_output_unittest.py +++ b/googletest/test/gtest_xml_output_unittest.py @@ -246,7 +246,8 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): # type-parameterized tests, so we don't run it under them. if SUPPORTS_TYPED_TESTS: def testNonEmptyXmlOutput(self): - """ + """Generates non-empty XML and verifies it matches the expected output. + Runs a test program that generates a non-empty XML output, and tests that the XML output is expected. """ @@ -286,7 +287,8 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): actual.unlink() def testDefaultOutputFile(self): - """ + """Tests XML file with default name is created when name is not specified. + Confirms that Google Test produces an XML output file with the expected default name if no name is explicitly specified. """ @@ -309,7 +311,8 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): self.assertTrue(os.path.isfile(output_file)) def testSuppressedXmlOutput(self): - """ + """Verifies XML output is suppressed if default listener is shut down. + Tests that no XML file is generated if the default XML listener is shut down before RUN_ALL_TESTS is invoked. """ @@ -363,11 +366,18 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): extra_env={SHARD_INDEX_ENV_VAR: '0', TOTAL_SHARDS_ENV_VAR: '10'}) - def _GetXmlOutput(self, gtest_prog_name, extra_args, extra_env, - expected_exit_code): - """ - Returns the xml output generated by running the program gtest_prog_name. + def _GetXmlOutput( + self, gtest_prog_name, extra_args, extra_env, expected_exit_code + ): + """Returns the XML output generated by running the program gtest_prog_name. + Furthermore, the program's exit code must be expected_exit_code. + + Args: + gtest_prog_name: Program to run. + extra_args: Optional arguments to pass to program. + extra_env: Optional environment variables to set. + expected_exit_code: Expected exit code from running gtest_prog_name. """ xml_path = os.path.join(gtest_test_utils.GetTempDir(), gtest_prog_name + 'out.xml') @@ -398,11 +408,19 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): def _TestXmlOutput(self, gtest_prog_name, expected_xml, expected_exit_code, extra_args=None, extra_env=None): - """ + """Asserts that the XML document matches. + Asserts that the XML document generated by running the program gtest_prog_name matches expected_xml, a string containing another XML document. Furthermore, the program's exit code must be expected_exit_code. + + Args: + gtest_prog_name: Program to run. + expected_xml: Path to XML document to match. + expected_exit_code: Expected exit code from running gtest_prog_name. + extra_args: Optional arguments to pass to program. + extra_env: Optional environment variables to set. """ actual = self._GetXmlOutput(gtest_prog_name, extra_args or [], diff --git a/googletest/test/gtest_xml_test_utils.py b/googletest/test/gtest_xml_test_utils.py index ae41bbad9..567a3141e 100755 --- a/googletest/test/gtest_xml_test_utils.py +++ b/googletest/test/gtest_xml_test_utils.py @@ -40,9 +40,9 @@ class GTestXMLTestCase(gtest_test_utils.TestCase): Base class for tests of Google Test's XML output functionality. """ - def AssertEquivalentNodes(self, expected_node, actual_node): - """ + """Asserts that actual_node is equivalent to expected_node. + Asserts that actual_node (a DOM node object) is equivalent to expected_node (another DOM node object), in that either both of them are CDATA nodes and have the same value, or both are DOM @@ -58,6 +58,10 @@ class GTestXMLTestCase(gtest_test_utils.TestCase): CDATA sections) as expected_node. Note that we ignore the order of the children as they are not guaranteed to be in any particular order. + + Args: + expected_node: expected DOM node object + actual_node: actual DOM node object """ if expected_node.nodeType == Node.CDATA_SECTION_NODE: @@ -126,18 +130,24 @@ class GTestXMLTestCase(gtest_test_utils.TestCase): } def _GetChildren(self, element): - """ - Fetches all of the child nodes of element, a DOM Element object. - Returns them as the values of a dictionary keyed by the IDs of the - children. For , , , and - elements, the ID is the value of their "name" attribute; for - elements, it is the value of the "message" attribute; for - elements, it is the value of their parent's "name" attribute plus the - literal string "properties"; CDATA sections and non-whitespace - text nodes are concatenated into a single CDATA section with ID - "detail". An exception is raised if any element other than the above - four is encountered, if two child elements with the same identifying - attributes are encountered, or if any other type of node is encountered. + """Fetches all of the child nodes of element, a DOM Element object. + + Returns them as the values of a dictionary keyed by the IDs of the children. + For , , , and elements, the ID + is the value of their "name" attribute; for elements, it is the + value of the "message" attribute; for elements, it is the value + of their parent's "name" attribute plus the literal string "properties"; + CDATA sections and non-whitespace text nodes are concatenated into a single + CDATA section with ID "detail". An exception is raised if any element other + than the above four is encountered, if two child elements with the same + identifying attributes are encountered, or if any other type of node is + encountered. + + Args: + element: DOM Element object + + Returns: + Dictionary where keys are the IDs of the children. """ children = {} @@ -171,7 +181,8 @@ class GTestXMLTestCase(gtest_test_utils.TestCase): return children def NormalizeXml(self, element): - """ + """Normalizes XML that may change from run to run. + Normalizes Google Test's XML output to eliminate references to transient information that may change from run to run. @@ -188,6 +199,9 @@ class GTestXMLTestCase(gtest_test_utils.TestCase): file's basename and a single asterisk for the line number. * The directory names in file paths are removed. * The stack traces are removed. + + Args: + element: DOM element to normalize """ if element.tagName == 'testcase': From 403a968d3c1e1de1232ba1c1a2775b74b9ea5579 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 26 Jan 2023 11:05:38 -0800 Subject: [PATCH 092/336] Fix formatting in Python files PiperOrigin-RevId: 504890435 Change-Id: Ia9a89d0d7a07fe70c12f7f0202c8256c94d2f118 --- .../test/googletest-catch-exceptions-test.py | 1 + googletest/test/googletest-shuffle-test.py | 85 +++++++++++------ googletest/test/gtest_test_utils.py | 34 ++++--- googletest/test/gtest_xml_output_unittest.py | 95 ++++++++++++------- googletest/test/gtest_xml_test_utils.py | 27 +++--- 5 files changed, 158 insertions(+), 84 deletions(-) diff --git a/googletest/test/googletest-catch-exceptions-test.py b/googletest/test/googletest-catch-exceptions-test.py index 127584ffb..ee4dc9ae6 100755 --- a/googletest/test/googletest-catch-exceptions-test.py +++ b/googletest/test/googletest-catch-exceptions-test.py @@ -81,6 +81,7 @@ EX_BINARY_OUTPUT = gtest_test_utils.Subprocess( # The tests. if SUPPORTS_SEH_EXCEPTIONS: + class CatchSehExceptionsTest(gtest_test_utils.TestCase): """Tests exception-catching behavior.""" diff --git a/googletest/test/googletest-shuffle-test.py b/googletest/test/googletest-shuffle-test.py index d049badb6..61e3a15ec 100755 --- a/googletest/test/googletest-shuffle-test.py +++ b/googletest/test/googletest-shuffle-test.py @@ -130,38 +130,50 @@ def CalculateTestLists(): if not ALL_TESTS: ALL_TESTS.extend( - GetTestsForAllIterations({}, [AlsoRunDisabledTestsFlag()])[0]) + GetTestsForAllIterations({}, [AlsoRunDisabledTestsFlag()])[0] + ) if not ACTIVE_TESTS: ACTIVE_TESTS.extend(GetTestsForAllIterations({}, [])[0]) if not FILTERED_TESTS: FILTERED_TESTS.extend( - GetTestsForAllIterations({}, [FilterFlag(TEST_FILTER)])[0]) + GetTestsForAllIterations({}, [FilterFlag(TEST_FILTER)])[0] + ) if not SHARDED_TESTS: SHARDED_TESTS.extend( - GetTestsForAllIterations({TOTAL_SHARDS_ENV_VAR: '3', - SHARD_INDEX_ENV_VAR: '1'}, - [])[0]) + GetTestsForAllIterations( + {TOTAL_SHARDS_ENV_VAR: '3', SHARD_INDEX_ENV_VAR: '1'}, [] + )[0] + ) if not SHUFFLED_ALL_TESTS: - SHUFFLED_ALL_TESTS.extend(GetTestsForAllIterations( - {}, [AlsoRunDisabledTestsFlag(), ShuffleFlag(), RandomSeedFlag(1)])[0]) + SHUFFLED_ALL_TESTS.extend( + GetTestsForAllIterations( + {}, [AlsoRunDisabledTestsFlag(), ShuffleFlag(), RandomSeedFlag(1)] + )[0] + ) if not SHUFFLED_ACTIVE_TESTS: - SHUFFLED_ACTIVE_TESTS.extend(GetTestsForAllIterations( - {}, [ShuffleFlag(), RandomSeedFlag(1)])[0]) + SHUFFLED_ACTIVE_TESTS.extend( + GetTestsForAllIterations({}, [ShuffleFlag(), RandomSeedFlag(1)])[0] + ) if not SHUFFLED_FILTERED_TESTS: - SHUFFLED_FILTERED_TESTS.extend(GetTestsForAllIterations( - {}, [ShuffleFlag(), RandomSeedFlag(1), FilterFlag(TEST_FILTER)])[0]) + SHUFFLED_FILTERED_TESTS.extend( + GetTestsForAllIterations( + {}, [ShuffleFlag(), RandomSeedFlag(1), FilterFlag(TEST_FILTER)] + )[0] + ) if not SHUFFLED_SHARDED_TESTS: SHUFFLED_SHARDED_TESTS.extend( - GetTestsForAllIterations({TOTAL_SHARDS_ENV_VAR: '3', - SHARD_INDEX_ENV_VAR: '1'}, - [ShuffleFlag(), RandomSeedFlag(1)])[0]) + GetTestsForAllIterations( + {TOTAL_SHARDS_ENV_VAR: '3', SHARD_INDEX_ENV_VAR: '1'}, + [ShuffleFlag(), RandomSeedFlag(1)], + )[0] + ) class GTestShuffleUnitTest(gtest_test_utils.TestCase): @@ -208,17 +220,29 @@ class GTestShuffleUnitTest(gtest_test_utils.TestCase): def testShuffleDoesNotRepeatTest(self): for test in SHUFFLED_ALL_TESTS: - self.assertEqual(1, SHUFFLED_ALL_TESTS.count(test), - '%s appears more than once' % (test,)) + self.assertEqual( + 1, + SHUFFLED_ALL_TESTS.count(test), + '%s appears more than once' % (test,), + ) for test in SHUFFLED_ACTIVE_TESTS: - self.assertEqual(1, SHUFFLED_ACTIVE_TESTS.count(test), - '%s appears more than once' % (test,)) + self.assertEqual( + 1, + SHUFFLED_ACTIVE_TESTS.count(test), + '%s appears more than once' % (test,), + ) for test in SHUFFLED_FILTERED_TESTS: - self.assertEqual(1, SHUFFLED_FILTERED_TESTS.count(test), - '%s appears more than once' % (test,)) + self.assertEqual( + 1, + SHUFFLED_FILTERED_TESTS.count(test), + '%s appears more than once' % (test,), + ) for test in SHUFFLED_SHARDED_TESTS: - self.assertEqual(1, SHUFFLED_SHARDED_TESTS.count(test), - '%s appears more than once' % (test,)) + self.assertEqual( + 1, + SHUFFLED_SHARDED_TESTS.count(test), + '%s appears more than once' % (test,), + ) def testShuffleDoesNotCreateNewTest(self): for test in SHUFFLED_ALL_TESTS: @@ -259,9 +283,11 @@ class GTestShuffleUnitTest(gtest_test_utils.TestCase): [test_case, _] = test.split('.') if test_cases and test_cases[-1] != test_case: test_cases.append(test_case) - self.assertEqual(1, test_cases.count(test_case), - 'Test case %s is not grouped together in %s' % - (test_case, tests)) + self.assertEqual( + 1, + test_cases.count(test_case), + 'Test case %s is not grouped together in %s' % (test_case, tests), + ) def testShuffleDoesNotInterleaveTestCases(self): self._VerifyTestCasesDoNotInterleave(SHUFFLED_ALL_TESTS) @@ -278,7 +304,9 @@ class GTestShuffleUnitTest(gtest_test_utils.TestCase): # pylint: disable-next=unbalanced-tuple-unpacking [tests_in_iteration1, tests_in_iteration2, tests_in_iteration3] = ( GetTestsForAllIterations( - {}, [ShuffleFlag(), RandomSeedFlag(1), RepeatFlag(3)])) + {}, [ShuffleFlag(), RandomSeedFlag(1), RepeatFlag(3)] + ) + ) # Make sure running the tests with random seed 1 gets the same # order as in iteration 1 above. @@ -309,7 +337,9 @@ class GTestShuffleUnitTest(gtest_test_utils.TestCase): # pylint: disable-next=unbalanced-tuple-unpacking [tests_in_iteration1, tests_in_iteration2, tests_in_iteration3] = ( GetTestsForAllIterations( - {}, [ShuffleFlag(), RandomSeedFlag(1), RepeatFlag(3)])) + {}, [ShuffleFlag(), RandomSeedFlag(1), RepeatFlag(3)] + ) + ) self.assertTrue( tests_in_iteration1 != tests_in_iteration2, tests_in_iteration1 @@ -343,5 +373,6 @@ class GTestShuffleUnitTest(gtest_test_utils.TestCase): sorted_active_tests.sort() self.assertEqual(sorted_active_tests, sorted_sharded_tests) + if __name__ == '__main__': gtest_test_utils.Main() diff --git a/googletest/test/gtest_test_utils.py b/googletest/test/gtest_test_utils.py index 6fc39b57d..964fa9fa5 100755 --- a/googletest/test/gtest_test_utils.py +++ b/googletest/test/gtest_test_utils.py @@ -68,8 +68,10 @@ TestCase = _test_module.TestCase # Initially maps a flag to its default value. After # _ParseAndStripGTestFlags() is called, maps a flag to its actual value. -_flag_map = {'source_dir': os.path.dirname(sys.argv[0]), - 'build_dir': os.path.dirname(sys.argv[0])} +_flag_map = { + 'source_dir': os.path.dirname(sys.argv[0]), + 'build_dir': os.path.dirname(sys.argv[0]), +} _gtest_flags_are_parsed = False @@ -91,7 +93,7 @@ def _ParseAndStripGTestFlags(argv): while i < len(argv): prefix = '--' + flag + '=' if argv[i].startswith(prefix): - _flag_map[flag] = argv[i][len(prefix):] + _flag_map[flag] = argv[i][len(prefix) :] del argv[i] break else: @@ -147,15 +149,16 @@ def GetTestExecutablePath(executable_name, build_dir=None): Args: executable_name: name of the test binary that the test script runs. - build_dir: directory where to look for executables, by default - the result of GetBuildDir(). + build_dir: directory where to look for executables, by default the + result of GetBuildDir(). Returns: The absolute path of the test binary. """ - path = os.path.abspath(os.path.join(build_dir or GetBuildDir(), - executable_name)) + path = os.path.abspath( + os.path.join(build_dir or GetBuildDir(), executable_name) + ) if (IS_WINDOWS or IS_CYGWIN or IS_OS2) and not path.endswith('.exe'): path += '.exe' @@ -163,7 +166,8 @@ def GetTestExecutablePath(executable_name, build_dir=None): message = ( 'Unable to find the test binary "%s". Please make sure to provide\n' 'a path to the binary via the --build_dir flag or the BUILD_DIR\n' - 'environment variable.' % path) + 'environment variable.' % path + ) print(message, file=sys.stderr) sys.exit(1) @@ -191,6 +195,7 @@ def GetExitStatus(exit_code): class Subprocess: + def __init__(self, command, working_dir=None, capture_stderr=True, env=None): """Changes into a specified directory, if provided, and executes a command. @@ -200,7 +205,7 @@ class Subprocess: command: The command to run, in the form of sys.argv. working_dir: The directory to change into. capture_stderr: Determines whether to capture stderr in the output member - or to discard it. + or to discard it. env: Dictionary with environment to pass to the subprocess. Returns: @@ -220,9 +225,14 @@ class Subprocess: else: stderr = subprocess.PIPE - p = subprocess.Popen(command, - stdout=subprocess.PIPE, stderr=stderr, - cwd=working_dir, universal_newlines=True, env=env) + p = subprocess.Popen( + command, + stdout=subprocess.PIPE, + stderr=stderr, + cwd=working_dir, + universal_newlines=True, + env=env, + ) # communicate returns a tuple with the file object for the child's # output. self.output = p.communicate()[0] diff --git a/googletest/test/gtest_xml_output_unittest.py b/googletest/test/gtest_xml_output_unittest.py index e46ad3999..5ca11cb6e 100755 --- a/googletest/test/gtest_xml_output_unittest.py +++ b/googletest/test/gtest_xml_output_unittest.py @@ -233,18 +233,21 @@ Expected equality of these values: GTEST_PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath(GTEST_PROGRAM_NAME) -SUPPORTS_TYPED_TESTS = 'TypedTest' in gtest_test_utils.Subprocess( - [GTEST_PROGRAM_PATH, GTEST_LIST_TESTS_FLAG], capture_stderr=False).output +SUPPORTS_TYPED_TESTS = ( + 'TypedTest' + in gtest_test_utils.Subprocess( + [GTEST_PROGRAM_PATH, GTEST_LIST_TESTS_FLAG], capture_stderr=False + ).output +) class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): - """ - Unit test for Google Test's XML output functionality. - """ + """Unit test for Google Test's XML output functionality.""" # This test currently breaks on platforms that do not support typed and # type-parameterized tests, so we don't run it under them. if SUPPORTS_TYPED_TESTS: + def testNonEmptyXmlOutput(self): """Generates non-empty XML and verifies it matches the expected output. @@ -274,12 +277,16 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): # parse the expected datetime manually. match = re.match(r'(\d+)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)', date_time_str) self.assertTrue( - re.match, - 'XML datettime string %s has incorrect format' % date_time_str) + re.match, 'XML datettime string %s has incorrect format' % date_time_str + ) date_time_from_xml = datetime.datetime( - year=int(match.group(1)), month=int(match.group(2)), - day=int(match.group(3)), hour=int(match.group(4)), - minute=int(match.group(5)), second=int(match.group(6))) + year=int(match.group(1)), + month=int(match.group(2)), + day=int(match.group(3)), + hour=int(match.group(4)), + minute=int(match.group(5)), + second=int(match.group(6)), + ) time_delta = abs(datetime.datetime.now() - date_time_from_xml) # timestamp value should be near the current local time @@ -292,10 +299,12 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): Confirms that Google Test produces an XML output file with the expected default name if no name is explicitly specified. """ - output_file = os.path.join(gtest_test_utils.GetTempDir(), - GTEST_DEFAULT_OUTPUT_FILE) + output_file = os.path.join( + gtest_test_utils.GetTempDir(), GTEST_DEFAULT_OUTPUT_FILE + ) gtest_prog_path = gtest_test_utils.GetTestExecutablePath( - 'gtest_no_test_unittest') + 'gtest_no_test_unittest' + ) try: os.remove(output_file) except OSError: @@ -305,7 +314,8 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): p = gtest_test_utils.Subprocess( [gtest_prog_path, '%s=xml' % GTEST_OUTPUT_FLAG], - working_dir=gtest_test_utils.GetTempDir()) + working_dir=gtest_test_utils.GetTempDir(), + ) self.assertTrue(p.exited) self.assertEqual(0, p.exit_code) self.assertTrue(os.path.isfile(output_file)) @@ -317,20 +327,24 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): shut down before RUN_ALL_TESTS is invoked. """ - xml_path = os.path.join(gtest_test_utils.GetTempDir(), - GTEST_PROGRAM_NAME + 'out.xml') + xml_path = os.path.join( + gtest_test_utils.GetTempDir(), GTEST_PROGRAM_NAME + 'out.xml' + ) if os.path.isfile(xml_path): os.remove(xml_path) - command = [GTEST_PROGRAM_PATH, - '%s=xml:%s' % (GTEST_OUTPUT_FLAG, xml_path), - '--shut_down_xml'] + command = [ + GTEST_PROGRAM_PATH, + '%s=xml:%s' % (GTEST_OUTPUT_FLAG, xml_path), + '--shut_down_xml', + ] p = gtest_test_utils.Subprocess(command) if p.terminated_by_signal: # p.signal is available only if p.terminated_by_signal is True. self.assertFalse( p.terminated_by_signal, - '%s was killed by signal %d' % (GTEST_PROGRAM_NAME, p.signal)) + '%s was killed by signal %d' % (GTEST_PROGRAM_NAME, p.signal), + ) else: self.assertTrue(p.exited) self.assertEqual( @@ -349,8 +363,12 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): non-selected tests do not show up in the XML output. """ - self._TestXmlOutput(GTEST_PROGRAM_NAME, EXPECTED_FILTERED_TEST_XML, 0, - extra_args=['%s=SuccessfulTest.*' % GTEST_FILTER_FLAG]) + self._TestXmlOutput( + GTEST_PROGRAM_NAME, + EXPECTED_FILTERED_TEST_XML, + 0, + extra_args=['%s=SuccessfulTest.*' % GTEST_FILTER_FLAG], + ) def testShardedTestXmlOutput(self): """Verifies XML output when run using multiple shards. @@ -363,8 +381,8 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): GTEST_PROGRAM_NAME, EXPECTED_SHARDED_TEST_XML, 0, - extra_env={SHARD_INDEX_ENV_VAR: '0', - TOTAL_SHARDS_ENV_VAR: '10'}) + extra_env={SHARD_INDEX_ENV_VAR: '0', TOTAL_SHARDS_ENV_VAR: '10'}, + ) def _GetXmlOutput( self, gtest_prog_name, extra_args, extra_env, expected_exit_code @@ -379,12 +397,15 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): extra_env: Optional environment variables to set. expected_exit_code: Expected exit code from running gtest_prog_name. """ - xml_path = os.path.join(gtest_test_utils.GetTempDir(), - gtest_prog_name + 'out.xml') + xml_path = os.path.join( + gtest_test_utils.GetTempDir(), gtest_prog_name + 'out.xml' + ) gtest_prog_path = gtest_test_utils.GetTestExecutablePath(gtest_prog_name) - command = ([gtest_prog_path, '%s=xml:%s' % (GTEST_OUTPUT_FLAG, xml_path)] + - extra_args) + command = [ + gtest_prog_path, + '%s=xml:%s' % (GTEST_OUTPUT_FLAG, xml_path), + ] + extra_args environ_copy = os.environ.copy() if extra_env: environ_copy.update(extra_env) @@ -406,8 +427,14 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): actual = minidom.parse(xml_path) return actual - def _TestXmlOutput(self, gtest_prog_name, expected_xml, - expected_exit_code, extra_args=None, extra_env=None): + def _TestXmlOutput( + self, + gtest_prog_name, + expected_xml, + expected_exit_code, + extra_args=None, + extra_env=None, + ): """Asserts that the XML document matches. Asserts that the XML document generated by running the program @@ -423,12 +450,12 @@ class GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase): extra_env: Optional environment variables to set. """ - actual = self._GetXmlOutput(gtest_prog_name, extra_args or [], - extra_env or {}, expected_exit_code) + actual = self._GetXmlOutput( + gtest_prog_name, extra_args or [], extra_env or {}, expected_exit_code + ) expected = minidom.parseString(expected_xml) self.NormalizeXml(actual.documentElement) - self.AssertEquivalentNodes(expected.documentElement, - actual.documentElement) + self.AssertEquivalentNodes(expected.documentElement, actual.documentElement) expected.unlink() actual.unlink() diff --git a/googletest/test/gtest_xml_test_utils.py b/googletest/test/gtest_xml_test_utils.py index 567a3141e..caa77b59b 100755 --- a/googletest/test/gtest_xml_test_utils.py +++ b/googletest/test/gtest_xml_test_utils.py @@ -35,10 +35,9 @@ from googletest.test import gtest_test_utils GTEST_DEFAULT_OUTPUT_FILE = 'test_detail.xml' + class GTestXMLTestCase(gtest_test_utils.TestCase): - """ - Base class for tests of Google Test's XML output functionality. - """ + """Base class for tests of Google Test's XML output functionality.""" def AssertEquivalentNodes(self, expected_node, actual_node): """Asserts that actual_node is equivalent to expected_node. @@ -165,15 +164,19 @@ class GTestXMLTestCase(gtest_test_utils.TestCase): 'Encountered unknown element <%s>' % child.tagName, ) child_id = child.getAttribute( - self.identifying_attribute[child.tagName]) + self.identifying_attribute[child.tagName] + ) self.assertNotIn(child_id, children) children[child_id] = child elif child.nodeType in [Node.TEXT_NODE, Node.CDATA_SECTION_NODE]: if 'detail' not in children: - if (child.nodeType == Node.CDATA_SECTION_NODE or - not child.nodeValue.isspace()): + if ( + child.nodeType == Node.CDATA_SECTION_NODE + or not child.nodeValue.isspace() + ): children['detail'] = child.ownerDocument.createCDATASection( - child.nodeValue) + child.nodeValue + ) else: children['detail'].nodeValue += child.nodeValue else: @@ -210,8 +213,9 @@ class GTestXMLTestCase(gtest_test_utils.TestCase): source_file.value = re.sub(r'^.*[/\\](.*)', '\\1', source_file.value) if element.tagName in ('testsuites', 'testsuite', 'testcase'): timestamp = element.getAttributeNode('timestamp') - timestamp.value = re.sub(r'^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d\d\d$', - '*', timestamp.value) + timestamp.value = re.sub( + r'^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d\d\d$', '*', timestamp.value + ) if element.tagName in ('testsuites', 'testsuite', 'testcase'): time = element.getAttributeNode('time') time.value = re.sub(r'^\d+(\.\d+)?$', '*', time.value) @@ -228,8 +232,9 @@ class GTestXMLTestCase(gtest_test_utils.TestCase): # Replaces the source line information with a normalized form. cdata = re.sub(source_line_pat, '\\1*\n', child.nodeValue) # Removes the actual stack trace. - child.nodeValue = re.sub(r'Stack trace:\n(.|\n)*', - 'Stack trace:\n*', cdata) + child.nodeValue = re.sub( + r'Stack trace:\n(.|\n)*', 'Stack trace:\n*', cdata + ) for child in element.childNodes: if child.nodeType == Node.ELEMENT_NODE: self.NormalizeXml(child) From b72202078d0a7a2f2509eb5237685bcf1baea3b4 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 27 Jan 2023 06:38:06 -0800 Subject: [PATCH 093/336] Test current behavior of doubles and floats in RecordProperty PiperOrigin-RevId: 505104193 Change-Id: I4c2758f22ee1321ed6b6662ab2668f6c5b6aa661 --- .../test/googletest-json-outfiles-test.py | 4 +++- googletest/test/gtest_xml_outfile2_test_.cc | 17 +++++++++++++++-- googletest/test/gtest_xml_outfiles_test.py | 4 +++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/googletest/test/googletest-json-outfiles-test.py b/googletest/test/googletest-json-outfiles-test.py index bc17fe217..3387b1ea3 100644 --- a/googletest/test/googletest-json-outfiles-test.py +++ b/googletest/test/googletest-json-outfiles-test.py @@ -97,7 +97,9 @@ EXPECTED_2 = { 'time': '*', 'classname': 'PropertyTwo', 'SetUpProp': '2', - 'TestSomeProperty': '2', + 'TestFloatProperty': '3', + 'TestDoubleProperty': '4', + 'TestSizetProperty': '5', 'TearDownProp': '2', }], }], diff --git a/googletest/test/gtest_xml_outfile2_test_.cc b/googletest/test/gtest_xml_outfile2_test_.cc index f743b31b7..047d3f6cf 100644 --- a/googletest/test/gtest_xml_outfile2_test_.cc +++ b/googletest/test/gtest_xml_outfile2_test_.cc @@ -39,7 +39,20 @@ class PropertyTwo : public testing::Test { }; TEST_F(PropertyTwo, TestSomeProperties) { +// 'initializing': conversion from 'int' to 'short', possible loss of data + GTEST_DISABLE_MSC_WARNINGS_PUSH_(4244) + + // Floats and doubles are written as int64_t, since RecordProperty takes an + // int64_t, so we test that the values written are truncated to int64_t. + float float_prop = 3.25; + RecordProperty("TestFloatProperty", float_prop); + + double double_prop = 4.75; + RecordProperty("TestDoubleProperty", double_prop); + + GTEST_DISABLE_MSC_WARNINGS_POP_() // 4244 + // Validate we can write an unsigned size_t as a property - size_t prop_two = 2; - RecordProperty("TestSomeProperty", prop_two); + size_t size_t_prop = 5; + RecordProperty("TestSizetProperty", size_t_prop); } diff --git a/googletest/test/gtest_xml_outfiles_test.py b/googletest/test/gtest_xml_outfiles_test.py index b482f0253..de6794f6f 100755 --- a/googletest/test/gtest_xml_outfiles_test.py +++ b/googletest/test/gtest_xml_outfiles_test.py @@ -60,7 +60,9 @@ EXPECTED_XML_2 = """ - + + + From f1c05d4544964b060460a683c1cf31e02f0ba094 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 30 Jan 2023 12:57:54 -0800 Subject: [PATCH 094/336] Use explicit short to fix MSVC compiler warning warning C4244: 'initializing': conversion from 'int' to 'short', possible loss of data PiperOrigin-RevId: 505774670 Change-Id: I3524040334a4b265bae12cfacdd2b615cbb1cfc8 --- googlemock/test/gmock-matchers-misc_test.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/googlemock/test/gmock-matchers-misc_test.cc b/googlemock/test/gmock-matchers-misc_test.cc index f99bbf4f1..1d1bfb981 100644 --- a/googlemock/test/gmock-matchers-misc_test.cc +++ b/googlemock/test/gmock-matchers-misc_test.cc @@ -863,7 +863,7 @@ TEST(ArgsTest, AcceptsOneTemplateArg) { } TEST(ArgsTest, AcceptsTwoTemplateArgs) { - const std::tuple t(4, 5, 6L); // NOLINT + const std::tuple t(short{4}, 5, 6L); // NOLINT EXPECT_THAT(t, (Args<0, 1>(Lt()))); EXPECT_THAT(t, (Args<1, 2>(Lt()))); @@ -871,13 +871,13 @@ TEST(ArgsTest, AcceptsTwoTemplateArgs) { } TEST(ArgsTest, AcceptsRepeatedTemplateArgs) { - const std::tuple t(4, 5, 6L); // NOLINT + const std::tuple t(short{4}, 5, 6L); // NOLINT EXPECT_THAT(t, (Args<0, 0>(Eq()))); EXPECT_THAT(t, Not(Args<1, 1>(Ne()))); } TEST(ArgsTest, AcceptsDecreasingTemplateArgs) { - const std::tuple t(4, 5, 6L); // NOLINT + const std::tuple t(short{4}, 5, 6L); // NOLINT EXPECT_THAT(t, (Args<2, 0>(Gt()))); EXPECT_THAT(t, Not(Args<2, 1>(Lt()))); } @@ -892,7 +892,7 @@ TEST(ArgsTest, AcceptsMoreTemplateArgsThanArityOfOriginalTuple) { } TEST(ArgsTest, CanBeNested) { - const std::tuple t(4, 5, 6L, 6); // NOLINT + const std::tuple t(short{4}, 5, 6L, 6); // NOLINT EXPECT_THAT(t, (Args<1, 2, 3>(Args<1, 2>(Eq())))); EXPECT_THAT(t, (Args<0, 1, 3>(Args<0, 2>(Lt())))); } From 4fb7039fda3f6588c7ca9664176f8c9e0a023b4a Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 30 Jan 2023 13:44:59 -0800 Subject: [PATCH 095/336] Use GTEST_DISABLE_MSC_WARNINGS macros to disable warnings Prior to this change we had a mixture of pragmas and GTEST_DISABLE_MSC_WARNINGS; this change consolidates all instances to use the macros. PiperOrigin-RevId: 505786926 Change-Id: I2be8f6304387393995081af42ed32c2ad1bba5a7 --- googlemock/include/gmock/gmock-actions.h | 9 ++----- googlemock/include/gmock/gmock-more-actions.h | 9 ++----- .../include/gmock/gmock-more-matchers.h | 14 +++++----- .../gmock/internal/gmock-internal-utils.h | 10 ++----- googlemock/src/gmock-spec-builders.cc | 13 +++------ googlemock/test/gmock-actions_test.cc | 27 ++++++++++--------- googlemock/test/gmock-function-mocker_test.cc | 20 +++++--------- .../test/gmock-matchers-arithmetic_test.cc | 16 ++++------- .../test/gmock-matchers-comparisons_test.cc | 17 +++++------- .../test/gmock-matchers-containers_test.cc | 12 +++------ googlemock/test/gmock-matchers-misc_test.cc | 12 +++------ googlemock/test/gmock-more-actions_test.cc | 16 +++++------ googlemock/test/gmock-spec-builders_test.cc | 9 ++----- googlemock/test/gmock_link_test.h | 9 ++----- googlemock/test/gmock_output_test_.cc | 9 ++----- googletest/include/gtest/gtest.h | 10 ++----- .../include/gtest/internal/gtest-param-util.h | 9 ++----- 17 files changed, 72 insertions(+), 149 deletions(-) diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h index a6c2489f5..1cffde2b8 100644 --- a/googlemock/include/gmock/gmock-actions.h +++ b/googlemock/include/gmock/gmock-actions.h @@ -146,10 +146,7 @@ #include "gmock/internal/gmock-port.h" #include "gmock/internal/gmock-pp.h" -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4100) -#endif +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4100) namespace testing { @@ -2295,8 +2292,6 @@ template } // namespace testing -#ifdef _MSC_VER -#pragma warning(pop) -#endif +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4100 #endif // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_ diff --git a/googlemock/include/gmock/gmock-more-actions.h b/googlemock/include/gmock/gmock-more-actions.h index 78169b1d0..40300766f 100644 --- a/googlemock/include/gmock/gmock-more-actions.h +++ b/googlemock/include/gmock/gmock-more-actions.h @@ -583,10 +583,7 @@ namespace testing { // the macro definition, as the warnings are generated when the macro // is expanded and macro expansion cannot contain #pragma. Therefore // we suppress them here. -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4100) -#endif +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4100) namespace internal { @@ -654,9 +651,7 @@ InvokeArgument(Params &&...params) { internal::FlatTupleConstructTag{}, std::forward(params)...)}; } -#ifdef _MSC_VER -#pragma warning(pop) -#endif +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4100 } // namespace testing diff --git a/googlemock/include/gmock/gmock-more-matchers.h b/googlemock/include/gmock/gmock-more-matchers.h index d9a921073..54ea68be9 100644 --- a/googlemock/include/gmock/gmock-more-matchers.h +++ b/googlemock/include/gmock/gmock-more-matchers.h @@ -49,14 +49,11 @@ namespace testing { // Silence C4100 (unreferenced formal // parameter) for MSVC -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4100) -#if (_MSC_VER == 1900) +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4100) +#if defined(_MSC_VER) && (_MSC_VER == 1900) // and silence C4800 (C4800: 'int *const ': forcing value // to bool 'true' or 'false') for MSVC 14 -#pragma warning(disable : 4800) -#endif +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800) #endif namespace internal { @@ -113,9 +110,10 @@ MATCHER(IsFalse, negation ? "is true" : "is false") { return !static_cast(arg); } -#ifdef _MSC_VER -#pragma warning(pop) +#if defined(_MSC_VER) && (_MSC_VER == 1900) +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4800 #endif +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4100 } // namespace testing diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h index 36ab8e26a..afbdce035 100644 --- a/googlemock/include/gmock/internal/gmock-internal-utils.h +++ b/googlemock/include/gmock/internal/gmock-internal-utils.h @@ -58,11 +58,7 @@ namespace internal { // Silence MSVC C4100 (unreferenced formal parameter) and // C4805('==': unsafe mix of type 'const int' and type 'const bool') -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4100) -#pragma warning(disable : 4805) -#endif +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4100 4805) // Joins a vector of strings as if they are fields of a tuple; returns // the joined string. @@ -480,9 +476,7 @@ using TupleElement = typename std::tuple_element::type; bool Base64Unescape(const std::string& encoded, std::string* decoded); -#ifdef _MSC_VER -#pragma warning(pop) -#endif +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4100 4805 } // namespace internal } // namespace testing diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index ea821f855..7d7c55ad8 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -57,11 +57,8 @@ // Silence C4800 (C4800: 'int *const ': forcing value // to bool 'true' or 'false') for MSVC 15 -#ifdef _MSC_VER -#if _MSC_VER == 1900 -#pragma warning(push) -#pragma warning(disable : 4800) -#endif +#if defined(_MSC_VER) && (_MSC_VER == 1900) +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800) #endif namespace testing { @@ -788,8 +785,6 @@ InSequence::~InSequence() { } // namespace testing -#ifdef _MSC_VER -#if _MSC_VER == 1900 -#pragma warning(pop) -#endif +#if defined(_MSC_VER) && (_MSC_VER == 1900) +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4800 #endif diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc index 295470ec1..f2d3042f0 100644 --- a/googlemock/test/gmock-actions_test.cc +++ b/googlemock/test/gmock-actions_test.cc @@ -31,19 +31,6 @@ // // This file tests the built-in actions. -// Silence C4100 (unreferenced formal parameter) and C4503 (decorated name -// length exceeded) for MSVC. -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4100) -#pragma warning(disable : 4503) -#if _MSC_VER == 1900 -// and silence C4800 (C4800: 'int *const ': forcing value -// to bool 'true' or 'false') for MSVC 15 -#pragma warning(disable : 4800) -#endif -#endif - #include "gmock/gmock-actions.h" #include @@ -59,6 +46,15 @@ #include "gtest/gtest-spi.h" #include "gtest/gtest.h" +// Silence C4100 (unreferenced formal parameter) and C4503 (decorated name +// length exceeded) for MSVC. +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4100 4503) +#if defined(_MSC_VER) && (_MSC_VER == 1900) +// and silence C4800 (C4800: 'int *const ': forcing value +// to bool 'true' or 'false') for MSVC 15 +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4800) +#endif + namespace testing { namespace { @@ -2165,3 +2161,8 @@ TEST(ActionMacro, LargeArity) { } // namespace } // namespace testing + +#if defined(_MSC_VER) && (_MSC_VER == 1900) +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4800 +#endif +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4100 4503 diff --git a/googlemock/test/gmock-function-mocker_test.cc b/googlemock/test/gmock-function-mocker_test.cc index 1d15a2993..e211aff95 100644 --- a/googlemock/test/gmock-function-mocker_test.cc +++ b/googlemock/test/gmock-function-mocker_test.cc @@ -27,17 +27,14 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Silence C4503 (decorated name length exceeded) for MSVC. -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4503) -#endif - // Google Mock - a framework for writing C++ mock classes. // // This file tests the function mocker classes. #include "gmock/gmock-function-mocker.h" +// Silence C4503 (decorated name length exceeded) for MSVC. +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4503) + #if GTEST_OS_WINDOWS // MSDN says the header file to be included for STDMETHOD is BaseTyps.h but // we are getting compiler errors if we use basetyps.h, hence including @@ -137,10 +134,7 @@ class FooInterface { // significant in determining whether two virtual functions had the same // signature. This was fixed in Visual Studio 2008. However, the compiler // still emits a warning that alerts about this change in behavior. -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4373) -#endif +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4373) class MockFoo : public FooInterface { public: MockFoo() {} @@ -285,9 +279,7 @@ class LegacyMockFoo : public FooInterface { LegacyMockFoo& operator=(const LegacyMockFoo&) = delete; }; -#ifdef _MSC_VER -#pragma warning(pop) -#endif +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4373 template class FunctionMockerTest : public testing::Test { @@ -1002,3 +994,5 @@ TEST(MockMethodMockFunctionTest, NoexceptSpecifierPreserved) { } // namespace gmock_function_mocker_test } // namespace testing + +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4503 diff --git a/googlemock/test/gmock-matchers-arithmetic_test.cc b/googlemock/test/gmock-matchers-arithmetic_test.cc index 36c2bf027..fd81a9e84 100644 --- a/googlemock/test/gmock-matchers-arithmetic_test.cc +++ b/googlemock/test/gmock-matchers-arithmetic_test.cc @@ -31,18 +31,14 @@ // // This file tests some commonly used argument matchers. -// Silence warning C4244: 'initializing': conversion from 'int' to 'short', -// possible loss of data and C4100, unreferenced local parameter -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4244) -#pragma warning(disable : 4100) -#endif - #include "test/gmock-matchers_test.h" #include +// Silence warning C4244: 'initializing': conversion from 'int' to 'short', +// possible loss of data and C4100, unreferenced local parameter +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4244 4100) + namespace testing { namespace gmock_matchers_test { namespace { @@ -1514,6 +1510,4 @@ TEST(AnyOfTest, WorksOnMoveOnlyType) { } // namespace gmock_matchers_test } // namespace testing -#ifdef _MSC_VER -#pragma warning(pop) -#endif +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4244 4100 diff --git a/googlemock/test/gmock-matchers-comparisons_test.cc b/googlemock/test/gmock-matchers-comparisons_test.cc index 83242d648..3db9746fd 100644 --- a/googlemock/test/gmock-matchers-comparisons_test.cc +++ b/googlemock/test/gmock-matchers-comparisons_test.cc @@ -31,18 +31,15 @@ // // This file tests some commonly used argument matchers. -// Silence warning C4244: 'initializing': conversion from 'int' to 'short', -// possible loss of data and C4100, unreferenced local parameter -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4244) -#pragma warning(disable : 4100) -#endif - #include #include "test/gmock-matchers_test.h" +// Silence warning C4244: 'initializing': conversion from 'int' to 'short', +// possible loss of data and C4100, unreferenced local parameter +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4244 4100) + + namespace testing { namespace gmock_matchers_test { namespace { @@ -2354,6 +2351,4 @@ TEST(PolymorphicMatcherTest, CanAccessImpl) { } // namespace gmock_matchers_test } // namespace testing -#ifdef _MSC_VER -#pragma warning(pop) -#endif +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4244 4100 diff --git a/googlemock/test/gmock-matchers-containers_test.cc b/googlemock/test/gmock-matchers-containers_test.cc index 98787f25e..b40a26a47 100644 --- a/googlemock/test/gmock-matchers-containers_test.cc +++ b/googlemock/test/gmock-matchers-containers_test.cc @@ -31,13 +31,11 @@ // // This file tests some commonly used argument matchers. +#include "gtest/gtest.h" + // Silence warning C4244: 'initializing': conversion from 'int' to 'short', // possible loss of data and C4100, unreferenced local parameter -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4244) -#pragma warning(disable : 4100) -#endif +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4244 4100) #include "test/gmock-matchers_test.h" @@ -3124,6 +3122,4 @@ TEST(ContainsTest, WorksForTwoDimensionalNativeArray) { } // namespace gmock_matchers_test } // namespace testing -#ifdef _MSC_VER -#pragma warning(pop) -#endif +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4244 4100 diff --git a/googlemock/test/gmock-matchers-misc_test.cc b/googlemock/test/gmock-matchers-misc_test.cc index 1d1bfb981..c1e4f3526 100644 --- a/googlemock/test/gmock-matchers-misc_test.cc +++ b/googlemock/test/gmock-matchers-misc_test.cc @@ -31,13 +31,11 @@ // // This file tests some commonly used argument matchers. +#include "gtest/gtest.h" + // Silence warning C4244: 'initializing': conversion from 'int' to 'short', // possible loss of data and C4100, unreferenced local parameter -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4244) -#pragma warning(disable : 4100) -#endif +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4244 4100) #include "test/gmock-matchers_test.h" @@ -1814,6 +1812,4 @@ TEST(ThrowsPredicateCompilesTest, MessageMatcherAcceptsNonMatcher) { } // namespace gmock_matchers_test } // namespace testing -#ifdef _MSC_VER -#pragma warning(pop) -#endif +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4244 4100 diff --git a/googlemock/test/gmock-more-actions_test.cc b/googlemock/test/gmock-more-actions_test.cc index b9b66bf90..866e1aba1 100644 --- a/googlemock/test/gmock-more-actions_test.cc +++ b/googlemock/test/gmock-more-actions_test.cc @@ -31,11 +31,6 @@ // // This file tests the built-in actions in gmock-actions.h. -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4577) -#endif - #include "gmock/gmock-more-actions.h" #include @@ -47,6 +42,8 @@ #include "gtest/gtest-spi.h" #include "gtest/gtest.h" +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4577) + namespace testing { namespace gmock_more_actions_test { @@ -982,11 +979,7 @@ TEST(DoAllTest, ImplicitlyConvertsActionArguments) { // is expanded and macro expansion cannot contain #pragma. Therefore // we suppress them here. // Also suppress C4503 decorated name length exceeded, name was truncated -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4100) -#pragma warning(disable : 4503) -#endif +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4100 4503) // Tests the ACTION*() macro family. // Tests that ACTION() can define an action that doesn't reference the @@ -1548,3 +1541,6 @@ TEST(ActionTemplateTest, CanBeOverloadedOnNumberOfValueParameters) { } // namespace gmock_more_actions_test } // namespace testing + +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4100 4503 +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4577 diff --git a/googlemock/test/gmock-spec-builders_test.cc b/googlemock/test/gmock-spec-builders_test.cc index 165944ead..6c5e398bb 100644 --- a/googlemock/test/gmock-spec-builders_test.cc +++ b/googlemock/test/gmock-spec-builders_test.cc @@ -1779,16 +1779,11 @@ TEST(DeletingMockEarlyTest, Success2) { // Suppresses warning on unreferenced formal parameter in MSVC with // -W4. -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4100) -#endif +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4100) ACTION_P(Delete, ptr) { delete ptr; } -#ifdef _MSC_VER -#pragma warning(pop) -#endif +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4100 TEST(DeletingMockEarlyTest, CanDeleteSelfInActionReturningVoid) { MockA* const a = new MockA; diff --git a/googlemock/test/gmock_link_test.h b/googlemock/test/gmock_link_test.h index eaf18e9d8..95a8cb807 100644 --- a/googlemock/test/gmock_link_test.h +++ b/googlemock/test/gmock_link_test.h @@ -423,10 +423,7 @@ TEST(LinkTest, TestThrow) { // the macro definition, as the warnings are generated when the macro // is expanded and macro expansion cannot contain #pragma. Therefore // we suppress them here. -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4100) -#endif +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4100) // Tests the linkage of actions created using ACTION macro. namespace { @@ -459,9 +456,7 @@ ACTION_P2(ReturnEqualsEitherOf, first, second) { } } // namespace -#ifdef _MSC_VER -#pragma warning(pop) -#endif +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4100 TEST(LinkTest, TestActionP2Macro) { Mock mock; diff --git a/googlemock/test/gmock_output_test_.cc b/googlemock/test/gmock_output_test_.cc index a17869159..af4eaa9eb 100644 --- a/googlemock/test/gmock_output_test_.cc +++ b/googlemock/test/gmock_output_test_.cc @@ -38,10 +38,7 @@ #include "gtest/gtest.h" // Silence C4100 (unreferenced formal parameter) -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4100) -#endif +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4100) using testing::_; using testing::AnyNumber; @@ -286,6 +283,4 @@ int main(int argc, char** argv) { return RUN_ALL_TESTS(); } -#ifdef _MSC_VER -#pragma warning(pop) -#endif +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4100 diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index c4e01adf9..f99df35de 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -166,11 +166,7 @@ namespace testing { // Silence C4100 (unreferenced formal parameter) and 4805 // unsafe mix of type 'const int' and type 'const bool' -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4805) -#pragma warning(disable : 4100) -#endif +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4805 4100) // The upper limit for valid stack trace depths. const int kMaxStackTraceDepth = 100; @@ -2214,9 +2210,7 @@ GTEST_API_ std::string TempDir(); // in it should be considered read-only. GTEST_API_ std::string SrcDir(); -#ifdef _MSC_VER -#pragma warning(pop) -#endif +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4805 4100 // Dynamically registers a test with the framework. // diff --git a/googletest/include/gtest/internal/gtest-param-util.h b/googletest/include/gtest/internal/gtest-param-util.h index 358ef72c7..50435f500 100644 --- a/googletest/include/gtest/internal/gtest-param-util.h +++ b/googletest/include/gtest/internal/gtest-param-util.h @@ -794,10 +794,7 @@ internal::ParamGenerator ValuesIn( namespace internal { // Used in the Values() function to provide polymorphic capabilities. -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4100) -#endif +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4100) template class ValueArray { @@ -818,9 +815,7 @@ class ValueArray { FlatTuple v_; }; -#ifdef _MSC_VER -#pragma warning(pop) -#endif +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4100 template class CartesianProductGenerator From d9251171f5a42eaf993395e7ef127546af5814b0 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 31 Jan 2023 11:36:17 -0800 Subject: [PATCH 096/336] Fix sign conversion warning from clang: googletest/samples/prime_tables.h:81:57: error: implicit conversion changes signedness: 'int' to 'unsigned long' [-Werror,-Wsign-conversion] : is_prime_size_(max + 1), is_prime_(new bool[max + 1]) { ~~~ ~~~~^~~ PiperOrigin-RevId: 506065360 Change-Id: Ida4550562531012c089e2f9fcf530b3a78889fa3 --- googletest/samples/prime_tables.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/googletest/samples/prime_tables.h b/googletest/samples/prime_tables.h index 7c0286e1a..08ad94939 100644 --- a/googletest/samples/prime_tables.h +++ b/googletest/samples/prime_tables.h @@ -78,8 +78,9 @@ class PreCalculatedPrimeTable : public PrimeTable { public: // 'max' specifies the maximum number the prime table holds. explicit PreCalculatedPrimeTable(int max) - : is_prime_size_(max + 1), is_prime_(new bool[max + 1]) { - CalculatePrimesUpTo(max); + : is_prime_size_(std::max(1, max + 1)), + is_prime_(new bool[static_cast(is_prime_size_)]) { + CalculatePrimesUpTo(is_prime_size_ - 1); } ~PreCalculatedPrimeTable() override { delete[] is_prime_; } From 0a3b403fe037ff80daa1826ae99eed41e94dea05 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 1 Feb 2023 09:32:33 -0800 Subject: [PATCH 097/336] Fix gmock_output_test when using MSVC std::pair is printed as "struct std::pair" when using MSVC vs "std::pair" with other compilers. Switch to "std::tuple", which is the same for all compilers. See https://learn.microsoft.com/en-us/cpp/standard-library/pair-structure https://learn.microsoft.com/en-us/cpp/standard-library/tuple-class PiperOrigin-RevId: 506340295 Change-Id: Ib4ce2f74d54888a4e4173f42da1b55cc5583f7d4 --- googlemock/test/gmock_output_test_.cc | 9 +++++++-- googlemock/test/gmock_output_test_golden.txt | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/googlemock/test/gmock_output_test_.cc b/googlemock/test/gmock_output_test_.cc index af4eaa9eb..ca5a646f3 100644 --- a/googlemock/test/gmock_output_test_.cc +++ b/googlemock/test/gmock_output_test_.cc @@ -33,6 +33,7 @@ #include #include +#include #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -254,12 +255,16 @@ TEST_F(GMockOutputTest, CatchesLeakedMocks) { } MATCHER_P2(IsPair, first, second, "") { - return Value(arg.first, first) && Value(arg.second, second); + return Value(std::get<0>(arg), first) && Value(std::get<1>(arg), second); } TEST_F(GMockOutputTest, PrintsMatcher) { const testing::Matcher m1 = Ge(48); - EXPECT_THAT((std::pair(42, true)), IsPair(m1, true)); + // Explicitly using std::tuple instead of std::pair due to differences between + // MSVC and other compilers. std::pair is printed as + // "struct std::pair" when using MSVC vs "std::pair" with + // other compilers. + EXPECT_THAT((std::tuple(42, true)), IsPair(m1, true)); } void TestCatchesLeakedMocksInAdHocTests() { diff --git a/googlemock/test/gmock_output_test_golden.txt b/googlemock/test/gmock_output_test_golden.txt index 467fa20ef..ac2a5e219 100644 --- a/googlemock/test/gmock_output_test_golden.txt +++ b/googlemock/test/gmock_output_test_golden.txt @@ -290,9 +290,9 @@ Stack trace: [ OK ] GMockOutputTest.CatchesLeakedMocks [ RUN ] GMockOutputTest.PrintsMatcher FILE:#: Failure -Value of: (std::pair(42, true)) +Value of: (std::tuple(42, true)) Expected: is pair (first: is >= 48, second: true) - Actual: (42, true) (of type std::pair) + Actual: (42, true) [ FAILED ] GMockOutputTest.PrintsMatcher [ FAILED ] GMockOutputTest.UnexpectedCall [ FAILED ] GMockOutputTest.UnexpectedCallToVoidFunction From fd36851c8d383a2b711905eb488692da1152a3d8 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 1 Feb 2023 11:44:24 -0800 Subject: [PATCH 098/336] Build gmock Python tests when building with cmake Fixes #4124. PiperOrigin-RevId: 506379032 Change-Id: Ibc44ffce1012bbf313565728a3d9e5e6e56ba660 --- googletest/cmake/internal_utils.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index 41405587f..0438bef83 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -259,10 +259,12 @@ endif() # Sets PYTHONINTERP_FOUND and PYTHON_EXECUTABLE. if ("${CMAKE_VERSION}" VERSION_LESS "3.12.0") find_package(PythonInterp) + set(PYTHONINTERP_FOUND ${PYTHONINTERP_FOUND} CACHE INTERNAL "") + set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE INTERNAL "") else() find_package(Python COMPONENTS Interpreter) - set(PYTHONINTERP_FOUND ${Python_Interpreter_FOUND}) - set(PYTHON_EXECUTABLE ${Python_EXECUTABLE}) + set(PYTHONINTERP_FOUND ${Python_Interpreter_FOUND} CACHE INTERNAL "") + set(PYTHON_EXECUTABLE ${Python_EXECUTABLE} CACHE INTERNAL "") endif() # cxx_test_with_flags(name cxx_flags libs srcs...) From 394a8a568cad47025d5f382d4519371df71b12e1 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 1 Feb 2023 12:13:51 -0800 Subject: [PATCH 099/336] Remove GMOCK_RENAME_MAIN GMOCK_RENAME_MAIN appears unused. PiperOrigin-RevId: 506387823 Change-Id: I732c1f64f9038991a5c9aea1f2ad6fff07622afa --- googlemock/test/gmock-spec-builders_test.cc | 7 ------- 1 file changed, 7 deletions(-) diff --git a/googlemock/test/gmock-spec-builders_test.cc b/googlemock/test/gmock-spec-builders_test.cc index 6c5e398bb..76c9ff746 100644 --- a/googlemock/test/gmock-spec-builders_test.cc +++ b/googlemock/test/gmock-spec-builders_test.cc @@ -2597,14 +2597,7 @@ TEST(ParameterlessExpectationsTest, } // namespace } // namespace testing -// Allows the user to define their own main and then invoke gmock_main -// from it. This might be necessary on some platforms which require -// specific setup and teardown. -#if GMOCK_RENAME_MAIN -int gmock_main(int argc, char** argv) { -#else int main(int argc, char** argv) { -#endif // GMOCK_RENAME_MAIN testing::InitGoogleMock(&argc, argv); // Ensures that the tests pass no matter what value of // --gmock_catch_leaked_mocks and --gmock_verbose the user specifies. From ebedaa18c7cafa15f06ab3d814440e510fad9559 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 1 Feb 2023 14:31:44 -0800 Subject: [PATCH 100/336] Fix include order PiperOrigin-RevId: 506424617 Change-Id: If7f0beb92022589523db204a6b5cbe9249cebf62 --- googlemock/test/gmock-matchers-arithmetic_test.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/googlemock/test/gmock-matchers-arithmetic_test.cc b/googlemock/test/gmock-matchers-arithmetic_test.cc index fd81a9e84..2c5f4d0bd 100644 --- a/googlemock/test/gmock-matchers-arithmetic_test.cc +++ b/googlemock/test/gmock-matchers-arithmetic_test.cc @@ -31,10 +31,10 @@ // // This file tests some commonly used argument matchers. -#include "test/gmock-matchers_test.h" - #include +#include "test/gmock-matchers_test.h" + // Silence warning C4244: 'initializing': conversion from 'int' to 'short', // possible loss of data and C4100, unreferenced local parameter GTEST_DISABLE_MSC_WARNINGS_PUSH_(4244 4100) From 6f21175f57afa370a707026fcaf246eb081d1639 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Thu, 2 Feb 2023 07:14:30 -0800 Subject: [PATCH 101/336] Add a trailing decimal point to FormatTimeInMillisAsSeconds() output when input is an exact N seconds. PiperOrigin-RevId: 506610898 Change-Id: Idcd705c719e0e721148c350c8a14f27b9eb5c4f7 --- googletest/src/gtest-internal-inl.h | 3 ++- googletest/src/gtest.cc | 8 ++++++++ googletest/test/gtest_unittest.cc | 14 +++++++++++--- googletest/test/gtest_xml_test_utils.py | 4 +++- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h index 2c9db4f20..9fbcfd34a 100644 --- a/googletest/src/gtest-internal-inl.h +++ b/googletest/src/gtest-internal-inl.h @@ -92,7 +92,8 @@ GTEST_API_ TimeInMillis GetTimeInMillis(); // Returns true if and only if Google Test should use colors in the output. GTEST_API_ bool ShouldUseColor(bool stdout_is_tty); -// Formats the given time in milliseconds as seconds. +// Formats the given time in milliseconds as seconds. If the input is an exact N +// seconds, the output has a trailing decimal point (e.g., "N." intead of "N"). GTEST_API_ std::string FormatTimeInMillisAsSeconds(TimeInMillis ms); // Converts the given time in milliseconds to a date string in the ISO 8601 diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 19acb1cc7..b9289439c 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -4089,6 +4090,13 @@ std::string XmlUnitTestResultPrinter::RemoveInvalidXmlCharacters( // Formats the given time in milliseconds as seconds. std::string FormatTimeInMillisAsSeconds(TimeInMillis ms) { ::std::stringstream ss; + // For the exact N seconds, makes sure output has a trailing decimal point. + // Sets precision so that we won't have many trailing zeros (e.g., 300 ms + // will be just 0.3, 410 ms 0.41, and so on) + ss << std::fixed + << std::setprecision( + ms % 1000 == 0 ? 0 : (ms % 100 == 0 ? 1 : (ms % 10 == 0 ? 2 : 3))) + << std::showpoint; ss << (static_cast(ms) * 1e-3); return ss.str(); } diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index e66e66b95..2199073de 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -382,7 +382,7 @@ TEST(CanonicalizeForStdLibVersioning, ElidesDoubleUnderNames) { // Tests FormatTimeInMillisAsSeconds(). TEST(FormatTimeInMillisAsSecondsTest, FormatsZero) { - EXPECT_EQ("0", FormatTimeInMillisAsSeconds(0)); + EXPECT_EQ("0.", FormatTimeInMillisAsSeconds(0)); } TEST(FormatTimeInMillisAsSecondsTest, FormatsPositiveNumber) { @@ -390,7 +390,11 @@ TEST(FormatTimeInMillisAsSecondsTest, FormatsPositiveNumber) { EXPECT_EQ("0.01", FormatTimeInMillisAsSeconds(10)); EXPECT_EQ("0.2", FormatTimeInMillisAsSeconds(200)); EXPECT_EQ("1.2", FormatTimeInMillisAsSeconds(1200)); - EXPECT_EQ("3", FormatTimeInMillisAsSeconds(3000)); + EXPECT_EQ("3.", FormatTimeInMillisAsSeconds(3000)); + EXPECT_EQ("10.", FormatTimeInMillisAsSeconds(10000)); + EXPECT_EQ("100.", FormatTimeInMillisAsSeconds(100000)); + EXPECT_EQ("123.456", FormatTimeInMillisAsSeconds(123456)); + EXPECT_EQ("1234567.89", FormatTimeInMillisAsSeconds(1234567890)); } TEST(FormatTimeInMillisAsSecondsTest, FormatsNegativeNumber) { @@ -398,7 +402,11 @@ TEST(FormatTimeInMillisAsSecondsTest, FormatsNegativeNumber) { EXPECT_EQ("-0.01", FormatTimeInMillisAsSeconds(-10)); EXPECT_EQ("-0.2", FormatTimeInMillisAsSeconds(-200)); EXPECT_EQ("-1.2", FormatTimeInMillisAsSeconds(-1200)); - EXPECT_EQ("-3", FormatTimeInMillisAsSeconds(-3000)); + EXPECT_EQ("-3.", FormatTimeInMillisAsSeconds(-3000)); + EXPECT_EQ("-10.", FormatTimeInMillisAsSeconds(-10000)); + EXPECT_EQ("-100.", FormatTimeInMillisAsSeconds(-100000)); + EXPECT_EQ("-123.456", FormatTimeInMillisAsSeconds(-123456)); + EXPECT_EQ("-1234567.89", FormatTimeInMillisAsSeconds(-1234567890)); } // Tests FormatEpochTimeInMillisAsIso8601(). The correctness of conversion diff --git a/googletest/test/gtest_xml_test_utils.py b/googletest/test/gtest_xml_test_utils.py index caa77b59b..8fcb6933c 100755 --- a/googletest/test/gtest_xml_test_utils.py +++ b/googletest/test/gtest_xml_test_utils.py @@ -218,7 +218,9 @@ class GTestXMLTestCase(gtest_test_utils.TestCase): ) if element.tagName in ('testsuites', 'testsuite', 'testcase'): time = element.getAttributeNode('time') - time.value = re.sub(r'^\d+(\.\d+)?$', '*', time.value) + # The value for exact N seconds has a traling decimal point (e.g., "10." + # instead of "10") + time.value = re.sub(r'^\d+\.(\d+)?$', '*', time.value) type_param = element.getAttributeNode('type_param') if type_param and type_param.value: type_param.value = '*' From 4f7c63d991824b8034a81a0dd91f8b90a20d7806 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 2 Feb 2023 09:01:41 -0800 Subject: [PATCH 102/336] Remove unneccessary "#if _MSC_VER" The GTEST_DISABLE_MSC_WARNINGS macros already have an _MSC_VER check. This change also adds a missing GTEST_DISABLE_MSC_WARNINGS_POP_ in gtest-typed-test_test.cc. PiperOrigin-RevId: 506636248 Change-Id: Ifdc044528f5448fbf0175887d1671f1e1f3040b9 --- googletest/test/googletest-output-test_.cc | 4 ---- googletest/test/gtest-typed-test_test.cc | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/googletest/test/googletest-output-test_.cc b/googletest/test/googletest-output-test_.cc index c2f96d980..1bace982e 100644 --- a/googletest/test/googletest-output-test_.cc +++ b/googletest/test/googletest-output-test_.cc @@ -39,9 +39,7 @@ #include "gtest/gtest.h" #include "src/gtest-internal-inl.h" -#if _MSC_VER GTEST_DISABLE_MSC_WARNINGS_PUSH_(4127 /* conditional expression is constant */) -#endif // _MSC_VER #if GTEST_IS_THREADSAFE using testing::ScopedFakeTestPartResultReporter; @@ -1046,8 +1044,6 @@ int main(int argc, char** argv) { // are registered, and torn down in the reverse order. testing::AddGlobalTestEnvironment(new FooEnvironment); testing::AddGlobalTestEnvironment(new BarEnvironment); -#if _MSC_VER GTEST_DISABLE_MSC_WARNINGS_POP_() // 4127 -#endif // _MSC_VER return RunAllTests(); } diff --git a/googletest/test/gtest-typed-test_test.cc b/googletest/test/gtest-typed-test_test.cc index 4b1c23ddb..0cc8b2114 100644 --- a/googletest/test/gtest-typed-test_test.cc +++ b/googletest/test/gtest-typed-test_test.cc @@ -36,9 +36,7 @@ #include "gtest/gtest.h" -#if _MSC_VER GTEST_DISABLE_MSC_WARNINGS_PUSH_(4127 /* conditional expression is constant */) -#endif // _MSC_VER using testing::Test; @@ -421,3 +419,5 @@ typedef Types > TrimTypes; INSTANTIATE_TYPED_TEST_SUITE_P(My, TrimmedTest, TrimTypes); } // namespace library2 + +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4127 From deaf5615f18dd3b051006ba7326e2a976f5dff46 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 2 Feb 2023 09:31:10 -0800 Subject: [PATCH 103/336] Fix -Wsign-conversion warnings googletest/test/gtest_xml_outfile2_test_.cc:48:39: warning: implicit conversion turns floating-point number into integer: 'float' to 'int64_t' (aka 'long') [-Wfloat-conversion] RecordProperty("TestFloatProperty", float_prop); ~~~~~~~~~~~~~~ ^~~~~~~~~~ googletest/test/gtest_xml_outfile2_test_.cc:51:40: warning: implicit conversion turns floating-point number into integer: 'double' to 'int64_t' (aka 'long') [-Wfloat-conversion] RecordProperty("TestDoubleProperty", double_prop); ~~~~~~~~~~~~~~ ^~~~~~~~~~~ googletest/test/gtest_xml_outfile2_test_.cc:57:39: warning: implicit conversion changes signedness: 'size_t' (aka 'unsigned long') to 'int64_t' (aka 'long') [-Wsign-conversion] RecordProperty("TestSizetProperty", size_t_prop); ~~~~~~~~~~~~~~ ^~~~~~~~~~~ PiperOrigin-RevId: 506644143 Change-Id: I9c2cd5f52daebe25e73bb97f696687797ed2cabf --- googletest/include/gtest/gtest.h | 8 ++++- googletest/src/gtest.cc | 5 --- .../test/googletest-json-outfiles-test.py | 9 ++++- googletest/test/gtest_xml_outfile2_test_.cc | 35 ++++++++++++++----- googletest/test/gtest_xml_outfiles_test.py | 9 ++++- 5 files changed, 50 insertions(+), 16 deletions(-) diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index f99df35de..35c080263 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -297,7 +297,13 @@ class GTEST_API_ Test { // SetUp/TearDown method of Environment objects registered with Google // Test) will be output as attributes of the element. static void RecordProperty(const std::string& key, const std::string& value); - static void RecordProperty(const std::string& key, int64_t value); + // We do not define a custom serialization except for values that can be + // converted to int64_t, but other values could be logged in this way. + template ::value, + bool> = true> + static void RecordProperty(const std::string& key, const T& value) { + RecordProperty(key, (Message() << static_cast(value)).GetString()); + } protected: // Creates a Test object. diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index b9289439c..f79f915f1 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -2459,11 +2459,6 @@ void Test::TearDown() {} void Test::RecordProperty(const std::string& key, const std::string& value) { UnitTest::GetInstance()->RecordProperty(key, value); } -// We do not define a customary serialization except for integers, -// but other values could be logged in this way. -void Test::RecordProperty(const std::string& key, int64_t value) { - RecordProperty(key, (Message() << value).GetString()); -} namespace internal { diff --git a/googletest/test/googletest-json-outfiles-test.py b/googletest/test/googletest-json-outfiles-test.py index 3387b1ea3..83a56de1e 100644 --- a/googletest/test/googletest-json-outfiles-test.py +++ b/googletest/test/googletest-json-outfiles-test.py @@ -88,7 +88,7 @@ EXPECTED_2 = { 'time': '*', 'timestamp': '*', 'testsuite': [{ - 'name': 'TestSomeProperties', + 'name': 'TestInt64Properties', 'file': 'gtest_xml_outfile2_test_.cc', 'line': 41, 'status': 'RUN', @@ -100,6 +100,13 @@ EXPECTED_2 = { 'TestFloatProperty': '3', 'TestDoubleProperty': '4', 'TestSizetProperty': '5', + 'TestBoolProperty': '1', + 'TestCharProperty': '65', + 'TestInt16Property': '6', + 'TestInt32Property': '7', + 'TestInt64Property': '8', + 'TestEnumProperty': '9', + 'TestAtomicIntProperty': '10', 'TearDownProp': '2', }], }], diff --git a/googletest/test/gtest_xml_outfile2_test_.cc b/googletest/test/gtest_xml_outfile2_test_.cc index 047d3f6cf..5ee216dff 100644 --- a/googletest/test/gtest_xml_outfile2_test_.cc +++ b/googletest/test/gtest_xml_outfile2_test_.cc @@ -38,21 +38,40 @@ class PropertyTwo : public testing::Test { void TearDown() override { RecordProperty("TearDownProp", 2); } }; -TEST_F(PropertyTwo, TestSomeProperties) { -// 'initializing': conversion from 'int' to 'short', possible loss of data - GTEST_DISABLE_MSC_WARNINGS_PUSH_(4244) - - // Floats and doubles are written as int64_t, since RecordProperty takes an - // int64_t, so we test that the values written are truncated to int64_t. +TEST_F(PropertyTwo, TestInt64Properties) { + // Floats and doubles are written as int64_t, so we test that the values + // written are truncated to int64_t. float float_prop = 3.25; RecordProperty("TestFloatProperty", float_prop); double double_prop = 4.75; RecordProperty("TestDoubleProperty", double_prop); - GTEST_DISABLE_MSC_WARNINGS_POP_() // 4244 - // Validate we can write an unsigned size_t as a property size_t size_t_prop = 5; RecordProperty("TestSizetProperty", size_t_prop); + + bool bool_prop = true; + RecordProperty("TestBoolProperty", bool_prop); + + char char_prop = 'A'; + RecordProperty("TestCharProperty", char_prop); + + int16_t int16_prop = 6; + RecordProperty("TestInt16Property", int16_prop); + + int32_t int32_prop = 7; + RecordProperty("TestInt32Property", int32_prop); + + int64_t int64_prop = 8; + RecordProperty("TestInt64Property", int64_prop); + + enum Foo { + NINE = 9, + }; + Foo enum_prop = NINE; + RecordProperty("TestEnumProperty", enum_prop); + + std::atomic atomic_int_prop(10); + RecordProperty("TestAtomicIntProperty", atomic_int_prop); } diff --git a/googletest/test/gtest_xml_outfiles_test.py b/googletest/test/gtest_xml_outfiles_test.py index de6794f6f..7ee0f3c85 100755 --- a/googletest/test/gtest_xml_outfiles_test.py +++ b/googletest/test/gtest_xml_outfiles_test.py @@ -57,12 +57,19 @@ EXPECTED_XML_1 = """ EXPECTED_XML_2 = """ - + + + + + + + + From 2f2e72bae991138cedd0e3d06a115022736cd568 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 2 Feb 2023 10:15:42 -0800 Subject: [PATCH 104/336] Fix compiler flags in Linux presubmit CXX_FLAGS should be CXXFLAGS and the quoting was wrong. As a result, "-Werror -Wdeprecated" was not being applied. https://cmake.org/cmake/help/latest/envvar/CXXFLAGS.html PiperOrigin-RevId: 506656655 Change-Id: Ic5e861be3b9c32257eb9aabb845c931f3cba7122 --- ci/linux-presubmit.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/linux-presubmit.sh b/ci/linux-presubmit.sh index 4eb5bbe4a..9e15d9a4f 100644 --- a/ci/linux-presubmit.sh +++ b/ci/linux-presubmit.sh @@ -51,7 +51,7 @@ for cc in /usr/local/bin/gcc /opt/llvm/clang/bin/clang; do --workdir="/build" \ --rm \ --env="CC=${cc}" \ - --env="CXX_FLAGS=\"-Werror -Wdeprecated\"" \ + --env=CXXFLAGS="-Werror -Wdeprecated" \ ${LINUX_LATEST_CONTAINER} \ /bin/bash -c " cmake /src \ From 3f9c7fcaa3e5a40cd3afc9a12327399f7b2a3496 Mon Sep 17 00:00:00 2001 From: Ben Yang Date: Thu, 2 Feb 2023 13:14:43 -0800 Subject: [PATCH 105/336] Update testing.md Fixed Parameter Generator table --- docs/reference/testing.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/reference/testing.md b/docs/reference/testing.md index 62cdcc1c6..877dfa322 100644 --- a/docs/reference/testing.md +++ b/docs/reference/testing.md @@ -110,6 +110,7 @@ namespace: | `Bool()` | Yields sequence `{false, true}`. | | `Combine(g1, g2, ..., gN)` | Yields as `std::tuple` *n*-tuples all combinations (Cartesian product) of the values generated by the given *n* generators `g1`, `g2`, ..., `gN`. | | `ConvertGenerator(g)` | Yields values generated by generator `g`, `static_cast` to `T`. | + The optional last argument *`name_generator`* is a function or functor that generates custom test name suffixes based on the test parameters. The function must accept an argument of type From 3d568bdda59a0b5e50d5f08038eb092b6d88e309 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Mon, 6 Feb 2023 10:59:27 -0800 Subject: [PATCH 106/336] Add support for the alternative base64 encoding in RFC 4648 section 5 to `WhenBase64Unescaped`. PiperOrigin-RevId: 507527786 Change-Id: Ie5e088b1814981f6c760d7e25418a430172705ec --- docs/reference/matchers.md | 2 +- googlemock/src/gmock-internal-utils.cc | 7 ++++++- googlemock/test/gmock-matchers-comparisons_test.cc | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/reference/matchers.md b/docs/reference/matchers.md index be962819c..243e3f951 100644 --- a/docs/reference/matchers.md +++ b/docs/reference/matchers.md @@ -102,7 +102,7 @@ The `argument` can be either a C string or a C++ string object: | `StrCaseNe(string)` | `argument` is not equal to `string`, ignoring case. | | `StrEq(string)` | `argument` is equal to `string`. | | `StrNe(string)` | `argument` is not equal to `string`. | -| `WhenBase64Unescaped(m)` | `argument` is a base-64 escaped string whose unescaped string matches `m`. | +| `WhenBase64Unescaped(m)` | `argument` is a base-64 escaped string whose unescaped string matches `m`. The web-safe format from [RFC 4648](https://www.rfc-editor.org/rfc/rfc4648#section-5) is supported. | `ContainsRegex()` and `MatchesRegex()` take ownership of the `RE` object. They use the regular expression syntax defined diff --git a/googlemock/src/gmock-internal-utils.cc b/googlemock/src/gmock-internal-utils.cc index 7bfff02a3..31d556506 100644 --- a/googlemock/src/gmock-internal-utils.cc +++ b/googlemock/src/gmock-internal-utils.cc @@ -198,6 +198,10 @@ GTEST_API_ void IllegalDoDefault(const char* file, int line) { "the variable in various places."); } +constexpr char UndoWebSafeEncoding(char c) { + return c == '-' ? '+' : c == '_' ? '/' : c; +} + constexpr char UnBase64Impl(char c, const char* const base64, char carry) { return *base64 == 0 ? static_cast(65) : *base64 == c @@ -208,7 +212,8 @@ constexpr char UnBase64Impl(char c, const char* const base64, char carry) { template constexpr std::array UnBase64Impl(IndexSequence, const char* const base64) { - return {{UnBase64Impl(static_cast(I), base64, 0)...}}; + return { + {UnBase64Impl(UndoWebSafeEncoding(static_cast(I)), base64, 0)...}}; } constexpr std::array UnBase64(const char* const base64) { diff --git a/googlemock/test/gmock-matchers-comparisons_test.cc b/googlemock/test/gmock-matchers-comparisons_test.cc index 3db9746fd..0738aafb7 100644 --- a/googlemock/test/gmock-matchers-comparisons_test.cc +++ b/googlemock/test/gmock-matchers-comparisons_test.cc @@ -1802,11 +1802,13 @@ TEST(WhenBase64UnescapedTest, MatchesUnescapedBase64Strings) { EXPECT_FALSE(m1.Matches("invalid base64")); EXPECT_FALSE(m1.Matches("aGVsbG8gd29ybGQ=")); // hello world EXPECT_TRUE(m1.Matches("aGVsbG8gd29ybGQh")); // hello world! + EXPECT_TRUE(m1.Matches("+/-_IQ")); // \xfb\xff\xbf! const Matcher m2 = WhenBase64Unescaped(EndsWith("!")); EXPECT_FALSE(m2.Matches("invalid base64")); EXPECT_FALSE(m2.Matches("aGVsbG8gd29ybGQ=")); // hello world EXPECT_TRUE(m2.Matches("aGVsbG8gd29ybGQh")); // hello world! + EXPECT_TRUE(m2.Matches("+/-_IQ")); // \xfb\xff\xbf! #if GTEST_INTERNAL_HAS_STRING_VIEW const Matcher m3 = @@ -1814,6 +1816,7 @@ TEST(WhenBase64UnescapedTest, MatchesUnescapedBase64Strings) { EXPECT_FALSE(m3.Matches("invalid base64")); EXPECT_FALSE(m3.Matches("aGVsbG8gd29ybGQ=")); // hello world EXPECT_TRUE(m3.Matches("aGVsbG8gd29ybGQh")); // hello world! + EXPECT_TRUE(m3.Matches("+/-_IQ")); // \xfb\xff\xbf! #endif // GTEST_INTERNAL_HAS_STRING_VIEW } From ee33b34bec6f9ccb51d3df6a369a6eb8b267447e Mon Sep 17 00:00:00 2001 From: Martijn Vels Date: Tue, 7 Feb 2023 08:27:29 -0800 Subject: [PATCH 107/336] Fix GTEST_HAS_ABSL define check for [-Werror=undef] compilations PiperOrigin-RevId: 507788664 Change-Id: Ib8cfbf3102a38e210fdae8a548fd84f0723ccc10 --- googlemock/include/gmock/internal/gmock-port.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/googlemock/include/gmock/internal/gmock-port.h b/googlemock/include/gmock/internal/gmock-port.h index bc18a25f3..55ddfb6c6 100644 --- a/googlemock/include/gmock/internal/gmock-port.h +++ b/googlemock/include/gmock/internal/gmock-port.h @@ -56,7 +56,7 @@ #include "gmock/internal/custom/gmock-port.h" #include "gtest/internal/gtest-port.h" -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL #include "absl/flags/declare.h" #include "absl/flags/flag.h" #endif @@ -73,7 +73,7 @@ #define GMOCK_FLAG(name) FLAGS_gmock_##name // Pick a command line flags implementation. -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL // Macros for defining flags. #define GMOCK_DEFINE_bool_(name, default_val, doc) \ From 0570e2d930a185bbc375be70d9ad96836b955a4f Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 7 Feb 2023 10:37:15 -0800 Subject: [PATCH 108/336] Remove GTEST_USES_PCRE references Nothing defines GTEST_USES_PCRE anymore. It was only meant for internal use, so nothing public should be relying on it: https://github.com/google/googletest/issues/2735#issuecomment-644849438. Found when compiling with "-Wundef". Fixes #2735. PiperOrigin-RevId: 507823660 Change-Id: Ie19e576ff01dc3b16381338578ece92adccfc09b --- googlemock/test/gmock-spec-builders_test.cc | 13 ++---------- googletest/test/googletest-death-test-test.cc | 21 ------------------- 2 files changed, 2 insertions(+), 32 deletions(-) diff --git a/googlemock/test/gmock-spec-builders_test.cc b/googlemock/test/gmock-spec-builders_test.cc index 76c9ff746..487b6c3fa 100644 --- a/googlemock/test/gmock-spec-builders_test.cc +++ b/googlemock/test/gmock-spec-builders_test.cc @@ -1088,16 +1088,7 @@ TEST(UnexpectedCallTest, UnsatisfiedPrerequisites) { // Verifies that the failure message contains the two unsatisfied // pre-requisites but not the satisfied one. -#if GTEST_USES_PCRE - EXPECT_THAT( - r.message(), - ContainsRegex( - // PCRE has trouble using (.|\n) to match any character, but - // supports the (?s) prefix for using . to match any character. - "(?s)the following immediate pre-requisites are not satisfied:\n" - ".*: pre-requisite #0\n" - ".*: pre-requisite #1")); -#elif GTEST_USES_POSIX_RE +#if GTEST_USES_POSIX_RE EXPECT_THAT(r.message(), ContainsRegex( // POSIX RE doesn't understand the (?s) prefix, but has no @@ -1112,7 +1103,7 @@ TEST(UnexpectedCallTest, UnsatisfiedPrerequisites) { "the following immediate pre-requisites are not satisfied:")); EXPECT_THAT(r.message(), ContainsRegex(": pre-requisite #0")); EXPECT_THAT(r.message(), ContainsRegex(": pre-requisite #1")); -#endif // GTEST_USES_PCRE +#endif // GTEST_USES_POSIX_RE b.DoB(1); b.DoB(3); diff --git a/googletest/test/googletest-death-test-test.cc b/googletest/test/googletest-death-test-test.cc index 4737ff9bf..515b59986 100644 --- a/googletest/test/googletest-death-test-test.cc +++ b/googletest/test/googletest-death-test-test.cc @@ -327,23 +327,6 @@ TEST_F(TestForDeathTest, SingleStatement) { #pragma GCC diagnostic pop #endif -#if GTEST_USES_PCRE - -void DieWithEmbeddedNul() { - fprintf(stderr, "Hello%cmy null world.\n", '\0'); - fflush(stderr); - _exit(1); -} - -// Tests that EXPECT_DEATH and ASSERT_DEATH work when the error -// message has a NUL character in it. -TEST_F(TestForDeathTest, EmbeddedNulInMessage) { - EXPECT_DEATH(DieWithEmbeddedNul(), "my null world"); - ASSERT_DEATH(DieWithEmbeddedNul(), "my null world"); -} - -#endif // GTEST_USES_PCRE - // Tests that death test macros expand to code which interacts well with switch // statements. TEST_F(TestForDeathTest, SwitchStatement) { @@ -521,16 +504,12 @@ TEST_F(TestForDeathTest, AcceptsAnythingConvertibleToRE) { const testing::internal::RE regex(regex_c_str); EXPECT_DEATH(GlobalFunction(), regex); -#if !GTEST_USES_PCRE - const ::std::string regex_std_str(regex_c_str); EXPECT_DEATH(GlobalFunction(), regex_std_str); // This one is tricky; a temporary pointer into another temporary. Reference // lifetime extension of the pointer is not sufficient. EXPECT_DEATH(GlobalFunction(), ::std::string(regex_c_str).c_str()); - -#endif // !GTEST_USES_PCRE } // Tests that a non-void function can be used in a death test. From b73f27fd164456fea9aba56163f5511355a03272 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Wed, 8 Feb 2023 08:29:22 -0800 Subject: [PATCH 109/336] Fix _MSC_VER check Use "#if defined(_MSC_VER)" instead of "#if _MSC_VER" to be consistent with other usages in googletest and to work with the "-Wundef" warning. PiperOrigin-RevId: 508087630 Change-Id: I29c16fd2fa51a9dfecd55e10362a020318318956 --- googletest/test/gtest_unittest.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index 2199073de..ecffa3765 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -446,7 +446,7 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test { // tzset() distinguishes between the TZ variable being present and empty // and not being present, so we have to consider the case of time_zone // being NULL. -#if _MSC_VER || GTEST_OS_WINDOWS_MINGW +#if defined(_MSC_VER) || GTEST_OS_WINDOWS_MINGW // ...Unless it's MSVC, whose standard library's _putenv doesn't // distinguish between an empty and a missing variable. const std::string env_var = From 097f64e98693500d44d022a781745e562aa492ad Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Thu, 9 Feb 2023 15:29:01 +0800 Subject: [PATCH 110/336] Revert "Fix gmock_output_test when using MSVC" This reverts commit 0a3b403fe037ff80daa1826ae99eed41e94dea05. --- googlemock/test/gmock_output_test_.cc | 9 ++------- googlemock/test/gmock_output_test_golden.txt | 4 ++-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/googlemock/test/gmock_output_test_.cc b/googlemock/test/gmock_output_test_.cc index ca5a646f3..af4eaa9eb 100644 --- a/googlemock/test/gmock_output_test_.cc +++ b/googlemock/test/gmock_output_test_.cc @@ -33,7 +33,6 @@ #include #include -#include #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -255,16 +254,12 @@ TEST_F(GMockOutputTest, CatchesLeakedMocks) { } MATCHER_P2(IsPair, first, second, "") { - return Value(std::get<0>(arg), first) && Value(std::get<1>(arg), second); + return Value(arg.first, first) && Value(arg.second, second); } TEST_F(GMockOutputTest, PrintsMatcher) { const testing::Matcher m1 = Ge(48); - // Explicitly using std::tuple instead of std::pair due to differences between - // MSVC and other compilers. std::pair is printed as - // "struct std::pair" when using MSVC vs "std::pair" with - // other compilers. - EXPECT_THAT((std::tuple(42, true)), IsPair(m1, true)); + EXPECT_THAT((std::pair(42, true)), IsPair(m1, true)); } void TestCatchesLeakedMocksInAdHocTests() { diff --git a/googlemock/test/gmock_output_test_golden.txt b/googlemock/test/gmock_output_test_golden.txt index ac2a5e219..467fa20ef 100644 --- a/googlemock/test/gmock_output_test_golden.txt +++ b/googlemock/test/gmock_output_test_golden.txt @@ -290,9 +290,9 @@ Stack trace: [ OK ] GMockOutputTest.CatchesLeakedMocks [ RUN ] GMockOutputTest.PrintsMatcher FILE:#: Failure -Value of: (std::tuple(42, true)) +Value of: (std::pair(42, true)) Expected: is pair (first: is >= 48, second: true) - Actual: (42, true) + Actual: (42, true) (of type std::pair) [ FAILED ] GMockOutputTest.PrintsMatcher [ FAILED ] GMockOutputTest.UnexpectedCall [ FAILED ] GMockOutputTest.UnexpectedCallToVoidFunction From b80a07ffe627b20781516f51c548367d1e4d57dd Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Mon, 13 Feb 2023 13:45:19 -0800 Subject: [PATCH 111/336] Avoid reliance on header without RTTI on MSVC Fixes: #4144 PiperOrigin-RevId: 509322023 Change-Id: I52bdf6c25ff433327e174d3f9583b3d50b872d58 --- googletest/include/gtest/internal/gtest-port.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index b4fa3f07e..bedd67d33 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -2352,7 +2352,8 @@ using Any = ::absl::any; } // namespace testing #else #ifdef __has_include -#if __has_include() && __cplusplus >= 201703L +#if __has_include() && __cplusplus >= 201703L && \ + (!defined(_MSC_VER) || GTEST_HAS_RTTI) // Otherwise for C++17 and higher use std::any for UniversalPrinter<> // specializations. #define GTEST_INTERNAL_HAS_ANY 1 From 2057566e4e16c88f1fea4d6c96b2e2bfb87507a6 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Tue, 14 Feb 2023 08:32:59 -0800 Subject: [PATCH 112/336] Remove some filesystem APIs and tests under !GTEST_HAS_FILE_SYSTEM PiperOrigin-RevId: 509537606 Change-Id: I68f7054e34b1fe76c1fd85099fffa4ee3c2b00c0 --- googletest/src/gtest.cc | 7 ++++++- googletest/test/gtest_dirs_test.cc | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index f79f915f1..a60a042cc 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -2325,7 +2325,9 @@ static std::vector GetReservedAttributesForElement( return std::vector(); } +#if GTEST_HAS_FILE_SYSTEM // TODO(jdesprez): Merge the two getReserved attributes once skip is improved +// This function is only used when file systems are enabled. static std::vector GetReservedOutputAttributesForElement( const std::string& xml_element) { if (xml_element == "testsuites") { @@ -2340,6 +2342,7 @@ static std::vector GetReservedOutputAttributesForElement( // This code is unreachable but some compilers may not realizes that. return std::vector(); } +#endif static std::string FormatWordList(const std::vector& words) { Message word_list; @@ -6802,7 +6805,7 @@ std::string TempDir() { #endif } -#if !defined(GTEST_CUSTOM_SRCDIR_FUNCTION_) +#if GTEST_HAS_FILE_SYSTEM && !defined(GTEST_CUSTOM_SRCDIR_FUNCTION_) // Returns the directory path (including terminating separator) of the current // executable as derived from argv[0]. static std::string GetCurrentExecutableDirectory() { @@ -6811,6 +6814,7 @@ static std::string GetCurrentExecutableDirectory() { } #endif +#if GTEST_HAS_FILE_SYSTEM std::string SrcDir() { #if defined(GTEST_CUSTOM_SRCDIR_FUNCTION_) return GTEST_CUSTOM_SRCDIR_FUNCTION_(); @@ -6825,6 +6829,7 @@ std::string SrcDir() { '/'); #endif } +#endif // Class ScopedTrace diff --git a/googletest/test/gtest_dirs_test.cc b/googletest/test/gtest_dirs_test.cc index c0da9ac46..1a5b63d3c 100644 --- a/googletest/test/gtest_dirs_test.cc +++ b/googletest/test/gtest_dirs_test.cc @@ -7,6 +7,8 @@ #include "gtest/gtest.h" #include "gtest/internal/gtest-port.h" +#if GTEST_HAS_FILE_SYSTEM + namespace { class SetEnv { @@ -94,4 +96,6 @@ TEST(SrcDirTest, NotInEnvironment) { EXPECT_NE(testing::SrcDir(), ""); } +#endif // GTEST_HAS_FILE_SYSTEM + } // namespace From f063cd25c90cbd4089a0ff96f5991df4f2721338 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 15 Feb 2023 15:21:19 -0800 Subject: [PATCH 113/336] Remove strdup usage PiperOrigin-RevId: 509947007 Change-Id: I31e1274afa889776829c877c40c9af589298dcf2 --- .../include/gtest/internal/gtest-port.h | 17 +--- googletest/src/gtest-death-test.cc | 94 +++++-------------- googletest/src/gtest-port.cc | 42 ++++----- googletest/test/gtest_unittest.cc | 16 ++-- 4 files changed, 54 insertions(+), 115 deletions(-) diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index bedd67d33..ae7fb350c 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -923,7 +923,7 @@ class GTEST_API_ RE { ~RE(); // Returns the string representation of the regex. - const char* pattern() const { return pattern_; } + const char* pattern() const { return pattern_.c_str(); } // FullMatch(str, re) returns true if and only if regular expression re // matches the entire str. @@ -941,7 +941,7 @@ class GTEST_API_ RE { private: void Init(const char* regex); - const char* pattern_; + std::string pattern_; bool is_valid_; #if GTEST_USES_POSIX_RE @@ -951,7 +951,7 @@ class GTEST_API_ RE { #else // GTEST_USES_SIMPLE_RE - const char* full_pattern_; // For FullMatch(); + std::string full_pattern_; // For FullMatch(); #endif }; @@ -2032,7 +2032,6 @@ inline int DoIsATTY(int fd) { return isatty(fd); } inline int StrCaseCmp(const char* s1, const char* s2) { return stricmp(s1, s2); } -inline char* StrDup(const char* src) { return strdup(src); } #else // !__BORLANDC__ #if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_ZOS || GTEST_OS_IOS || \ GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT || defined(ESP_PLATFORM) @@ -2043,24 +2042,14 @@ inline int DoIsATTY(int fd) { return _isatty(fd); } inline int StrCaseCmp(const char* s1, const char* s2) { return _stricmp(s1, s2); } -inline char* StrDup(const char* src) { return _strdup(src); } #endif // __BORLANDC__ -#elif GTEST_OS_ESP8266 - -inline int DoIsATTY(int fd) { return isatty(fd); } -inline int StrCaseCmp(const char* s1, const char* s2) { - return strcasecmp(s1, s2); -} -inline char* StrDup(const char* src) { return strdup(src); } - #else inline int DoIsATTY(int fd) { return isatty(fd); } inline int StrCaseCmp(const char* s1, const char* s2) { return strcasecmp(s1, s2); } -inline char* StrDup(const char* src) { return strdup(src); } #endif // GTEST_OS_WINDOWS diff --git a/googletest/src/gtest-death-test.cc b/googletest/src/gtest-death-test.cc index b6968a9c9..7fcf9bf5b 100644 --- a/googletest/src/gtest-death-test.cc +++ b/googletest/src/gtest-death-test.cc @@ -33,7 +33,9 @@ #include "gtest/gtest-death-test.h" #include +#include #include +#include #include "gtest/internal/custom/gtest.h" #include "gtest/internal/gtest-port.h" @@ -621,6 +623,17 @@ bool DeathTestImpl::Passed(bool status_ok) { return success; } +// Note: The return value points into args, so the return value's lifetime is +// bound to that of args. +std::unique_ptr CreateArgvFromArgs(std::vector& args) { + auto result = std::make_unique(args.size() + 1); + for (size_t i = 0; i < args.size(); ++i) { + result[i] = &args[i][0]; + } + result[args.size()] = nullptr; // extra null terminator + return result; +} + #if GTEST_OS_WINDOWS // WindowsDeathTest implements death tests on Windows. Due to the // specifics of starting new processes on Windows, death tests there are @@ -836,36 +849,6 @@ class FuchsiaDeathTest : public DeathTestImpl { zx::socket stderr_socket_; }; -// Utility class for accumulating command-line arguments. -class Arguments { - public: - Arguments() { args_.push_back(nullptr); } - - ~Arguments() { - for (std::vector::iterator i = args_.begin(); i != args_.end(); - ++i) { - free(*i); - } - } - void AddArgument(const char* argument) { - args_.insert(args_.end() - 1, posix::StrDup(argument)); - } - - template - void AddArguments(const ::std::vector& arguments) { - for (typename ::std::vector::const_iterator i = arguments.begin(); - i != arguments.end(); ++i) { - args_.insert(args_.end() - 1, posix::StrDup(i->c_str())); - } - } - char* const* Argv() { return &args_[0]; } - - int size() { return static_cast(args_.size()) - 1; } - - private: - std::vector args_; -}; - // Waits for the child in a death test to exit, returning its exit // status, or 0 if no child process exists. As a side effect, sets the // outcome data member. @@ -986,10 +969,10 @@ DeathTest::TestRole FuchsiaDeathTest::AssumeRole() { kInternalRunDeathTestFlag + "=" + file_ + "|" + StreamableToString(line_) + "|" + StreamableToString(death_test_index); - Arguments args; - args.AddArguments(GetInjectableArgvs()); - args.AddArgument(filter_flag.c_str()); - args.AddArgument(internal_flag.c_str()); + + std::vector args = GetInjectableArgvs(); + args.push_back(filter_flag); + args.push_back(internal_flag); // Build the pipe for communication with the child. zx_status_t status; @@ -1041,8 +1024,9 @@ DeathTest::TestRole FuchsiaDeathTest::AssumeRole() { GTEST_DEATH_TEST_CHECK_(status == ZX_OK); // Spawn the child process. - status = fdio_spawn_etc(child_job, FDIO_SPAWN_CLONE_ALL, args.Argv()[0], - args.Argv(), nullptr, 2, spawn_actions, + std::unique_ptr argv = CreateArgvFromArgs(args); + status = fdio_spawn_etc(child_job, FDIO_SPAWN_CLONE_ALL, argv[0], argv.get(), + nullptr, 2, spawn_actions, child_process_.reset_and_get_address(), nullptr); GTEST_DEATH_TEST_CHECK_(status == ZX_OK); @@ -1173,34 +1157,6 @@ class ExecDeathTest : public ForkingDeathTest { const int line_; }; -// Utility class for accumulating command-line arguments. -class Arguments { - public: - Arguments() { args_.push_back(nullptr); } - - ~Arguments() { - for (std::vector::iterator i = args_.begin(); i != args_.end(); - ++i) { - free(*i); - } - } - void AddArgument(const char* argument) { - args_.insert(args_.end() - 1, posix::StrDup(argument)); - } - - template - void AddArguments(const ::std::vector& arguments) { - for (typename ::std::vector::const_iterator i = arguments.begin(); - i != arguments.end(); ++i) { - args_.insert(args_.end() - 1, posix::StrDup(i->c_str())); - } - } - char* const* Argv() { return &args_[0]; } - - private: - std::vector args_; -}; - // A struct that encompasses the arguments to the child process of a // threadsafe-style death test process. struct ExecDeathTestArgs { @@ -1410,10 +1366,9 @@ DeathTest::TestRole ExecDeathTest::AssumeRole() { StreamableToString(line_) + "|" + StreamableToString(death_test_index) + "|" + StreamableToString(pipe_fd[1]); - Arguments args; - args.AddArguments(GetArgvsForDeathTestChildProcess()); - args.AddArgument(filter_flag.c_str()); - args.AddArgument(internal_flag.c_str()); + std::vector args = GetArgvsForDeathTestChildProcess(); + args.push_back(filter_flag); + args.push_back(internal_flag); DeathTest::set_last_death_test_message(""); @@ -1422,7 +1377,8 @@ DeathTest::TestRole ExecDeathTest::AssumeRole() { // is necessary. FlushInfoLog(); - const pid_t child_pid = ExecDeathTestSpawnChild(args.Argv(), pipe_fd[0]); + std::unique_ptr argv = CreateArgvFromArgs(args); + const pid_t child_pid = ExecDeathTestSpawnChild(argv.get(), pipe_fd[0]); GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1])); set_child_pid(child_pid); set_read_fd(pipe_fd[0]); diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc index d797fe4d5..105a3ec8c 100644 --- a/googletest/src/gtest-port.cc +++ b/googletest/src/gtest-port.cc @@ -668,7 +668,6 @@ RE::~RE() { regfree(&partial_regex_); regfree(&full_regex_); } - free(const_cast(pattern_)); } // Returns true if and only if regular expression re matches the entire str. @@ -690,7 +689,7 @@ bool RE::PartialMatch(const char* str, const RE& re) { // Initializes an RE from its string representation. void RE::Init(const char* regex) { - pattern_ = posix::StrDup(regex); + pattern_ = regex; // Reserves enough bytes to hold the regular expression used for a // full match. @@ -920,27 +919,26 @@ bool MatchRegexAnywhere(const char* regex, const char* str) { // Implements the RE class. -RE::~RE() { - free(const_cast(pattern_)); - free(const_cast(full_pattern_)); -} +RE::~RE() = default; // Returns true if and only if regular expression re matches the entire str. bool RE::FullMatch(const char* str, const RE& re) { - return re.is_valid_ && MatchRegexAnywhere(re.full_pattern_, str); + return re.is_valid_ && MatchRegexAnywhere(re.full_pattern_.c_str(), str); } // Returns true if and only if regular expression re matches a substring of // str (including str itself). bool RE::PartialMatch(const char* str, const RE& re) { - return re.is_valid_ && MatchRegexAnywhere(re.pattern_, str); + return re.is_valid_ && MatchRegexAnywhere(re.pattern_.c_str(), str); } // Initializes an RE from its string representation. void RE::Init(const char* regex) { - pattern_ = full_pattern_ = nullptr; + full_pattern_.clear(); + pattern_.clear(); + if (regex != nullptr) { - pattern_ = posix::StrDup(regex); + pattern_ = regex; } is_valid_ = ValidateRegex(regex); @@ -949,25 +947,19 @@ void RE::Init(const char* regex) { return; } - const size_t len = strlen(regex); // Reserves enough bytes to hold the regular expression used for a - // full match: we need space to prepend a '^', append a '$', and - // terminate the string with '\0'. - char* buffer = static_cast(malloc(len + 3)); - full_pattern_ = buffer; + // full match: we need space to prepend a '^' and append a '$'. + full_pattern_.reserve(pattern_.size() + 2); - if (*regex != '^') - *buffer++ = '^'; // Makes sure full_pattern_ starts with '^'. + if (pattern_.empty() || pattern_.front() != '^') { + full_pattern_.push_back('^'); // Makes sure full_pattern_ starts with '^'. + } - // We don't use snprintf or strncpy, as they trigger a warning when - // compiled with VC++ 8.0. - memcpy(buffer, regex, len); - buffer += len; + full_pattern_.append(pattern_); - if (len == 0 || regex[len - 1] != '$') - *buffer++ = '$'; // Makes sure full_pattern_ ends with '$'. - - *buffer = '\0'; + if (pattern_.empty() || pattern_.back() != '$') { + full_pattern_.push_back('$'); // Makes sure full_pattern_ ends with '$'. + } } #endif // GTEST_USES_POSIX_RE diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index ecffa3765..580ce8379 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -60,6 +60,7 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) { #include #include +#include #include #include #include @@ -424,10 +425,12 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test { private: void SetUp() override { - saved_tz_ = nullptr; + saved_tz_.reset(); - GTEST_DISABLE_MSC_DEPRECATED_PUSH_(/* getenv, strdup: deprecated */) - if (getenv("TZ")) saved_tz_ = strdup(getenv("TZ")); + GTEST_DISABLE_MSC_DEPRECATED_PUSH_(/* getenv: deprecated */) + if (const char* tz = getenv("TZ")) { + saved_tz_ = std::make_unique(tz); + } GTEST_DISABLE_MSC_DEPRECATED_POP_() // Set up the time zone for FormatEpochTimeInMillisAsIso8601 to use. We @@ -437,9 +440,8 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test { } void TearDown() override { - SetTimeZone(saved_tz_); - free(const_cast(saved_tz_)); - saved_tz_ = nullptr; + SetTimeZone(saved_tz_ != nullptr ? saved_tz_->c_str() : nullptr); + saved_tz_.reset(); } static void SetTimeZone(const char* time_zone) { @@ -471,7 +473,7 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test { #endif } - const char* saved_tz_; + std::unique_ptr saved_tz_; // Empty and null are different here }; const TimeInMillis FormatEpochTimeInMillisAsIso8601Test::kMillisPerSec; From 7a7231c442484be389fdf01594310349ca0e42a8 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Thu, 16 Feb 2023 07:33:08 -0800 Subject: [PATCH 114/336] Fix link in ReportUninterestingCall message This CL changes the link in the ReportUninterestingCall message from .../gmock_cook_book.md#knowing-when-to-expect to .../gmock_cook_book.md#knowing-when-to-expect-useoncall. This is necessary following https://github.com/google/googletest/commit/31ff597. PiperOrigin-RevId: 510138974 Change-Id: Ic98c84b07751d27dfc95eddbe7874f76d68b456f --- googlemock/src/gmock-spec-builders.cc | 2 +- googlemock/test/gmock-spec-builders_test.cc | 2 +- googlemock/test/gmock_output_test_golden.txt | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index 7d7c55ad8..afd802c32 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -297,7 +297,7 @@ void ReportUninterestingCall(CallReaction reaction, const std::string& msg) { "See " "https://github.com/google/googletest/blob/main/docs/" "gmock_cook_book.md#" - "knowing-when-to-expect for details.\n", + "knowing-when-to-expect-useoncall for details.\n", stack_frames_to_skip); break; default: // FAIL diff --git a/googlemock/test/gmock-spec-builders_test.cc b/googlemock/test/gmock-spec-builders_test.cc index 487b6c3fa..ad56ead07 100644 --- a/googlemock/test/gmock-spec-builders_test.cc +++ b/googlemock/test/gmock-spec-builders_test.cc @@ -2050,7 +2050,7 @@ class GMockVerboseFlagTest : public VerboseFlagPreservingFixture { "See " "https://github.com/google/googletest/blob/main/docs/" "gmock_cook_book.md#" - "knowing-when-to-expect for details."; + "knowing-when-to-expect-useoncall for details."; // A void-returning function. CaptureStdout(); diff --git a/googlemock/test/gmock_output_test_golden.txt b/googlemock/test/gmock_output_test_golden.txt index ac2a5e219..d6c03338f 100644 --- a/googlemock/test/gmock_output_test_golden.txt +++ b/googlemock/test/gmock_output_test_golden.txt @@ -75,14 +75,14 @@ GMOCK WARNING: Uninteresting mock function call - returning default value. Function call: Bar2(0, 1) Returns: false -NOTE: You can safely ignore the above warning unless this call should not happen. Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call. See https://github.com/google/googletest/blob/main/docs/gmock_cook_book.md#knowing-when-to-expect for details. +NOTE: You can safely ignore the above warning unless this call should not happen. Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call. See https://github.com/google/googletest/blob/main/docs/gmock_cook_book.md#knowing-when-to-expect-useoncall for details. [ OK ] GMockOutputTest.UninterestingCall [ RUN ] GMockOutputTest.UninterestingCallToVoidFunction GMOCK WARNING: Uninteresting mock function call - returning directly. Function call: Bar3(0, 1) -NOTE: You can safely ignore the above warning unless this call should not happen. Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call. See https://github.com/google/googletest/blob/main/docs/gmock_cook_book.md#knowing-when-to-expect for details. +NOTE: You can safely ignore the above warning unless this call should not happen. Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call. See https://github.com/google/googletest/blob/main/docs/gmock_cook_book.md#knowing-when-to-expect-useoncall for details. [ OK ] GMockOutputTest.UninterestingCallToVoidFunction [ RUN ] GMockOutputTest.RetiredExpectation unknown file: Failure @@ -266,14 +266,14 @@ Uninteresting mock function call - taking default action specified at: FILE:#: Function call: Bar2(2, 2) Returns: true -NOTE: You can safely ignore the above warning unless this call should not happen. Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call. See https://github.com/google/googletest/blob/main/docs/gmock_cook_book.md#knowing-when-to-expect for details. +NOTE: You can safely ignore the above warning unless this call should not happen. Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call. See https://github.com/google/googletest/blob/main/docs/gmock_cook_book.md#knowing-when-to-expect-useoncall for details. GMOCK WARNING: Uninteresting mock function call - taking default action specified at: FILE:#: Function call: Bar2(1, 1) Returns: false -NOTE: You can safely ignore the above warning unless this call should not happen. Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call. See https://github.com/google/googletest/blob/main/docs/gmock_cook_book.md#knowing-when-to-expect for details. +NOTE: You can safely ignore the above warning unless this call should not happen. Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call. See https://github.com/google/googletest/blob/main/docs/gmock_cook_book.md#knowing-when-to-expect-useoncall for details. [ OK ] GMockOutputTest.UninterestingCallWithDefaultAction [ RUN ] GMockOutputTest.ExplicitActionsRunOutWithDefaultAction From fe5b7ef71e60072283d57e0417776d05eb4b3e7f Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Fri, 17 Feb 2023 23:22:27 -0800 Subject: [PATCH 115/336] Set CMP0069 policy to avoid warnings When googletest and googlemock are included as a git submodule and referenced as part of an existing CMake project, multiple warnings are printed out due to not setting a value for the CMP0069 policy. --- googletest/cmake/internal_utils.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index 0438bef83..7b9f0b7fc 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -16,6 +16,10 @@ if (POLICY CMP0054) cmake_policy(SET CMP0054 NEW) endif (POLICY CMP0054) +if (POLICY CMP0069) + cmake_policy(SET CMP0069 NEW) +endif (POLICY CMP0069) + # Tweaks CMake's default compiler/linker settings to suit Google Test's needs. # # This must be a macro(), as inside a function string() can only From 810fb81153d916e728853bd88b11fef365a95e62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C5=A9=20Ph=E1=BA=A1m?= <39726720+VuPhamVan@users.noreply.github.com> Date: Sun, 19 Feb 2023 21:59:23 +0700 Subject: [PATCH 116/336] Fix typo --- docs/reference/assertions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/assertions.md b/docs/reference/assertions.md index 7bf03a3dd..1cdff266e 100644 --- a/docs/reference/assertions.md +++ b/docs/reference/assertions.md @@ -515,7 +515,7 @@ Verifies that *`expression`* is a success `HRESULT`. ### EXPECT_HRESULT_FAILED {#EXPECT_HRESULT_FAILED} `EXPECT_HRESULT_FAILED(`*`expression`*`)` \ -`EXPECT_HRESULT_FAILED(`*`expression`*`)` +`ASSERT_HRESULT_FAILED(`*`expression`*`)` Verifies that *`expression`* is a failure `HRESULT`. From 750d67d809700ae8fca6d610f7b41b71aa161808 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 21 Feb 2023 10:24:42 -0800 Subject: [PATCH 117/336] Remove int64_t cast in RecordProperty Historically, calls to RecordProperty with values that are convertible to int64_t have been casted to int64_t. The result was that types like float or double would be truncated when printed (e.g., 4.75 -> 4). This change removes the cast so that the types are printed in a more appropriate manner. PiperOrigin-RevId: 511238685 Change-Id: I80de5db14462da2a3e1f476086025ae514383a17 --- googletest/include/gtest/gtest.h | 2 +- googletest/test/googletest-json-outfiles-test.py | 10 +++++----- googletest/test/gtest_xml_outfile2_test_.cc | 4 +--- googletest/test/gtest_xml_outfiles_test.py | 10 +++++----- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index 35c080263..6fdf55243 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -302,7 +302,7 @@ class GTEST_API_ Test { template ::value, bool> = true> static void RecordProperty(const std::string& key, const T& value) { - RecordProperty(key, (Message() << static_cast(value)).GetString()); + RecordProperty(key, (Message() << value).GetString()); } protected: diff --git a/googletest/test/googletest-json-outfiles-test.py b/googletest/test/googletest-json-outfiles-test.py index 83a56de1e..ff1572234 100644 --- a/googletest/test/googletest-json-outfiles-test.py +++ b/googletest/test/googletest-json-outfiles-test.py @@ -88,7 +88,7 @@ EXPECTED_2 = { 'time': '*', 'timestamp': '*', 'testsuite': [{ - 'name': 'TestInt64Properties', + 'name': 'TestInt64ConvertibleProperties', 'file': 'gtest_xml_outfile2_test_.cc', 'line': 41, 'status': 'RUN', @@ -97,11 +97,11 @@ EXPECTED_2 = { 'time': '*', 'classname': 'PropertyTwo', 'SetUpProp': '2', - 'TestFloatProperty': '3', - 'TestDoubleProperty': '4', + 'TestFloatProperty': '3.25', + 'TestDoubleProperty': '4.75', 'TestSizetProperty': '5', - 'TestBoolProperty': '1', - 'TestCharProperty': '65', + 'TestBoolProperty': 'true', + 'TestCharProperty': 'A', 'TestInt16Property': '6', 'TestInt32Property': '7', 'TestInt64Property': '8', diff --git a/googletest/test/gtest_xml_outfile2_test_.cc b/googletest/test/gtest_xml_outfile2_test_.cc index 5ee216dff..ed58dc8df 100644 --- a/googletest/test/gtest_xml_outfile2_test_.cc +++ b/googletest/test/gtest_xml_outfile2_test_.cc @@ -38,9 +38,7 @@ class PropertyTwo : public testing::Test { void TearDown() override { RecordProperty("TearDownProp", 2); } }; -TEST_F(PropertyTwo, TestInt64Properties) { - // Floats and doubles are written as int64_t, so we test that the values - // written are truncated to int64_t. +TEST_F(PropertyTwo, TestInt64ConvertibleProperties) { float float_prop = 3.25; RecordProperty("TestFloatProperty", float_prop); diff --git a/googletest/test/gtest_xml_outfiles_test.py b/googletest/test/gtest_xml_outfiles_test.py index 7ee0f3c85..50291b0a8 100755 --- a/googletest/test/gtest_xml_outfiles_test.py +++ b/googletest/test/gtest_xml_outfiles_test.py @@ -57,14 +57,14 @@ EXPECTED_XML_1 = """ EXPECTED_XML_2 = """ - + - - + + - - + + From 10493e3854db0c4709f9ddd1ac10b974d30219f5 Mon Sep 17 00:00:00 2001 From: Sergey Date: Tue, 21 Feb 2023 13:29:20 -0700 Subject: [PATCH 118/336] Fix error in_death_test_child_process: undeclared identifier The error occurs if !GTEST_HAS_DEATH_TEST on Windows. --- googletest/src/gtest.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index a60a042cc..dd7752cf1 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -5416,6 +5416,9 @@ int UnitTest::Run() { impl()->set_catch_exceptions(GTEST_FLAG_GET(catch_exceptions)); #if GTEST_OS_WINDOWS +#if !GTEST_HAS_DEATH_TEST + const bool in_death_test_child_process = false; +#endif // Either the user wants Google Test to catch exceptions thrown by the // tests or this is executing in the context of death test child // process. In either case the user does not want to see pop-up dialogs From d9a4bbcaf22d7cb37e42af3103019060d11bce3d Mon Sep 17 00:00:00 2001 From: Dino Radakovic Date: Wed, 22 Feb 2023 08:18:00 -0800 Subject: [PATCH 119/336] Update googletest's test docker containers PiperOrigin-RevId: 511500508 Change-Id: Ib686f93d317b95ac9b9bcb0a5566500316ba1929 --- ci/linux-presubmit.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/linux-presubmit.sh b/ci/linux-presubmit.sh index 9e15d9a4f..626989d2f 100644 --- a/ci/linux-presubmit.sh +++ b/ci/linux-presubmit.sh @@ -31,8 +31,8 @@ set -euox pipefail -readonly LINUX_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20220217" -readonly LINUX_GCC_FLOOR_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-floor:20220621" +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" if [[ -z ${GTEST_ROOT:-} ]]; then GTEST_ROOT="$(realpath $(dirname ${0})/..)" From 39a26e12d67ed6c21feeb606372bfee39a8e6d53 Mon Sep 17 00:00:00 2001 From: Dino Radakovic Date: Wed, 22 Feb 2023 09:02:08 -0800 Subject: [PATCH 120/336] Avoid redundant declaration of static constexpr members in c++17 Keep declarations in c++ < 17 using new macro, GTEST_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL. Fixes #4148. PiperOrigin-RevId: 511510401 Change-Id: I76c3f2fccf07a0978adcbe5f8f0203b9d0c33872 --- googletest/include/gtest/internal/gtest-internal.h | 2 ++ googletest/include/gtest/internal/gtest-port.h | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h index e1eb2b510..733950484 100644 --- a/googletest/include/gtest/internal/gtest-internal.h +++ b/googletest/include/gtest/internal/gtest-internal.h @@ -900,8 +900,10 @@ class HasDebugStringAndShortDebugString { HasDebugStringType::value && HasShortDebugStringType::value; }; +#ifdef GTEST_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL template constexpr bool HasDebugStringAndShortDebugString::value; +#endif // When the compiler sees expression IsContainerTest(0), if C is an // STL-style container class, the first overload of IsContainerTest diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index ae7fb350c..5cea3e02b 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -2447,4 +2447,9 @@ using Variant = ::std::variant; #endif // __has_include #endif // GTEST_HAS_ABSL +#if defined(GTEST_INTERNAL_CPLUSPLUS_LANG) && \ + GTEST_INTERNAL_CPLUSPLUS_LANG < 201703L +#define GTEST_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL 1 +#endif + #endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_ From d0ba3ccc7659a7af2ee5d2039f8e6978f35b67ce Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Thu, 23 Feb 2023 12:39:43 -0800 Subject: [PATCH 121/336] Added a missing semicolon for GTEST_FLAG_SET code snippet. PiperOrigin-RevId: 511858980 Change-Id: I0f9e6ffdeb8ae809d662eb3ff46eab5a109a8d93 --- docs/advanced.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/advanced.md b/docs/advanced.md index 7d15dfdd7..6b4c3f0b5 100644 --- a/docs/advanced.md +++ b/docs/advanced.md @@ -562,7 +562,7 @@ The automated testing framework does not set the style flag. You can choose a particular style of death tests by setting the flag programmatically: ```c++ -GTEST_FLAG_SET(death_test_style, "threadsafe") +GTEST_FLAG_SET(death_test_style, "threadsafe"); ``` You can do this in `main()` to set the style for all death tests in the binary, From 3d787f5a0d58cfc37a0563bb15647a0d8aa2c1bf Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Fri, 24 Feb 2023 09:49:45 -0800 Subject: [PATCH 122/336] Add `const` qualifier to `gtest_sentinel` which doesn't change. PiperOrigin-RevId: 512094429 Change-Id: I29b116da65bc7471c43021d1650d90f7b2a685c2 --- googletest/include/gtest/internal/gtest-death-test-internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/include/gtest/internal/gtest-death-test-internal.h b/googletest/include/gtest/internal/gtest-death-test-internal.h index 4687dae2b..21f3d29f1 100644 --- a/googletest/include/gtest/internal/gtest-death-test-internal.h +++ b/googletest/include/gtest/internal/gtest-death-test-internal.h @@ -238,7 +238,7 @@ inline Matcher MakeDeathTestMatcher( } \ break; \ case ::testing::internal::DeathTest::EXECUTE_TEST: { \ - ::testing::internal::DeathTest::ReturnSentinel gtest_sentinel( \ + const ::testing::internal::DeathTest::ReturnSentinel gtest_sentinel( \ gtest_dt); \ GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, gtest_dt); \ gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); \ From 95d8c7ac4389b38b197bc7521dffb62508653eb5 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Mon, 27 Feb 2023 11:21:04 -0800 Subject: [PATCH 123/336] Reformat to current g3doc style guide. No content changes. PiperOrigin-RevId: 512681427 Change-Id: I88b22d82430ed145b8342747adf300f3e734d43b --- docs/primer.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/primer.md b/docs/primer.md index 2ffbf53bc..80c2d0a69 100644 --- a/docs/primer.md +++ b/docs/primer.md @@ -45,23 +45,23 @@ minutes to learn the basics and get started. So let's go! ## Beware of the nomenclature {: .callout .note} -_Note:_ There might be some confusion arising from different definitions of the -terms _Test_, _Test Case_ and _Test Suite_, so beware of misunderstanding these. +*Note:* There might be some confusion arising from different definitions of the +terms *Test*, *Test Case* and *Test Suite*, so beware of misunderstanding these. -Historically, googletest started to use the term _Test Case_ for grouping +Historically, googletest started to use the term *Test Case* for grouping related tests, whereas current publications, including International Software Testing Qualifications Board ([ISTQB](http://www.istqb.org/)) materials and various textbooks on software quality, use the term -_[Test Suite][istqb test suite]_ for this. +*[Test Suite][istqb test suite]* for this. -The related term _Test_, as it is used in googletest, corresponds to the term -_[Test Case][istqb test case]_ of ISTQB and others. +The related term *Test*, as it is used in googletest, corresponds to the term +*[Test Case][istqb test case]* of ISTQB and others. -The term _Test_ is commonly of broad enough sense, including ISTQB's definition -of _Test Case_, so it's not much of a problem here. But the term _Test Case_ as +The term *Test* is commonly of broad enough sense, including ISTQB's definition +of *Test Case*, so it's not much of a problem here. But the term *Test Case* as was used in Google Test is of contradictory sense and thus confusing. -googletest recently started replacing the term _Test Case_ with _Test Suite_. +googletest recently started replacing the term *Test Case* with *Test Suite*. The preferred API is *TestSuite*. The older TestCase API is being slowly deprecated and refactored away. @@ -381,7 +381,7 @@ If a fatal failure happens the subsequent steps will be skipped. ## Writing the main() Function -Most users should _not_ need to write their own `main` function and instead link +Most users should *not* need to write their own `main` function and instead link with `gtest_main` (as opposed to with `gtest`), which defines a suitable entry point. See the end of this section for details. The remainder of this section should only apply when you need to do something custom before the tests run that @@ -476,7 +476,7 @@ NOTE: `ParseGUnitFlags()` is deprecated in favor of `InitGoogleTest()`. * Google Test is designed to be thread-safe. The implementation is thread-safe on systems where the `pthreads` library is available. It is currently - _unsafe_ to use Google Test assertions from two threads concurrently on + *unsafe* to use Google Test assertions from two threads concurrently on other systems (e.g. Windows). In most tests this is not an issue as usually the assertions are done in the main thread. If you want to help, you can volunteer to implement the necessary synchronization primitives in From 6882aa0987c6d3266a05bbec609587a6f80510b9 Mon Sep 17 00:00:00 2001 From: Phoebe Liang Date: Mon, 27 Feb 2023 13:02:26 -0800 Subject: [PATCH 124/336] Reorder printers list. PiperOrigin-RevId: 512708763 Change-Id: I1f24f2e1d17359aee5aa4cdf614c9357872ca03b --- googletest/include/gtest/gtest-printers.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h index 7d7e77c19..739d54526 100644 --- a/googletest/include/gtest/gtest-printers.h +++ b/googletest/include/gtest/gtest-printers.h @@ -306,9 +306,10 @@ template void PrintWithFallback(const T& value, ::std::ostream* os) { using Printer = typename FindFirstPrinter< T, void, ContainerPrinter, FunctionPointerPrinter, PointerPrinter, + ProtobufPrinter, internal_stream_operator_without_lexical_name_lookup::StreamPrinter, - ProtobufPrinter, ConvertibleToIntegerPrinter, - ConvertibleToStringViewPrinter, RawBytesPrinter, FallbackPrinter>::type; + ConvertibleToIntegerPrinter, ConvertibleToStringViewPrinter, + RawBytesPrinter, FallbackPrinter>::type; Printer::PrintValue(value, os); } From 8aa75fa7712d04185c974d535cd6e678a253e9fa Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Mon, 27 Feb 2023 18:46:37 -0800 Subject: [PATCH 125/336] Eliminate argv list action parameter. PiperOrigin-RevId: 512791992 Change-Id: Ie7fc37ea06ea7d9f595268c9ec84a0e144c297bb --- WORKSPACE | 8 ++++---- googletest/src/gtest.cc | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 0f10a6a9a..cb5f83faf 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -3,10 +3,10 @@ workspace(name = "com_google_googletest") 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 = "com_google_absl", # 2023-02-27T15:50:25Z + sha256 = "baf8e734ac3ce213a889ce7c248b981ee1730e2093e32808e0f0a910dc985f76", + strip_prefix = "abseil-cpp-0c1114c4fb83c844c7fd74708338cca1d3d9b0dc", + urls = ["https://github.com/abseil/abseil-cpp/archive/0c1114c4fb83c844c7fd74708338cca1d3d9b0dc.zip"], ) # Note this must use a commit from the `abseil` branch of the RE2 project. diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 8195e5f18..fb578d586 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -6667,8 +6667,7 @@ void ParseGoogleTestFlagsOnly(int* argc, char** argv) { if (*argc > 0) { // absl::ParseCommandLine() requires *argc > 0. auto positional_args = absl::flags_internal::ParseCommandLineImpl( - *argc, argv, absl::flags_internal::ArgvListAction::kRemoveParsedArgs, - absl::flags_internal::UsageFlagsAction::kHandleUsage, + *argc, argv, absl::flags_internal::UsageFlagsAction::kHandleUsage, absl::flags_internal::OnUndefinedFlag::kReportUndefined); // Any command-line positional arguments not part of any command-line flag // (or arguments to a flag) are copied back out to argv, with the program From 6f1c4b3d7b139c7217698bf4115be9f40785f661 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Thu, 24 Nov 2022 23:54:19 +0800 Subject: [PATCH 126/336] Fixes the test gmock_output_test.py with MSVC For MSVC, gmock_output_test.py output struct std::pair, for GCC, it's output std::pair, it's not the same, my intention is getting these to be same by removing struct for MSVC's outptu, and strip redundant space for GCC. As a by-product, ``` #ifdef _MSC_VER #define ERROR_DESC "class std::runtime_error" #else #define ERROR_DESC "std::runtime_error" #endif ``` can be simplified to ``` #define ERROR_DESC "std::runtime_error" ``` Signed-off-by: Yonggang Luo --- googlemock/test/gmock_output_test_golden.txt | 2 +- .../include/gtest/internal/gtest-type-util.h | 30 +++++++++++++++++++ googletest/test/gtest_unittest.cc | 4 --- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/googlemock/test/gmock_output_test_golden.txt b/googlemock/test/gmock_output_test_golden.txt index 467fa20ef..9a7adf6af 100644 --- a/googlemock/test/gmock_output_test_golden.txt +++ b/googlemock/test/gmock_output_test_golden.txt @@ -292,7 +292,7 @@ Stack trace: FILE:#: Failure Value of: (std::pair(42, true)) Expected: is pair (first: is >= 48, second: true) - Actual: (42, true) (of type std::pair) + Actual: (42, true) (of type std::pair) [ FAILED ] GMockOutputTest.PrintsMatcher [ FAILED ] GMockOutputTest.UnexpectedCall [ FAILED ] GMockOutputTest.UnexpectedCallToVoidFunction diff --git a/googletest/include/gtest/internal/gtest-type-util.h b/googletest/include/gtest/internal/gtest-type-util.h index 17a470b62..b23ad559f 100644 --- a/googletest/include/gtest/internal/gtest-type-util.h +++ b/googletest/include/gtest/internal/gtest-type-util.h @@ -67,6 +67,22 @@ inline std::string CanonicalizeForStdLibVersioning(std::string s) { s.erase(strlen("std"), end - strlen("std")); } } + + /* Strip redundant spaces in typename to match MSVC */ + /* For example, std::pair -> std::pair */ + static const char to_search[] = ", "; + static const char replace_str[] = ","; + size_t pos = 0; + while (true) { + // Get the next occurrence from the current position + pos = s.find(to_search, pos); + if (pos == std::string::npos) { + break; + } + // Replace this occurrence of substring + s.replace(pos, strlen(to_search), replace_str); + pos += strlen(replace_str); + } return s; } @@ -85,6 +101,20 @@ inline std::string GetTypeName(const std::type_info& type) { const std::string name_str(status == 0 ? readable_name : name); free(readable_name); return CanonicalizeForStdLibVersioning(name_str); +#elif defined(_MSC_VER) + // Strip struct and class due to differences between + // MSVC and other compilers. std::pair is printed as + // "struct std::pair" when using MSVC vs "std::pair" with + // other compilers. + std::string s = name; + // Only strip the leading "struct " and "class ", so uses rfind == 0 to + // ensure that + if (s.rfind("struct ", 0) == 0) { + s = s.substr(strlen("struct ")); + } else if (s.rfind("class ", 0) == 0) { + s = s.substr(strlen("class ")); + } + return s; #else return name; #endif // GTEST_HAS_CXXABI_H_ || __HP_aCC diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index ecffa3765..180c3abe6 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -3314,11 +3314,7 @@ TEST_F(SingleEvaluationTest, OtherCases) { #if GTEST_HAS_RTTI -#ifdef _MSC_VER -#define ERROR_DESC "class std::runtime_error" -#else #define ERROR_DESC "std::runtime_error" -#endif #else // GTEST_HAS_RTTI From 555486f408ab4906118eddf11c856da7f8690f14 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Tue, 28 Feb 2023 08:16:34 -0800 Subject: [PATCH 127/336] Rephrase the description of TEST_F() arguments for clarity. PiperOrigin-RevId: 512937964 Change-Id: Ifa6369a80dc7d8efe60511417496d58317cfc28d --- docs/primer.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/primer.md b/docs/primer.md index 80c2d0a69..d559fe84f 100644 --- a/docs/primer.md +++ b/docs/primer.md @@ -227,14 +227,14 @@ When using a fixture, use `TEST_F()` instead of `TEST()` as it allows you to access objects and subroutines in the test fixture: ```c++ -TEST_F(TestFixtureName, TestName) { +TEST_F(TestFixtureClassName, TestName) { ... test body ... } ``` -Like `TEST()`, the first argument is the test suite name, but for `TEST_F()` -this must be the name of the test fixture class. You've probably guessed: `_F` -is for fixture. +Unlike `TEST()`, in `TEST_F()` the first argument must be the name of the test +fixture class. (`_F` stands for "Fixture"). No test suite name is specified for +this macro. Unfortunately, the C++ macro system does not allow us to create a single macro that can handle both types of tests. Using the wrong macro causes a compiler From cead3d57c93ff8c4e5c1bbae57a5c0b0b0f6e168 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Fri, 3 Mar 2023 02:24:39 -0800 Subject: [PATCH 128/336] Internal Code Change PiperOrigin-RevId: 513770561 Change-Id: I82fbed177c6ba4e2e5b776ae3e0255c868e32e25 --- googlemock/src/gmock-internal-utils.cc | 2 +- googlemock/src/gmock-matchers.cc | 2 +- googlemock/src/gmock-spec-builders.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/googlemock/src/gmock-internal-utils.cc b/googlemock/src/gmock-internal-utils.cc index 31d556506..774cce334 100644 --- a/googlemock/src/gmock-internal-utils.cc +++ b/googlemock/src/gmock-internal-utils.cc @@ -87,7 +87,7 @@ GTEST_API_ std::string ConvertIdentifierNameToWords(const char* id_name) { (!IsDigit(prev_char) && IsDigit(*p)); if (IsAlNum(*p)) { - if (starts_new_word && result != "") result += ' '; + if (starts_new_word && !result.empty()) result += ' '; result += ToLower(*p); } } diff --git a/googlemock/src/gmock-matchers.cc b/googlemock/src/gmock-matchers.cc index 5810b6aa3..07bba4f01 100644 --- a/googlemock/src/gmock-matchers.cc +++ b/googlemock/src/gmock-matchers.cc @@ -53,7 +53,7 @@ GTEST_API_ std::string FormatMatcherDescription( bool negation, const char* matcher_name, const std::vector& param_names, const Strings& param_values) { std::string result = ConvertIdentifierNameToWords(matcher_name); - if (param_values.size() >= 1) { + if (!param_values.empty()) { result += " " + JoinAsKeyValueTuple(param_names, param_values); } return negation ? "not (" + result + ")" : result; diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index afd802c32..a7fe91175 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -503,7 +503,7 @@ class MockObjectRegistry { std::cout << internal::FormatFileLocation(state.first_used_file, state.first_used_line); std::cout << " ERROR: this mock object"; - if (state.first_used_test != "") { + if (!state.first_used_test.empty()) { std::cout << " (used in test " << state.first_used_test_suite << "." << state.first_used_test << ")"; } From 23142843f7c875907a6ed7985174a6e346e82c3d Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 3 Mar 2023 15:54:32 -0800 Subject: [PATCH 129/336] Use "#ifdef GTEST_OS_..." instead of "#if GTEST_OS_..." This is compatible with compiling with "-Wundef" (#3267). PiperOrigin-RevId: 513943378 Change-Id: I47cf5fabbb77be061c4483a0adc54511af6b191c --- googlemock/include/gmock/gmock-actions.h | 4 +- googlemock/include/gmock/gmock-nice-strict.h | 2 +- googlemock/src/gmock-spec-builders.cc | 6 +- googlemock/src/gmock_main.cc | 8 +- googlemock/test/gmock-actions_test.cc | 2 +- googlemock/test/gmock-function-mocker_test.cc | 12 +- googlemock/test/gmock-internal-utils_test.cc | 4 +- googlemock/test/gmock_link_test.h | 6 +- googletest/include/gtest/gtest-death-test.h | 2 +- googletest/include/gtest/gtest.h | 2 +- .../include/gtest/internal/gtest-internal.h | 4 +- .../include/gtest/internal/gtest-port.h | 157 +++++++++++------- .../include/gtest/internal/gtest-string.h | 2 +- googletest/src/gtest-death-test.cc | 46 ++--- googletest/src/gtest-filepath.cc | 38 +++-- googletest/src/gtest-internal-inl.h | 4 +- googletest/src/gtest-port.cc | 54 +++--- googletest/src/gtest.cc | 67 ++++---- googletest/src/gtest_main.cc | 8 +- .../googletest-break-on-failure-unittest_.cc | 8 +- googletest/test/googletest-death-test-test.cc | 24 +-- googletest/test/googletest-filepath-test.cc | 24 +-- googletest/test/googletest-options-test.cc | 24 +-- googletest/test/googletest-output-test_.cc | 2 +- googletest/test/googletest-port-test.cc | 26 +-- googletest/test/googletest-printers-test.cc | 2 +- googletest/test/gtest_unittest.cc | 30 ++-- 27 files changed, 305 insertions(+), 263 deletions(-) diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h index 1cffde2b8..c0bb8a9c6 100644 --- a/googlemock/include/gmock/gmock-actions.h +++ b/googlemock/include/gmock/gmock-actions.h @@ -1273,7 +1273,7 @@ class AssignAction { const T2 value_; }; -#if !GTEST_OS_WINDOWS_MOBILE +#ifndef GTEST_OS_WINDOWS_MOBILE // Implements the SetErrnoAndReturn action to simulate return from // various system calls and libc functions. @@ -1926,7 +1926,7 @@ PolymorphicAction> Assign(T1* ptr, T2 val) { return MakePolymorphicAction(internal::AssignAction(ptr, val)); } -#if !GTEST_OS_WINDOWS_MOBILE +#ifndef GTEST_OS_WINDOWS_MOBILE // Creates an action that sets errno and returns the appropriate error. template diff --git a/googlemock/include/gmock/gmock-nice-strict.h b/googlemock/include/gmock/gmock-nice-strict.h index 4f0eb35db..056d47141 100644 --- a/googlemock/include/gmock/gmock-nice-strict.h +++ b/googlemock/include/gmock/gmock-nice-strict.h @@ -98,7 +98,7 @@ constexpr bool HasStrictnessModifier() { // deregistration. This guarantees that MockClass's constructor and destructor // run with the same level of strictness as its instance methods. -#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW && \ +#if defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_MINGW) && \ (defined(_MSC_VER) || defined(__clang__)) // We need to mark these classes with this declspec to ensure that // the empty base class optimization is performed. diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index a7fe91175..5a98fafd1 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -48,10 +48,10 @@ #include "gtest/gtest.h" #include "gtest/internal/gtest-port.h" -#if GTEST_OS_CYGWIN || GTEST_OS_LINUX || GTEST_OS_MAC +#if defined(GTEST_OS_CYGWIN) || defined(GTEST_OS_LINUX) || defined(GTEST_OS_MAC) #include // NOLINT #endif -#if GTEST_OS_QURT +#ifdef GTEST_OS_QURT #include #endif @@ -526,7 +526,7 @@ class MockObjectRegistry { // RUN_ALL_TESTS() has already returned when this destructor is // called. Therefore we cannot use the normal Google Test // failure reporting mechanism. -#if GTEST_OS_QURT +#ifdef GTEST_OS_QURT qurt_exception_raise_fatal(); #else _exit(1); // We cannot call exit() as it is not reentrant and diff --git a/googlemock/src/gmock_main.cc b/googlemock/src/gmock_main.cc index b411c5ecb..fb37b53a3 100644 --- a/googlemock/src/gmock_main.cc +++ b/googlemock/src/gmock_main.cc @@ -32,8 +32,8 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -#if GTEST_OS_ESP8266 || GTEST_OS_ESP32 -#if GTEST_OS_ESP8266 +#if defined(GTEST_OS_ESP8266) || defined(GTEST_OS_ESP32) +#ifdef GTEST_OS_ESP8266 extern "C" { #endif void setup() { @@ -43,7 +43,7 @@ void setup() { testing::InitGoogleMock(); } void loop() { RUN_ALL_TESTS(); } -#if GTEST_OS_ESP8266 +#ifdef GTEST_OS_ESP8266 } #endif @@ -55,7 +55,7 @@ void loop() { RUN_ALL_TESTS(); } // Windows. See the following link to track the current status of this bug: // https://web.archive.org/web/20170912203238/connect.microsoft.com/VisualStudio/feedback/details/394464/wmain-link-error-in-the-static-library // // NOLINT -#if GTEST_OS_WINDOWS_MOBILE +#ifdef GTEST_OS_WINDOWS_MOBILE #include // NOLINT GTEST_API_ int _tmain(int argc, TCHAR** argv) { diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc index f2d3042f0..7734830ec 100644 --- a/googlemock/test/gmock-actions_test.cc +++ b/googlemock/test/gmock-actions_test.cc @@ -1592,7 +1592,7 @@ TEST(WithArgsTest, RefQualifiedInnerAction) { EXPECT_EQ(19, mock.AsStdFunction()(0, 17)); } -#if !GTEST_OS_WINDOWS_MOBILE +#ifndef GTEST_OS_WINDOWS_MOBILE class SetErrnoAndReturnTest : public testing::Test { protected: diff --git a/googlemock/test/gmock-function-mocker_test.cc b/googlemock/test/gmock-function-mocker_test.cc index e211aff95..4db498d85 100644 --- a/googlemock/test/gmock-function-mocker_test.cc +++ b/googlemock/test/gmock-function-mocker_test.cc @@ -35,7 +35,7 @@ // Silence C4503 (decorated name length exceeded) for MSVC. GTEST_DISABLE_MSC_WARNINGS_PUSH_(4503) -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS // MSDN says the header file to be included for STDMETHOD is BaseTyps.h but // we are getting compiler errors if we use basetyps.h, hence including // objbase.h for definition of STDMETHOD. @@ -120,7 +120,7 @@ class FooInterface { virtual int RefQualifiedOverloaded() & = 0; virtual int RefQualifiedOverloaded() && = 0; -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS STDMETHOD_(int, CTNullary)() = 0; STDMETHOD_(bool, CTUnary)(int x) = 0; STDMETHOD_(int, CTDecimal) @@ -178,7 +178,7 @@ class MockFoo : public FooInterface { MOCK_METHOD(int (*)(bool), ReturnsFunctionPointer1, (int), ()); MOCK_METHOD(fn_ptr, ReturnsFunctionPointer2, (int), ()); -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS MOCK_METHOD(int, CTNullary, (), (Calltype(STDMETHODCALLTYPE))); MOCK_METHOD(bool, CTUnary, (int), (Calltype(STDMETHODCALLTYPE))); MOCK_METHOD(int, CTDecimal, @@ -248,7 +248,7 @@ class LegacyMockFoo : public FooInterface { MOCK_METHOD1(ReturnsFunctionPointer1, int (*(int))(bool)); MOCK_METHOD1(ReturnsFunctionPointer2, fn_ptr(int)); -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, CTNullary, int()); MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, CTUnary, bool(int)); // NOLINT MOCK_METHOD10_WITH_CALLTYPE(STDMETHODCALLTYPE, CTDecimal, @@ -404,7 +404,7 @@ TYPED_TEST(FunctionMockerTest, MocksTypeWithTemplatedCopyCtor) { EXPECT_TRUE(this->foo_->TypeWithTemplatedCopyCtor(TemplatedCopyable())); } -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS // Tests mocking a nullary function with calltype. TYPED_TEST(FunctionMockerTest, MocksNullaryFunctionWithCallType) { EXPECT_CALL(this->mock_foo_, CTNullary()) @@ -620,7 +620,7 @@ TYPED_TEST(TemplateMockTest, MethodWithCommaInReturnTypeWorks) { EXPECT_EQ(a_map, mock.ReturnTypeWithComma(1)); } -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS // Tests mocking template interfaces with calltype. template diff --git a/googlemock/test/gmock-internal-utils_test.cc b/googlemock/test/gmock-internal-utils_test.cc index 932bece5a..360d02ae5 100644 --- a/googlemock/test/gmock-internal-utils_test.cc +++ b/googlemock/test/gmock-internal-utils_test.cc @@ -56,7 +56,7 @@ #include "src/gtest-internal-inl.h" #undef GTEST_IMPLEMENTATION_ -#if GTEST_OS_CYGWIN +#ifdef GTEST_OS_CYGWIN #include // For ssize_t. NOLINT #endif @@ -167,7 +167,7 @@ TEST(KindOfTest, Integer) { EXPECT_EQ(kInteger, GMOCK_KIND_OF_(unsigned long long)); // NOLINT EXPECT_EQ(kInteger, GMOCK_KIND_OF_(wchar_t)); // NOLINT EXPECT_EQ(kInteger, GMOCK_KIND_OF_(size_t)); // NOLINT -#if GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_CYGWIN +#if defined(GTEST_OS_LINUX) || defined(GTEST_OS_MAC) || defined(GTEST_OS_CYGWIN) // ssize_t is not defined on Windows and possibly some other OSes. EXPECT_EQ(kInteger, GMOCK_KIND_OF_(ssize_t)); // NOLINT #endif diff --git a/googlemock/test/gmock_link_test.h b/googlemock/test/gmock_link_test.h index 95a8cb807..8d2abb1a6 100644 --- a/googlemock/test/gmock_link_test.h +++ b/googlemock/test/gmock_link_test.h @@ -116,7 +116,7 @@ #include "gmock/gmock.h" -#if !GTEST_OS_WINDOWS_MOBILE +#ifndef GTEST_OS_WINDOWS_MOBILE #include #endif @@ -181,7 +181,7 @@ using testing::WithArg; using testing::WithArgs; using testing::WithoutArgs; -#if !GTEST_OS_WINDOWS_MOBILE +#ifndef GTEST_OS_WINDOWS_MOBILE using testing::SetErrnoAndReturn; #endif @@ -306,7 +306,7 @@ TEST(LinkTest, TestSetArrayArgument) { mock.VoidFromString(&ch); } -#if !GTEST_OS_WINDOWS_MOBILE +#ifndef GTEST_OS_WINDOWS_MOBILE // Tests the linkage of the SetErrnoAndReturn action. TEST(LinkTest, TestSetErrnoAndReturn) { diff --git a/googletest/include/gtest/gtest-death-test.h b/googletest/include/gtest/gtest-death-test.h index 84e5a5bbd..b793528b1 100644 --- a/googletest/include/gtest/gtest-death-test.h +++ b/googletest/include/gtest/gtest-death-test.h @@ -203,7 +203,7 @@ class GTEST_API_ ExitedWithCode { const int exit_code_; }; -#if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA +#if !defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_FUCHSIA) // Tests that an exit code describes an exit due to termination by a // given signal. class GTEST_API_ KilledBySignal { diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index 6fdf55243..2bf64938c 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -1999,7 +1999,7 @@ GTEST_API_ AssertionResult FloatLE(const char* expr1, const char* expr2, GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2, double val1, double val2); -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS // Macros that test for HRESULT failure and success, these are only useful // on Windows, and rely on Windows SDK macros and APIs to compile. diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h index 733950484..ae2ca95ef 100644 --- a/googletest/include/gtest/internal/gtest-internal.h +++ b/googletest/include/gtest/internal/gtest-internal.h @@ -41,7 +41,7 @@ #include "gtest/internal/gtest-port.h" -#if GTEST_OS_LINUX +#ifdef GTEST_OS_LINUX #include #include #include @@ -457,7 +457,7 @@ class TestFactoryImpl : public TestFactoryBase { Test* CreateTest() override { return new TestClass; } }; -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS // Predicate-formatters for implementing the HRESULT checking macros // {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED} diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 5cea3e02b..f2b0bbf9a 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -361,13 +361,13 @@ // Brings in definitions for functions used in the testing::internal::posix // namespace (read, write, close, chdir, isatty, stat). We do not currently // use them on Windows Mobile. -#if GTEST_OS_WINDOWS -#if !GTEST_OS_WINDOWS_MOBILE +#ifdef GTEST_OS_WINDOWS +#ifndef GTEST_OS_WINDOWS_MOBILE #include #include #endif // In order to avoid having to include , use forward declaration -#if GTEST_OS_WINDOWS_MINGW && !defined(__MINGW64_VERSION_MAJOR) +#if defined(GTEST_OS_WINDOWS_MINGW) && !defined(__MINGW64_VERSION_MAJOR) // MinGW defined _CRITICAL_SECTION and _RTL_CRITICAL_SECTION as two // separate (equivalent) structs, instead of using typedef typedef struct _CRITICAL_SECTION GTEST_CRITICAL_SECTION; @@ -377,7 +377,7 @@ typedef struct _CRITICAL_SECTION GTEST_CRITICAL_SECTION; // WindowsTypesTest.CRITICAL_SECTIONIs_RTL_CRITICAL_SECTION. typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #endif -#elif GTEST_OS_XTENSA +#elif defined(GTEST_OS_XTENSA) #include // Xtensa toolchains define strcasecmp in the string.h header instead of // strings.h. string.h is already included. @@ -389,7 +389,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #include #endif // GTEST_OS_WINDOWS -#if GTEST_OS_LINUX_ANDROID +#ifdef GTEST_OS_LINUX_ANDROID // Used to define __ANDROID_API__ matching the target NDK API level. #include // NOLINT #endif @@ -397,13 +397,17 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // Defines this to true if and only if Google Test can use POSIX regular // expressions. #ifndef GTEST_HAS_POSIX_RE -#if GTEST_OS_LINUX_ANDROID +#ifdef GTEST_OS_LINUX_ANDROID // On Android, is only available starting with Gingerbread. #define GTEST_HAS_POSIX_RE (__ANDROID_API__ >= 9) #else -#define GTEST_HAS_POSIX_RE \ - !(GTEST_OS_WINDOWS || GTEST_OS_XTENSA || GTEST_OS_QURT) +#if !(defined(GTEST_OS_WINDOWS) || defined(GTEST_OS_XTENSA) || \ + defined(GTEST_OS_QURT)) +#define GTEST_HAS_POSIX_RE 1 +#else +#define GTEST_HAS_POSIX_RE 0 #endif +#endif // GTEST_OS_LINUX_ANDROID #endif // Select the regular expression implementation. @@ -472,11 +476,14 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // Cygwin 1.7 and below doesn't support ::std::wstring. // Solaris' libc++ doesn't support it either. Android has // no support for it at least as recent as Froyo (2.2). -#define GTEST_HAS_STD_WSTRING \ - (!(GTEST_OS_LINUX_ANDROID || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \ - GTEST_OS_HAIKU || GTEST_OS_ESP32 || GTEST_OS_ESP8266 || \ - GTEST_OS_XTENSA || GTEST_OS_QURT)) - +#if (!(defined(GTEST_OS_LINUX_ANDROID) || defined(GTEST_OS_CYGWIN) || \ + defined(GTEST_OS_SOLARIS) || defined(GTEST_OS_HAIKU) || \ + defined(GTEST_OS_ESP32) || defined(GTEST_OS_ESP8266) || \ + defined(GTEST_OS_XTENSA) || defined(GTEST_OS_QURT))) +#define GTEST_HAS_STD_WSTRING 1 +#else +#define GTEST_HAS_STD_WSTRING 0 +#endif #endif // GTEST_HAS_STD_WSTRING #ifndef GTEST_HAS_FILE_SYSTEM @@ -506,7 +513,8 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // -frtti -fno-exceptions, the build fails at link time with undefined // references to __cxa_bad_typeid. Note sure if STL or toolchain bug, // so disable RTTI when detected. -#if GTEST_OS_LINUX_ANDROID && defined(_STLPORT_MAJOR) && !defined(__EXCEPTIONS) +#if defined(GTEST_OS_LINUX_ANDROID) && defined(_STLPORT_MAJOR) && \ + !defined(__EXCEPTIONS) #define GTEST_HAS_RTTI 0 #else #define GTEST_HAS_RTTI 1 @@ -554,11 +562,17 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // // To disable threading support in Google Test, add -DGTEST_HAS_PTHREAD=0 // to your compiler flags. -#define GTEST_HAS_PTHREAD \ - (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX || GTEST_OS_QNX || \ - GTEST_OS_FREEBSD || GTEST_OS_NACL || GTEST_OS_NETBSD || GTEST_OS_FUCHSIA || \ - GTEST_OS_DRAGONFLY || GTEST_OS_GNU_KFREEBSD || GTEST_OS_OPENBSD || \ - GTEST_OS_HAIKU || GTEST_OS_GNU_HURD) +#if (defined(GTEST_OS_LINUX) || defined(GTEST_OS_MAC) || \ + defined(GTEST_OS_HPUX) || defined(GTEST_OS_QNX) || \ + defined(GTEST_OS_FREEBSD) || defined(GTEST_OS_NACL) || \ + defined(GTEST_OS_NETBSD) || defined(GTEST_OS_FUCHSIA) || \ + defined(GTEST_OS_DRAGONFLY) || defined(GTEST_OS_GNU_KFREEBSD) || \ + defined(GTEST_OS_OPENBSD) || defined(GTEST_OS_HAIKU) || \ + defined(GTEST_OS_GNU_HURD)) +#define GTEST_HAS_PTHREAD 1 +#else +#define GTEST_HAS_PTHREAD 0 +#endif #endif // GTEST_HAS_PTHREAD #if GTEST_HAS_PTHREAD @@ -577,8 +591,8 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #ifndef GTEST_HAS_CLONE // The user didn't tell us, so we need to figure it out. -#if GTEST_OS_LINUX && !defined(__ia64__) -#if GTEST_OS_LINUX_ANDROID +#if defined(GTEST_OS_LINUX) && !defined(__ia64__) +#if defined(GTEST_OS_LINUX_ANDROID) // On Android, clone() became available at different API levels for each 32-bit // architecture. #if defined(__LP64__) || (defined(__arm__) && __ANDROID_API__ >= 9) || \ @@ -603,9 +617,10 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // By default, we assume that stream redirection is supported on all // platforms except known mobile / embedded ones. Also, if the port doesn't have // a file system, stream redirection is not supported. -#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || \ - GTEST_OS_WINDOWS_RT || GTEST_OS_ESP8266 || GTEST_OS_XTENSA || \ - GTEST_OS_QURT || !GTEST_HAS_FILE_SYSTEM +#if defined(GTEST_OS_WINDOWS_MOBILE) || defined(GTEST_OS_WINDOWS_PHONE) || \ + defined(GTEST_OS_WINDOWS_RT) || defined(GTEST_OS_ESP8266) || \ + defined(GTEST_OS_XTENSA) || defined(GTEST_OS_QURT) || \ + !GTEST_HAS_FILE_SYSTEM #define GTEST_HAS_STREAM_REDIRECTION 0 #else #define GTEST_HAS_STREAM_REDIRECTION 1 @@ -614,13 +629,16 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // Determines whether to support death tests. // pops up a dialog window that cannot be suppressed programmatically. -#if (GTEST_OS_LINUX || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \ - (GTEST_OS_MAC && !GTEST_OS_IOS) || \ - (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER) || GTEST_OS_WINDOWS_MINGW || \ - GTEST_OS_AIX || GTEST_OS_HPUX || GTEST_OS_OPENBSD || GTEST_OS_QNX || \ - GTEST_OS_FREEBSD || GTEST_OS_NETBSD || GTEST_OS_FUCHSIA || \ - GTEST_OS_DRAGONFLY || GTEST_OS_GNU_KFREEBSD || GTEST_OS_HAIKU || \ - GTEST_OS_GNU_HURD) +#if (defined(GTEST_OS_LINUX) || defined(GTEST_OS_CYGWIN) || \ + defined(GTEST_OS_SOLARIS) || \ + (defined(GTEST_OS_MAC) && !defined(GTEST_OS_IOS)) || \ + (defined(GTEST_OS_WINDOWS_DESKTOP) && _MSC_VER) || \ + defined(GTEST_OS_WINDOWS_MINGW) || defined(GTEST_OS_AIX) || \ + defined(GTEST_OS_HPUX) || defined(GTEST_OS_OPENBSD) || \ + defined(GTEST_OS_QNX) || defined(GTEST_OS_FREEBSD) || \ + defined(GTEST_OS_NETBSD) || defined(GTEST_OS_FUCHSIA) || \ + defined(GTEST_OS_DRAGONFLY) || defined(GTEST_OS_GNU_KFREEBSD) || \ + defined(GTEST_OS_HAIKU) || defined(GTEST_OS_GNU_HURD)) // Death tests require a file system to work properly. #if GTEST_HAS_FILE_SYSTEM #define GTEST_HAS_DEATH_TEST 1 @@ -638,14 +656,21 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #endif // Determines whether the system compiler uses UTF-16 for encoding wide strings. -#define GTEST_WIDE_STRING_USES_UTF16_ \ - (GTEST_OS_WINDOWS || GTEST_OS_CYGWIN || GTEST_OS_AIX || GTEST_OS_OS2) +#if defined(GTEST_OS_WINDOWS) || defined(GTEST_OS_CYGWIN) || \ + defined(GTEST_OS_AIX) || defined(GTEST_OS_OS2) +#define GTEST_WIDE_STRING_USES_UTF16_ 1 +#else +#define GTEST_WIDE_STRING_USES_UTF16_ 0 +#endif // Determines whether test results can be streamed to a socket. -#if GTEST_OS_LINUX || GTEST_OS_GNU_KFREEBSD || GTEST_OS_DRAGONFLY || \ - GTEST_OS_FREEBSD || GTEST_OS_NETBSD || GTEST_OS_OPENBSD || \ - GTEST_OS_GNU_HURD +#if defined(GTEST_OS_LINUX) || defined(GTEST_OS_GNU_KFREEBSD) || \ + defined(GTEST_OS_DRAGONFLY) || defined(GTEST_OS_FREEBSD) || \ + defined(GTEST_OS_NETBSD) || defined(GTEST_OS_OPENBSD) || \ + defined(GTEST_OS_GNU_HURD) #define GTEST_CAN_STREAM_RESULTS_ 1 +#else +#define GTEST_CAN_STREAM_RESULTS_ 0 #endif // Defines some utility macros. @@ -759,10 +784,14 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #ifndef GTEST_IS_THREADSAFE -#define GTEST_IS_THREADSAFE \ - (GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ || \ - (GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT) || \ - GTEST_HAS_PTHREAD) +#if (GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ || \ + (defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_PHONE) && \ + !defined(GTEST_OS_WINDOWS_RT)) || \ + GTEST_HAS_PTHREAD) +#define GTEST_IS_THREADSAFE 1 +#else +#define GTEST_IS_THREADSAFE 0 +#endif #endif // GTEST_IS_THREADSAFE @@ -1185,7 +1214,7 @@ void ClearInjectableArgvs(); // Defines synchronization primitives. #if GTEST_IS_THREADSAFE -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS // Provides leak-safe Windows kernel handle ownership. // Used in death tests and in threading support. class GTEST_API_ AutoHandle { @@ -1264,7 +1293,7 @@ GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 // On MinGW, we can have both GTEST_OS_WINDOWS and GTEST_HAS_PTHREAD // defined, but we don't want to use MinGW's pthreads implementation, which // has conformance problems with some versions of the POSIX standard. -#if GTEST_HAS_PTHREAD && !GTEST_OS_WINDOWS_MINGW +#if GTEST_HAS_PTHREAD && !defined(GTEST_OS_WINDOWS_MINGW) // As a C-function, ThreadFuncWithCLinkage cannot be templated itself. // Consequently, it cannot select a correct instantiation of ThreadWithParam @@ -1350,7 +1379,8 @@ class ThreadWithParam : public ThreadWithParamBase { // Mutex and ThreadLocal have already been imported into the namespace. // Nothing to do here. -#elif GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT +#elif defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_PHONE) && \ + !defined(GTEST_OS_WINDOWS_RT) // Mutex implements mutex on Windows platforms. It is used in conjunction // with class MutexLock: @@ -1903,7 +1933,7 @@ class GTEST_API_ ThreadLocal { // we cannot detect it. GTEST_API_ size_t GetThreadCount(); -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS #define GTEST_PATH_SEP_ "\\" #define GTEST_HAS_ALT_PATH_SEP_ 1 #else @@ -1980,11 +2010,11 @@ namespace posix { // File system porting. #if GTEST_HAS_FILE_SYSTEM -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS typedef struct _stat StatStruct; -#if GTEST_OS_WINDOWS_MOBILE +#ifdef GTEST_OS_WINDOWS_MOBILE inline int FileNo(FILE* file) { return reinterpret_cast(_fileno(file)); } // Stat(), RmDir(), and IsDir() are not needed on Windows CE at this // time and thus not defined there. @@ -1995,7 +2025,7 @@ inline int RmDir(const char* dir) { return _rmdir(dir); } inline bool IsDir(const StatStruct& st) { return (_S_IFDIR & st.st_mode) != 0; } #endif // GTEST_OS_WINDOWS_MOBILE -#elif GTEST_OS_ESP8266 +#elif defined(GTEST_OS_ESP8266) typedef struct stat StatStruct; inline int FileNo(FILE* file) { return fileno(file); } @@ -2012,7 +2042,7 @@ typedef struct stat StatStruct; inline int FileNo(FILE* file) { return fileno(file); } inline int Stat(const char* path, StatStruct* buf) { return stat(path, buf); } -#if GTEST_OS_QURT +#ifdef GTEST_OS_QURT // QuRT doesn't support any directory functions, including rmdir inline int RmDir(const char*) { return 0; } #else @@ -2025,7 +2055,7 @@ inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); } // Other functions with a different name on Windows. -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS #ifdef __BORLANDC__ inline int DoIsATTY(int fd) { return isatty(fd); } @@ -2033,8 +2063,9 @@ inline int StrCaseCmp(const char* s1, const char* s2) { return stricmp(s1, s2); } #else // !__BORLANDC__ -#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_ZOS || GTEST_OS_IOS || \ - GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT || defined(ESP_PLATFORM) +#if defined(GTEST_OS_WINDOWS_MOBILE) || defined(GTEST_OS_ZOS) || \ + defined(GTEST_OS_IOS) || defined(GTEST_OS_WINDOWS_PHONE) || \ + defined(GTEST_OS_WINDOWS_RT) || defined(ESP_PLATFORM) inline int DoIsATTY(int /* fd */) { return 0; } #else inline int DoIsATTY(int fd) { return _isatty(fd); } @@ -2072,13 +2103,13 @@ GTEST_DISABLE_MSC_DEPRECATED_PUSH_() // StrError() aren't needed on Windows CE at this time and thus not // defined there. #if GTEST_HAS_FILE_SYSTEM -#if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && \ - !GTEST_OS_WINDOWS_RT && !GTEST_OS_ESP8266 && !GTEST_OS_XTENSA && \ - !GTEST_OS_QURT +#if !defined(GTEST_OS_WINDOWS_MOBILE) && !defined(GTEST_OS_WINDOWS_PHONE) && \ + !defined(GTEST_OS_WINDOWS_RT) && !defined(GTEST_OS_ESP8266) && \ + !defined(GTEST_OS_XTENSA) && !defined(GTEST_OS_QURT) inline int ChDir(const char* dir) { return chdir(dir); } #endif inline FILE* FOpen(const char* path, const char* mode) { -#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW +#if defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_MINGW) struct wchar_codecvt : public std::codecvt {}; std::wstring_convert converter; std::wstring wide_path = converter.from_bytes(path); @@ -2088,14 +2119,14 @@ inline FILE* FOpen(const char* path, const char* mode) { return fopen(path, mode); #endif // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW } -#if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT +#if !defined(GTEST_OS_WINDOWS_MOBILE) && !defined(GTEST_OS_QURT) inline FILE* FReopen(const char* path, const char* mode, FILE* stream) { return freopen(path, mode, stream); } inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); } #endif // !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT inline int FClose(FILE* fp) { return fclose(fp); } -#if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT +#if !defined(GTEST_OS_WINDOWS_MOBILE) && !defined(GTEST_OS_QURT) inline int Read(int fd, void* buf, unsigned int count) { return static_cast(read(fd, buf, count)); } @@ -2106,14 +2137,14 @@ inline int Close(int fd) { return close(fd); } #endif // !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT #endif // GTEST_HAS_FILE_SYSTEM -#if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT +#if !defined(GTEST_OS_WINDOWS_MOBILE) && !defined(GTEST_OS_QURT) inline const char* StrError(int errnum) { return strerror(errnum); } #endif // !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_QURT inline const char* GetEnv(const char* name) { -#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || \ - GTEST_OS_WINDOWS_RT || GTEST_OS_ESP8266 || GTEST_OS_XTENSA || \ - GTEST_OS_QURT +#if defined(GTEST_OS_WINDOWS_MOBILE) || defined(GTEST_OS_WINDOWS_PHONE) || \ + defined(GTEST_OS_WINDOWS_RT) || defined(GTEST_OS_ESP8266) || \ + defined(GTEST_OS_XTENSA) || defined(GTEST_OS_QURT) // We are on an embedded platform, which has no environment variables. static_cast(name); // To prevent 'unused argument' warning. return nullptr; @@ -2129,7 +2160,7 @@ inline const char* GetEnv(const char* name) { GTEST_DISABLE_MSC_DEPRECATED_POP_() -#if GTEST_OS_WINDOWS_MOBILE +#ifdef GTEST_OS_WINDOWS_MOBILE // Windows CE has no C library. The abort() function is used in // several places in Google Test. This implementation provides a reasonable // imitation of standard behaviour. @@ -2145,7 +2176,7 @@ GTEST_DISABLE_MSC_DEPRECATED_POP_() // MSVC-based platforms. We map the GTEST_SNPRINTF_ macro to the appropriate // function in order to achieve that. We use macro definition here because // snprintf is a variadic function. -#if defined(_MSC_VER) && !GTEST_OS_WINDOWS_MOBILE +#if defined(_MSC_VER) && !defined(GTEST_OS_WINDOWS_MOBILE) // MSVC 2005 and above support variadic macros. #define GTEST_SNPRINTF_(buffer, size, format, ...) \ _snprintf_s(buffer, size, size, format, __VA_ARGS__) diff --git a/googletest/include/gtest/internal/gtest-string.h b/googletest/include/gtest/internal/gtest-string.h index cc0dd7529..7c05b5833 100644 --- a/googletest/include/gtest/internal/gtest-string.h +++ b/googletest/include/gtest/internal/gtest-string.h @@ -73,7 +73,7 @@ class GTEST_API_ String { // memory using malloc(). static const char* CloneCString(const char* c_str); -#if GTEST_OS_WINDOWS_MOBILE +#ifdef GTEST_OS_WINDOWS_MOBILE // Windows CE does not have the 'ANSI' versions of Win32 APIs. To be // able to pass strings to Win32 APIs on CE we need to convert them // to 'Unicode', UTF-16. diff --git a/googletest/src/gtest-death-test.cc b/googletest/src/gtest-death-test.cc index 7fcf9bf5b..f91eba22d 100644 --- a/googletest/src/gtest-death-test.cc +++ b/googletest/src/gtest-death-test.cc @@ -42,7 +42,7 @@ #if GTEST_HAS_DEATH_TEST -#if GTEST_OS_MAC +#ifdef GTEST_OS_MAC #include #endif // GTEST_OS_MAC @@ -50,24 +50,24 @@ #include #include -#if GTEST_OS_LINUX +#ifdef GTEST_OS_LINUX #include #endif // GTEST_OS_LINUX #include -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS #include #else #include #include #endif // GTEST_OS_WINDOWS -#if GTEST_OS_QNX +#ifdef GTEST_OS_QNX #include #endif // GTEST_OS_QNX -#if GTEST_OS_FUCHSIA +#ifdef GTEST_OS_FUCHSIA #include #include #include @@ -139,7 +139,7 @@ namespace internal { // Valid only for fast death tests. Indicates the code is running in the // child process of a fast style death test. -#if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA +#if !defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_FUCHSIA) static bool g_in_fast_death_test_child = false; #endif @@ -149,7 +149,7 @@ static bool g_in_fast_death_test_child = false; // tests. IMPORTANT: This is an internal utility. Using it may break the // implementation of death tests. User code MUST NOT use it. bool InDeathTestChild() { -#if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA +#if defined(GTEST_OS_WINDOWS) || defined(GTEST_OS_FUCHSIA) // On Windows and Fuchsia, death tests are thread-safe regardless of the value // of the death_test_style flag. @@ -171,7 +171,7 @@ ExitedWithCode::ExitedWithCode(int exit_code) : exit_code_(exit_code) {} // ExitedWithCode function-call operator. bool ExitedWithCode::operator()(int exit_status) const { -#if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA +#if defined(GTEST_OS_WINDOWS) || defined(GTEST_OS_FUCHSIA) return exit_status == exit_code_; @@ -182,7 +182,7 @@ bool ExitedWithCode::operator()(int exit_status) const { #endif // GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA } -#if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA +#if !defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_FUCHSIA) // KilledBySignal constructor. KilledBySignal::KilledBySignal(int signum) : signum_(signum) {} @@ -209,7 +209,7 @@ namespace internal { static std::string ExitSummary(int exit_code) { Message m; -#if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA +#if defined(GTEST_OS_WINDOWS) || defined(GTEST_OS_FUCHSIA) m << "Exited with exit status " << exit_code; @@ -236,7 +236,7 @@ bool ExitedUnsuccessfully(int exit_status) { return !ExitedWithCode(0)(exit_status); } -#if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA +#if !defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_FUCHSIA) // Generates a textual failure message when a death test finds more than // one thread running, or cannot determine the number of threads, prior // to executing the given statement. It is the responsibility of the @@ -265,7 +265,7 @@ static const char kDeathTestReturned = 'R'; static const char kDeathTestThrew = 'T'; static const char kDeathTestInternalError = 'I'; -#if GTEST_OS_FUCHSIA +#ifdef GTEST_OS_FUCHSIA // File descriptor used for the pipe in the child process. static const int kFuchsiaReadPipeFd = 3; @@ -634,7 +634,7 @@ std::unique_ptr CreateArgvFromArgs(std::vector& args) { return result; } -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS // WindowsDeathTest implements death tests on Windows. Due to the // specifics of starting new processes on Windows, death tests there are // always threadsafe, and Google Test considers the @@ -821,7 +821,7 @@ DeathTest::TestRole WindowsDeathTest::AssumeRole() { return OVERSEE_TEST; } -#elif GTEST_OS_FUCHSIA +#elif defined(GTEST_OS_FUCHSIA) class FuchsiaDeathTest : public DeathTestImpl { public: @@ -1164,7 +1164,7 @@ struct ExecDeathTestArgs { int close_fd; // File descriptor to close; the read end of a pipe }; -#if GTEST_OS_QNX +#ifdef GTEST_OS_QNX extern "C" char** environ; #else // GTEST_OS_QNX // The main function for a threadsafe-style death test child process. @@ -1245,7 +1245,7 @@ static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) { ExecDeathTestArgs args = {argv, close_fd}; pid_t child_pid = -1; -#if GTEST_OS_QNX +#ifdef GTEST_OS_QNX // Obtains the current directory and sets it to be closed in the child // process. const int cwd_fd = open(".", O_RDONLY); @@ -1276,7 +1276,7 @@ static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) { GTEST_DEATH_TEST_CHECK_SYSCALL_(close(cwd_fd)); #else // GTEST_OS_QNX -#if GTEST_OS_LINUX +#ifdef GTEST_OS_LINUX // When a SIGPROF signal is received while fork() or clone() are executing, // the process may hang. To avoid this, we ignore SIGPROF here and re-enable // it after the call to fork()/clone() is complete. @@ -1327,7 +1327,7 @@ static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) { _exit(0); } #endif // GTEST_OS_QNX -#if GTEST_OS_LINUX +#ifdef GTEST_OS_LINUX GTEST_DEATH_TEST_CHECK_SYSCALL_( sigaction(SIGPROF, &saved_sigprof_action, nullptr)); #endif // GTEST_OS_LINUX @@ -1419,14 +1419,14 @@ bool DefaultDeathTestFactory::Create(const char* statement, } } -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS if (GTEST_FLAG_GET(death_test_style) == "threadsafe" || GTEST_FLAG_GET(death_test_style) == "fast") { *test = new WindowsDeathTest(statement, std::move(matcher), file, line); } -#elif GTEST_OS_FUCHSIA +#elif defined(GTEST_OS_FUCHSIA) if (GTEST_FLAG_GET(death_test_style) == "threadsafe" || GTEST_FLAG_GET(death_test_style) == "fast") { @@ -1453,7 +1453,7 @@ bool DefaultDeathTestFactory::Create(const char* statement, return true; } -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS // Recreates the pipe and event handles from the provided parameters, // signals the event, and returns a file descriptor wrapped around the pipe // handle. This function is called in the child process only. @@ -1530,7 +1530,7 @@ InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() { SplitString(GTEST_FLAG_GET(internal_run_death_test), '|', &fields); int write_fd = -1; -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS unsigned int parent_process_id = 0; size_t write_handle_as_size_t = 0; @@ -1547,7 +1547,7 @@ InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() { write_fd = GetStatusFileDescriptor(parent_process_id, write_handle_as_size_t, event_handle_as_size_t); -#elif GTEST_OS_FUCHSIA +#elif defined(GTEST_OS_FUCHSIA) if (fields.size() != 3 || !ParseNaturalNumber(fields[1], &line) || !ParseNaturalNumber(fields[2], &index)) { diff --git a/googletest/src/gtest-filepath.cc b/googletest/src/gtest-filepath.cc index 940585db9..48dee13ef 100644 --- a/googletest/src/gtest-filepath.cc +++ b/googletest/src/gtest-filepath.cc @@ -34,9 +34,9 @@ #include "gtest/gtest-message.h" #include "gtest/internal/gtest-port.h" -#if GTEST_OS_WINDOWS_MOBILE +#ifdef GTEST_OS_WINDOWS_MOBILE #include -#elif GTEST_OS_WINDOWS +#elif defined(GTEST_OS_WINDOWS) #include #include #else @@ -47,7 +47,7 @@ #include "gtest/internal/gtest-string.h" -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS #define GTEST_PATH_MAX_ _MAX_PATH #elif defined(PATH_MAX) #define GTEST_PATH_MAX_ PATH_MAX @@ -62,7 +62,7 @@ namespace testing { namespace internal { -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS // On Windows, '\\' is the standard path separator, but many tools and the // Windows API also accept '/' as an alternate path separator. Unless otherwise // noted, a file path can contain either kind of path separators, or a mixture @@ -70,7 +70,7 @@ namespace internal { const char kPathSeparator = '\\'; const char kAlternatePathSeparator = '/'; const char kAlternatePathSeparatorString[] = "/"; -#if GTEST_OS_WINDOWS_MOBILE +#ifdef GTEST_OS_WINDOWS_MOBILE // Windows CE doesn't have a current directory. You should not use // the current directory in tests on Windows CE, but this at least // provides a reasonable fallback. @@ -96,19 +96,20 @@ static bool IsPathSeparator(char c) { // Returns the current working directory, or "" if unsuccessful. FilePath FilePath::GetCurrentDir() { -#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_PHONE || \ - GTEST_OS_WINDOWS_RT || GTEST_OS_ESP8266 || GTEST_OS_ESP32 || \ - GTEST_OS_XTENSA || GTEST_OS_QURT +#if defined(GTEST_OS_WINDOWS_MOBILE) || defined(GTEST_OS_WINDOWS_PHONE) || \ + defined(GTEST_OS_WINDOWS_RT) || defined(GTEST_OS_ESP8266) || \ + defined(GTEST_OS_ESP32) || defined(GTEST_OS_XTENSA) || \ + defined(GTEST_OS_QURT) // These platforms do not have a current directory, so we just return // something reasonable. return FilePath(kCurrentDirectoryString); -#elif GTEST_OS_WINDOWS +#elif defined(GTEST_OS_WINDOWS) char cwd[GTEST_PATH_MAX_ + 1] = {'\0'}; return FilePath(_getcwd(cwd, sizeof(cwd)) == nullptr ? "" : cwd); #else char cwd[GTEST_PATH_MAX_ + 1] = {'\0'}; char* result = getcwd(cwd, sizeof(cwd)); -#if GTEST_OS_NACL +#ifdef GTEST_OS_NACL // getcwd will likely fail in NaCl due to the sandbox, so return something // reasonable. The user may have provided a shim implementation for getcwd, // however, so fallback only when failure is detected. @@ -151,7 +152,7 @@ size_t FilePath::CalculateRootLength() const { const auto& path = pathname_; auto s = path.begin(); auto end = path.end(); -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS if (end - s >= 2 && s[1] == ':' && (end - s == 2 || IsPathSeparator(s[2])) && (('A' <= s[0] && s[0] <= 'Z') || ('a' <= s[0] && s[0] <= 'z'))) { // A typical absolute path like "C:\Windows" or "D:" @@ -244,7 +245,7 @@ FilePath FilePath::ConcatPaths(const FilePath& directory, // Returns true if pathname describes something findable in the file-system, // either a file, directory, or whatever. bool FilePath::FileOrDirectoryExists() const { -#if GTEST_OS_WINDOWS_MOBILE +#ifdef GTEST_OS_WINDOWS_MOBILE LPCWSTR unicode = String::AnsiToUtf16(pathname_.c_str()); const DWORD attributes = GetFileAttributes(unicode); delete[] unicode; @@ -259,7 +260,7 @@ bool FilePath::FileOrDirectoryExists() const { // that exists. bool FilePath::DirectoryExists() const { bool result = false; -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS // Don't strip off trailing separator if path is a root directory on // Windows (like "C:\\"). const FilePath& path(IsRootDirectory() ? *this @@ -268,7 +269,7 @@ bool FilePath::DirectoryExists() const { const FilePath& path(*this); #endif -#if GTEST_OS_WINDOWS_MOBILE +#ifdef GTEST_OS_WINDOWS_MOBILE LPCWSTR unicode = String::AnsiToUtf16(path.c_str()); const DWORD attributes = GetFileAttributes(unicode); delete[] unicode; @@ -344,14 +345,15 @@ bool FilePath::CreateDirectoriesRecursively() const { // directory for any reason, including if the parent directory does not // exist. Not named "CreateDirectory" because that's a macro on Windows. bool FilePath::CreateFolder() const { -#if GTEST_OS_WINDOWS_MOBILE +#ifdef GTEST_OS_WINDOWS_MOBILE FilePath removed_sep(this->RemoveTrailingPathSeparator()); LPCWSTR unicode = String::AnsiToUtf16(removed_sep.c_str()); int result = CreateDirectory(unicode, nullptr) ? 0 : -1; delete[] unicode; -#elif GTEST_OS_WINDOWS +#elif defined(GTEST_OS_WINDOWS) int result = _mkdir(pathname_.c_str()); -#elif GTEST_OS_ESP8266 || GTEST_OS_XTENSA || GTEST_OS_QURT +#elif defined(GTEST_OS_ESP8266) || defined(GTEST_OS_XTENSA) || \ + defined(GTEST_OS_QURT) // do nothing int result = 0; #else @@ -380,7 +382,7 @@ void FilePath::Normalize() { auto out = pathname_.begin(); auto i = pathname_.cbegin(); -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS // UNC paths are treated specially if (pathname_.end() - i >= 3 && IsPathSeparator(*i) && IsPathSeparator(*(i + 1)) && !IsPathSeparator(*(i + 2))) { diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h index 9fbcfd34a..036c3415a 100644 --- a/googletest/src/gtest-internal-inl.h +++ b/googletest/src/gtest-internal-inl.h @@ -55,7 +55,7 @@ #include // NOLINT #endif -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS #include // NOLINT #endif // GTEST_OS_WINDOWS @@ -384,7 +384,7 @@ class GTEST_API_ UnitTestOptions { static bool FilterMatchesTest(const std::string& test_suite_name, const std::string& test_name); -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS // Function for supporting the gtest_catch_exception flag. // Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc index 105a3ec8c..da4d12d8a 100644 --- a/googletest/src/gtest-port.cc +++ b/googletest/src/gtest-port.cc @@ -38,7 +38,7 @@ #include #include -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS #include #include #include @@ -51,32 +51,34 @@ #include #endif // GTEST_OS_WINDOWS -#if GTEST_OS_MAC +#ifdef GTEST_OS_MAC #include #include #include #endif // GTEST_OS_MAC -#if GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD || \ - GTEST_OS_NETBSD || GTEST_OS_OPENBSD +#if defined(GTEST_OS_DRAGONFLY) || defined(GTEST_OS_FREEBSD) || \ + defined(GTEST_OS_GNU_KFREEBSD) || defined(GTEST_OS_NETBSD) || \ + defined(GTEST_OS_OPENBSD) #include -#if GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD +#if defined(GTEST_OS_DRAGONFLY) || defined(GTEST_OS_FREEBSD) || \ + defined(GTEST_OS_GNU_KFREEBSD) #include #endif #endif -#if GTEST_OS_QNX +#ifdef GTEST_OS_QNX #include #include #include #endif // GTEST_OS_QNX -#if GTEST_OS_AIX +#ifdef GTEST_OS_AIX #include #include #endif // GTEST_OS_AIX -#if GTEST_OS_FUCHSIA +#ifdef GTEST_OS_FUCHSIA #include #include #endif // GTEST_OS_FUCHSIA @@ -90,7 +92,7 @@ namespace testing { namespace internal { -#if GTEST_OS_LINUX || GTEST_OS_GNU_HURD +#if defined(GTEST_OS_LINUX) || defined(GTEST_OS_GNU_HURD) namespace { template @@ -113,7 +115,7 @@ size_t GetThreadCount() { return ReadProcFileField(filename, 19); } -#elif GTEST_OS_MAC +#elif defined(GTEST_OS_MAC) size_t GetThreadCount() { const task_t task = mach_task_self(); @@ -131,20 +133,20 @@ size_t GetThreadCount() { } } -#elif GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD || \ - GTEST_OS_NETBSD +#elif defined(GTEST_OS_DRAGONFLY) || defined(GTEST_OS_FREEBSD) || \ + defined(GTEST_OS_GNU_KFREEBSD) || defined(GTEST_OS_NETBSD) -#if GTEST_OS_NETBSD +#ifdef GTEST_OS_NETBSD #undef KERN_PROC #define KERN_PROC KERN_PROC2 #define kinfo_proc kinfo_proc2 #endif -#if GTEST_OS_DRAGONFLY +#ifdef GTEST_OS_DRAGONFLY #define KP_NLWP(kp) (kp.kp_nthreads) -#elif GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD +#elif defined(GTEST_OS_FREEBSD) || defined(GTEST_OS_GNU_KFREEBSD) #define KP_NLWP(kp) (kp.ki_numthreads) -#elif GTEST_OS_NETBSD +#elif defined(GTEST_OS_NETBSD) #define KP_NLWP(kp) (kp.p_nlwps) #endif @@ -156,7 +158,7 @@ size_t GetThreadCount() { KERN_PROC, KERN_PROC_PID, getpid(), -#if GTEST_OS_NETBSD +#ifdef GTEST_OS_NETBSD sizeof(struct kinfo_proc), 1, #endif @@ -169,7 +171,7 @@ size_t GetThreadCount() { } return static_cast(KP_NLWP(info)); } -#elif GTEST_OS_OPENBSD +#elif defined(GTEST_OS_OPENBSD) // Returns the number of threads running in the process, or 0 to indicate that // we cannot detect it. @@ -206,7 +208,7 @@ size_t GetThreadCount() { return nthreads; } -#elif GTEST_OS_QNX +#elif defined(GTEST_OS_QNX) // Returns the number of threads running in the process, or 0 to indicate that // we cannot detect it. @@ -226,7 +228,7 @@ size_t GetThreadCount() { } } -#elif GTEST_OS_AIX +#elif defined(GTEST_OS_AIX) size_t GetThreadCount() { struct procentry64 entry; @@ -239,7 +241,7 @@ size_t GetThreadCount() { } } -#elif GTEST_OS_FUCHSIA +#elif defined(GTEST_OS_FUCHSIA) size_t GetThreadCount() { int dummy_buffer; @@ -264,7 +266,7 @@ size_t GetThreadCount() { #endif // GTEST_OS_LINUX -#if GTEST_IS_THREADSAFE && GTEST_OS_WINDOWS +#if defined(GTEST_IS_THREADSAFE) && defined(GTEST_OS_WINDOWS) AutoHandle::AutoHandle() : handle_(INVALID_HANDLE_VALUE) {} @@ -1027,7 +1029,7 @@ class CapturedStream { public: // The ctor redirects the stream to a temporary file. explicit CapturedStream(int fd) : fd_(fd), uncaptured_fd_(dup(fd)) { -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS char temp_dir_path[MAX_PATH + 1] = {'\0'}; // NOLINT char temp_file_path[MAX_PATH + 1] = {'\0'}; // NOLINT @@ -1046,7 +1048,7 @@ class CapturedStream { // directory, so we create the temporary file in a temporary directory. std::string name_template; -#if GTEST_OS_LINUX_ANDROID +#ifdef GTEST_OS_LINUX_ANDROID // Note: Android applications are expected to call the framework's // Context.getExternalStorageDirectory() method through JNI to get // the location of the world-writable SD Card directory. However, @@ -1059,7 +1061,7 @@ class CapturedStream { // '/sdcard' and other variants cannot be relied on, as they are not // guaranteed to be mounted, or may have a delay in mounting. name_template = "/data/local/tmp/"; -#elif GTEST_OS_IOS +#elif defined(GTEST_OS_IOS) char user_temp_dir[PATH_MAX + 1]; // Documented alternative to NSTemporaryDirectory() (for obtaining creating @@ -1246,7 +1248,7 @@ void ClearInjectableArgvs() { } #endif // GTEST_HAS_DEATH_TEST -#if GTEST_OS_WINDOWS_MOBILE +#ifdef GTEST_OS_WINDOWS_MOBILE namespace posix { void Abort() { DebugBreak(); diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index fb578d586..88bbcd201 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -61,7 +61,7 @@ #include "gtest/internal/custom/gtest.h" #include "gtest/internal/gtest-port.h" -#if GTEST_OS_LINUX +#ifdef GTEST_OS_LINUX #include // NOLINT #include // NOLINT @@ -74,18 +74,18 @@ #include -#elif GTEST_OS_ZOS +#elif defined(GTEST_OS_ZOS) #include // NOLINT // On z/OS we additionally need strings.h for strcasecmp. #include // NOLINT -#elif GTEST_OS_WINDOWS_MOBILE // We are on Windows CE. +#elif defined(GTEST_OS_WINDOWS_MOBILE) // We are on Windows CE. #include // NOLINT #undef min -#elif GTEST_OS_WINDOWS // We are on Windows proper. +#elif defined(GTEST_OS_WINDOWS) // We are on Windows proper. #include // NOLINT #undef min @@ -99,7 +99,7 @@ #include // NOLINT #include // NOLINT -#if GTEST_OS_WINDOWS_MINGW +#ifdef GTEST_OS_WINDOWS_MINGW #include // NOLINT #endif // GTEST_OS_WINDOWS_MINGW @@ -125,11 +125,11 @@ #include "src/gtest-internal-inl.h" -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS #define vsnprintf _vsnprintf #endif // GTEST_OS_WINDOWS -#if GTEST_OS_MAC +#ifdef GTEST_OS_MAC #ifndef GTEST_OS_IOS #include #endif @@ -630,7 +630,7 @@ static ::std::vector g_argvs; FilePath GetCurrentExecutableName() { FilePath result; -#if GTEST_OS_WINDOWS || GTEST_OS_OS2 +#if defined(GTEST_OS_WINDOWS) || defined(GTEST_OS_OS2) result.Set(FilePath(GetArgvs()[0]).RemoveExtension("exe")); #else result.Set(FilePath(GetArgvs()[0])); @@ -1165,7 +1165,7 @@ TimeInMillis GetTimeInMillis() { // class String. -#if GTEST_OS_WINDOWS_MOBILE +#ifdef GTEST_OS_WINDOWS_MOBILE // Creates a UTF-16 wide string from the given ANSI string, allocating // memory using new. The caller is responsible for deleting the return // value using delete[]. Returns the wide string, or NULL if the @@ -1867,14 +1867,14 @@ AssertionResult IsNotSubstring(const char* needle_expr, namespace internal { -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS namespace { // Helper function for IsHRESULT{SuccessFailure} predicates AssertionResult HRESULTFailureHelper(const char* expr, const char* expected, long hr) { // NOLINT -#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_TV_TITLE +#if defined(GTEST_OS_WINDOWS_MOBILE) || defined(GTEST_OS_WINDOWS_TV_TITLE) // Windows CE doesn't support FormatMessage. const char error_text[] = ""; @@ -2135,9 +2135,9 @@ bool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs, if (rhs == nullptr) return false; -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS return _wcsicmp(lhs, rhs) == 0; -#elif GTEST_OS_LINUX && !GTEST_OS_LINUX_ANDROID +#elif defined(GTEST_OS_LINUX) && !defined(GTEST_OS_LINUX_ANDROID) return wcscasecmp(lhs, rhs) == 0; #else // Android, Mac OS X and Cygwin don't define wcscasecmp. @@ -3144,7 +3144,7 @@ static void PrintTestPartResult(const TestPartResult& test_part_result) { // following statements add the test part result message to the Output // window such that the user can double-click on it to jump to the // corresponding source code location; otherwise they do nothing. -#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE +#if defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_MOBILE) // We don't call OutputDebugString*() on Windows Mobile, as printing // to stdout is done by OutputDebugString() there already - we don't // want the same message printed twice. @@ -3154,8 +3154,9 @@ static void PrintTestPartResult(const TestPartResult& test_part_result) { } // class PrettyUnitTestResultPrinter -#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && \ - !GTEST_OS_WINDOWS_RT && !GTEST_OS_WINDOWS_MINGW +#if defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_MOBILE) && \ + !defined(GTEST_OS_WINDOWS_PHONE) && !defined(GTEST_OS_WINDOWS_RT) && \ + !defined(GTEST_OS_WINDOWS_MINGW) // Returns the character attribute for the given color. static WORD GetColorAttribute(GTestColor color) { @@ -3227,7 +3228,7 @@ bool ShouldUseColor(bool stdout_is_tty) { const char* const gtest_color = c.c_str(); if (String::CaseInsensitiveCStringEquals(gtest_color, "auto")) { -#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW +#if defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_MINGW) // On Windows the TERM variable is usually not set, but the // console there does support colors. return stdout_is_tty; @@ -3282,8 +3283,9 @@ static void ColoredPrintf(GTestColor color, const char* fmt, ...) { return; } -#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && \ - !GTEST_OS_WINDOWS_RT && !GTEST_OS_WINDOWS_MINGW +#if defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_MOBILE) && \ + !defined(GTEST_OS_WINDOWS_PHONE) && !defined(GTEST_OS_WINDOWS_RT) && \ + !defined(GTEST_OS_WINDOWS_MINGW) const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE); // Gets the current text color. @@ -5036,7 +5038,7 @@ class ScopedPrematureExitFile { } ~ScopedPrematureExitFile() { -#if !GTEST_OS_ESP8266 +#ifndef GTEST_OS_ESP8266 if (!premature_exit_filepath_.empty()) { int retval = remove(premature_exit_filepath_.c_str()); if (retval) { @@ -5332,7 +5334,8 @@ void UnitTest::AddTestPartResult(TestPartResult::Type result_type, // with another testing framework) and specify the former on the // command line for debugging. if (GTEST_FLAG_GET(break_on_failure)) { -#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT +#if defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_PHONE) && \ + !defined(GTEST_OS_WINDOWS_RT) // Using DebugBreak on Windows allows gtest to still break into a debugger // when a failure happens and both the --gtest_break_on_failure and // the --gtest_catch_exceptions flags are specified. @@ -5417,26 +5420,28 @@ int UnitTest::Run() { // used for the duration of the program. impl()->set_catch_exceptions(GTEST_FLAG_GET(catch_exceptions)); -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS // Either the user wants Google Test to catch exceptions thrown by the // tests or this is executing in the context of death test child // process. In either case the user does not want to see pop-up dialogs // about crashes - they are expected. if (impl()->catch_exceptions() || in_death_test_child_process) { -#if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT +#if !defined(GTEST_OS_WINDOWS_MOBILE) && !defined(GTEST_OS_WINDOWS_PHONE) && \ + !defined(GTEST_OS_WINDOWS_RT) // SetErrorMode doesn't exist on CE. SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX); #endif // !GTEST_OS_WINDOWS_MOBILE -#if (defined(_MSC_VER) || GTEST_OS_WINDOWS_MINGW) && !GTEST_OS_WINDOWS_MOBILE +#if (defined(_MSC_VER) || defined(GTEST_OS_WINDOWS_MINGW)) && \ + !defined(GTEST_OS_WINDOWS_MOBILE) // Death test children can be terminated with _abort(). On Windows, // _abort() can show a dialog with a warning message. This forces the // abort message to go to stderr instead. _set_error_mode(_OUT_TO_STDERR); #endif -#if defined(_MSC_VER) && !GTEST_OS_WINDOWS_MOBILE +#if defined(_MSC_VER) && !defined(GTEST_OS_WINDOWS_MOBILE) // In the debug version, Visual Studio pops up a separate dialog // offering a choice to debug the aborted program. We need to suppress // this dialog or it will pop up for every EXPECT/ASSERT_DEATH statement @@ -6520,7 +6525,7 @@ static const char kColorEncodedHelpMessage[] = #endif // GTEST_CAN_STREAM_RESULTS_ "\n" "Assertion Behavior:\n" -#if GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS +#if defined(GTEST_HAS_DEATH_TEST) && !defined(GTEST_OS_WINDOWS) " @G--" GTEST_FLAG_PREFIX_ "death_test_style=@Y(@Gfast@Y|@Gthreadsafe@Y)@D\n" " Set the default death test style.\n" @@ -6687,7 +6692,7 @@ void ParseGoogleTestFlagsOnly(int* argc, char** argv) { // Fix the value of *_NSGetArgc() on macOS, but if and only if // *_NSGetArgv() == argv // Only applicable to char** version of argv -#if GTEST_OS_MAC +#ifdef GTEST_OS_MAC #ifndef GTEST_OS_IOS if (*_NSGetArgv() == argv) { *_NSGetArgc() = *argc; @@ -6799,9 +6804,9 @@ static std::string GetDirFromEnv( std::string TempDir() { #if defined(GTEST_CUSTOM_TEMPDIR_FUNCTION_) return GTEST_CUSTOM_TEMPDIR_FUNCTION_(); -#elif GTEST_OS_WINDOWS || GTEST_OS_WINDOWS_MOBILE +#elif defined(GTEST_OS_WINDOWS) || defined(GTEST_OS_WINDOWS_MOBILE) return GetDirFromEnv({"TEST_TMPDIR", "TEMP"}, "\\temp\\", '\\'); -#elif GTEST_OS_LINUX_ANDROID +#elif defined(GTEST_OS_LINUX_ANDROID) return GetDirFromEnv({"TEST_TMPDIR", "TMPDIR"}, "/data/local/tmp/", '/'); #else return GetDirFromEnv({"TEST_TMPDIR", "TMPDIR"}, "/tmp/", '/'); @@ -6821,10 +6826,10 @@ static std::string GetCurrentExecutableDirectory() { std::string SrcDir() { #if defined(GTEST_CUSTOM_SRCDIR_FUNCTION_) return GTEST_CUSTOM_SRCDIR_FUNCTION_(); -#elif GTEST_OS_WINDOWS || GTEST_OS_WINDOWS_MOBILE +#elif defined(GTEST_OS_WINDOWS) || defined(GTEST_OS_WINDOWS_MOBILE) return GetDirFromEnv({"TEST_SRCDIR"}, GetCurrentExecutableDirectory().c_str(), '\\'); -#elif GTEST_OS_LINUX_ANDROID +#elif defined(GTEST_OS_LINUX_ANDROID) return GetDirFromEnv({"TEST_SRCDIR"}, GetCurrentExecutableDirectory().c_str(), '/'); #else diff --git a/googletest/src/gtest_main.cc b/googletest/src/gtest_main.cc index 5abaa29fa..c2e3b3cc9 100644 --- a/googletest/src/gtest_main.cc +++ b/googletest/src/gtest_main.cc @@ -31,10 +31,10 @@ #include "gtest/gtest.h" -#if GTEST_OS_ESP8266 || GTEST_OS_ESP32 +#if defined(GTEST_OS_ESP8266) || defined(GTEST_OS_ESP32) // Arduino-like platforms: program entry points are setup/loop instead of main. -#if GTEST_OS_ESP8266 +#ifdef GTEST_OS_ESP8266 extern "C" { #endif @@ -42,11 +42,11 @@ void setup() { testing::InitGoogleTest(); } void loop() { RUN_ALL_TESTS(); } -#if GTEST_OS_ESP8266 +#ifdef GTEST_OS_ESP8266 } #endif -#elif GTEST_OS_QURT +#elif defined(GTEST_OS_QURT) // QuRT: program entry point is main, but argc/argv are unusable. GTEST_API_ int main() { diff --git a/googletest/test/googletest-break-on-failure-unittest_.cc b/googletest/test/googletest-break-on-failure-unittest_.cc index 324294f33..337e34c33 100644 --- a/googletest/test/googletest-break-on-failure-unittest_.cc +++ b/googletest/test/googletest-break-on-failure-unittest_.cc @@ -39,7 +39,7 @@ #include "gtest/gtest.h" -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS #include #include #endif @@ -49,7 +49,7 @@ namespace { // A test that's expected to fail. TEST(Foo, Bar) { EXPECT_EQ(2, 3); } -#if GTEST_HAS_SEH && !GTEST_OS_WINDOWS_MOBILE +#if GTEST_HAS_SEH && !defined(GTEST_OS_WINDOWS_MOBILE) // On Windows Mobile global exception handlers are not supported. LONG WINAPI ExitWithExceptionCode(struct _EXCEPTION_POINTERS* exception_pointers) { @@ -60,12 +60,12 @@ ExitWithExceptionCode(struct _EXCEPTION_POINTERS* exception_pointers) { } // namespace int main(int argc, char** argv) { -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS // Suppresses display of the Windows error dialog upon encountering // a general protection fault (segment violation). SetErrorMode(SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS); -#if GTEST_HAS_SEH && !GTEST_OS_WINDOWS_MOBILE +#if GTEST_HAS_SEH && !defined(GTEST_OS_WINDOWS_MOBILE) // The default unhandled exception filter does not always exit // with the exception code as exit code - for example it exits with diff --git a/googletest/test/googletest-death-test-test.cc b/googletest/test/googletest-death-test-test.cc index 515b59986..a361a5741 100644 --- a/googletest/test/googletest-death-test-test.cc +++ b/googletest/test/googletest-death-test-test.cc @@ -39,7 +39,7 @@ using testing::internal::AlwaysTrue; #if GTEST_HAS_DEATH_TEST -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS #include // For chdir(). #include // For O_BINARY #include @@ -52,7 +52,7 @@ using testing::internal::AlwaysTrue; #include #include -#if GTEST_OS_LINUX +#ifdef GTEST_OS_LINUX #include #endif // GTEST_OS_LINUX @@ -200,7 +200,7 @@ int DieInDebugElse12(int* sideeffect) { return 12; } -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS // Death in dbg due to Windows CRT assertion failure, not opt. int DieInCRTDebugElse12(int* sideeffect) { @@ -220,7 +220,7 @@ int DieInCRTDebugElse12(int* sideeffect) { #endif // GTEST_OS_WINDOWS -#if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA +#if defined(GTEST_OS_WINDOWS) || defined(GTEST_OS_FUCHSIA) // Tests the ExitedWithCode predicate. TEST(ExitStatusPredicateTest, ExitedWithCode) { @@ -374,7 +374,7 @@ TEST_F(TestForDeathTest, FastDeathTestInChangedDir) { ASSERT_DEATH(_exit(1), ""); } -#if GTEST_OS_LINUX +#ifdef GTEST_OS_LINUX void SigprofAction(int, siginfo_t*, void*) { /* no op */ } @@ -641,7 +641,7 @@ TEST_F(TestForDeathTest, TestExpectDebugDeath) { #endif } -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS // https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/crtsetreportmode // In debug mode, the calls to _CrtSetReportMode and _CrtSetReportFile enable @@ -693,7 +693,7 @@ void ExpectDebugDeathHelper(bool* aborted) { *aborted = false; } -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS TEST(PopUpDeathTest, DoesNotShowPopUpOnAbort) { printf( "This test should be considered failing if it shows " @@ -805,14 +805,14 @@ static void TestExitMacros() { EXPECT_EXIT(_exit(1), testing::ExitedWithCode(1), ""); ASSERT_EXIT(_exit(42), testing::ExitedWithCode(42), ""); -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS // Of all signals effects on the process exit code, only those of SIGABRT // are documented on Windows. // See https://msdn.microsoft.com/en-us/query-bi/m/dwwzkt4c. EXPECT_EXIT(raise(SIGABRT), testing::ExitedWithCode(3), "") << "b_ar"; -#elif !GTEST_OS_FUCHSIA +#elif !defined(GTEST_OS_FUCHSIA) // Fuchsia has no unix signals. EXPECT_EXIT(raise(SIGKILL), testing::KilledBySignal(SIGKILL), "") << "foo"; @@ -1177,7 +1177,7 @@ TEST(GetLastErrnoDescription, GetLastErrnoDescriptionWorks) { EXPECT_STREQ("", GetLastErrnoDescription().c_str()); } -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS TEST(AutoHandleTest, AutoHandleWorks) { HANDLE handle = ::CreateEvent(NULL, FALSE, FALSE, NULL); ASSERT_NE(INVALID_HANDLE_VALUE, handle); @@ -1204,7 +1204,7 @@ TEST(AutoHandleTest, AutoHandleWorks) { } #endif // GTEST_OS_WINDOWS -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS typedef unsigned __int64 BiggestParsable; typedef signed __int64 BiggestSignedParsable; #else @@ -1301,7 +1301,7 @@ TEST(ParseNaturalNumberTest, WorksForShorterIntegers) { EXPECT_EQ(123, char_result); } -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS TEST(EnvironmentTest, HandleFitsIntoSizeT) { ASSERT_TRUE(sizeof(HANDLE) <= sizeof(size_t)); } diff --git a/googletest/test/googletest-filepath-test.cc b/googletest/test/googletest-filepath-test.cc index 5f0c9c2fb..0a33d7140 100644 --- a/googletest/test/googletest-filepath-test.cc +++ b/googletest/test/googletest-filepath-test.cc @@ -41,9 +41,9 @@ #include "gtest/internal/gtest-filepath.h" #include "src/gtest-internal-inl.h" -#if GTEST_OS_WINDOWS_MOBILE +#ifdef GTEST_OS_WINDOWS_MOBILE #include // NOLINT -#elif GTEST_OS_WINDOWS +#elif defined(GTEST_OS_WINDOWS) #include // NOLINT #endif // GTEST_OS_WINDOWS_MOBILE @@ -51,7 +51,7 @@ namespace testing { namespace internal { namespace { -#if GTEST_OS_WINDOWS_MOBILE +#ifdef GTEST_OS_WINDOWS_MOBILE // Windows CE doesn't have the remove C function. int remove(const char* path) { @@ -80,7 +80,7 @@ TEST(GetCurrentDirTest, ReturnsCurrentDir) { const FilePath cwd = FilePath::GetCurrentDir(); posix::ChDir(original_dir.c_str()); -#if GTEST_OS_WINDOWS || GTEST_OS_OS2 +#if defined(GTEST_OS_WINDOWS) || defined(GTEST_OS_OS2) // Skips the ":". const char* const cwd_without_drive = strchr(cwd.c_str(), ':'); @@ -174,7 +174,7 @@ TEST(RemoveDirectoryNameTest, ShouldAlsoGiveFileNameForAlternateSeparator) { // RemoveFileName "" -> "./" TEST(RemoveFileNameTest, EmptyName) { -#if GTEST_OS_WINDOWS_MOBILE +#ifdef GTEST_OS_WINDOWS_MOBILE // On Windows CE, we use the root as the current directory. EXPECT_EQ(GTEST_PATH_SEP_, FilePath("").RemoveFileName().string()); #else @@ -357,7 +357,7 @@ TEST(RemoveTrailingPathSeparatorTest, ShouldReturnUnmodified) { } TEST(DirectoryTest, RootDirectoryExists) { -#if GTEST_OS_WINDOWS // We are on Windows. +#ifdef GTEST_OS_WINDOWS // We are on Windows. char current_drive[_MAX_PATH]; // NOLINT current_drive[0] = static_cast(_getdrive() + 'A' - 1); current_drive[1] = ':'; @@ -369,7 +369,7 @@ TEST(DirectoryTest, RootDirectoryExists) { #endif // GTEST_OS_WINDOWS } -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS TEST(DirectoryTest, RootOfWrongDriveDoesNotExists) { const int saved_drive_ = _getdrive(); // Find a drive that doesn't exist. Start with 'Z' to avoid common ones. @@ -387,7 +387,7 @@ TEST(DirectoryTest, RootOfWrongDriveDoesNotExists) { } #endif // GTEST_OS_WINDOWS -#if !GTEST_OS_WINDOWS_MOBILE +#ifndef GTEST_OS_WINDOWS_MOBILE // Windows CE _does_ consider an empty directory to exist. TEST(DirectoryTest, EmptyPathDirectoryDoesNotExist) { EXPECT_FALSE(FilePath("").DirectoryExists()); @@ -395,7 +395,7 @@ TEST(DirectoryTest, EmptyPathDirectoryDoesNotExist) { #endif // !GTEST_OS_WINDOWS_MOBILE TEST(DirectoryTest, CurrentDirectoryExists) { -#if GTEST_OS_WINDOWS // We are on Windows. +#ifdef GTEST_OS_WINDOWS // We are on Windows. #ifndef _WIN32_CE // Windows CE doesn't have a current directory. EXPECT_TRUE(FilePath(".").DirectoryExists()); @@ -423,7 +423,7 @@ TEST(NormalizeTest, MultipleConsecutiveSeparatorsInMidstring) { // "/bar" == //bar" == "///bar" TEST(NormalizeTest, MultipleConsecutiveSeparatorsAtStringStart) { EXPECT_EQ(GTEST_PATH_SEP_ "bar", FilePath(GTEST_PATH_SEP_ "bar").string()); -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS EXPECT_EQ(GTEST_PATH_SEP_ GTEST_PATH_SEP_ "bar", FilePath(GTEST_PATH_SEP_ GTEST_PATH_SEP_ "bar").string()); #else @@ -620,7 +620,7 @@ TEST(FilePathTest, IsDirectory) { TEST(FilePathTest, IsAbsolutePath) { EXPECT_FALSE(FilePath("is" GTEST_PATH_SEP_ "relative").IsAbsolutePath()); EXPECT_FALSE(FilePath("").IsAbsolutePath()); -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS EXPECT_TRUE( FilePath("c:\\" GTEST_PATH_SEP_ "is_not" GTEST_PATH_SEP_ "relative") .IsAbsolutePath()); @@ -638,7 +638,7 @@ TEST(FilePathTest, IsAbsolutePath) { } TEST(FilePathTest, IsRootDirectory) { -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS EXPECT_TRUE(FilePath("a:\\").IsRootDirectory()); EXPECT_TRUE(FilePath("Z:/").IsRootDirectory()); EXPECT_TRUE(FilePath("e://").IsRootDirectory()); diff --git a/googletest/test/googletest-options-test.cc b/googletest/test/googletest-options-test.cc index 874632098..b712c06fa 100644 --- a/googletest/test/googletest-options-test.cc +++ b/googletest/test/googletest-options-test.cc @@ -40,11 +40,11 @@ #include "gtest/gtest.h" -#if GTEST_OS_WINDOWS_MOBILE +#ifdef GTEST_OS_WINDOWS_MOBILE #include -#elif GTEST_OS_WINDOWS +#elif defined(GTEST_OS_WINDOWS) #include -#elif GTEST_OS_OS2 +#elif defined(GTEST_OS_OS2) // For strcasecmp on OS/2 #include #endif // GTEST_OS_WINDOWS_MOBILE @@ -92,7 +92,7 @@ TEST(XmlOutputTest, GetOutputFileFromDirectoryPath) { .string(); const std::string& output_file = UnitTestOptions::GetAbsolutePathToOutputFile(); -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS EXPECT_STRCASEEQ(expected_output_file.c_str(), output_file.c_str()); #else EXPECT_EQ(expected_output_file, output_file.c_str()); @@ -101,19 +101,19 @@ TEST(XmlOutputTest, GetOutputFileFromDirectoryPath) { TEST(OutputFileHelpersTest, GetCurrentExecutableName) { const std::string exe_str = GetCurrentExecutableName().string(); -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS const bool success = _strcmpi("googletest-options-test", exe_str.c_str()) == 0 || _strcmpi("gtest-options-ex_test", exe_str.c_str()) == 0 || _strcmpi("gtest_all_test", exe_str.c_str()) == 0 || _strcmpi("gtest_dll_test", exe_str.c_str()) == 0; -#elif GTEST_OS_OS2 +#elif defined(GTEST_OS_OS2) const bool success = strcasecmp("googletest-options-test", exe_str.c_str()) == 0 || strcasecmp("gtest-options-ex_test", exe_str.c_str()) == 0 || strcasecmp("gtest_all_test", exe_str.c_str()) == 0 || strcasecmp("gtest_dll_test", exe_str.c_str()) == 0; -#elif GTEST_OS_FUCHSIA +#elif defined(GTEST_OS_FUCHSIA) const bool success = exe_str == "app"; #else const bool success = @@ -123,7 +123,7 @@ TEST(OutputFileHelpersTest, GetCurrentExecutableName) { if (!success) FAIL() << "GetCurrentExecutableName() returns " << exe_str; } -#if !GTEST_OS_FUCHSIA +#ifndef GTEST_OS_FUCHSIA class XmlOutputChangeDirTest : public Test { protected: @@ -176,7 +176,7 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativePath) { .string(); const std::string& output_file = UnitTestOptions::GetAbsolutePathToOutputFile(); -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS EXPECT_STRCASEEQ(expected_output_file.c_str(), output_file.c_str()); #else EXPECT_EQ(expected_output_file, output_file.c_str()); @@ -184,7 +184,7 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativePath) { } TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsoluteFile) { -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS GTEST_FLAG_SET(output, "xml:c:\\tmp\\filename.abc"); EXPECT_EQ(FilePath("c:\\tmp\\filename.abc").string(), UnitTestOptions::GetAbsolutePathToOutputFile()); @@ -196,7 +196,7 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsoluteFile) { } TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsolutePath) { -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS const std::string path = "c:\\tmp\\"; #else const std::string path = "/tmp/"; @@ -208,7 +208,7 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsolutePath) { const std::string& output_file = UnitTestOptions::GetAbsolutePathToOutputFile(); -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS EXPECT_STRCASEEQ(expected_output_file.c_str(), output_file.c_str()); #else EXPECT_EQ(expected_output_file, output_file.c_str()); diff --git a/googletest/test/googletest-output-test_.cc b/googletest/test/googletest-output-test_.cc index 1bace982e..090fb070b 100644 --- a/googletest/test/googletest-output-test_.cc +++ b/googletest/test/googletest-output-test_.cc @@ -1028,7 +1028,7 @@ int main(int argc, char** argv) { if (GTEST_FLAG_GET(internal_run_death_test) != "") { // Skip the usual output capturing if we're running as the child // process of an threadsafe-style death test. -#if GTEST_OS_WINDOWS +#if defined(GTEST_OS_WINDOWS) posix::FReopen("nul:", "w", stdout); #else posix::FReopen("/dev/null", "w", stdout); diff --git a/googletest/test/googletest-port-test.cc b/googletest/test/googletest-port-test.cc index bb536ac54..a93572a93 100644 --- a/googletest/test/googletest-port-test.cc +++ b/googletest/test/googletest-port-test.cc @@ -32,7 +32,7 @@ #include "gtest/internal/gtest-port.h" -#if GTEST_OS_MAC +#ifdef GTEST_OS_MAC #include #endif // GTEST_OS_MAC @@ -281,9 +281,11 @@ TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownFileAndLine) { EXPECT_EQ("unknown file", FormatCompilerIndependentFileLocation(nullptr, -1)); } -#if GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_QNX || GTEST_OS_FUCHSIA || \ - GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD || \ - GTEST_OS_NETBSD || GTEST_OS_OPENBSD || GTEST_OS_GNU_HURD +#if defined(GTEST_OS_LINUX) || defined(GTEST_OS_MAC) || \ + defined(GTEST_OS_QNX) || defined(GTEST_OS_FUCHSIA) || \ + defined(GTEST_OS_DRAGONFLY) || defined(GTEST_OS_FREEBSD) || \ + defined(GTEST_OS_GNU_KFREEBSD) || defined(GTEST_OS_NETBSD) || \ + defined(GTEST_OS_OPENBSD) || defined(GTEST_OS_GNU_HURD) void* ThreadFunc(void* data) { internal::Mutex* mutex = static_cast(data); mutex->Lock(); @@ -916,7 +918,7 @@ TEST(RETest, PartialMatchWorks) { #endif // GTEST_USES_POSIX_RE -#if !GTEST_OS_WINDOWS_MOBILE +#ifndef GTEST_OS_WINDOWS_MOBILE TEST(CaptureTest, CapturesStdout) { CaptureStdout(); @@ -1064,7 +1066,7 @@ class AtomicCounterWithMutex { GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_unlock(&memory_barrier_mutex)); GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_destroy(&memory_barrier_mutex)); -#elif GTEST_OS_WINDOWS +#elif defined(GTEST_OS_WINDOWS) // On Windows, performing an interlocked access puts up a memory barrier. volatile LONG dummy = 0; ::InterlockedIncrement(&dummy); @@ -1146,14 +1148,14 @@ class DestructorCall { public: DestructorCall() { invoked_ = false; -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS wait_event_.Reset(::CreateEvent(NULL, TRUE, FALSE, NULL)); GTEST_CHECK_(wait_event_.Get() != NULL); #endif } bool CheckDestroyed() const { -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS if (::WaitForSingleObject(wait_event_.Get(), 1000) != WAIT_OBJECT_0) return false; #endif @@ -1162,7 +1164,7 @@ class DestructorCall { void ReportDestroyed() { invoked_ = true; -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS ::SetEvent(wait_event_.Get()); #endif } @@ -1178,7 +1180,7 @@ class DestructorCall { private: bool invoked_; -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS AutoHandle wait_event_; #endif static std::vector* const list_; @@ -1278,12 +1280,12 @@ TEST(ThreadLocalTest, ThreadLocalMutationsAffectOnlyCurrentThread) { #endif // GTEST_IS_THREADSAFE -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS TEST(WindowsTypesTest, HANDLEIsVoidStar) { StaticAssertTypeEq(); } -#if GTEST_OS_WINDOWS_MINGW && !defined(__MINGW64_VERSION_MAJOR) +#if defined(GTEST_OS_WINDOWS_MINGW) && !defined(__MINGW64_VERSION_MAJOR) TEST(WindowsTypesTest, _CRITICAL_SECTIONIs_CRITICAL_SECTION) { StaticAssertTypeEq(); } diff --git a/googletest/test/googletest-printers-test.cc b/googletest/test/googletest-printers-test.cc index 34aa92457..fa8b084db 100644 --- a/googletest/test/googletest-printers-test.cc +++ b/googletest/test/googletest-printers-test.cc @@ -432,7 +432,7 @@ TEST(PrintBuiltInTypeTest, Integer) { // Size types. TEST(PrintBuiltInTypeTest, Size_t) { EXPECT_EQ("1", Print(sizeof('a'))); // size_t. -#if !GTEST_OS_WINDOWS +#ifndef GTEST_OS_WINDOWS // Windows has no ssize_t type. EXPECT_EQ("-2", Print(static_cast(-2))); // ssize_t. #endif // !GTEST_OS_WINDOWS diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index 580ce8379..461297abd 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -448,7 +448,7 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test { // tzset() distinguishes between the TZ variable being present and empty // and not being present, so we have to consider the case of time_zone // being NULL. -#if defined(_MSC_VER) || GTEST_OS_WINDOWS_MINGW +#if defined(_MSC_VER) || defined(GTEST_OS_WINDOWS_MINGW) // ...Unless it's MSVC, whose standard library's _putenv doesn't // distinguish between an empty and a missing variable. const std::string env_var = @@ -458,7 +458,7 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test { tzset(); GTEST_DISABLE_MSC_WARNINGS_POP_() #else -#if GTEST_OS_LINUX_ANDROID && __ANDROID_API__ < 21 +#if defined(GTEST_OS_LINUX_ANDROID) && __ANDROID_API__ < 21 // Work around KitKat bug in tzset by setting "UTC" before setting "UTC+00". // See https://github.com/android/ndk/issues/1604. setenv("TZ", "UTC", 1); @@ -1090,7 +1090,7 @@ TEST(StringTest, CaseInsensitiveWideCStringEquals) { EXPECT_TRUE(String::CaseInsensitiveWideCStringEquals(L"FOOBAR", L"foobar")); } -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS // Tests String::ShowWideCString(). TEST(StringTest, ShowWideCString) { @@ -1099,7 +1099,7 @@ TEST(StringTest, ShowWideCString) { EXPECT_STREQ("foo", String::ShowWideCString(L"foo").c_str()); } -#if GTEST_OS_WINDOWS_MOBILE +#ifdef GTEST_OS_WINDOWS_MOBILE TEST(StringTest, AnsiAndUtf16Null) { EXPECT_EQ(NULL, String::AnsiToUtf16(NULL)); EXPECT_EQ(NULL, String::Utf16ToAnsi(NULL)); @@ -1676,7 +1676,7 @@ TEST_F(GTestFlagSaverTest, VerifyGTestFlags) { VerifyAndModifyFlags(); } // value. If the value argument is "", unsets the environment // variable. The caller must ensure that both arguments are not NULL. static void SetEnv(const char* name, const char* value) { -#if GTEST_OS_WINDOWS_MOBILE +#ifdef GTEST_OS_WINDOWS_MOBILE // Environment variables are not supported on Windows CE. return; #elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9) @@ -1699,7 +1699,7 @@ static void SetEnv(const char* name, const char* value) { // We cast away the 'const' since that would work for both variants. putenv(const_cast(added_env[name]->c_str())); delete prev_env; -#elif GTEST_OS_WINDOWS // If we are on Windows proper. +#elif defined(GTEST_OS_WINDOWS) // If we are on Windows proper. _putenv((Message() << name << "=" << value).GetString().c_str()); #else if (*value == '\0') { @@ -1710,7 +1710,7 @@ static void SetEnv(const char* name, const char* value) { #endif // GTEST_OS_WINDOWS_MOBILE } -#if !GTEST_OS_WINDOWS_MOBILE +#ifndef GTEST_OS_WINDOWS_MOBILE // Environment variables are not supported on Windows CE. using testing::internal::Int32FromGTestEnv; @@ -1819,7 +1819,7 @@ TEST(ParseInt32FlagTest, ParsesAndReturnsValidValue) { // Tests that Int32FromEnvOrDie() parses the value of the var or // returns the correct default. // Environment variables are not supported on Windows CE. -#if !GTEST_OS_WINDOWS_MOBILE +#ifndef GTEST_OS_WINDOWS_MOBILE TEST(Int32FromEnvOrDieTest, ParsesAndReturnsValidValue) { EXPECT_EQ(333, Int32FromEnvOrDie(GTEST_FLAG_PREFIX_UPPER_ "UnsetVar", 333)); SetEnv(GTEST_FLAG_PREFIX_UPPER_ "UnsetVar", "123"); @@ -1892,7 +1892,7 @@ TEST_F(ShouldShardTest, ReturnsFalseWhenTotalShardIsOne) { // Tests that sharding is enabled if total_shards > 1 and // we are not in a death test subprocess. // Environment variables are not supported on Windows CE. -#if !GTEST_OS_WINDOWS_MOBILE +#ifndef GTEST_OS_WINDOWS_MOBILE TEST_F(ShouldShardTest, WorksWhenShardEnvVarsAreValid) { SetEnv(index_var_, "4"); SetEnv(total_var_, "22"); @@ -3926,7 +3926,7 @@ TEST(AssertionTest, NamedEnum) { enum { kCaseA = -1, -#if GTEST_OS_LINUX +#ifdef GTEST_OS_LINUX // We want to test the case where the size of the anonymous enum is // larger than sizeof(int), to make sure our implementation of the @@ -3949,7 +3949,7 @@ enum { }; TEST(AssertionTest, AnonymousEnum) { -#if GTEST_OS_LINUX +#ifdef GTEST_OS_LINUX EXPECT_EQ(static_cast(kCaseA), static_cast(kCaseB)); @@ -3983,7 +3983,7 @@ TEST(AssertionTest, AnonymousEnum) { #endif // !GTEST_OS_MAC && !defined(__SUNPRO_CC) -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS static HRESULT UnexpectedHRESULTFailure() { return E_UNEXPECTED; } @@ -4343,7 +4343,7 @@ TEST(AssertionWithMessageTest, ASSERT_TRUE) { "(null)(null)"); } -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS // Tests using wide strings in assertion messages. TEST(AssertionWithMessageTest, WideStringMessage) { EXPECT_NONFATAL_FAILURE( @@ -6224,7 +6224,7 @@ TEST_F(ParseFlagsTest, AbseilPositionalFlags) { } #endif -#if GTEST_OS_WINDOWS +#ifdef GTEST_OS_WINDOWS // Tests parsing wide strings. TEST_F(ParseFlagsTest, WideStrings) { const wchar_t* argv[] = {L"foo.exe", @@ -6614,7 +6614,7 @@ TEST(ColoredOutputTest, UsesColorsWhenStdoutIsTty) { TEST(ColoredOutputTest, UsesColorsWhenTermSupportsColors) { GTEST_FLAG_SET(color, "auto"); -#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW +#if defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_MINGW) // On Windows, we ignore the TERM variable as it's usually not set. SetEnv("TERM", "dumb"); From a08c03c5f52802c50a541d7283be31a4c3177807 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 3 Mar 2023 15:56:41 -0800 Subject: [PATCH 130/336] Always specify definitions for internal macros These macros should only be used within googletest, so changing them will not affect external users. This allows compiling with -Wundef (#3267). PiperOrigin-RevId: 513943800 Change-Id: I697b1005c29b0d5af06f583f202d86db48b567b9 --- .../include/gtest/internal/gtest-port.h | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index f2b0bbf9a..ba5e9bc32 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -202,16 +202,17 @@ // is suppressed. // GTEST_INTERNAL_HAS_ANY - for enabling UniversalPrinter or // UniversalPrinter specializations. +// Always defined to 0 or 1. // GTEST_INTERNAL_HAS_OPTIONAL - for enabling UniversalPrinter // or // UniversalPrinter -// specializations. +// specializations. Always defined to 0 or 1. // GTEST_INTERNAL_HAS_STRING_VIEW - for enabling Matcher or // Matcher -// specializations. +// specializations. Always defined to 0 or 1. // GTEST_INTERNAL_HAS_VARIANT - for enabling UniversalPrinter or // UniversalPrinter -// specializations. +// specializations. Always defined to 0 or 1. // // Synchronization: // Mutex, MutexLock, ThreadLocal, GetThreadCount() @@ -2389,6 +2390,10 @@ using Any = ::std::any; #endif // __has_include #endif // GTEST_HAS_ABSL +#ifndef GTEST_INTERNAL_HAS_ANY +#define GTEST_INTERNAL_HAS_ANY 0 +#endif + #if GTEST_HAS_ABSL // Always use absl::optional for UniversalPrinter<> specializations if // googletest is built with absl support. @@ -2421,6 +2426,10 @@ inline ::std::nullopt_t Nullopt() { return ::std::nullopt; } #endif // __has_include #endif // GTEST_HAS_ABSL +#ifndef GTEST_INTERNAL_HAS_OPTIONAL +#define GTEST_INTERNAL_HAS_OPTIONAL 0 +#endif + #if GTEST_HAS_ABSL // Always use absl::string_view for Matcher<> specializations if googletest // is built with absl support. @@ -2449,6 +2458,10 @@ using StringView = ::std::string_view; #endif // __has_include #endif // GTEST_HAS_ABSL +#ifndef GTEST_INTERNAL_HAS_STRING_VIEW +#define GTEST_INTERNAL_HAS_STRING_VIEW 0 +#endif + #if GTEST_HAS_ABSL // Always use absl::variant for UniversalPrinter<> specializations if googletest // is built with absl support. @@ -2478,6 +2491,10 @@ using Variant = ::std::variant; #endif // __has_include #endif // GTEST_HAS_ABSL +#ifndef GTEST_INTERNAL_HAS_VARIANT +#define GTEST_INTERNAL_HAS_VARIANT 0 +#endif + #if defined(GTEST_INTERNAL_CPLUSPLUS_LANG) && \ GTEST_INTERNAL_CPLUSPLUS_LANG < 201703L #define GTEST_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL 1 From 7b1ced0682af5fb10e4619457552cd11936c294a Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 3 Mar 2023 15:59:04 -0800 Subject: [PATCH 131/336] Only define GTEST_IS_THREADSAFE to 1, not 0 According to the comments, "Feature-indicating macros", such as GTEST_IS_THREADSAFE should be defined to 1 when supported and otherwise undefined (never 0). PiperOrigin-RevId: 513944266 Change-Id: I0f5c8bed107a5f20e957ec7c70339540ca2fe831 --- googletest/include/gtest/internal/gtest-port.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index ba5e9bc32..b757c7d8d 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -790,8 +790,6 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; !defined(GTEST_OS_WINDOWS_RT)) || \ GTEST_HAS_PTHREAD) #define GTEST_IS_THREADSAFE 1 -#else -#define GTEST_IS_THREADSAFE 0 #endif #endif // GTEST_IS_THREADSAFE From dc10c3b5e55c1101e7759bdb7bf9790cebbf4ad2 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 3 Mar 2023 16:01:13 -0800 Subject: [PATCH 132/336] Use "#ifdef" with public macros This allows compilation with "-Wundef" (#3267). PiperOrigin-RevId: 513944726 Change-Id: I1a3854bb2333d5dec6c0ff91ee1eddd9a766ab91 --- googlemock/test/gmock-matchers-misc_test.cc | 2 +- googlemock/test/gmock-spec-builders_test.cc | 2 +- googletest/include/gtest/gtest-death-test.h | 4 ++-- googletest/include/gtest/gtest.h | 2 +- .../gtest/internal/gtest-death-test-internal.h | 2 +- googletest/include/gtest/internal/gtest-port.h | 16 ++++++++-------- googletest/src/gtest-death-test.cc | 4 ++-- googletest/src/gtest-internal-inl.h | 10 +++++----- googletest/src/gtest-port.cc | 6 +++--- googletest/src/gtest.cc | 12 ++++++------ googletest/test/googletest-death-test-test.cc | 4 ++-- googletest/test/googletest-death-test_ex_test.cc | 2 +- googletest/test/googletest-output-test_.cc | 10 +++++----- googletest/test/googletest-port-test.cc | 10 +++++----- googletest/test/gtest_help_test_.cc | 2 +- googletest/test/gtest_stress_test.cc | 2 +- googletest/test/gtest_unittest.cc | 10 +++++----- 17 files changed, 50 insertions(+), 50 deletions(-) diff --git a/googlemock/test/gmock-matchers-misc_test.cc b/googlemock/test/gmock-matchers-misc_test.cc index c1e4f3526..0c7aa4994 100644 --- a/googlemock/test/gmock-matchers-misc_test.cc +++ b/googlemock/test/gmock-matchers-misc_test.cc @@ -200,7 +200,7 @@ TEST(IsTrueTest, IsTrueIsFalse) { EXPECT_THAT(nonnull_unique, Not(IsFalse())); } -#if GTEST_HAS_TYPED_TEST +#ifdef GTEST_HAS_TYPED_TEST // Tests ContainerEq with different container types, and // different element types. diff --git a/googlemock/test/gmock-spec-builders_test.cc b/googlemock/test/gmock-spec-builders_test.cc index ad56ead07..d53196b35 100644 --- a/googlemock/test/gmock-spec-builders_test.cc +++ b/googlemock/test/gmock-spec-builders_test.cc @@ -1088,7 +1088,7 @@ TEST(UnexpectedCallTest, UnsatisfiedPrerequisites) { // Verifies that the failure message contains the two unsatisfied // pre-requisites but not the satisfied one. -#if GTEST_USES_POSIX_RE +#ifdef GTEST_USES_POSIX_RE EXPECT_THAT(r.message(), ContainsRegex( // POSIX RE doesn't understand the (?s) prefix, but has no diff --git a/googletest/include/gtest/gtest-death-test.h b/googletest/include/gtest/gtest-death-test.h index b793528b1..08fef8c7d 100644 --- a/googletest/include/gtest/gtest-death-test.h +++ b/googletest/include/gtest/gtest-death-test.h @@ -51,7 +51,7 @@ GTEST_DECLARE_string_(death_test_style); namespace testing { -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST namespace internal { @@ -328,7 +328,7 @@ class GTEST_API_ KilledBySignal { // death tests are supported; otherwise they just issue a warning. This is // useful when you are combining death test assertions with normal test // assertions in one test. -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST #define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \ EXPECT_DEATH(statement, regex) #define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \ diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index 2bf64938c..c1001d67e 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -600,7 +600,7 @@ class GTEST_API_ TestInfo { const TestResult* result() const { return &result_; } private: -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST friend class internal::DefaultDeathTestFactory; #endif // GTEST_HAS_DEATH_TEST friend class Test; diff --git a/googletest/include/gtest/internal/gtest-death-test-internal.h b/googletest/include/gtest/internal/gtest-death-test-internal.h index 21f3d29f1..522eed854 100644 --- a/googletest/include/gtest/internal/gtest-death-test-internal.h +++ b/googletest/include/gtest/internal/gtest-death-test-internal.h @@ -57,7 +57,7 @@ const char kDeathTestStyleFlag[] = "death_test_style"; const char kDeathTestUseFork[] = "death_test_use_fork"; const char kInternalRunDeathTestFlag[] = "internal_run_death_test"; -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ /* class A needs to have dll-interface to be used by clients of class B */) diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index b757c7d8d..29503db05 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -161,10 +161,10 @@ // NOT define them. // // These macros are public so that portable tests can be written. -// Such tests typically surround code using a feature with an #if +// Such tests typically surround code using a feature with an #ifdef // which controls that code. For example: // -// #if GTEST_HAS_DEATH_TEST +// #ifdef GTEST_HAS_DEATH_TEST // EXPECT_DEATH(DoSomethingDeadly()); // #endif // @@ -794,7 +794,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #endif // GTEST_IS_THREADSAFE -#if GTEST_IS_THREADSAFE +#ifdef GTEST_IS_THREADSAFE // Some platforms don't support including these threading related headers. #include // NOLINT #include // NOLINT @@ -909,7 +909,7 @@ GTEST_API_ bool IsTrue(bool condition); // Defines RE. -#if GTEST_USES_RE2 +#ifdef GTEST_USES_RE2 // This is almost `using RE = ::RE2`, except it is copy-constructible, and it // needs to disambiguate the `std::string`, `absl::string_view`, and `const @@ -934,7 +934,7 @@ class GTEST_API_ RE { RE2 regex_; }; -#elif GTEST_USES_POSIX_RE || GTEST_USES_SIMPLE_RE +#elif defined(GTEST_USES_POSIX_RE) || defined(GTEST_USES_SIMPLE_RE) // A simple C++ wrapper for . It uses the POSIX Extended // Regular Expression syntax. @@ -972,7 +972,7 @@ class GTEST_API_ RE { std::string pattern_; bool is_valid_; -#if GTEST_USES_POSIX_RE +#ifdef GTEST_USES_POSIX_RE regex_t full_regex_; // For FullMatch(). regex_t partial_regex_; // For PartialMatch(). @@ -1200,7 +1200,7 @@ GTEST_API_ std::string ReadEntireFile(FILE* file); // All command line arguments. GTEST_API_ std::vector GetArgvs(); -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST std::vector GetInjectableArgvs(); // Deprecated: pass the args vector by value instead. @@ -1211,7 +1211,7 @@ void ClearInjectableArgvs(); #endif // GTEST_HAS_DEATH_TEST // Defines synchronization primitives. -#if GTEST_IS_THREADSAFE +#ifdef GTEST_IS_THREADSAFE #ifdef GTEST_OS_WINDOWS // Provides leak-safe Windows kernel handle ownership. diff --git a/googletest/src/gtest-death-test.cc b/googletest/src/gtest-death-test.cc index f91eba22d..649b17b57 100644 --- a/googletest/src/gtest-death-test.cc +++ b/googletest/src/gtest-death-test.cc @@ -40,7 +40,7 @@ #include "gtest/internal/custom/gtest.h" #include "gtest/internal/gtest-port.h" -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST #ifdef GTEST_OS_MAC #include @@ -133,7 +133,7 @@ GTEST_DEFINE_string_( namespace testing { -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST namespace internal { diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h index 036c3415a..007e0498f 100644 --- a/googletest/src/gtest-internal-inl.h +++ b/googletest/src/gtest-internal-inl.h @@ -672,7 +672,7 @@ class GTEST_API_ UnitTestImpl { void AddTestInfo(internal::SetUpTestSuiteFunc set_up_tc, internal::TearDownTestSuiteFunc tear_down_tc, TestInfo* test_info) { -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST // In order to support thread-safe death tests, we need to // remember the original working directory when the test program // was first invoked. We cannot do this in RUN_ALL_TESTS(), as @@ -778,7 +778,7 @@ class GTEST_API_ UnitTestImpl { return gtest_trace_stack_.get(); } -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST void InitDeathTestSubprocessControlInfo() { internal_run_death_test_flag_.reset(ParseInternalRunDeathTestFlag()); } @@ -943,7 +943,7 @@ class GTEST_API_ UnitTestImpl { // How long the test took to run, in milliseconds. TimeInMillis elapsed_time_; -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST // The decomposed components of the gtest_internal_run_death_test flag, // parsed when RUN_ALL_TESTS is called. std::unique_ptr internal_run_death_test_flag_; @@ -967,7 +967,7 @@ inline UnitTestImpl* GetUnitTestImpl() { return UnitTest::GetInstance()->impl(); } -#if GTEST_USES_SIMPLE_RE +#ifdef GTEST_USES_SIMPLE_RE // Internal helper functions for implementing the simple regular // expression matcher. @@ -993,7 +993,7 @@ GTEST_API_ bool MatchRegexAnywhere(const char* regex, const char* str); GTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, char** argv); GTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv); -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST // Returns the message describing the last system error, regardless of the // platform. diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc index da4d12d8a..994fabd44 100644 --- a/googletest/src/gtest-port.cc +++ b/googletest/src/gtest-port.cc @@ -657,7 +657,7 @@ void ThreadLocalRegistry::OnThreadLocalDestroyed( #endif // GTEST_IS_THREADSAFE && GTEST_OS_WINDOWS -#if GTEST_USES_POSIX_RE +#ifdef GTEST_USES_POSIX_RE // Implements RE. Currently only needed for death tests. @@ -719,7 +719,7 @@ void RE::Init(const char* regex) { delete[] full_pattern; } -#elif GTEST_USES_SIMPLE_RE +#elif defined(GTEST_USES_SIMPLE_RE) // Returns true if and only if ch appears anywhere in str (excluding the // terminating '\0' character). @@ -1221,7 +1221,7 @@ std::string ReadEntireFile(FILE* file) { return content; } -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST static const std::vector* g_injected_test_argvs = nullptr; // Owned. diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 88bbcd201..7ffbf418b 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -5018,7 +5018,7 @@ void OsStackTraceGetter::UponLeavingGTest() GTEST_LOCK_EXCLUDED_(mutex_) { #endif // GTEST_HAS_ABSL } -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST // A helper class that creates the premature-exit file in its // constructor and deletes the file in its destructor. class ScopedPrematureExitFile { @@ -5383,7 +5383,7 @@ void UnitTest::RecordProperty(const std::string& key, // We don't protect this under mutex_, as we only support calling it // from the main thread. int UnitTest::Run() { -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST const bool in_death_test_child_process = GTEST_FLAG_GET(internal_run_death_test).length() > 0; @@ -5560,7 +5560,7 @@ UnitTestImpl::UnitTestImpl(UnitTest* parent) random_(0), // Will be reseeded before first use. start_timestamp_(0), elapsed_time_(0), -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST death_test_factory_(new DefaultDeathTestFactory), #endif // Will be overridden by the flag before first use. @@ -5600,7 +5600,7 @@ void UnitTestImpl::RecordProperty(const TestProperty& test_property) { test_result->RecordProperty(xml_element, test_property); } -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST // Disables event forwarding if the control is currently in a death test // subprocess. Must not be called before InitGoogleTest. void UnitTestImpl::SuppressTestEventsIfInSubprocess() { @@ -5663,7 +5663,7 @@ void UnitTestImpl::PostFlagParsingInit() { listeners()->Append(new GTEST_CUSTOM_TEST_EVENT_LISTENER_()); #endif // defined(GTEST_CUSTOM_TEST_EVENT_LISTENER_) -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST InitDeathTestSubprocessControlInfo(); SuppressTestEventsIfInSubprocess(); #endif // GTEST_HAS_DEATH_TEST @@ -5801,7 +5801,7 @@ bool UnitTestImpl::RunAllTests() { // death test. bool in_subprocess_for_death_test = false; -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST in_subprocess_for_death_test = (internal_run_death_test_flag_.get() != nullptr); #if defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_) diff --git a/googletest/test/googletest-death-test-test.cc b/googletest/test/googletest-death-test-test.cc index a361a5741..3579ce880 100644 --- a/googletest/test/googletest-death-test-test.cc +++ b/googletest/test/googletest-death-test-test.cc @@ -37,7 +37,7 @@ using testing::internal::AlwaysFalse; using testing::internal::AlwaysTrue; -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST #ifdef GTEST_OS_WINDOWS #include // For chdir(). @@ -1353,7 +1353,7 @@ void DieWithMessage(const char* message) { TEST(MatcherDeathTest, DoesNotBreakBareRegexMatching) { // googletest tests this, of course; here we ensure that including googlemock // has not broken it. -#if GTEST_USES_POSIX_RE +#ifdef GTEST_USES_POSIX_RE EXPECT_DEATH(DieWithMessage("O, I die, Horatio."), "I d[aeiou]e"); #else EXPECT_DEATH(DieWithMessage("O, I die, Horatio."), "I di?e"); diff --git a/googletest/test/googletest-death-test_ex_test.cc b/googletest/test/googletest-death-test_ex_test.cc index f2515e377..34d55013b 100644 --- a/googletest/test/googletest-death-test_ex_test.cc +++ b/googletest/test/googletest-death-test_ex_test.cc @@ -33,7 +33,7 @@ #include "gtest/gtest-death-test.h" #include "gtest/gtest.h" -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST #if GTEST_HAS_SEH #include // For RaiseException(). diff --git a/googletest/test/googletest-output-test_.cc b/googletest/test/googletest-output-test_.cc index 090fb070b..1a496ac80 100644 --- a/googletest/test/googletest-output-test_.cc +++ b/googletest/test/googletest-output-test_.cc @@ -41,7 +41,7 @@ GTEST_DISABLE_MSC_WARNINGS_PUSH_(4127 /* conditional expression is constant */) -#if GTEST_IS_THREADSAFE +#ifdef GTEST_IS_THREADSAFE using testing::ScopedFakeTestPartResultReporter; using testing::TestPartResultArray; @@ -247,7 +247,7 @@ TEST(SCOPED_TRACETest, CanBeRepeated) { << "contain trace point A, B, and D."; } -#if GTEST_IS_THREADSAFE +#ifdef GTEST_IS_THREADSAFE // Tests that SCOPED_TRACE()s can be used concurrently from multiple // threads. Namely, an assertion should be affected by // SCOPED_TRACE()s in its own thread only. @@ -773,7 +773,7 @@ REGISTER_TYPED_TEST_SUITE_P(DetectNotInstantiatedTypesTest, Used); // typedef ::testing::Types MyTypes; // INSTANTIATE_TYPED_TEST_SUITE_P(All, DetectNotInstantiatedTypesTest, MyTypes); -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST // We rely on the golden file to verify that tests whose test case // name ends with DeathTest are run first. @@ -851,7 +851,7 @@ TEST_F(ExpectFailureTest, ExpectNonFatalFailure) { "failure."); } -#if GTEST_IS_THREADSAFE +#ifdef GTEST_IS_THREADSAFE class ExpectFailureWithThreadsTest : public ExpectFailureTest { protected: @@ -1024,7 +1024,7 @@ int main(int argc, char** argv) { std::count(argv, argv + argc, std::string("internal_skip_environment_and_ad_hoc_tests")) > 0; -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST if (GTEST_FLAG_GET(internal_run_death_test) != "") { // Skip the usual output capturing if we're running as the child // process of an threadsafe-style death test. diff --git a/googletest/test/googletest-port-test.cc b/googletest/test/googletest-port-test.cc index a93572a93..f3ebda9f5 100644 --- a/googletest/test/googletest-port-test.cc +++ b/googletest/test/googletest-port-test.cc @@ -361,7 +361,7 @@ TEST(GtestCheckDeathTest, DiesWithCorrectOutputOnFailure) { const char regex[] = #ifdef _MSC_VER "googletest-port-test\\.cc\\(\\d+\\):" -#elif GTEST_USES_POSIX_RE +#elif defined(GTEST_USES_POSIX_RE) "googletest-port-test\\.cc:[0-9]+" #else "googletest-port-test\\.cc:\\d+" @@ -372,7 +372,7 @@ TEST(GtestCheckDeathTest, DiesWithCorrectOutputOnFailure) { regex); } -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST TEST(GtestCheckDeathTest, LivesSilentlyOnSuccess) { EXPECT_EXIT( @@ -399,7 +399,7 @@ TEST(RegexEngineSelectionTest, SelectsCorrectRegexEngine) { #endif } -#if GTEST_USES_POSIX_RE +#ifdef GTEST_USES_POSIX_RE template class RETest : public ::testing::Test {}; @@ -456,7 +456,7 @@ TYPED_TEST(RETest, PartialMatchWorks) { EXPECT_FALSE(RE::PartialMatch(TypeParam("zza"), re)); } -#elif GTEST_USES_SIMPLE_RE +#elif defined(GTEST_USES_SIMPLE_RE) TEST(IsInSetTest, NulCharIsNotInAnySet) { EXPECT_FALSE(IsInSet('\0', "")); @@ -1011,7 +1011,7 @@ TEST(ThreadLocalTest, PointerAndConstPointerReturnSameValue) { EXPECT_EQ(thread_local_string.pointer(), const_thread_local_string.pointer()); } -#if GTEST_IS_THREADSAFE +#ifdef GTEST_IS_THREADSAFE void AddTwo(int* param) { *param += 2; } diff --git a/googletest/test/gtest_help_test_.cc b/googletest/test/gtest_help_test_.cc index da289f05f..18b5f3cdd 100644 --- a/googletest/test/gtest_help_test_.cc +++ b/googletest/test/gtest_help_test_.cc @@ -39,6 +39,6 @@ TEST(HelpFlagTest, ShouldNotBeRun) { ASSERT_TRUE(false) << "Tests shouldn't be run when --help is specified."; } -#if GTEST_HAS_DEATH_TEST +#ifdef GTEST_HAS_DEATH_TEST TEST(DeathTest, UsedByPythonScriptToDetectSupportForDeathTestsInThisBinary) {} #endif diff --git a/googletest/test/gtest_stress_test.cc b/googletest/test/gtest_stress_test.cc index 24b173ffd..af9733ad3 100644 --- a/googletest/test/gtest_stress_test.cc +++ b/googletest/test/gtest_stress_test.cc @@ -35,7 +35,7 @@ #include "gtest/gtest.h" #include "src/gtest-internal-inl.h" -#if GTEST_IS_THREADSAFE +#ifdef GTEST_IS_THREADSAFE namespace testing { namespace { diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index 461297abd..2f137d245 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -270,7 +270,7 @@ using testing::internal::CaptureStdout; using testing::internal::GetCapturedStdout; #endif -#if GTEST_IS_THREADSAFE +#ifdef GTEST_IS_THREADSAFE using testing::internal::ThreadWithParam; #endif @@ -1189,7 +1189,7 @@ TEST_F(ScopedFakeTestPartResultReporterTest, DeprecatedConstructor) { EXPECT_EQ(1, results.size()); } -#if GTEST_IS_THREADSAFE +#ifdef GTEST_IS_THREADSAFE class ScopedFakeTestPartResultReporterWithThreadsTest : public ScopedFakeTestPartResultReporterTest { @@ -1347,7 +1347,7 @@ TEST_F(ExpectNonfatalFailureTest, AcceptsMacroThatExpandsToUnprotectedComma) { ""); } -#if GTEST_IS_THREADSAFE +#ifdef GTEST_IS_THREADSAFE typedef ScopedFakeTestPartResultReporterWithThreadsTest ExpectFailureWithThreadsTest; @@ -6178,7 +6178,7 @@ TEST_F(ParseFlagsTest, FilterBad) { const char* argv2[] = {"foo.exe", "--gtest_filter", nullptr}; -#if GTEST_HAS_ABSL && GTEST_HAS_DEATH_TEST +#if GTEST_HAS_ABSL && defined(GTEST_HAS_DEATH_TEST) // Invalid flag arguments are a fatal error when using the Abseil Flags. EXPECT_EXIT(GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter(""), true), testing::ExitedWithCode(1), @@ -6197,7 +6197,7 @@ TEST_F(ParseFlagsTest, OutputEmpty) { const char* argv2[] = {"foo.exe", "--gtest_output", nullptr}; -#if GTEST_HAS_ABSL && GTEST_HAS_DEATH_TEST +#if GTEST_HAS_ABSL && defined(GTEST_HAS_DEATH_TEST) // Invalid flag arguments are a fatal error when using the Abseil Flags. EXPECT_EXIT(GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), true), testing::ExitedWithCode(1), From 16feffa8fa7cb6e061787ce345c16eb24326d2ce Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 3 Mar 2023 16:03:22 -0800 Subject: [PATCH 133/336] Replace "#if GTEST_HAS_ABSL" with "#ifdef GTEST_HAS_ABSL" This allows compilation with "-Wundef" (#3267). PiperOrigin-RevId: 513945230 Change-Id: I45ef19c7ff3d20e97216bd031d406a03365471da --- googletest/include/gtest/gtest-printers.h | 2 +- googletest/include/gtest/internal/gtest-port.h | 15 ++++++++------- googletest/src/gtest-internal-inl.h | 2 +- googletest/src/gtest.cc | 12 ++++++------ googletest/test/googletest-port-test.cc | 2 +- googletest/test/gtest_unittest.cc | 10 +++++----- 6 files changed, 22 insertions(+), 21 deletions(-) diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h index 739d54526..b2d7b0a39 100644 --- a/googletest/include/gtest/gtest-printers.h +++ b/googletest/include/gtest/gtest-printers.h @@ -857,7 +857,7 @@ class UniversalPrinter> { public: static void Print(const Variant& value, ::std::ostream* os) { *os << '('; -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL absl::visit(Visitor{os, value.index()}, value); #else std::visit(Visitor{os, value.index()}, value); diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 29503db05..9a35de0fb 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -178,6 +178,7 @@ // define themselves. // GTEST_USES_SIMPLE_RE - our own simple regex is used; // the above RE\b(s) are mutually exclusive. +// GTEST_HAS_ABSL - Google Test is compiled with Abseil. // Misc public macros // ------------------ @@ -304,7 +305,7 @@ #include "gtest/internal/custom/gtest-port.h" #include "gtest/internal/gtest-port-arch.h" -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL #include "absl/flags/declare.h" #include "absl/flags/flag.h" #include "absl/flags/reflection.h" @@ -412,7 +413,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; #endif // Select the regular expression implementation. -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL // When using Abseil, RE2 is required. #include "absl/strings/string_view.h" #include "re2/re2.h" @@ -2248,7 +2249,7 @@ using TimeInMillis = int64_t; // Represents time in milliseconds. #endif // !defined(GTEST_FLAG) // Pick a command line flags implementation. -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL // Macros for defining flags. #define GTEST_DEFINE_bool_(name, default_val, doc) \ @@ -2359,7 +2360,7 @@ const char* StringFromGTestEnv(const char* flag, const char* default_val); #endif // !defined(GTEST_INTERNAL_DEPRECATED) -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL // Always use absl::any for UniversalPrinter<> specializations if googletest // is built with absl support. #define GTEST_INTERNAL_HAS_ANY 1 @@ -2392,7 +2393,7 @@ using Any = ::std::any; #define GTEST_INTERNAL_HAS_ANY 0 #endif -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL // Always use absl::optional for UniversalPrinter<> specializations if // googletest is built with absl support. #define GTEST_INTERNAL_HAS_OPTIONAL 1 @@ -2428,7 +2429,7 @@ inline ::std::nullopt_t Nullopt() { return ::std::nullopt; } #define GTEST_INTERNAL_HAS_OPTIONAL 0 #endif -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL // Always use absl::string_view for Matcher<> specializations if googletest // is built with absl support. #define GTEST_INTERNAL_HAS_STRING_VIEW 1 @@ -2460,7 +2461,7 @@ using StringView = ::std::string_view; #define GTEST_INTERNAL_HAS_STRING_VIEW 0 #endif -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL // Always use absl::variant for UniversalPrinter<> specializations if googletest // is built with absl support. #define GTEST_INTERNAL_HAS_VARIANT 1 diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h index 007e0498f..16841b55c 100644 --- a/googletest/src/gtest-internal-inl.h +++ b/googletest/src/gtest-internal-inl.h @@ -442,7 +442,7 @@ class OsStackTraceGetter : public OsStackTraceGetterInterface { void UponLeavingGTest() override; private: -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL Mutex mutex_; // Protects all internal state. // We save the stack frame below the frame that calls user code. diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 7ffbf418b..0dd3ebadc 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -135,7 +135,7 @@ #endif #endif -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL #include "absl/debugging/failure_signal_handler.h" #include "absl/debugging/stacktrace.h" #include "absl/debugging/symbolize.h" @@ -4958,7 +4958,7 @@ const char* const OsStackTraceGetterInterface::kElidedFramesMarker = std::string OsStackTraceGetter::CurrentStackTrace(int max_depth, int skip_count) GTEST_LOCK_EXCLUDED_(mutex_) { -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL std::string result; if (max_depth <= 0) { @@ -5007,7 +5007,7 @@ std::string OsStackTraceGetter::CurrentStackTrace(int max_depth, int skip_count) } void OsStackTraceGetter::UponLeavingGTest() GTEST_LOCK_EXCLUDED_(mutex_) { -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL void* caller_frame = nullptr; if (absl::GetStackTrace(&caller_frame, 1, 3) <= 0) { caller_frame = nullptr; @@ -5686,7 +5686,7 @@ void UnitTestImpl::PostFlagParsingInit() { ConfigureStreamingOutput(); #endif // GTEST_CAN_STREAM_RESULTS_ -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL if (GTEST_FLAG_GET(install_failure_signal_handler)) { absl::FailureSignalHandlerOptions options; absl::InstallFailureSignalHandler(options); @@ -6668,7 +6668,7 @@ void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) { // Parses the command line for Google Test flags, without initializing // other parts of Google Test. void ParseGoogleTestFlagsOnly(int* argc, char** argv) { -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL if (*argc > 0) { // absl::ParseCommandLine() requires *argc > 0. auto positional_args = absl::flags_internal::ParseCommandLineImpl( @@ -6720,7 +6720,7 @@ void InitGoogleTestImpl(int* argc, CharType** argv) { g_argvs.push_back(StreamableToString(argv[i])); } -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL absl::InitializeSymbolizer(g_argvs[0].c_str()); // When using the Abseil Flags library, set the program usage message to the diff --git a/googletest/test/googletest-port-test.cc b/googletest/test/googletest-port-test.cc index f3ebda9f5..d01ccaae0 100644 --- a/googletest/test/googletest-port-test.cc +++ b/googletest/test/googletest-port-test.cc @@ -390,7 +390,7 @@ TEST(GtestCheckDeathTest, LivesSilentlyOnSuccess) { // the platform. The test will produce compiler errors in case of failure. // For simplicity, we only cover the most important platforms here. TEST(RegexEngineSelectionTest, SelectsCorrectRegexEngine) { -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL EXPECT_TRUE(GTEST_USES_RE2); #elif GTEST_HAS_POSIX_RE EXPECT_TRUE(GTEST_USES_POSIX_RE); diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index 2f137d245..aea8e1f21 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -6178,12 +6178,12 @@ TEST_F(ParseFlagsTest, FilterBad) { const char* argv2[] = {"foo.exe", "--gtest_filter", nullptr}; -#if GTEST_HAS_ABSL && defined(GTEST_HAS_DEATH_TEST) +#if defined(GTEST_HAS_ABSL) && defined(GTEST_HAS_DEATH_TEST) // Invalid flag arguments are a fatal error when using the Abseil Flags. EXPECT_EXIT(GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter(""), true), testing::ExitedWithCode(1), "ERROR: Missing the value for the flag 'gtest_filter'"); -#elif !GTEST_HAS_ABSL +#elif !defined(GTEST_HAS_ABSL) GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter(""), true); #else static_cast(argv); @@ -6197,12 +6197,12 @@ TEST_F(ParseFlagsTest, OutputEmpty) { const char* argv2[] = {"foo.exe", "--gtest_output", nullptr}; -#if GTEST_HAS_ABSL && defined(GTEST_HAS_DEATH_TEST) +#if defined(GTEST_HAS_ABSL) && defined(GTEST_HAS_DEATH_TEST) // Invalid flag arguments are a fatal error when using the Abseil Flags. EXPECT_EXIT(GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), true), testing::ExitedWithCode(1), "ERROR: Missing the value for the flag 'gtest_output'"); -#elif !GTEST_HAS_ABSL +#elif !defined(GTEST_HAS_ABSL) GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), true); #else static_cast(argv); @@ -6210,7 +6210,7 @@ TEST_F(ParseFlagsTest, OutputEmpty) { #endif } -#if GTEST_HAS_ABSL +#ifdef GTEST_HAS_ABSL TEST_F(ParseFlagsTest, AbseilPositionalFlags) { const char* argv[] = {"foo.exe", "--gtest_throw_on_failure=1", "--", "--other_flag", nullptr}; From 0bdd45085ab7e81dc7fc9dc3ac9bb20110be3db7 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 3 Mar 2023 16:05:40 -0800 Subject: [PATCH 134/336] Remove GTEST_FOR_GOOGLE_ macro The "more details" warning message printed by this macro is no longer needed. PiperOrigin-RevId: 513945729 Change-Id: I644910216dbef2fe92eee3a648f2078e705cc7a1 --- googletest/src/gtest.cc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 0dd3ebadc..55f8e507a 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -5966,10 +5966,6 @@ bool UnitTestImpl::RunAllTests() { "() before calling RUN_ALL_TESTS(). This is INVALID. Soon " GTEST_NAME_ " will start to enforce the valid usage. " "Please fix it ASAP, or IT WILL START TO FAIL.\n"); // NOLINT -#if GTEST_FOR_GOOGLE_ - ColoredPrintf(GTestColor::kRed, - "For more details, see http://wiki/Main/ValidGUnitMain.\n"); -#endif // GTEST_FOR_GOOGLE_ } return !failed; From 2ddba266914d6437c313d36f73a4be3a6172e638 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 3 Mar 2023 16:07:40 -0800 Subject: [PATCH 135/336] Always specify definitions for internal macros These macros should only be used within googletest, so changing them will not affect external users. This allows compiling with -Wundef (#3267). PiperOrigin-RevId: 513946162 Change-Id: I2f2b7df9123adeba4147593b2b55fde349ccce4f --- .../include/gtest/internal/gtest-port.h | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 9a35de0fb..ba90620e1 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -214,6 +214,14 @@ // GTEST_INTERNAL_HAS_VARIANT - for enabling UniversalPrinter or // UniversalPrinter // specializations. Always defined to 0 or 1. +// GTEST_USE_OWN_FLAGFILE_FLAG_ - Always defined to 0 or 1. +// GTEST_HAS_CXXABI_H_ - Always defined to 0 or 1. +// GTEST_CAN_STREAM_RESULTS_ - Always defined to 0 or 1. +// GTEST_HAS_ALT_PATH_SEP_ - Always defined to 0 or 1. +// GTEST_WIDE_STRING_USES_UTF16_ - Always defined to 0 or 1. +// GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ - Always defined to 0 or 1. +// GTEST_HAS_DOWNCAST_ - Always defined to 0 or 1. +// GTEST_HAS_NOTIFICATION_- Always defined to 0 or 1. // // Synchronization: // Mutex, MutexLock, ThreadLocal, GetThreadCount() @@ -305,6 +313,18 @@ #include "gtest/internal/custom/gtest-port.h" #include "gtest/internal/gtest-port-arch.h" +#ifndef GTEST_HAS_DOWNCAST_ +#define GTEST_HAS_DOWNCAST_ 0 +#endif + +#ifndef GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ +#define GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ 0 +#endif + +#ifndef GTEST_HAS_NOTIFICATION_ +#define GTEST_HAS_NOTIFICATION_ 0 +#endif + #ifdef GTEST_HAS_ABSL #include "absl/flags/declare.h" #include "absl/flags/flag.h" From d92a270d2d9d6bb7ed3bf7dc3f698028550a65ef Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 3 Mar 2023 16:09:49 -0800 Subject: [PATCH 136/336] Fix compilation with -Wundef. Fixes #3267 PiperOrigin-RevId: 513946600 Change-Id: I0dd1daa04aeb735a238c4c0af6676565d64cbc21 --- googletest/cmake/internal_utils.cmake | 4 +-- googletest/include/gtest/gtest.h | 28 +++++++++---------- .../include/gtest/internal/gtest-port.h | 10 +++++-- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index 0438bef83..b09da33fa 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -91,13 +91,13 @@ macro(config_compiler_and_linker) set(cxx_base_flags "${cxx_base_flags} -utf-8") endif() elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - set(cxx_base_flags "-Wall -Wshadow -Wconversion") + set(cxx_base_flags "-Wall -Wshadow -Wconversion -Wundef") set(cxx_exception_flags "-fexceptions") set(cxx_no_exception_flags "-fno-exceptions") set(cxx_strict_flags "-W -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wredundant-decls") set(cxx_no_rtti_flags "-fno-rtti") elseif (CMAKE_COMPILER_IS_GNUCXX) - set(cxx_base_flags "-Wall -Wshadow") + set(cxx_base_flags "-Wall -Wshadow -Wundef") if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0.0) set(cxx_base_flags "${cxx_base_flags} -Wno-error=dangling-else") endif() diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index c1001d67e..04a84f32e 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -1747,7 +1747,7 @@ class TestWithParam : public Test, public WithParamInterface {}; // Define this macro to 1 to omit the definition of FAIL(), which is a // generic name and clashes with some other libraries. -#if !GTEST_DONT_DEFINE_FAIL +#if !(defined(GTEST_DONT_DEFINE_FAIL) && GTEST_DONT_DEFINE_FAIL) #define FAIL() GTEST_FAIL() #endif @@ -1756,7 +1756,7 @@ class TestWithParam : public Test, public WithParamInterface {}; // Define this macro to 1 to omit the definition of SUCCEED(), which // is a generic name and clashes with some other libraries. -#if !GTEST_DONT_DEFINE_SUCCEED +#if !(defined(GTEST_DONT_DEFINE_SUCCEED) && GTEST_DONT_DEFINE_SUCCEED) #define SUCCEED() GTEST_SUCCEED() #endif @@ -1800,19 +1800,19 @@ class TestWithParam : public Test, public WithParamInterface {}; // Define these macros to 1 to omit the definition of the corresponding // EXPECT or ASSERT, which clashes with some users' own code. -#if !GTEST_DONT_DEFINE_EXPECT_TRUE +#if !(defined(GTEST_DONT_DEFINE_EXPECT_TRUE) && GTEST_DONT_DEFINE_EXPECT_TRUE) #define EXPECT_TRUE(condition) GTEST_EXPECT_TRUE(condition) #endif -#if !GTEST_DONT_DEFINE_EXPECT_FALSE +#if !(defined(GTEST_DONT_DEFINE_EXPECT_FALSE) && GTEST_DONT_DEFINE_EXPECT_FALSE) #define EXPECT_FALSE(condition) GTEST_EXPECT_FALSE(condition) #endif -#if !GTEST_DONT_DEFINE_ASSERT_TRUE +#if !(defined(GTEST_DONT_DEFINE_ASSERT_TRUE) && GTEST_DONT_DEFINE_ASSERT_TRUE) #define ASSERT_TRUE(condition) GTEST_ASSERT_TRUE(condition) #endif -#if !GTEST_DONT_DEFINE_ASSERT_FALSE +#if !(defined(GTEST_DONT_DEFINE_ASSERT_FALSE) && GTEST_DONT_DEFINE_ASSERT_FALSE) #define ASSERT_FALSE(condition) GTEST_ASSERT_FALSE(condition) #endif @@ -1891,27 +1891,27 @@ class TestWithParam : public Test, public WithParamInterface {}; // Define macro GTEST_DONT_DEFINE_ASSERT_XY to 1 to omit the definition of // ASSERT_XY(), which clashes with some users' own code. -#if !GTEST_DONT_DEFINE_ASSERT_EQ +#if !(defined(GTEST_DONT_DEFINE_ASSERT_EQ) && GTEST_DONT_DEFINE_ASSERT_EQ) #define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2) #endif -#if !GTEST_DONT_DEFINE_ASSERT_NE +#if !(defined(GTEST_DONT_DEFINE_ASSERT_NE) && GTEST_DONT_DEFINE_ASSERT_NE) #define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2) #endif -#if !GTEST_DONT_DEFINE_ASSERT_LE +#if !(defined(GTEST_DONT_DEFINE_ASSERT_LE) && GTEST_DONT_DEFINE_ASSERT_LE) #define ASSERT_LE(val1, val2) GTEST_ASSERT_LE(val1, val2) #endif -#if !GTEST_DONT_DEFINE_ASSERT_LT +#if !(defined(GTEST_DONT_DEFINE_ASSERT_LT) && GTEST_DONT_DEFINE_ASSERT_LT) #define ASSERT_LT(val1, val2) GTEST_ASSERT_LT(val1, val2) #endif -#if !GTEST_DONT_DEFINE_ASSERT_GE +#if !(defined(GTEST_DONT_DEFINE_ASSERT_GE) && GTEST_DONT_DEFINE_ASSERT_GE) #define ASSERT_GE(val1, val2) GTEST_ASSERT_GE(val1, val2) #endif -#if !GTEST_DONT_DEFINE_ASSERT_GT +#if !(defined(GTEST_DONT_DEFINE_ASSERT_GT) && GTEST_DONT_DEFINE_ASSERT_GT) #define ASSERT_GT(val1, val2) GTEST_ASSERT_GT(val1, val2) #endif @@ -2169,7 +2169,7 @@ constexpr bool StaticAssertTypeEq() noexcept { // Define this macro to 1 to omit the definition of TEST(), which // is a generic name and clashes with some other libraries. -#if !GTEST_DONT_DEFINE_TEST +#if !(defined(GTEST_DONT_DEFINE_TEST) && GTEST_DONT_DEFINE_TEST) #define TEST(test_suite_name, test_name) GTEST_TEST(test_suite_name, test_name) #endif @@ -2201,7 +2201,7 @@ constexpr bool StaticAssertTypeEq() noexcept { #define GTEST_TEST_F(test_fixture, test_name) \ GTEST_TEST_(test_fixture, test_name, test_fixture, \ ::testing::internal::GetTypeId()) -#if !GTEST_DONT_DEFINE_TEST_F +#if !(defined(GTEST_DONT_DEFINE_TEST_F) && GTEST_DONT_DEFINE_TEST_F) #define TEST_F(test_fixture, test_name) GTEST_TEST_F(test_fixture, test_name) #endif diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index ba90620e1..72533605c 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -469,8 +469,12 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // cleanups prior to that. To reliably check for C++ exception availability with // clang, check for // __EXCEPTIONS && __has_feature(cxx_exceptions). -#define GTEST_HAS_EXCEPTIONS (__EXCEPTIONS && __has_feature(cxx_exceptions)) -#elif defined(__GNUC__) && __EXCEPTIONS +#if defined(__EXCEPTIONS) && __EXCEPTIONS && __has_feature(cxx_exceptions) +#define GTEST_HAS_EXCEPTIONS 1 +#else +#define GTEST_HAS_EXCEPTIONS 0 +#endif +#elif defined(__GNUC__) && defined(__EXCEPTIONS) && __EXCEPTIONS // gcc defines __EXCEPTIONS to 1 if and only if exceptions are enabled. #define GTEST_HAS_EXCEPTIONS 1 #elif defined(__SUNPRO_CC) @@ -478,7 +482,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // detecting whether they are enabled or not. Therefore, we assume that // they are enabled unless the user tells us otherwise. #define GTEST_HAS_EXCEPTIONS 1 -#elif defined(__IBMCPP__) && __EXCEPTIONS +#elif defined(__IBMCPP__) && defined(__EXCEPTIONS) && __EXCEPTIONS // xlC defines __EXCEPTIONS to 1 if and only if exceptions are enabled. #define GTEST_HAS_EXCEPTIONS 1 #elif defined(__HP_aCC) From e1ee0fa3e121e819c7a76d4d3b417de8f73ebfd7 Mon Sep 17 00:00:00 2001 From: Dino Radakovic Date: Mon, 6 Mar 2023 09:03:15 -0800 Subject: [PATCH 137/336] Fix indentation syntax error in feature request issue template Fixes #4166 PiperOrigin-RevId: 514427586 Change-Id: I947b2a0f3687430f27e37fcd2b3fff8b1cb0b16e --- .github/ISSUE_TEMPLATE/10-feature_request.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/10-feature_request.yml b/.github/ISSUE_TEMPLATE/10-feature_request.yml index 91ad04177..f3bbc091e 100644 --- a/.github/ISSUE_TEMPLATE/10-feature_request.yml +++ b/.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? From 92f0d72507801f2d47533bfb2ad8960d93ed0224 Mon Sep 17 00:00:00 2001 From: Alexander Nikforov Date: Mon, 6 Mar 2023 16:34:55 -0800 Subject: [PATCH 138/336] __cpp_char8_t does not cover std::u8string implementation, but __cpp_lib_char8_t does --- googletest/include/gtest/gtest-printers.h | 2 +- googletest/src/gtest-printers.cc | 2 +- googletest/test/googletest-printers-test.cc | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h index 739d54526..09f7316f1 100644 --- a/googletest/include/gtest/gtest-printers.h +++ b/googletest/include/gtest/gtest-printers.h @@ -1003,7 +1003,7 @@ template <> class UniversalTersePrinter : public UniversalTersePrinter { }; -#ifdef __cpp_char8_t +#ifdef __cpp_lib_char8_t template <> class UniversalTersePrinter { public: diff --git a/googletest/src/gtest-printers.cc b/googletest/src/gtest-printers.cc index d475ad36f..de740e7dc 100644 --- a/googletest/src/gtest-printers.cc +++ b/googletest/src/gtest-printers.cc @@ -528,7 +528,7 @@ void PrintStringTo(const ::std::string& s, ostream* os) { } } -#ifdef __cpp_char8_t +#ifdef __cpp_lib_char8_t void PrintU8StringTo(const ::std::u8string& s, ostream* os) { PrintCharsAsStringTo(s.data(), s.size(), os); } diff --git a/googletest/test/googletest-printers-test.cc b/googletest/test/googletest-printers-test.cc index 34aa92457..23c30f115 100644 --- a/googletest/test/googletest-printers-test.cc +++ b/googletest/test/googletest-printers-test.cc @@ -532,7 +532,9 @@ TEST(PrintU8StringTest, NonConst) { EXPECT_EQ(PrintPointer(p) + " pointing to u8\"\\xE4\\xB8\\x96\"", Print(static_cast(p))); } +#endif +#ifdef __cpp_lib_char8_t // NULL u8 string. TEST(PrintU8StringTest, Null) { const char8_t* p = nullptr; @@ -936,7 +938,7 @@ TEST(PrintWideStringTest, StringAmbiguousHex) { } #endif // GTEST_HAS_STD_WSTRING -#ifdef __cpp_char8_t +#ifdef __cpp_lib_char8_t TEST(PrintStringTest, U8String) { std::u8string str = u8"Hello, 世界"; EXPECT_EQ(str, str); // Verify EXPECT_EQ compiles with this type. From 1a727c27aa36c602b24bf170a301aec8686b88e8 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Tue, 7 Mar 2023 03:05:23 -0800 Subject: [PATCH 139/336] Internal Code Change PiperOrigin-RevId: 514678702 Change-Id: I5b0089d905152ccb85022be395ed340e42586234 --- googlemock/include/gmock/internal/gmock-internal-utils.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h index afbdce035..b5283ed02 100644 --- a/googlemock/include/gmock/internal/gmock-internal-utils.h +++ b/googlemock/include/gmock/internal/gmock-internal-utils.h @@ -311,7 +311,8 @@ GTEST_API_ WithoutMatchers GetWithoutMatchers(); // crashes). template inline T Invalid() { - Assert(false, "", -1, "Internal error: attempt to return invalid value"); + Assert(/*condition=*/false, /*file=*/"", /*line=*/-1, + "Internal error: attempt to return invalid value"); #if defined(__GNUC__) || defined(__clang__) __builtin_unreachable(); #elif defined(_MSC_VER) From cf4f4400db41a70b87df127aee20fe802dae5520 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Tue, 7 Mar 2023 10:39:52 -0800 Subject: [PATCH 140/336] Suppress std::string DLL interface warning introduced in commit f063cd25c90cbd4089a0ff96f5991df4f2721338 Fixes #4171 PiperOrigin-RevId: 514777144 Change-Id: I6f4b309c407684522fc1bc94dcc980ea1fe09cd9 --- googletest/include/gtest/internal/gtest-port.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 72533605c..0160fadcc 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -960,6 +960,8 @@ class GTEST_API_ RE { }; #elif defined(GTEST_USES_POSIX_RE) || defined(GTEST_USES_SIMPLE_RE) +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \ +/* class A needs to have dll-interface to be used by clients of class B */) // A simple C++ wrapper for . It uses the POSIX Extended // Regular Expression syntax. @@ -1008,7 +1010,7 @@ class GTEST_API_ RE { #endif }; - +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4251 #endif // ::testing::internal::RE implementation // Formats a source file path and a line number as they would appear From 678c1c73de2cf004d58f5dbbef299083997d924a Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 7 Mar 2023 15:34:10 -0800 Subject: [PATCH 141/336] Fix compilation of googletest-printers-test.cc when using -Wundef #3267 PiperOrigin-RevId: 514858420 Change-Id: Ic712aafad25f5e63ae48f647557de95cef890978 --- googletest/test/googletest-printers-test.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/googletest/test/googletest-printers-test.cc b/googletest/test/googletest-printers-test.cc index fa8b084db..5fdc08675 100644 --- a/googletest/test/googletest-printers-test.cc +++ b/googletest/test/googletest-printers-test.cc @@ -1796,7 +1796,8 @@ TEST(UniversalPrintTest, SmartPointers) { std::shared_ptr p3(new int(1979)); EXPECT_EQ("(ptr = " + PrintPointer(p3.get()) + ", value = 1979)", PrintToString(p3)); -#if __cpp_lib_shared_ptr_arrays >= 201611L +#if defined(__cpp_lib_shared_ptr_arrays) && \ + (__cpp_lib_shared_ptr_arrays >= 201611L) std::shared_ptr p4(new int[2]); EXPECT_EQ("(" + PrintPointer(p4.get()) + ")", PrintToString(p4)); #endif @@ -1815,7 +1816,8 @@ TEST(UniversalPrintTest, SmartPointers) { EXPECT_EQ("(nullptr)", PrintToString(std::shared_ptr())); EXPECT_EQ("(nullptr)", PrintToString(std::shared_ptr())); EXPECT_EQ("(nullptr)", PrintToString(std::shared_ptr())); -#if __cpp_lib_shared_ptr_arrays >= 201611L +#if defined(__cpp_lib_shared_ptr_arrays) && \ + (__cpp_lib_shared_ptr_arrays >= 201611L) EXPECT_EQ("(nullptr)", PrintToString(std::shared_ptr())); EXPECT_EQ("(nullptr)", PrintToString(std::shared_ptr())); EXPECT_EQ("(nullptr)", PrintToString(std::shared_ptr())); From a798c2f10200b6293a5cc236b5f41b26c1ae7378 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 7 Mar 2023 15:57:28 -0800 Subject: [PATCH 142/336] Add -Wundef to the CI scripts when building with Bazel The CMake build already adds -Wundef for gcc/clang. This change makes sure that the gcc/clang Bazel builds also compile correctly with -Wundef (#3267). PiperOrigin-RevId: 514864451 Change-Id: I7798a4a4c68d037e23625db24ee29df454367734 --- ci/linux-presubmit.sh | 3 +++ ci/macos-presubmit.sh | 1 + 2 files changed, 4 insertions(+) diff --git a/ci/linux-presubmit.sh b/ci/linux-presubmit.sh index 626989d2f..6bac88787 100644 --- a/ci/linux-presubmit.sh +++ b/ci/linux-presubmit.sh @@ -78,6 +78,7 @@ time docker run \ --copt="-Wall" \ --copt="-Werror" \ --copt="-Wuninitialized" \ + --copt="-Wundef" \ --copt="-Wno-error=pragmas" \ --distdir="/bazel-distdir" \ --features=external_include_paths \ @@ -99,6 +100,7 @@ for std in ${STD}; do --copt="-Wall" \ --copt="-Werror" \ --copt="-Wuninitialized" \ + --copt="-Wundef" \ --define="absl=${absl}" \ --distdir="/bazel-distdir" \ --features=external_include_paths \ @@ -123,6 +125,7 @@ for std in ${STD}; do --copt="-Wall" \ --copt="-Werror" \ --copt="-Wuninitialized" \ + --copt="-Wundef" \ --define="absl=${absl}" \ --distdir="/bazel-distdir" \ --features=external_include_paths \ diff --git a/ci/macos-presubmit.sh b/ci/macos-presubmit.sh index 8f35df58d..681ebc2a9 100644 --- a/ci/macos-presubmit.sh +++ b/ci/macos-presubmit.sh @@ -66,6 +66,7 @@ for absl in 0 1; do ${BAZEL_BIN} test ... \ --copt="-Wall" \ --copt="-Werror" \ + --copt="-Wundef" \ --cxxopt="-std=c++14" \ --define="absl=${absl}" \ --features=external_include_paths \ From 82a570453ccd9a9ca8a75b82aa1850b74ce27337 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Tue, 7 Mar 2023 22:33:13 -0800 Subject: [PATCH 143/336] Apply clang-tidy fixes PiperOrigin-RevId: 514936218 Change-Id: I24c443a2ca75c875052b0cf2d0a48e808d03ae43 --- googletest/test/googletest-listener-test.cc | 8 +------- googletest/test/googletest-output-test_.cc | 2 +- googletest/test/googletest-param-test-test.cc | 2 +- googletest/test/googletest-printers-test.cc | 1 - googletest/test/googletest-shuffle-test_.cc | 1 - googletest/test/gtest_unittest.cc | 5 ----- 6 files changed, 3 insertions(+), 16 deletions(-) diff --git a/googletest/test/googletest-listener-test.cc b/googletest/test/googletest-listener-test.cc index 89d01b37f..654486d78 100644 --- a/googletest/test/googletest-listener-test.cc +++ b/googletest/test/googletest-listener-test.cc @@ -38,13 +38,7 @@ #include "gtest/internal/custom/gtest.h" using ::testing::AddGlobalTestEnvironment; -using ::testing::Environment; using ::testing::InitGoogleTest; -using ::testing::Test; -using ::testing::TestEventListener; -using ::testing::TestInfo; -using ::testing::TestPartResult; -using ::testing::TestSuite; using ::testing::UnitTest; // Used by tests to register their events. @@ -278,7 +272,7 @@ int main(int argc, char** argv) { AddGlobalTestEnvironment(new EnvironmentInvocationCatcher); - GTEST_CHECK_(events.size() == 0) + GTEST_CHECK_(events.empty()) << "AddGlobalTestEnvironment should not generate any events itself."; GTEST_FLAG_SET(repeat, 2); diff --git a/googletest/test/googletest-output-test_.cc b/googletest/test/googletest-output-test_.cc index 1a496ac80..44d0fc137 100644 --- a/googletest/test/googletest-output-test_.cc +++ b/googletest/test/googletest-output-test_.cc @@ -1025,7 +1025,7 @@ int main(int argc, char** argv) { std::string("internal_skip_environment_and_ad_hoc_tests")) > 0; #ifdef GTEST_HAS_DEATH_TEST - if (GTEST_FLAG_GET(internal_run_death_test) != "") { + if (!GTEST_FLAG_GET(internal_run_death_test).empty()) { // Skip the usual output capturing if we're running as the child // process of an threadsafe-style death test. #if defined(GTEST_OS_WINDOWS) diff --git a/googletest/test/googletest-param-test-test.cc b/googletest/test/googletest-param-test-test.cc index 63db28607..c9c5e78e4 100644 --- a/googletest/test/googletest-param-test-test.cc +++ b/googletest/test/googletest-param-test-test.cc @@ -221,7 +221,7 @@ class DogAdder { } DogAdder operator+(const DogAdder& other) const { Message msg; - msg << value_.c_str() << other.value_.c_str(); + msg << value_ << other.value_; return DogAdder(msg.GetString().c_str()); } bool operator<(const DogAdder& other) const { return value_ < other.value_; } diff --git a/googletest/test/googletest-printers-test.cc b/googletest/test/googletest-printers-test.cc index 5fdc08675..401e0463f 100644 --- a/googletest/test/googletest-printers-test.cc +++ b/googletest/test/googletest-printers-test.cc @@ -266,7 +266,6 @@ using ::std::set; using ::std::vector; using ::testing::PrintToString; using ::testing::internal::FormatForComparisonFailureMessage; -using ::testing::internal::ImplicitCast_; using ::testing::internal::NativeArray; using ::testing::internal::RelationToSourceReference; using ::testing::internal::Strings; diff --git a/googletest/test/googletest-shuffle-test_.cc b/googletest/test/googletest-shuffle-test_.cc index a14e22f98..b570c4880 100644 --- a/googletest/test/googletest-shuffle-test_.cc +++ b/googletest/test/googletest-shuffle-test_.cc @@ -35,7 +35,6 @@ namespace { using ::testing::EmptyTestEventListener; using ::testing::InitGoogleTest; -using ::testing::Message; using ::testing::Test; using ::testing::TestEventListeners; using ::testing::TestInfo; diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index aea8e1f21..768911ab3 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -211,7 +211,6 @@ using testing::TestPartResult; using testing::TestPartResultArray; using testing::TestProperty; using testing::TestResult; -using testing::TestSuite; using testing::TimeInMillis; using testing::UnitTest; using testing::internal::AlwaysFalse; @@ -227,7 +226,6 @@ using testing::internal::FloatingPoint; using testing::internal::ForEach; using testing::internal::FormatEpochTimeInMillisAsIso8601; using testing::internal::FormatTimeInMillisAsSeconds; -using testing::internal::GetCurrentOsStackTraceExceptTop; using testing::internal::GetElementOr; using testing::internal::GetNextRandomSeed; using testing::internal::GetRandomSeedFromFlag; @@ -244,8 +242,6 @@ using testing::internal::IsNotContainer; using testing::internal::kMaxRandomSeed; using testing::internal::kTestTypeIdInGoogleTest; using testing::internal::NativeArray; -using testing::internal::OsStackTraceGetter; -using testing::internal::OsStackTraceGetterInterface; using testing::internal::ParseFlag; using testing::internal::RelationToSourceCopy; using testing::internal::RelationToSourceReference; @@ -259,7 +255,6 @@ using testing::internal::StreamableToString; using testing::internal::String; using testing::internal::TestEventListenersAccessor; using testing::internal::TestResultAccessor; -using testing::internal::UnitTestImpl; using testing::internal::WideStringToUtf8; using testing::internal::edit_distance::CalculateOptimalEdits; using testing::internal::edit_distance::CreateUnifiedDiff; From 48a1b110583dd55e5076952b2acd772d9aaf6372 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 8 Mar 2023 15:09:58 -0800 Subject: [PATCH 144/336] Add a comment to clarify Fuchsia process launcher requirement. PiperOrigin-RevId: 515154129 Change-Id: I3dd9e912e160d09d1f74a467336212701d4e1b7d --- googletest/src/gtest-death-test.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/googletest/src/gtest-death-test.cc b/googletest/src/gtest-death-test.cc index 649b17b57..1bf2f3120 100644 --- a/googletest/src/gtest-death-test.cc +++ b/googletest/src/gtest-death-test.cc @@ -1024,6 +1024,11 @@ DeathTest::TestRole FuchsiaDeathTest::AssumeRole() { GTEST_DEATH_TEST_CHECK_(status == ZX_OK); // Spawn the child process. + // Note: The test component must have `fuchsia.process.Launcher` declared + // in its manifest. (Fuchsia integration tests require creating a + // "Fuchsia Test Component" which contains a "Fuchsia Component Manifest") + // Launching processes is a privileged operation in Fuschia, and the + // declaration indicates that the ability is required for the component. std::unique_ptr argv = CreateArgvFromArgs(args); status = fdio_spawn_etc(child_job, FDIO_SPAWN_CLONE_ALL, argv[0], argv.get(), nullptr, 2, spawn_actions, From 50e07d1c92875e66138d5d5ee3bb46ef237115bb Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Thu, 9 Mar 2023 01:19:08 -0800 Subject: [PATCH 145/336] Apply clang-tidy fixes PiperOrigin-RevId: 515265927 Change-Id: Iea11668fa4bbf08f6d418a3823e836fb5b874dcc --- googletest/test/googletest-port-test.cc | 4 ++-- googletest/test/gtest_stress_test.cc | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/googletest/test/googletest-port-test.cc b/googletest/test/googletest-port-test.cc index d01ccaae0..1ba3f502c 100644 --- a/googletest/test/googletest-port-test.cc +++ b/googletest/test/googletest-port-test.cc @@ -1104,9 +1104,9 @@ TEST(MutexTest, OnlyOneThreadCanLockAtATime) { // Creates and runs kThreadCount threads that increment locked_counter // kCycleCount times each. for (int i = 0; i < kThreadCount; ++i) { - counting_threads[i].reset(new ThreadType( + counting_threads[i] = std::make_unique( &CountingThreadFunc, make_pair(&locked_counter, kCycleCount), - &threads_can_start)); + &threads_can_start); } threads_can_start.Notify(); for (int i = 0; i < kThreadCount; ++i) counting_threads[i]->Join(); diff --git a/googletest/test/gtest_stress_test.cc b/googletest/test/gtest_stress_test.cc index af9733ad3..0cf218529 100644 --- a/googletest/test/gtest_stress_test.cc +++ b/googletest/test/gtest_stress_test.cc @@ -30,6 +30,7 @@ // Tests that SCOPED_TRACE() and various Google Test assertions can be // used in a large number of threads concurrently. +#include #include #include "gtest/gtest.h" @@ -118,8 +119,8 @@ TEST(StressTest, CanUseScopedTraceAndAssertionsInManyThreads) { std::unique_ptr > threads[kThreadCount]; Notification threads_can_start; for (int i = 0; i != kThreadCount; i++) - threads[i].reset( - new ThreadWithParam(&ManyAsserts, i, &threads_can_start)); + threads[i] = std::make_unique>(&ManyAsserts, i, + &threads_can_start); threads_can_start.Notify(); From 2d3b36d40a04a34edd2d00cdc6e30a20602bb847 Mon Sep 17 00:00:00 2001 From: Sergey Date: Thu, 2 Mar 2023 15:31:26 -0700 Subject: [PATCH 146/336] Environment variables are accessible in UWP/WinRT apps Environment variables, for example `GTEST_FILTER`, `GTEST_OUTPUT` can be set before getting WinRT app run. GoogleTest can read environment variables and use them. It's easier than setting and passing command line parameters to WinRT app. --- googletest/include/gtest/internal/gtest-port.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 0160fadcc..eb78992f2 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -2169,8 +2169,8 @@ inline const char* StrError(int errnum) { return strerror(errnum); } inline const char* GetEnv(const char* name) { #if defined(GTEST_OS_WINDOWS_MOBILE) || defined(GTEST_OS_WINDOWS_PHONE) || \ - defined(GTEST_OS_WINDOWS_RT) || defined(GTEST_OS_ESP8266) || \ - defined(GTEST_OS_XTENSA) || defined(GTEST_OS_QURT) + defined(GTEST_OS_ESP8266) || defined(GTEST_OS_XTENSA) || \ + defined(GTEST_OS_QURT) // We are on an embedded platform, which has no environment variables. static_cast(name); // To prevent 'unused argument' warning. return nullptr; From 038e392ebd8081c756e180475cc361f711fb438d Mon Sep 17 00:00:00 2001 From: Lawrence Wolf-Sonkin Date: Fri, 10 Mar 2023 14:42:38 -0800 Subject: [PATCH 147/336] [gtest] Drop custom-rolled heterogeneous comparator functors in favor of C++ standard ones * Standard heterogeneous comparator functors such as `std::equal_to<>` and `std::less<>` [have been available since C++14](https://en.cppreference.com/w/cpp/utility/functional/less_void) * Now that [C++14 is the minimum supported version of C++ in Googletest](https://github.com/google/oss-policies-info/blob/main/foundational-cxx-support-matrix.md), let's delete these duplications of the standard library PiperOrigin-RevId: 515743068 Change-Id: I1563a2f94039c3a6688429298555545a922f6d7e --- googlemock/include/gmock/gmock-matchers.h | 13 ++--- googletest/include/gtest/gtest-matchers.h | 65 ++++++----------------- 2 files changed, 23 insertions(+), 55 deletions(-) diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index fc00c3560..6b264d690 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -257,6 +257,7 @@ #include #include +#include #include #include #include @@ -1199,27 +1200,27 @@ class PairMatchBase { }; }; -class Eq2Matcher : public PairMatchBase { +class Eq2Matcher : public PairMatchBase> { public: static const char* Desc() { return "an equal pair"; } }; -class Ne2Matcher : public PairMatchBase { +class Ne2Matcher : public PairMatchBase> { public: static const char* Desc() { return "an unequal pair"; } }; -class Lt2Matcher : public PairMatchBase { +class Lt2Matcher : public PairMatchBase> { public: static const char* Desc() { return "a pair where the first < the second"; } }; -class Gt2Matcher : public PairMatchBase { +class Gt2Matcher : public PairMatchBase> { public: static const char* Desc() { return "a pair where the first > the second"; } }; -class Le2Matcher : public PairMatchBase { +class Le2Matcher : public PairMatchBase> { public: static const char* Desc() { return "a pair where the first <= the second"; } }; -class Ge2Matcher : public PairMatchBase { +class Ge2Matcher : public PairMatchBase> { public: static const char* Desc() { return "a pair where the first >= the second"; } }; diff --git a/googletest/include/gtest/gtest-matchers.h b/googletest/include/gtest/gtest-matchers.h index 4a60b0d0b..d73d83414 100644 --- a/googletest/include/gtest/gtest-matchers.h +++ b/googletest/include/gtest/gtest-matchers.h @@ -40,6 +40,7 @@ #define GOOGLETEST_INCLUDE_GTEST_GTEST_MATCHERS_H_ #include +#include #include #include #include @@ -178,43 +179,6 @@ class MatcherInterface : public MatcherDescriberInterface { namespace internal { -struct AnyEq { - template - bool operator()(const A& a, const B& b) const { - return a == b; - } -}; -struct AnyNe { - template - bool operator()(const A& a, const B& b) const { - return a != b; - } -}; -struct AnyLt { - template - bool operator()(const A& a, const B& b) const { - return a < b; - } -}; -struct AnyGt { - template - bool operator()(const A& a, const B& b) const { - return a > b; - } -}; -struct AnyLe { - template - bool operator()(const A& a, const B& b) const { - return a <= b; - } -}; -struct AnyGe { - template - bool operator()(const A& a, const B& b) const { - return a >= b; - } -}; - // A match result listener that ignores the explanation. class DummyMatchResultListener : public MatchResultListener { public: @@ -758,50 +722,53 @@ class ComparisonBase { }; template -class EqMatcher : public ComparisonBase, Rhs, AnyEq> { +class EqMatcher : public ComparisonBase, Rhs, std::equal_to<>> { public: explicit EqMatcher(const Rhs& rhs) - : ComparisonBase, Rhs, AnyEq>(rhs) {} + : ComparisonBase, Rhs, std::equal_to<>>(rhs) {} static const char* Desc() { return "is equal to"; } static const char* NegatedDesc() { return "isn't equal to"; } }; template -class NeMatcher : public ComparisonBase, Rhs, AnyNe> { +class NeMatcher + : public ComparisonBase, Rhs, std::not_equal_to<>> { public: explicit NeMatcher(const Rhs& rhs) - : ComparisonBase, Rhs, AnyNe>(rhs) {} + : ComparisonBase, Rhs, std::not_equal_to<>>(rhs) {} static const char* Desc() { return "isn't equal to"; } static const char* NegatedDesc() { return "is equal to"; } }; template -class LtMatcher : public ComparisonBase, Rhs, AnyLt> { +class LtMatcher : public ComparisonBase, Rhs, std::less<>> { public: explicit LtMatcher(const Rhs& rhs) - : ComparisonBase, Rhs, AnyLt>(rhs) {} + : ComparisonBase, Rhs, std::less<>>(rhs) {} static const char* Desc() { return "is <"; } static const char* NegatedDesc() { return "isn't <"; } }; template -class GtMatcher : public ComparisonBase, Rhs, AnyGt> { +class GtMatcher : public ComparisonBase, Rhs, std::greater<>> { public: explicit GtMatcher(const Rhs& rhs) - : ComparisonBase, Rhs, AnyGt>(rhs) {} + : ComparisonBase, Rhs, std::greater<>>(rhs) {} static const char* Desc() { return "is >"; } static const char* NegatedDesc() { return "isn't >"; } }; template -class LeMatcher : public ComparisonBase, Rhs, AnyLe> { +class LeMatcher + : public ComparisonBase, Rhs, std::less_equal<>> { public: explicit LeMatcher(const Rhs& rhs) - : ComparisonBase, Rhs, AnyLe>(rhs) {} + : ComparisonBase, Rhs, std::less_equal<>>(rhs) {} static const char* Desc() { return "is <="; } static const char* NegatedDesc() { return "isn't <="; } }; template -class GeMatcher : public ComparisonBase, Rhs, AnyGe> { +class GeMatcher + : public ComparisonBase, Rhs, std::greater_equal<>> { public: explicit GeMatcher(const Rhs& rhs) - : ComparisonBase, Rhs, AnyGe>(rhs) {} + : ComparisonBase, Rhs, std::greater_equal<>>(rhs) {} static const char* Desc() { return "is >="; } static const char* NegatedDesc() { return "isn't >="; } }; From 391ce627def20c1e8a54d10b12949b15086473dd Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Sat, 11 Mar 2023 02:48:04 -0800 Subject: [PATCH 148/336] Internal Code Change PiperOrigin-RevId: 515855852 Change-Id: I8016eefd45c36089e189bbd1ebbe9fdabe68255b --- googlemock/include/gmock/gmock-matchers.h | 1 + 1 file changed, 1 insertion(+) diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index 6b264d690..a480576dd 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -1474,6 +1474,7 @@ class SomeOfArrayMatcher { operator Matcher() const { // NOLINT using RawU = typename std::decay::type; std::vector> matchers; + matchers.reserve(matchers_.size()); for (const auto& matcher : matchers_) { matchers.push_back(MatcherCast(matcher)); } From abad8af018b232a089ea6397383a2b8fc4422cc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Sroczy=C5=84ski?= Date: Tue, 14 Mar 2023 23:48:08 +0100 Subject: [PATCH 149/336] Add COMPONENT to install --- googletest/CMakeLists.txt | 2 ++ googletest/cmake/internal_utils.cmake | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/googletest/CMakeLists.txt b/googletest/CMakeLists.txt index 95bfa4420..d06c14797 100644 --- a/googletest/CMakeLists.txt +++ b/googletest/CMakeLists.txt @@ -100,12 +100,14 @@ if (INSTALL_GTEST) set(version_file "${generated_dir}/${cmake_package_name}ConfigVersion.cmake") write_basic_package_version_file(${version_file} VERSION ${GOOGLETEST_VERSION} COMPATIBILITY AnyNewerVersion) install(EXPORT ${targets_export_name} + COMPONENT "${PROJECT_NAME}" NAMESPACE ${cmake_package_name}:: DESTINATION ${cmake_files_install_dir}) set(config_file "${generated_dir}/${cmake_package_name}Config.cmake") configure_package_config_file("${gtest_SOURCE_DIR}/cmake/Config.cmake.in" "${config_file}" INSTALL_DESTINATION ${cmake_files_install_dir}) install(FILES ${version_file} ${config_file} + COMPONENT "${PROJECT_NAME}" DESTINATION ${cmake_files_install_dir}) endif() diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index b09da33fa..edf637e22 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -327,10 +327,12 @@ endfunction() function(install_project) if(INSTALL_GTEST) install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/" + COMPONENT "${PROJECT_NAME}" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") # Install the project targets. install(TARGETS ${ARGN} EXPORT ${targets_export_name} + COMPONENT "${PROJECT_NAME}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") @@ -342,6 +344,7 @@ function(install_project) get_target_property(t_pdb_output_directory ${t} PDB_OUTPUT_DIRECTORY) install(FILES "${t_pdb_output_directory}/\${CMAKE_INSTALL_CONFIG_NAME}/$<$:${t_pdb_name_debug}>$<$>:${t_pdb_name}>.pdb" + COMPONENT "${PROJECT_NAME}" DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL) endforeach() @@ -352,6 +355,7 @@ function(install_project) configure_file("${PROJECT_SOURCE_DIR}/cmake/${t}.pc.in" "${configured_pc}" @ONLY) install(FILES "${configured_pc}" + COMPONENT "${PROJECT_NAME}" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") endforeach() endif() From f53219cdcb7b084ef57414efea92ee5b71989558 Mon Sep 17 00:00:00 2001 From: Deanna Garcia Date: Thu, 16 Mar 2023 10:47:38 -0700 Subject: [PATCH 150/336] Move transitive dependencies of googletest to googletest_deps.bzl to allow other bazel projects to depend on that rule instead of googletests' transitive dependencies directly. PiperOrigin-RevId: 517166391 Change-Id: I9158e24d3f9613f3bcc811c028e1a15f213b7c40 --- WORKSPACE | 19 +++---------------- googletest_deps.bzl | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 16 deletions(-) create mode 100644 googletest_deps.bzl diff --git a/WORKSPACE b/WORKSPACE index cb5f83faf..1c8ea24d3 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,23 +1,10 @@ workspace(name = "com_google_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-02-27T15:50:25Z - sha256 = "baf8e734ac3ce213a889ce7c248b981ee1730e2093e32808e0f0a910dc985f76", - strip_prefix = "abseil-cpp-0c1114c4fb83c844c7fd74708338cca1d3d9b0dc", - urls = ["https://github.com/abseil/abseil-cpp/archive/0c1114c4fb83c844c7fd74708338cca1d3d9b0dc.zip"], -) - -# 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"], -) - http_archive( name = "rules_python", # 2023-01-10T22:00:51Z sha256 = "5de54486a60ad8948dabe49605bb1c08053e04001a431ab3e96745b4d97a4419", diff --git a/googletest_deps.bzl b/googletest_deps.bzl new file mode 100644 index 000000000..7fe809616 --- /dev/null +++ b/googletest_deps.bzl @@ -0,0 +1,22 @@ +"""Load dependencies needed to use the googletest library as a 3rd-party consumer.""" + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +def googletest_deps(): + """Loads common dependencies needed to use the googletest library.""" + + if not native.existing_rule("com_googlesource_code_re2"): + 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"], + ) + + if not native.existing_rule("com_google_absl"): + http_archive( + name = "com_google_absl", # 2023-02-27T15:50:25Z + sha256 = "baf8e734ac3ce213a889ce7c248b981ee1730e2093e32808e0f0a910dc985f76", + strip_prefix = "abseil-cpp-0c1114c4fb83c844c7fd74708338cca1d3d9b0dc", + urls = ["https://github.com/abseil/abseil-cpp/archive/0c1114c4fb83c844c7fd74708338cca1d3d9b0dc.zip"], + ) From 28219b169c62f110f7b85810b60bfdd4eedea9ef Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Sun, 19 Mar 2023 14:30:14 -0700 Subject: [PATCH 151/336] Fix typo in test case name. PiperOrigin-RevId: 517814929 Change-Id: I2bc498ba048d4deab1cf2a021487f63fe44c466d --- googletest/test/gtest_unittest.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index 768911ab3..bd4fc60a6 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -6975,7 +6975,7 @@ TEST(EventListenerTest, SuppressEventForwarding) { // Tests that events generated by Google Test are not forwarded in // death test subprocesses. -TEST(EventListenerDeathTest, EventsNotForwardedInDeathTestSubprecesses) { +TEST(EventListenerDeathTest, EventsNotForwardedInDeathTestSubprocesses) { EXPECT_DEATH_IF_SUPPORTED( { GTEST_CHECK_(TestEventListenersAccessor::EventForwardingEnabled( From 9fd3fb00ff2f94a8b4aad9f757e94bf89f9b8ead Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Mon, 20 Mar 2023 02:42:15 -0700 Subject: [PATCH 152/336] Remove unused using-declarations in sample unit tests PiperOrigin-RevId: 517910369 Change-Id: I87f29fb09bc83e7d1c7cffdf267b2f691d261c26 --- googletest/samples/sample10_unittest.cc | 1 - googletest/samples/sample9_unittest.cc | 1 - 2 files changed, 2 deletions(-) diff --git a/googletest/samples/sample10_unittest.cc b/googletest/samples/sample10_unittest.cc index 95b4811b8..210795493 100644 --- a/googletest/samples/sample10_unittest.cc +++ b/googletest/samples/sample10_unittest.cc @@ -38,7 +38,6 @@ using ::testing::InitGoogleTest; using ::testing::Test; using ::testing::TestEventListeners; using ::testing::TestInfo; -using ::testing::TestPartResult; using ::testing::UnitTest; namespace { diff --git a/googletest/samples/sample9_unittest.cc b/googletest/samples/sample9_unittest.cc index d627ea7d5..0a2f0970d 100644 --- a/googletest/samples/sample9_unittest.cc +++ b/googletest/samples/sample9_unittest.cc @@ -40,7 +40,6 @@ using ::testing::Test; using ::testing::TestEventListeners; using ::testing::TestInfo; using ::testing::TestPartResult; -using ::testing::TestSuite; using ::testing::UnitTest; namespace { // Provides alternative output mode which produces minimal amount of From 471087fbfcbc3c66071189a67c313eb1d525ee51 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Mon, 20 Mar 2023 02:43:07 -0700 Subject: [PATCH 153/336] Introduce std::make_unique and bool literals where possible PiperOrigin-RevId: 517910526 Change-Id: I398704f4b2ca0a55c86a06ca8b47d34c8670ddd7 --- googlemock/test/gmock-actions_test.cc | 14 +++++--------- googlemock/test/gmock-matchers-comparisons_test.cc | 3 ++- googlemock/test/gmock-matchers-containers_test.cc | 4 ++-- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc index 7734830ec..ee9b889bd 100644 --- a/googlemock/test/gmock-actions_test.cc +++ b/googlemock/test/gmock-actions_test.cc @@ -444,7 +444,7 @@ TEST(DefaultValueTest, GetWorksForMoveOnlyIfSet) { EXPECT_TRUE(DefaultValue>::Exists()); EXPECT_TRUE(DefaultValue>::Get() == nullptr); DefaultValue>::SetFactory( - [] { return std::unique_ptr(new int(42)); }); + [] { return std::make_unique(42); }); EXPECT_TRUE(DefaultValue>::Exists()); std::unique_ptr i = DefaultValue>::Get(); EXPECT_EQ(42, *i); @@ -1751,9 +1751,7 @@ TEST(ReturnNewTest, ConstructorThatTakes10Arguments) { delete c; } -std::unique_ptr UniquePtrSource() { - return std::unique_ptr(new int(19)); -} +std::unique_ptr UniquePtrSource() { return std::make_unique(19); } std::vector> VectorUniquePtrSource() { std::vector> out; @@ -1802,7 +1800,7 @@ TEST(MockMethodTest, CanReturnMoveOnlyValue_Invoke) { // Check default value DefaultValue>::SetFactory( - [] { return std::unique_ptr(new int(42)); }); + [] { return std::make_unique(42); }); EXPECT_EQ(42, *mock.MakeUnique()); EXPECT_CALL(mock, MakeUnique()).WillRepeatedly(Invoke(UniquePtrSource)); @@ -1822,7 +1820,7 @@ TEST(MockMethodTest, CanReturnMoveOnlyValue_Invoke) { TEST(MockMethodTest, CanTakeMoveOnlyValue) { MockClass mock; - auto make = [](int i) { return std::unique_ptr(new int(i)); }; + auto make = [](int i) { return std::make_unique(i); }; EXPECT_CALL(mock, TakeUnique(_)).WillRepeatedly([](std::unique_ptr i) { return *i; @@ -2053,9 +2051,7 @@ struct Double { } }; -std::unique_ptr UniqueInt(int i) { - return std::unique_ptr(new int(i)); -} +std::unique_ptr UniqueInt(int i) { return std::make_unique(i); } TEST(FunctorActionTest, ActionFromFunction) { Action a = &Add; diff --git a/googlemock/test/gmock-matchers-comparisons_test.cc b/googlemock/test/gmock-matchers-comparisons_test.cc index 0738aafb7..b849990d8 100644 --- a/googlemock/test/gmock-matchers-comparisons_test.cc +++ b/googlemock/test/gmock-matchers-comparisons_test.cc @@ -31,6 +31,7 @@ // // This file tests some commonly used argument matchers. +#include #include #include "test/gmock-matchers_test.h" @@ -1542,7 +1543,7 @@ TEST(PairTest, MatchesCorrectly) { TEST(PairTest, WorksWithMoveOnly) { pair, std::unique_ptr> p; - p.second.reset(new int(7)); + p.second = std::make_unique(7); EXPECT_THAT(p, Pair(Eq(nullptr), Ne(nullptr))); } diff --git a/googlemock/test/gmock-matchers-containers_test.cc b/googlemock/test/gmock-matchers-containers_test.cc index b40a26a47..c8d8ea378 100644 --- a/googlemock/test/gmock-matchers-containers_test.cc +++ b/googlemock/test/gmock-matchers-containers_test.cc @@ -1824,8 +1824,8 @@ TEST(UnorderedElementsAreArrayTest, SucceedsWhenExpected) { } TEST(UnorderedElementsAreArrayTest, VectorBool) { - const bool a[] = {0, 1, 0, 1, 1}; - const bool b[] = {1, 0, 1, 1, 0}; + const bool a[] = {false, true, false, true, true}; + const bool b[] = {true, false, true, true, false}; std::vector expected(std::begin(a), std::end(a)); std::vector actual(std::begin(b), std::end(b)); StringMatchResultListener listener; From 3288c4deae0710464a0fd21316084c408798b960 Mon Sep 17 00:00:00 2001 From: Phoebe Liang Date: Mon, 20 Mar 2023 12:11:18 -0700 Subject: [PATCH 154/336] Revise documentation to include AbslStringify PiperOrigin-RevId: 518039451 Change-Id: Ife548d0f83266746ce1981bea31e70e6b43027c9 --- docs/advanced.md | 199 ++++++++++++++++++++++++++--------------------- 1 file changed, 111 insertions(+), 88 deletions(-) diff --git a/docs/advanced.md b/docs/advanced.md index 6b4c3f0b5..d0369237e 100644 --- a/docs/advanced.md +++ b/docs/advanced.md @@ -1,9 +1,9 @@ -# Advanced googletest Topics +# Advanced GoogleTest Topics ## Introduction -Now that you have read the [googletest Primer](primer.md) and learned how to -write tests using googletest, it's time to learn some new tricks. This document +Now that you have read the [GoogleTest Primer](primer.md) and learned how to +write tests using GoogleTest, it's time to learn some new tricks. This document will show you more assertions as well as how to construct complex failure messages, propagate fatal failures, reuse and speed up your test fixtures, and use various flags with your tests. @@ -25,7 +25,7 @@ Reference. ### Predicate Assertions for Better Error Messages -Even though googletest has a rich set of assertions, they can never be complete, +Even though GoogleTest has a rich set of assertions, they can never be complete, as it's impossible (nor a good idea) to anticipate all scenarios a user might run into. Therefore, sometimes a user has to use `EXPECT_TRUE()` to check a complex expression, for lack of a better macro. This has the problem of not @@ -35,7 +35,7 @@ failure message by themselves, streaming it into `EXPECT_TRUE()`. However, this is awkward especially when the expression has side-effects or is expensive to evaluate. -googletest gives you three different options to solve this problem: +GoogleTest gives you three different options to solve this problem: #### Using an Existing Boolean Function @@ -304,9 +304,9 @@ TEST_F(SkipFixture, SkipsOneTest) { As with assertion macros, you can stream a custom message into `GTEST_SKIP()`. -## Teaching googletest How to Print Your Values +## Teaching GoogleTest How to Print Your Values -When a test assertion such as `EXPECT_EQ` fails, googletest prints the argument +When a test assertion such as `EXPECT_EQ` fails, GoogleTest prints the argument values to help you debug. It does this using a user-extensible value printer. This printer knows how to print built-in C++ types, native arrays, STL @@ -315,73 +315,96 @@ prints the raw bytes in the value and hopes that you the user can figure it out. As mentioned earlier, the printer is *extensible*. That means you can teach it to do a better job at printing your particular type than to dump the bytes. To -do that, define `<<` for your type: - -```c++ -#include +do that, define an `AbslStringify()` overload as a `friend` function template +for your type: +```cpp namespace foo { -class Bar { // We want googletest to be able to print instances of this. -... - // Create a free inline friend function. - friend std::ostream& operator<<(std::ostream& os, const Bar& bar) { - return os << bar.DebugString(); // whatever needed to print bar to os +class Point { // We want GoogleTest to be able to print instances of this. + ... + // Provide a friend overload. + template + friend void AbslStringify(Sink& sink, const Point& point) { + absl::Format(&sink, "(%d, %d)", point.x, point.y); } + + int x; + int y; }; // If you can't declare the function in the class it's important that the -// << operator is defined in the SAME namespace that defines Bar. C++'s look-up -// rules rely on that. -std::ostream& operator<<(std::ostream& os, const Bar& bar) { - return os << bar.DebugString(); // whatever needed to print bar to os +// AbslStringify overload is defined in the SAME namespace that defines Point. +// C++'s look-up rules rely on that. +enum class EnumWithStringify { kMany = 0, kChoices = 1 }; + +template +void AbslStringify(Sink& sink, EnumWithStringify e) { + absl::Format(&sink, "%s", e == EnumWithStringify::kMany ? "Many" : "Choices"); } } // namespace foo ``` -Sometimes, this might not be an option: your team may consider it bad style to -have a `<<` operator for `Bar`, or `Bar` may already have a `<<` operator that -doesn't do what you want (and you cannot change it). If so, you can instead -define a `PrintTo()` function like this: +{: .callout .note} +Note: `AbslStringify()` utilizes a generic "sink" buffer to construct its +string. For more information about supported operations on `AbslStringify()`'s +sink, see go/abslstringify. + +`AbslStringify()` can also use `absl::StrFormat`'s catch-all `%v` type specifier +within its own format strings to perform type deduction. `Point` above could be +formatted as `"(%v, %v)"` for example, and deduce the `int` values as `%d`. + +Sometimes, `AbslStringify()` might not be an option: your team may wish to print +types with extra debugging information for testing purposes only. If so, you can +instead define a `PrintTo()` function like this: ```c++ #include namespace foo { -class Bar { +class Point { ... - friend void PrintTo(const Bar& bar, std::ostream* os) { - *os << bar.DebugString(); // whatever needed to print bar to os + friend void PrintTo(const Point& point, std::ostream* os) { + *os << "(" << point.x << "," << point.y << ")"; } + + int x; + int y; }; // If you can't declare the function in the class it's important that PrintTo() -// is defined in the SAME namespace that defines Bar. C++'s look-up rules rely -// on that. -void PrintTo(const Bar& bar, std::ostream* os) { - *os << bar.DebugString(); // whatever needed to print bar to os +// is defined in the SAME namespace that defines Point. C++'s look-up rules +// rely on that. +void PrintTo(const Point& point, std::ostream* os) { + *os << "(" << point.x << "," << point.y << ")"; } } // namespace foo ``` -If you have defined both `<<` and `PrintTo()`, the latter will be used when -googletest is concerned. This allows you to customize how the value appears in -googletest's output without affecting code that relies on the behavior of its -`<<` operator. +If you have defined both `AbslStringify()` and `PrintTo()`, the latter will be +used by GoogleTest. This allows you to customize how the value appears in +GoogleTest's output without affecting code that relies on the behavior of +`AbslStringify()`. -If you want to print a value `x` using googletest's value printer yourself, just +If you have an existing `<<` operator and would like to define an +`AbslStringify()`, the latter will be used for GoogleTest printing. + +If you want to print a value `x` using GoogleTest's value printer yourself, just call `::testing::PrintToString(x)`, which returns an `std::string`: ```c++ -vector > bar_ints = GetBarIntVector(); +vector > point_ints = GetPointIntVector(); -EXPECT_TRUE(IsCorrectBarIntVector(bar_ints)) - << "bar_ints = " << testing::PrintToString(bar_ints); +EXPECT_TRUE(IsCorrectPointIntVector(point_ints)) + << "point_ints = " << testing::PrintToString(point_ints); ``` +For more details regarding `AbslStringify()` and its integration with other +libraries, see go/abslstringify. + ## Death Tests In many applications, there are assertions that can cause application failure if @@ -451,7 +474,7 @@ Note that a death test only cares about three things: 3. does the stderr output match `matcher`? In particular, if `statement` generates an `ASSERT_*` or `EXPECT_*` failure, it -will **not** cause the death test to fail, as googletest assertions don't abort +will **not** cause the death test to fail, as GoogleTest assertions don't abort the process. ### Death Test Naming @@ -482,14 +505,14 @@ TEST_F(FooDeathTest, DoesThat) { ### Regular Expression Syntax -When built with Bazel and using Abseil, googletest uses the +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 +systems (Linux, Cygwin, Mac), GoogleTest uses the [POSIX extended regular expression](http://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](http://en.wikipedia.org/wiki/Regular_expression#POSIX_extended). -On Windows, googletest uses its own simple regular expression implementation. It +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 @@ -519,7 +542,7 @@ Expression | Meaning `$` | 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 +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 @@ -539,7 +562,7 @@ arrange that kind of environment. For example, statically-initialized modules may start threads before main is ever reached. Once threads have been created, it may be difficult or impossible to clean them up. -googletest has three features intended to raise awareness of threading issues. +GoogleTest has three features intended to raise awareness of threading issues. 1. A warning is emitted if multiple threads are running when a death test is encountered. @@ -592,7 +615,7 @@ TEST(MyDeathTest, TestTwo) { The `statement` argument of `ASSERT_EXIT()` can be any valid C++ statement. If it leaves the current function via a `return` statement or by throwing an -exception, the death test is considered to have failed. Some googletest macros +exception, the death test is considered to have failed. Some GoogleTest macros may return from the current function (e.g. `ASSERT_TRUE()`), so be sure to avoid them in `statement`. @@ -726,7 +749,7 @@ TEST(FooTest, Bar) { } ``` -To alleviate this, googletest provides three different solutions. You could use +To alleviate this, GoogleTest provides three different solutions. You could use either exceptions, the `(ASSERT|EXPECT)_NO_FATAL_FAILURE` assertions or the `HasFatalFailure()` function. They are described in the following two subsections. @@ -760,7 +783,7 @@ in it, the test will continue after the subroutine returns. This may not be what you want. Often people want fatal failures to propagate like exceptions. For that -googletest offers the following macros: +GoogleTest offers the following macros: Fatal assertion | Nonfatal assertion | Verifies ------------------------------------- | ------------------------------------- | -------- @@ -852,7 +875,7 @@ will output XML like this: > needs to be prefixed with `::testing::Test::` if used outside of the > `TEST` body and the test fixture class. > * *`key`* must be a valid XML attribute name, and cannot conflict with the -> ones already used by googletest (`name`, `status`, `time`, `classname`, +> ones already used by GoogleTest (`name`, `status`, `time`, `classname`, > `type_param`, and `value_param`). > * Calling `RecordProperty()` outside of the lifespan of a test is allowed. > If it's called outside of a test but between a test suite's @@ -863,13 +886,13 @@ will output XML like this: ## Sharing Resources Between Tests in the Same Test Suite -googletest creates a new test fixture object for each test in order to make +GoogleTest creates a new test fixture object for each test in order to make tests independent and easier to debug. However, sometimes tests use resources that are expensive to set up, making the one-copy-per-test model prohibitively expensive. If the tests don't change the resource, there's no harm in their sharing a -single resource copy. So, in addition to per-test set-up/tear-down, googletest +single resource copy. So, in addition to per-test set-up/tear-down, GoogleTest also supports per-test-suite set-up/tear-down. To use it: 1. In your test fixture class (say `FooTest` ), declare as `static` some member @@ -881,7 +904,7 @@ also supports per-test-suite set-up/tear-down. To use it: `u`!) to set up the shared resources and a `static void TearDownTestSuite()` function to tear them down. -That's it! googletest automatically calls `SetUpTestSuite()` before running the +That's it! GoogleTest automatically calls `SetUpTestSuite()` before running the *first test* in the `FooTest` test suite (i.e. before creating the first `FooTest` object), and calls `TearDownTestSuite()` after running the *last test* in it (i.e. after deleting the last `FooTest` object). In between, the tests can @@ -974,7 +997,7 @@ class Environment : public ::testing::Environment { }; ``` -Then, you register an instance of your environment class with googletest by +Then, you register an instance of your environment class with GoogleTest by calling the `::testing::AddGlobalTestEnvironment()` function: ```c++ @@ -991,7 +1014,7 @@ It's OK to register multiple environment objects. In this suite, their `SetUp()` will be called in the order they are registered, and their `TearDown()` will be called in the reverse order. -Note that googletest takes ownership of the registered environment objects. +Note that GoogleTest takes ownership of the registered environment objects. Therefore **do not delete them** by yourself. You should call `AddGlobalTestEnvironment()` before `RUN_ALL_TESTS()` is called, @@ -1501,12 +1524,12 @@ To test them, we use the following special techniques: ## "Catching" Failures -If you are building a testing utility on top of googletest, you'll want to test -your utility. What framework would you use to test it? googletest, of course. +If you are building a testing utility on top of GoogleTest, you'll want to test +your utility. What framework would you use to test it? GoogleTest, of course. The challenge is to verify that your testing utility reports failures correctly. In frameworks that report a failure by throwing an exception, you could catch -the exception and assert on it. But googletest doesn't use exceptions, so how do +the exception and assert on it. But GoogleTest doesn't use exceptions, so how do we test that a piece of code generates an expected failure? `"gtest/gtest-spi.h"` contains some constructs to do this. @@ -1649,9 +1672,9 @@ particular, you cannot find the test suite name in `SetUpTestSuite()`, `TearDownTestSuite()` (where you know the test suite name implicitly), or functions called from them. -## Extending googletest by Handling Test Events +## Extending GoogleTest by Handling Test Events -googletest provides an **event listener API** to let you receive notifications +GoogleTest provides an **event listener API** to let you receive notifications about the progress of a test program and test failures. The events you can listen to include the start and end of the test program, a test suite, or a test method, among others. You may use this API to augment or replace the standard @@ -1712,7 +1735,7 @@ Here's an example: ### Using Event Listeners To use the event listener you have defined, add an instance of it to the -googletest event listener list (represented by class +GoogleTest event listener list (represented by class [`TestEventListeners`](reference/testing.md#TestEventListeners) - note the "s" at the end of the name) in your `main()` function, before calling `RUN_ALL_TESTS()`: @@ -1723,7 +1746,7 @@ int main(int argc, char** argv) { // Gets hold of the event listener list. testing::TestEventListeners& listeners = testing::UnitTest::GetInstance()->listeners(); - // Adds a listener to the end. googletest takes the ownership. + // Adds a listener to the end. GoogleTest takes the ownership. listeners.Append(new MinimalistPrinter); return RUN_ALL_TESTS(); } @@ -1775,7 +1798,7 @@ See [sample10_unittest.cc] for an example of a failure-raising listener. ## Running Test Programs: Advanced Options -googletest test programs are ordinary executables. Once built, you can run them +GoogleTest test programs are ordinary executables. Once built, you can run them directly and affect their behavior via the following environment variables and/or command line flags. For the flags to work, your programs must call `::testing::InitGoogleTest()` before calling `RUN_ALL_TESTS()`. @@ -1808,10 +1831,10 @@ corresponding environment variable for this flag. #### Running a Subset of the Tests -By default, a googletest program runs all tests the user has defined. Sometimes, +By default, a GoogleTest program runs all tests the user has defined. Sometimes, you want to run only a subset of the tests (e.g. for debugging or quickly verifying a change). If you set the `GTEST_FILTER` environment variable or the -`--gtest_filter` flag to a filter string, googletest will only run the tests +`--gtest_filter` flag to a filter string, GoogleTest will only run the tests whose full names (in the form of `TestSuiteName.TestName`) match the filter. The format of a filter is a '`:`'-separated list of wildcard patterns (called @@ -1842,7 +1865,7 @@ For example: #### Stop test execution upon first failure -By default, a googletest program runs all tests the user has defined. In some +By default, a GoogleTest program runs all tests the user has defined. In some cases (e.g. iterative test development & execution) it may be desirable stop test execution upon first failure (trading improved latency for completeness). If `GTEST_FAIL_FAST` environment variable or `--gtest_fail_fast` flag is set, @@ -1859,7 +1882,7 @@ If you need to disable all tests in a test suite, you can either add `DISABLED_` to the front of the name of each test, or alternatively add it to the front of the test suite name. -For example, the following tests won't be run by googletest, even though they +For example, the following tests won't be run by GoogleTest, even though they will still be compiled: ```c++ @@ -1874,7 +1897,7 @@ TEST_F(DISABLED_BarTest, DoesXyz) { ... } {: .callout .note} NOTE: This feature should only be used for temporary pain-relief. You still have -to fix the disabled tests at a later date. As a reminder, googletest will print +to fix the disabled tests at a later date. As a reminder, GoogleTest will print a banner warning you if a test program contains any disabled tests. {: .callout .tip} @@ -1932,16 +1955,16 @@ You can specify the `--gtest_shuffle` flag (or set the `GTEST_SHUFFLE` environment variable to `1`) to run the tests in a program in a random order. This helps to reveal bad dependencies between tests. -By default, googletest uses a random seed calculated from the current time. +By default, GoogleTest uses a random seed calculated from the current time. Therefore you'll get a different order every time. The console output includes the random seed value, such that you can reproduce an order-related test failure later. To specify the random seed explicitly, use the `--gtest_random_seed=SEED` flag (or set the `GTEST_RANDOM_SEED` environment variable), where `SEED` is an integer in the range [0, 99999]. The seed value 0 is special: it tells -googletest to do the default behavior of calculating the seed from the current +GoogleTest to do the default behavior of calculating the seed from the current time. -If you combine this with `--gtest_repeat=N`, googletest will pick a different +If you combine this with `--gtest_repeat=N`, GoogleTest will pick a different random seed and re-shuffle the tests in each iteration. ### Distributing Test Functions to Multiple Machines @@ -2000,7 +2023,7 @@ shards, but here's one possible scenario: #### Colored Terminal Output -googletest can use colors in its terminal output to make it easier to spot the +GoogleTest can use colors in its terminal output to make it easier to spot the important information:
...
@@ -2025,25 +2048,25 @@ important information:
 
 You can set the `GTEST_COLOR` environment variable or the `--gtest_color`
 command line flag to `yes`, `no`, or `auto` (the default) to enable colors,
-disable colors, or let googletest decide. When the value is `auto`, googletest
+disable colors, or let GoogleTest decide. When the value is `auto`, GoogleTest
 will use colors if and only if the output goes to a terminal and (on non-Windows
 platforms) the `TERM` environment variable is set to `xterm` or `xterm-color`.
 
 #### Suppressing test passes
 
-By default, googletest prints 1 line of output for each test, indicating if it
+By default, GoogleTest prints 1 line of output for each test, indicating if it
 passed or failed. To show only test failures, run the test program with
 `--gtest_brief=1`, or set the GTEST_BRIEF environment variable to `1`.
 
 #### Suppressing the Elapsed Time
 
-By default, googletest prints the time it takes to run each test. To disable
+By default, GoogleTest prints the time it takes to run each test. To disable
 that, run the test program with the `--gtest_print_time=0` command line flag, or
 set the GTEST_PRINT_TIME environment variable to `0`.
 
 #### Suppressing UTF-8 Text Output
 
-In case of assertion failures, googletest prints expected and actual values of
+In case of assertion failures, GoogleTest prints expected and actual values of
 type `string` both as hex-encoded strings as well as in readable UTF-8 text if
 they contain valid non-ASCII UTF-8 characters. If you want to suppress the UTF-8
 text because, for example, you don't have an UTF-8 compatible output medium, run
@@ -2052,7 +2075,7 @@ environment variable to `0`.
 
 #### Generating an XML Report
 
-googletest can emit a detailed XML report to a file in addition to its normal
+GoogleTest can emit a detailed XML report to a file in addition to its normal
 textual output. The report contains the duration of each test, and thus can help
 you identify slow tests.
 
@@ -2063,15 +2086,15 @@ in which case the output can be found in the `test_detail.xml` file in the
 current directory.
 
 If you specify a directory (for example, `"xml:output/directory/"` on Linux or
-`"xml:output\directory\"` on Windows), googletest will create the XML file in
+`"xml:output\directory\"` on Windows), GoogleTest will create the XML file in
 that directory, named after the test executable (e.g. `foo_test.xml` for test
 program `foo_test` or `foo_test.exe`). If the file already exists (perhaps left
-over from a previous run), googletest will pick a different name (e.g.
+over from a previous run), GoogleTest will pick a different name (e.g.
 `foo_test_1.xml`) to avoid overwriting it.
 
 The report is based on the `junitreport` Ant task. Since that format was
 originally intended for Java, a little interpretation is required to make it
-apply to googletest tests, as shown here:
+apply to GoogleTest tests, as shown here:
 
 ```xml
 
@@ -2086,8 +2109,8 @@ apply to googletest tests, as shown here:
 ```
 
 *   The root `` element corresponds to the entire test program.
-*   `` elements correspond to googletest test suites.
-*   `` elements correspond to googletest test functions.
+*   `` elements correspond to GoogleTest test suites.
+*   `` elements correspond to GoogleTest test functions.
 
 For instance, the following program
 
@@ -2120,7 +2143,7 @@ could generate this report:
 Things to note:
 
 *   The `tests` attribute of a `` or `` element tells how
-    many test functions the googletest program or test suite contains, while the
+    many test functions the GoogleTest program or test suite contains, while the
     `failures` attribute tells how many of them failed.
 
 *   The `time` attribute expresses the duration of the test, test suite, or
@@ -2132,12 +2155,12 @@ Things to note:
 *   The `file` and `line` attributes record the source file location, where the
     test was defined.
 
-*   Each `` element corresponds to a single failed googletest
+*   Each `` element corresponds to a single failed GoogleTest
     assertion.
 
 #### Generating a JSON Report
 
-googletest can also emit a JSON report as an alternative format to XML. To
+GoogleTest can also emit a JSON report as an alternative format to XML. To
 generate the JSON report, set the `GTEST_OUTPUT` environment variable or the
 `--gtest_output` flag to the string `"json:path_to_output_file"`, which will
 create the file at the given location. You can also just use the string
@@ -2362,7 +2385,7 @@ variable has been set.
 
 When running test programs under a debugger, it's very convenient if the
 debugger can catch an assertion failure and automatically drop into interactive
-mode. googletest's *break-on-failure* mode supports this behavior.
+mode. GoogleTest's *break-on-failure* mode supports this behavior.
 
 To enable it, set the `GTEST_BREAK_ON_FAILURE` environment variable to a value
 other than `0`. Alternatively, you can use the `--gtest_break_on_failure`
@@ -2370,9 +2393,9 @@ command line flag.
 
 #### Disabling Catching Test-Thrown Exceptions
 
-googletest can be used either with or without exceptions enabled. If a test
+GoogleTest can be used either with or without exceptions enabled. If a test
 throws a C++ exception or (on Windows) a structured exception (SEH), by default
-googletest catches it, reports it as a test failure, and continues with the next
+GoogleTest catches it, reports it as a test failure, and continues with the next
 test method. This maximizes the coverage of a test run. Also, on Windows an
 uncaught exception will cause a pop-up window, so catching the exceptions allows
 you to run the tests automatically.
@@ -2410,4 +2433,4 @@ void __tsan_on_report() {
 ```
 
 After compiling your project with one of the sanitizers enabled, if a particular
-test triggers a sanitizer error, googletest will report that it failed.
+test triggers a sanitizer error, GoogleTest will report that it failed.

From e9faae170f8ab3086a76c299f19d659ba6079967 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Tue, 21 Mar 2023 02:35:52 -0700
Subject: [PATCH 155/336] Internal Code Change

PiperOrigin-RevId: 518213370
Change-Id: I88d0acc195dadf8d03cd15c8534c721141db14ea
---
 googlemock/include/gmock/gmock-matchers.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h
index a480576dd..7c5d65cf1 100644
--- a/googlemock/include/gmock/gmock-matchers.h
+++ b/googlemock/include/gmock/gmock-matchers.h
@@ -563,7 +563,7 @@ namespace internal {
 // If the explanation is not empty, prints it to the ostream.
 inline void PrintIfNotEmpty(const std::string& explanation,
                             ::std::ostream* os) {
-  if (explanation != "" && os != nullptr) {
+  if (!explanation.empty() && os != nullptr) {
     *os << ", " << explanation;
   }
 }
@@ -2966,7 +2966,7 @@ class KeyMatcherImpl : public MatcherInterface {
     const bool match = inner_matcher_.MatchAndExplain(
         pair_getters::First(key_value, Rank0()), &inner_listener);
     const std::string explanation = inner_listener.str();
-    if (explanation != "") {
+    if (!explanation.empty()) {
       *listener << "whose first field is a value " << explanation;
     }
     return match;
@@ -3113,12 +3113,12 @@ class PairMatcherImpl : public MatcherInterface {
                       const std::string& second_explanation,
                       MatchResultListener* listener) const {
     *listener << "whose both fields match";
-    if (first_explanation != "") {
+    if (!first_explanation.empty()) {
       *listener << ", where the first field is a value " << first_explanation;
     }
-    if (second_explanation != "") {
+    if (!second_explanation.empty()) {
       *listener << ", ";
-      if (first_explanation != "") {
+      if (!first_explanation.empty()) {
         *listener << "and ";
       } else {
         *listener << "where ";

From 974e18ee6f146a2418f9cea83170c640e7d622d6 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Tue, 21 Mar 2023 10:06:47 -0700
Subject: [PATCH 156/336] Fix minor bug -- if ExecDeathTestChildMain() ever
 returns, we should exit with a non-zero status.

PiperOrigin-RevId: 518306642
Change-Id: I72fb2764e477acb0362593c63f7748c4f64db0c6
---
 googletest/src/gtest-death-test.cc | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/googletest/src/gtest-death-test.cc b/googletest/src/gtest-death-test.cc
index 1bf2f3120..df04111ec 100644
--- a/googletest/src/gtest-death-test.cc
+++ b/googletest/src/gtest-death-test.cc
@@ -1328,8 +1328,7 @@ static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) {
 #endif  // GTEST_HAS_CLONE
 
   if (use_fork && (child_pid = fork()) == 0) {
-    ExecDeathTestChildMain(&args);
-    _exit(0);
+    _exit(ExecDeathTestChildMain(&args));
   }
 #endif  // GTEST_OS_QNX
 #ifdef GTEST_OS_LINUX

From 5fce13091d223069436ad7a5aad53f026b0f2041 Mon Sep 17 00:00:00 2001
From: Aaron Jacobs 
Date: Wed, 22 Mar 2023 20:19:06 -0700
Subject: [PATCH 157/336] gtest.cc: add a newline after a failure when there is
 no OS stack trace.

This makes the behavior consistent when GTEST_STACK_TRACE_DEPTH is set to zero
and not: there is always vertical whitespace separating failure messages.

PiperOrigin-RevId: 518744611
Change-Id: I5b4af40633849850660504c3f497a76601d4311d
---
 googlemock/test/gmock_output_test_golden.txt  | 18 +++++++++++
 googletest/src/gtest.cc                       |  2 ++
 .../test/googletest-json-output-unittest.py   |  2 +-
 googletest/test/googletest-output-test.py     |  2 +-
 googletest/test/gtest_xml_output_unittest.py  | 30 +++++++++++--------
 5 files changed, 39 insertions(+), 15 deletions(-)

diff --git a/googlemock/test/gmock_output_test_golden.txt b/googlemock/test/gmock_output_test_golden.txt
index d6c03338f..a22564433 100644
--- a/googlemock/test/gmock_output_test_golden.txt
+++ b/googlemock/test/gmock_output_test_golden.txt
@@ -40,6 +40,7 @@ FILE:#: EXPECT_CALL(foo_, Bar2(0, _))...
            Actual: 1
          Expected: to be called once
            Actual: never called - unsatisfied and active
+
 [  FAILED  ] GMockOutputTest.UnexpectedCall
 [ RUN      ] GMockOutputTest.UnexpectedCallToVoidFunction
 unknown file: Failure
@@ -53,6 +54,7 @@ FILE:#: EXPECT_CALL(foo_, Bar3(0, _))...
            Actual: 1
          Expected: to be called once
            Actual: never called - unsatisfied and active
+
 [  FAILED  ] GMockOutputTest.UnexpectedCallToVoidFunction
 [ RUN      ] GMockOutputTest.ExcessiveCall
 FILE:#: Failure
@@ -61,6 +63,7 @@ Mock function called more times than expected - returning default value.
           Returns: false
          Expected: to be called once
            Actual: called twice - over-saturated and active
+
 [  FAILED  ] GMockOutputTest.ExcessiveCall
 [ RUN      ] GMockOutputTest.ExcessiveCallToVoidFunction
 FILE:#: Failure
@@ -68,6 +71,7 @@ Mock function called more times than expected - returning directly.
     Function call: Bar3(0, 1)
          Expected: to be called once
            Actual: called twice - over-saturated and active
+
 [  FAILED  ] GMockOutputTest.ExcessiveCallToVoidFunction
 [ RUN      ] GMockOutputTest.UninterestingCall
 
@@ -104,6 +108,7 @@ FILE:#: tried expectation #1: EXPECT_CALL(foo_, Bar2(0, 0))...
            Actual: 1
          Expected: to be called once
            Actual: never called - unsatisfied and active
+
 [  FAILED  ] GMockOutputTest.RetiredExpectation
 [ RUN      ] GMockOutputTest.UnsatisfiedPrerequisite
 unknown file: Failure
@@ -125,6 +130,7 @@ FILE:#: pre-requisite #0
                    (end of pre-requisites)
          Expected: to be called once
            Actual: never called - unsatisfied and active
+
 [  FAILED  ] GMockOutputTest.UnsatisfiedPrerequisite
 [ RUN      ] GMockOutputTest.UnsatisfiedPrerequisites
 unknown file: Failure
@@ -147,6 +153,7 @@ FILE:#: pre-requisite #1
                    (end of pre-requisites)
          Expected: to be called once
            Actual: never called - unsatisfied and active
+
 [  FAILED  ] GMockOutputTest.UnsatisfiedPrerequisites
 [ RUN      ] GMockOutputTest.UnsatisfiedWith
 FILE:#: Failure
@@ -154,16 +161,19 @@ Actual function call count doesn't match EXPECT_CALL(foo_, Bar2(_, _))...
     Expected args: are a pair where the first >= the second
          Expected: to be called once
            Actual: never called - unsatisfied and active
+
 [  FAILED  ] GMockOutputTest.UnsatisfiedWith
 [ RUN      ] GMockOutputTest.UnsatisfiedExpectation
 FILE:#: Failure
 Actual function call count doesn't match EXPECT_CALL(foo_, Bar2(0, _))...
          Expected: to be called twice
            Actual: called once - unsatisfied and active
+
 FILE:#: Failure
 Actual function call count doesn't match EXPECT_CALL(foo_, Bar(_, _, _))...
          Expected: to be called once
            Actual: never called - unsatisfied and active
+
 [  FAILED  ] GMockOutputTest.UnsatisfiedExpectation
 [ RUN      ] GMockOutputTest.MismatchArguments
 unknown file: Failure
@@ -180,6 +190,7 @@ FILE:#: EXPECT_CALL(foo_, Bar(Ref(s), _, Ge(0)))...
            Actual: -0.1
          Expected: to be called once
            Actual: never called - unsatisfied and active
+
 [  FAILED  ] GMockOutputTest.MismatchArguments
 [ RUN      ] GMockOutputTest.MismatchWith
 unknown file: Failure
@@ -194,6 +205,7 @@ FILE:#: EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1)))...
            Actual: don't match
          Expected: to be called once
            Actual: never called - unsatisfied and active
+
 [  FAILED  ] GMockOutputTest.MismatchWith
 [ RUN      ] GMockOutputTest.MismatchArgumentsAndWith
 unknown file: Failure
@@ -210,6 +222,7 @@ FILE:#: EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1)))...
            Actual: don't match
          Expected: to be called once
            Actual: never called - unsatisfied and active
+
 [  FAILED  ] GMockOutputTest.MismatchArgumentsAndWith
 [ RUN      ] GMockOutputTest.UnexpectedCallWithDefaultAction
 unknown file: Failure
@@ -227,6 +240,7 @@ FILE:#: EXPECT_CALL(foo_, Bar2(2, 2))...
            Actual: 0
          Expected: to be called once
            Actual: never called - unsatisfied and active
+
 unknown file: Failure
 
 Unexpected mock function call - taking default action specified at:
@@ -242,6 +256,7 @@ FILE:#: EXPECT_CALL(foo_, Bar2(2, 2))...
            Actual: 0
          Expected: to be called once
            Actual: never called - unsatisfied and active
+
 [  FAILED  ] GMockOutputTest.UnexpectedCallWithDefaultAction
 [ RUN      ] GMockOutputTest.ExcessiveCallWithDefaultAction
 FILE:#: Failure
@@ -251,6 +266,7 @@ FILE:#:
           Returns: true
          Expected: to be called once
            Actual: called twice - over-saturated and active
+
 FILE:#: Failure
 Mock function called more times than expected - taking default action specified at:
 FILE:#:
@@ -258,6 +274,7 @@ FILE:#:
           Returns: false
          Expected: to be called once
            Actual: called twice - over-saturated and active
+
 [  FAILED  ] GMockOutputTest.ExcessiveCallWithDefaultAction
 [ RUN      ] GMockOutputTest.UninterestingCallWithDefaultAction
 
@@ -293,6 +310,7 @@ FILE:#: Failure
 Value of: (std::tuple(42, true))
 Expected: is pair (first: is >= 48, second: true)
   Actual: (42, true)
+
 [  FAILED  ] GMockOutputTest.PrintsMatcher
 [  FAILED  ] GMockOutputTest.UnexpectedCall
 [  FAILED  ] GMockOutputTest.UnexpectedCallToVoidFunction
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 55f8e507a..897c0cd98 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -5319,6 +5319,8 @@ void UnitTest::AddTestPartResult(TestPartResult::Type result_type,
 
   if (os_stack_trace.c_str() != nullptr && !os_stack_trace.empty()) {
     msg << internal::kStackTraceMarker << os_stack_trace;
+  } else {
+    msg << "\n";
   }
 
   const TestPartResult result = TestPartResult(
diff --git a/googletest/test/googletest-json-output-unittest.py b/googletest/test/googletest-json-output-unittest.py
index b3a08deb1..e955e7b00 100644
--- a/googletest/test/googletest-json-output-unittest.py
+++ b/googletest/test/googletest-json-output-unittest.py
@@ -54,7 +54,7 @@ SUPPORTS_STACK_TRACES = NO_STACKTRACE_SUPPORT_FLAG not in sys.argv
 if SUPPORTS_STACK_TRACES:
   STACK_TRACE_TEMPLATE = '\nStack trace:\n*'
 else:
-  STACK_TRACE_TEMPLATE = ''
+  STACK_TRACE_TEMPLATE = '\n'
 
 EXPECTED_NON_EMPTY = {
     'tests': 26,
diff --git a/googletest/test/googletest-output-test.py b/googletest/test/googletest-output-test.py
index 347b85461..6d80d5325 100755
--- a/googletest/test/googletest-output-test.py
+++ b/googletest/test/googletest-output-test.py
@@ -132,7 +132,7 @@ def RemoveStackTraces(output):
   """Removes all traces of stack traces from a Google Test program's output."""
 
   # *? means "find the shortest string that matches".
-  return re.sub(r'Stack trace:(.|\n)*?\n\n', '', output)
+  return re.sub(r'Stack trace:(.|\n)*?\n', '', output)
 
 
 def RemoveTime(output):
diff --git a/googletest/test/gtest_xml_output_unittest.py b/googletest/test/gtest_xml_output_unittest.py
index 5ca11cb6e..e7e44fc16 100755
--- a/googletest/test/gtest_xml_output_unittest.py
+++ b/googletest/test/gtest_xml_output_unittest.py
@@ -59,8 +59,10 @@ SUPPORTS_STACK_TRACES = NO_STACKTRACE_SUPPORT_FLAG not in sys.argv
 
 if SUPPORTS_STACK_TRACES:
   STACK_TRACE_TEMPLATE = '\nStack trace:\n*'
+  STACK_TRACE_ENTITY_TEMPLATE = ''
 else:
-  STACK_TRACE_TEMPLATE = ''
+  STACK_TRACE_TEMPLATE = '\n'
+  STACK_TRACE_ENTITY_TEMPLATE = '
'
   # unittest.main() can't handle unknown flags
   sys.argv.remove(NO_STACKTRACE_SUPPORT_FLAG)
 
@@ -71,7 +73,7 @@ EXPECTED_NON_EMPTY_XML = """
   
   
     
-      
@@ -80,11 +82,11 @@ Expected equality of these values:
   
     
     
-      
-      
@@ -93,14 +95,14 @@ Expected equality of these values:
   
   
     
-      ]]>%(stack)s]]>
     
   
   
     
-      
     
@@ -110,19 +112,19 @@ Invalid characters in brackets []%(stack)s]]>
   
   
     
-      
     
     
-      
     
     
-      
-      
     
 
@@ -187,7 +189,8 @@ It is good practice to tell why you skip a test.%(stack)s]]>
     
   
 """ % {
-    'stack': STACK_TRACE_TEMPLATE
+    'stack': STACK_TRACE_TEMPLATE,
+    'stack_entity': STACK_TRACE_ENTITY_TEMPLATE,
 }
 
 EXPECTED_FILTERED_TEST_XML = """
@@ -221,14 +224,15 @@ EXPECTED_NO_TEST_XML = """
             timestamp="*" name="AllTests">
   
     
-      
     
   
 """ % {
-    'stack': STACK_TRACE_TEMPLATE
+    'stack': STACK_TRACE_TEMPLATE,
+    'stack_entity': STACK_TRACE_ENTITY_TEMPLATE,
 }
 
 GTEST_PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath(GTEST_PROGRAM_NAME)

From 5d6ba6d3b0a836f373d5ae83688880381cb7b3d4 Mon Sep 17 00:00:00 2001
From: gonzalobg <65027571+gonzalobg@users.noreply.github.com>
Date: Thu, 23 Mar 2023 10:26:58 +0100
Subject: [PATCH 158/336] Add doc comment

---
 googletest/include/gtest/internal/gtest-port.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index 77549e849..adf6f0b5b 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -794,7 +794,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
 // Ask the compiler not to perform tail call optimization inside
 // the marked function.
 #define GTEST_NO_TAIL_CALL_ __attribute__((disable_tail_calls))
-#elif __GNUC__ && !defined(__NVCOMPILER)
+#elif __GNUC__ && !defined(__NVCOMPILER) // NVIDIA C++ Compiler warnings
 #define GTEST_NO_TAIL_CALL_ \
   __attribute__((optimize("no-optimize-sibling-calls")))
 #else

From 6f01e3dc125e82f2d3d87839a8be52f610c732ea Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Thu, 23 Mar 2023 03:07:47 -0700
Subject: [PATCH 159/336] Internal Code Change

PiperOrigin-RevId: 518810140
Change-Id: Id3f9471f827894761080bc9199b0a092dc829b5f
---
 googletest/src/gtest-assertion-result.cc |  4 ++--
 googletest/src/gtest-death-test.cc       |  2 +-
 googletest/src/gtest-test-part.cc        |  2 --
 googletest/src/gtest-typed-test.cc       |  2 +-
 googletest/src/gtest.cc                  | 11 +++++------
 5 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/googletest/src/gtest-assertion-result.cc b/googletest/src/gtest-assertion-result.cc
index f1c0b10dc..399892167 100644
--- a/googletest/src/gtest-assertion-result.cc
+++ b/googletest/src/gtest-assertion-result.cc
@@ -44,7 +44,7 @@ namespace testing {
 // Used in EXPECT_TRUE/FALSE(assertion_result).
 AssertionResult::AssertionResult(const AssertionResult& other)
     : success_(other.success_),
-      message_(other.message_.get() != nullptr
+      message_(other.message_ != nullptr
                    ? new ::std::string(*other.message_)
                    : static_cast< ::std::string*>(nullptr)) {}
 
@@ -58,7 +58,7 @@ void AssertionResult::swap(AssertionResult& other) {
 // Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.
 AssertionResult AssertionResult::operator!() const {
   AssertionResult negation(!success_);
-  if (message_.get() != nullptr) negation << *message_;
+  if (message_ != nullptr) negation << *message_;
   return negation;
 }
 
diff --git a/googletest/src/gtest-death-test.cc b/googletest/src/gtest-death-test.cc
index df04111ec..0b87ba5bc 100644
--- a/googletest/src/gtest-death-test.cc
+++ b/googletest/src/gtest-death-test.cc
@@ -1524,7 +1524,7 @@ static int GetStatusFileDescriptor(unsigned int parent_process_id,
 // initialized from the GTEST_FLAG(internal_run_death_test) flag if
 // the flag is specified; otherwise returns NULL.
 InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {
-  if (GTEST_FLAG_GET(internal_run_death_test) == "") return nullptr;
+  if (GTEST_FLAG_GET(internal_run_death_test).empty()) return nullptr;
 
   // GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we
   // can use it here.
diff --git a/googletest/src/gtest-test-part.cc b/googletest/src/gtest-test-part.cc
index eb7c8d1cf..df677e6f6 100644
--- a/googletest/src/gtest-test-part.cc
+++ b/googletest/src/gtest-test-part.cc
@@ -37,8 +37,6 @@
 
 namespace testing {
 
-using internal::GetUnitTestImpl;
-
 // Gets the summary of the failure message by omitting the stack trace
 // in it.
 std::string TestPartResult::ExtractSummary(const char* message) {
diff --git a/googletest/src/gtest-typed-test.cc b/googletest/src/gtest-typed-test.cc
index a2828b83c..9941306f0 100644
--- a/googletest/src/gtest-typed-test.cc
+++ b/googletest/src/gtest-typed-test.cc
@@ -90,7 +90,7 @@ const char* TypedTestSuitePState::VerifyRegisteredTestNames(
   }
 
   const std::string& errors_str = errors.GetString();
-  if (errors_str != "") {
+  if (!errors_str.empty()) {
     fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(),
             errors_str.c_str());
     fflush(stderr);
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 897c0cd98..7832492d2 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -408,7 +408,7 @@ uint32_t Random::Generate(uint32_t range) {
 // GTestIsInitialized() returns true if and only if the user has initialized
 // Google Test.  Useful for catching the user mistake of not initializing
 // Google Test before calling RUN_ALL_TESTS().
-static bool GTestIsInitialized() { return GetArgvs().size() > 0; }
+static bool GTestIsInitialized() { return !GetArgvs().empty(); }
 
 // Iterates over a vector of TestSuites, keeping a running sum of the
 // results of calling a given int-returning method on each.
@@ -5306,7 +5306,7 @@ void UnitTest::AddTestPartResult(TestPartResult::Type result_type,
   msg << message;
 
   internal::MutexLock lock(&mutex_);
-  if (impl_->gtest_trace_stack().size() > 0) {
+  if (!impl_->gtest_trace_stack().empty()) {
     msg << "\n" << GTEST_NAME_ << " trace:";
 
     for (size_t i = impl_->gtest_trace_stack().size(); i > 0; --i) {
@@ -5606,7 +5606,7 @@ void UnitTestImpl::RecordProperty(const TestProperty& test_property) {
 // Disables event forwarding if the control is currently in a death test
 // subprocess. Must not be called before InitGoogleTest.
 void UnitTestImpl::SuppressTestEventsIfInSubprocess() {
-  if (internal_run_death_test_flag_.get() != nullptr)
+  if (internal_run_death_test_flag_ != nullptr)
     listeners()->SuppressEventForwarding();
 }
 #endif  // GTEST_HAS_DEATH_TEST
@@ -5622,7 +5622,7 @@ void UnitTestImpl::ConfigureXmlOutput() {
   } else if (output_format == "json") {
     listeners()->SetDefaultXmlGenerator(new JsonUnitTestResultPrinter(
         UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));
-  } else if (output_format != "") {
+  } else if (!output_format.empty()) {
     GTEST_LOG_(WARNING) << "WARNING: unrecognized output format \""
                         << output_format << "\" ignored.";
   }
@@ -5804,8 +5804,7 @@ bool UnitTestImpl::RunAllTests() {
   bool in_subprocess_for_death_test = false;
 
 #ifdef GTEST_HAS_DEATH_TEST
-  in_subprocess_for_death_test =
-      (internal_run_death_test_flag_.get() != nullptr);
+  in_subprocess_for_death_test = (internal_run_death_test_flag_ != nullptr);
 #if defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_)
   if (in_subprocess_for_death_test) {
     GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_();

From a0ced33ac6df214966bb90ba036e0a5666dca14e Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Fri, 24 Mar 2023 00:22:33 -0700
Subject: [PATCH 160/336] Internal Code Change

PiperOrigin-RevId: 519071084
Change-Id: I6459d60606e93bf658e505544538367508722857
---
 googletest/include/gtest/gtest-assertion-result.h | 4 ++--
 googletest/include/gtest/gtest.h                  | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/googletest/include/gtest/gtest-assertion-result.h b/googletest/include/gtest/gtest-assertion-result.h
index addbb59c6..62fbea6e3 100644
--- a/googletest/include/gtest/gtest-assertion-result.h
+++ b/googletest/include/gtest/gtest-assertion-result.h
@@ -181,7 +181,7 @@ class GTEST_API_ AssertionResult {
   // assertion's expectation). When nothing has been streamed into the
   // object, returns an empty string.
   const char* message() const {
-    return message_.get() != nullptr ? message_->c_str() : "";
+    return message_ != nullptr ? message_->c_str() : "";
   }
   // Deprecated; please use message() instead.
   const char* failure_message() const { return message(); }
@@ -204,7 +204,7 @@ class GTEST_API_ AssertionResult {
  private:
   // Appends the contents of message to message_.
   void AppendMessage(const Message& a_message) {
-    if (message_.get() == nullptr) message_.reset(new ::std::string);
+    if (message_ == nullptr) message_.reset(new ::std::string);
     message_->append(a_message.GetString().c_str());
   }
 
diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h
index 04a84f32e..e54382683 100644
--- a/googletest/include/gtest/gtest.h
+++ b/googletest/include/gtest/gtest.h
@@ -551,14 +551,14 @@ class GTEST_API_ TestInfo {
   // Returns the name of the parameter type, or NULL if this is not a typed
   // or a type-parameterized test.
   const char* type_param() const {
-    if (type_param_.get() != nullptr) return type_param_->c_str();
+    if (type_param_ != nullptr) return type_param_->c_str();
     return nullptr;
   }
 
   // Returns the text representation of the value parameter, or NULL if this
   // is not a value-parameterized test.
   const char* value_param() const {
-    if (value_param_.get() != nullptr) return value_param_->c_str();
+    if (value_param_ != nullptr) return value_param_->c_str();
     return nullptr;
   }
 
@@ -697,7 +697,7 @@ class GTEST_API_ TestSuite {
   // Returns the name of the parameter type, or NULL if this is not a
   // type-parameterized test suite.
   const char* type_param() const {
-    if (type_param_.get() != nullptr) return type_param_->c_str();
+    if (type_param_ != nullptr) return type_param_->c_str();
     return nullptr;
   }
 

From e9fb5c7bacc4a25b030569c92ff9f6925288f1c3 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Fri, 24 Mar 2023 05:57:22 -0700
Subject: [PATCH 161/336] Replace `const char*` with `absl::string_view` as the
 latter is preferred.

PiperOrigin-RevId: 519122695
Change-Id: I7dcf969d15d26ccc4b376e3ab6db7f4c08c7386f
---
 docs/advanced.md | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/docs/advanced.md b/docs/advanced.md
index d0369237e..3871db13b 100644
--- a/docs/advanced.md
+++ b/docs/advanced.md
@@ -1066,7 +1066,7 @@ they must be declared **public** rather than **protected** in order to use
 
 ```c++
 class FooTest :
-    public testing::TestWithParam {
+    public testing::TestWithParam {
   // You can implement all the usual fixture class members here.
   // To access the test parameter, call GetParam() from class
   // TestWithParam.
@@ -1077,7 +1077,7 @@ class BaseTest : public testing::Test {
   ...
 };
 class BarTest : public BaseTest,
-                public testing::WithParamInterface {
+                public testing::WithParamInterface {
   ...
 };
 ```
@@ -1148,8 +1148,8 @@ with parameter values `"cat"` and `"dog"` using the
 [`ValuesIn`](reference/testing.md#param-generators) parameter generator:
 
 ```c++
-const char* pets[] = {"cat", "dog"};
-INSTANTIATE_TEST_SUITE_P(Pets, FooTest, testing::ValuesIn(pets));
+constexpr absl::string_view kPets[] = {"cat", "dog"};
+INSTANTIATE_TEST_SUITE_P(Pets, FooTest, testing::ValuesIn(kPets));
 ```
 
 The tests from the instantiation above will have these names:

From 88af49efa72a06d56910d69ecfd87e3b330e5778 Mon Sep 17 00:00:00 2001
From: Derek Mauro 
Date: Mon, 27 Mar 2023 12:09:24 -0700
Subject: [PATCH 162/336] Migrate CI builds to MSVC 2022

PiperOrigin-RevId: 519792199
Change-Id: Ic821b264bf1aef5e03f22fb0e288dd9d56fd536b
---
 ci/windows-presubmit.bat | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/ci/windows-presubmit.bat b/ci/windows-presubmit.bat
index 8668ff359..5ec4131c1 100644
--- a/ci/windows-presubmit.bat
+++ b/ci/windows-presubmit.bat
@@ -5,9 +5,11 @@ SET BAZEL_EXE=%KOKORO_GFILE_DIR%\bazel-5.1.1-windows-x86_64.exe
 SET PATH=C:\Python37;%PATH%
 SET BAZEL_PYTHON=C:\python37\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
@@ -18,12 +20,12 @@ IF EXIST git\googletest (
 IF %errorlevel% neq 0 EXIT /B 1
 
 :: ----------------------------------------------------------------------------
-:: CMake Visual Studio 15 2017 Win64
-MKDIR cmake_msvc2017
-CD cmake_msvc2017
+:: CMake Visual Studio 17 2022 Win64
+MKDIR cmake_msvc2022
+CD cmake_msvc2022
 
 %CMAKE_BIN% .. ^
-  -G "Visual Studio 15 2017 Win64" ^
+  -G "Visual Studio 17 2022 Win64" ^
   -DPYTHON_EXECUTABLE:FILEPATH=c:\python37\python.exe ^
   -DPYTHON_INCLUDE_DIR:PATH=c:\python37\include ^
   -DPYTHON_LIBRARY:FILEPATH=c:\python37\lib\site-packages\pip ^
@@ -39,12 +41,12 @@ IF %errorlevel% neq 0 EXIT /B 1
 IF %errorlevel% neq 0 EXIT /B 1
 
 CD ..
-RMDIR /S /Q cmake_msvc2017
+RMDIR /S /Q cmake_msvc2022
 
 :: ----------------------------------------------------------------------------
-:: Bazel Visual Studio 15 2017 Win64
+:: Bazel Visual Studio 17 2022 Win64
 
-SET BAZEL_VC=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC
+SET BAZEL_VS=C:\Program Files\Microsoft Visual Studio\2022\Community
 %BAZEL_EXE% test ... ^
   --compilation_mode=dbg ^
   --copt=/std:c++14 ^

From 13b1900717fe93238d615691b6d0d951b0e154c4 Mon Sep 17 00:00:00 2001
From: Derek Mauro 
Date: Tue, 28 Mar 2023 06:27:28 -0700
Subject: [PATCH 163/336] Remove the Win64 arch from the CMake Generator since
 this can't be used with MSVC 2022

We also have to use Python 3.4 since that is what the base image has,
however, I will create a new image soon that has a modern version
of Python.

PiperOrigin-RevId: 520010732
Change-Id: Icf2420fd97d2bbc310382a17793045b6e16d62bb
---
 ci/windows-presubmit.bat | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/ci/windows-presubmit.bat b/ci/windows-presubmit.bat
index 5ec4131c1..48962eb9e 100644
--- a/ci/windows-presubmit.bat
+++ b/ci/windows-presubmit.bat
@@ -2,8 +2,8 @@ SETLOCAL ENABLEDELAYEDEXPANSION
 
 SET BAZEL_EXE=%KOKORO_GFILE_DIR%\bazel-5.1.1-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="cmake.exe"
 SET CTEST_BIN="ctest.exe"
@@ -20,12 +20,12 @@ IF EXIST git\googletest (
 IF %errorlevel% neq 0 EXIT /B 1
 
 :: ----------------------------------------------------------------------------
-:: CMake Visual Studio 17 2022 Win64
+:: CMake
 MKDIR cmake_msvc2022
 CD cmake_msvc2022
 
 %CMAKE_BIN% .. ^
-  -G "Visual Studio 17 2022 Win64" ^
+  -G "Visual Studio 17 2022" ^
   -DPYTHON_EXECUTABLE:FILEPATH=c:\python37\python.exe ^
   -DPYTHON_INCLUDE_DIR:PATH=c:\python37\include ^
   -DPYTHON_LIBRARY:FILEPATH=c:\python37\lib\site-packages\pip ^
@@ -44,7 +44,7 @@ CD ..
 RMDIR /S /Q cmake_msvc2022
 
 :: ----------------------------------------------------------------------------
-:: Bazel Visual Studio 17 2022 Win64
+:: Bazel
 
 SET BAZEL_VS=C:\Program Files\Microsoft Visual Studio\2022\Community
 %BAZEL_EXE% test ... ^

From 3656c2713e08bd5dadae740f71ef37a92336027b Mon Sep 17 00:00:00 2001
From: Derek Mauro 
Date: Tue, 28 Mar 2023 07:02:23 -0700
Subject: [PATCH 164/336] Fix redundant redeclaration warning

Fixes #4200

PiperOrigin-RevId: 520017094
Change-Id: Id707a1c0489edde083771ccd412d7035612474dc
---
 googlemock/include/gmock/internal/gmock-internal-utils.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h
index b5283ed02..d34443866 100644
--- a/googlemock/include/gmock/internal/gmock-internal-utils.h
+++ b/googlemock/include/gmock/internal/gmock-internal-utils.h
@@ -465,8 +465,10 @@ struct Function {
   using MakeResultIgnoredValue = IgnoredValue(Args...);
 };
 
+#ifdef GTEST_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
 template 
 constexpr size_t Function::ArgumentCount;
+#endif
 
 // Workaround for MSVC error C2039: 'type': is not a member of 'std'
 // when std::tuple_element is used.

From 0cd05c6ea982e5db608f81973faca52fe31f6ec3 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Wed, 29 Mar 2023 12:24:40 -0700
Subject: [PATCH 165/336] Update naming to "GoogleTest" in the GoogleTest
 Primer.

PiperOrigin-RevId: 520409541
Change-Id: I75a0b8615ece923137d4f5dcdb915f38e4c3b1b2
---
 docs/primer.md | 68 +++++++++++++++++++++++++-------------------------
 1 file changed, 34 insertions(+), 34 deletions(-)

diff --git a/docs/primer.md b/docs/primer.md
index d559fe84f..31d63160e 100644
--- a/docs/primer.md
+++ b/docs/primer.md
@@ -1,44 +1,44 @@
-# Googletest Primer
+# GoogleTest Primer
 
-## Introduction: Why googletest?
+## Introduction: Why GoogleTest?
 
-*googletest* helps you write better C++ tests.
+*GoogleTest* helps you write better C++ tests.
 
-googletest is a testing framework developed by the Testing Technology team with
+GoogleTest is a testing framework developed by the Testing Technology team with
 Google's specific requirements and constraints in mind. Whether you work on
-Linux, Windows, or a Mac, if you write C++ code, googletest can help you. And it
+Linux, Windows, or a Mac, if you write C++ code, GoogleTest can help you. And it
 supports *any* kind of tests, not just unit tests.
 
-So what makes a good test, and how does googletest fit in? We believe:
+So what makes a good test, and how does GoogleTest fit in? We believe:
 
 1.  Tests should be *independent* and *repeatable*. It's a pain to debug a test
-    that succeeds or fails as a result of other tests. googletest isolates the
+    that succeeds or fails as a result of other tests. GoogleTest isolates the
     tests by running each of them on a different object. When a test fails,
-    googletest allows you to run it in isolation for quick debugging.
+    GoogleTest allows you to run it in isolation for quick debugging.
 2.  Tests should be well *organized* and reflect the structure of the tested
-    code. googletest groups related tests into test suites that can share data
+    code. GoogleTest groups related tests into test suites that can share data
     and subroutines. This common pattern is easy to recognize and makes tests
     easy to maintain. Such consistency is especially helpful when people switch
     projects and start to work on a new code base.
 3.  Tests should be *portable* and *reusable*. Google has a lot of code that is
-    platform-neutral; its tests should also be platform-neutral. googletest
+    platform-neutral; its tests should also be platform-neutral. GoogleTest
     works on different OSes, with different compilers, with or without
-    exceptions, so googletest tests can work with a variety of configurations.
+    exceptions, so GoogleTest tests can work with a variety of configurations.
 4.  When tests fail, they should provide as much *information* about the problem
-    as possible. googletest doesn't stop at the first test failure. Instead, it
+    as possible. GoogleTest doesn't stop at the first test failure. Instead, it
     only stops the current test and continues with the next. You can also set up
     tests that report non-fatal failures after which the current test continues.
     Thus, you can detect and fix multiple bugs in a single run-edit-compile
     cycle.
 5.  The testing framework should liberate test writers from housekeeping chores
-    and let them focus on the test *content*. googletest automatically keeps
+    and let them focus on the test *content*. GoogleTest automatically keeps
     track of all tests defined, and doesn't require the user to enumerate them
     in order to run them.
-6.  Tests should be *fast*. With googletest, you can reuse shared resources
+6.  Tests should be *fast*. With GoogleTest, you can reuse shared resources
     across tests and pay for the set-up/tear-down only once, without making
     tests depend on each other.
 
-Since googletest is based on the popular xUnit architecture, you'll feel right
+Since GoogleTest is based on the popular xUnit architecture, you'll feel right
 at home if you've used JUnit or PyUnit before. If not, it will take you about 10
 minutes to learn the basics and get started. So let's go!
 
@@ -48,27 +48,27 @@ minutes to learn the basics and get started. So let's go!
 *Note:* There might be some confusion arising from different definitions of the
 terms *Test*, *Test Case* and *Test Suite*, so beware of misunderstanding these.
 
-Historically, googletest started to use the term *Test Case* for grouping
+Historically, GoogleTest started to use the term *Test Case* for grouping
 related tests, whereas current publications, including International Software
 Testing Qualifications Board ([ISTQB](http://www.istqb.org/)) materials and
 various textbooks on software quality, use the term
 *[Test Suite][istqb test suite]* for this.
 
-The related term *Test*, as it is used in googletest, corresponds to the term
+The related term *Test*, as it is used in GoogleTest, corresponds to the term
 *[Test Case][istqb test case]* of ISTQB and others.
 
 The term *Test* is commonly of broad enough sense, including ISTQB's definition
 of *Test Case*, so it's not much of a problem here. But the term *Test Case* as
 was used in Google Test is of contradictory sense and thus confusing.
 
-googletest recently started replacing the term *Test Case* with *Test Suite*.
+GoogleTest recently started replacing the term *Test Case* with *Test Suite*.
 The preferred API is *TestSuite*. The older TestCase API is being slowly
 deprecated and refactored away.
 
 So please be aware of the different definitions of the terms:
 
 
-Meaning                                                                              | googletest Term         | [ISTQB](http://www.istqb.org/) Term
+Meaning                                                                              | GoogleTest Term         | [ISTQB](http://www.istqb.org/) Term
 :----------------------------------------------------------------------------------- | :---------------------- | :----------------------------------
 Exercise a particular program path with specific input values and verify the results | [TEST()](#simple-tests) | [Test Case][istqb test case]
 
@@ -78,7 +78,7 @@ Exercise a particular program path with specific input values and verify the res
 
 ## Basic Concepts
 
-When using googletest, you start by writing *assertions*, which are statements
+When using GoogleTest, you start by writing *assertions*, which are statements
 that check whether a condition is true. An assertion's result can be *success*,
 *nonfatal failure*, or *fatal failure*. If a fatal failure occurs, it aborts the
 current function; otherwise the program continues normally.
@@ -98,11 +98,11 @@ assertion level and building up to tests and test suites.
 
 ## Assertions
 
-googletest assertions are macros that resemble function calls. You test a class
+GoogleTest assertions are macros that resemble function calls. You test a class
 or function by making assertions about its behavior. When an assertion fails,
-googletest prints the assertion's source file and line number location, along
+GoogleTest prints the assertion's source file and line number location, along
 with a failure message. You may also supply a custom failure message which will
-be appended to googletest's message.
+be appended to GoogleTest's message.
 
 The assertions come in pairs that test the same thing but have different effects
 on the current function. `ASSERT_*` versions generate fatal failures when they
@@ -149,7 +149,7 @@ To create a test:
 1.  Use the `TEST()` macro to define and name a test function. These are
     ordinary C++ functions that don't return a value.
 2.  In this function, along with any valid C++ statements you want to include,
-    use the various googletest assertions to check values.
+    use the various GoogleTest assertions to check values.
 3.  The test's result is determined by the assertions; if any assertion in the
     test fails (either fatally or non-fatally), or if the test crashes, the
     entire test fails. Otherwise, it succeeds.
@@ -190,7 +190,7 @@ TEST(FactorialTest, HandlesPositiveInput) {
 }
 ```
 
-googletest groups the test results by test suites, so logically related tests
+GoogleTest groups the test results by test suites, so logically related tests
 should be in the same test suite; in other words, the first argument to their
 `TEST()` should be the same. In the above example, we have two tests,
 `HandlesZeroInput` and `HandlesPositiveInput`, that belong to the same test
@@ -244,12 +244,12 @@ Also, you must first define a test fixture class before using it in a
 `TEST_F()`, or you'll get the compiler error "`virtual outside class
 declaration`".
 
-For each test defined with `TEST_F()`, googletest will create a *fresh* test
+For each test defined with `TEST_F()`, GoogleTest will create a *fresh* test
 fixture at runtime, immediately initialize it via `SetUp()`, run the test, clean
 up by calling `TearDown()`, and then delete the test fixture. Note that
 different tests in the same test suite have different test fixture objects, and
-googletest always deletes a test fixture before it creates the next one.
-googletest does **not** reuse the same test fixture for multiple tests. Any
+GoogleTest always deletes a test fixture before it creates the next one.
+GoogleTest does **not** reuse the same test fixture for multiple tests. Any
 changes one test makes to the fixture do not affect other tests.
 
 As an example, let's write tests for a FIFO queue class named `Queue`, which has
@@ -325,7 +325,7 @@ would lead to a segfault when `n` is `NULL`.
 
 When these tests run, the following happens:
 
-1.  googletest constructs a `QueueTest` object (let's call it `t1`).
+1.  GoogleTest constructs a `QueueTest` object (let's call it `t1`).
 2.  `t1.SetUp()` initializes `t1`.
 3.  The first test (`IsEmptyInitially`) runs on `t1`.
 4.  `t1.TearDown()` cleans up after the test finishes.
@@ -337,7 +337,7 @@ When these tests run, the following happens:
 
 ## Invoking the Tests
 
-`TEST()` and `TEST_F()` implicitly register their tests with googletest. So,
+`TEST()` and `TEST_F()` implicitly register their tests with GoogleTest. So,
 unlike with many other C++ testing frameworks, you don't have to re-list all
 your defined tests in order to run them.
 
@@ -348,7 +348,7 @@ test suites, or even different source files.
 
 When invoked, the `RUN_ALL_TESTS()` macro:
 
-*   Saves the state of all googletest flags.
+*   Saves the state of all GoogleTest flags.
 
 *   Creates a test fixture object for the first test.
 
@@ -360,7 +360,7 @@ When invoked, the `RUN_ALL_TESTS()` macro:
 
 *   Deletes the fixture.
 
-*   Restores the state of all googletest flags.
+*   Restores the state of all GoogleTest flags.
 
 *   Repeats the above steps for the next test, until all tests have run.
 
@@ -374,7 +374,7 @@ If a fatal failure happens the subsequent steps will be skipped.
 > return the value of `RUN_ALL_TESTS()`.
 >
 > Also, you should call `RUN_ALL_TESTS()` only **once**. Calling it more than
-> once conflicts with some advanced googletest features (e.g., thread-safe
+> once conflicts with some advanced GoogleTest features (e.g., thread-safe
 > [death tests](advanced.md#death-tests)) and thus is not supported.
 
 **Availability**: Linux, Windows, Mac.
@@ -456,7 +456,7 @@ int main(int argc, char **argv) {
 ```
 
 The `::testing::InitGoogleTest()` function parses the command line for
-googletest flags, and removes all recognized flags. This allows the user to
+GoogleTest flags, and removes all recognized flags. This allows the user to
 control a test program's behavior via various flags, which we'll cover in the
 [AdvancedGuide](advanced.md). You **must** call this function before calling
 `RUN_ALL_TESTS()`, or the flags won't be properly initialized.

From b5fd99bbd55ebe1a3488b8ea3717fba089293457 Mon Sep 17 00:00:00 2001
From: Aaron Jacobs 
Date: Thu, 30 Mar 2023 13:34:34 -0700
Subject: [PATCH 166/336] gtest.cc: run tests within a test suite in a
 deterministic order.

Ensure that tests are run in the order specified in the source code, even if
they are registered manually using RegisterTest. There should be no behavior
change for the common case.

PiperOrigin-RevId: 520729483
Change-Id: I400c78400c6929fccae0676214d993251f31888f
---
 googletest/src/gtest.cc | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 7832492d2..c2581fa03 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -44,6 +44,7 @@
 #include   // NOLINT
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2981,6 +2982,25 @@ void TestSuite::Run() {
 
   TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();
 
+  // Ensure our tests are in a deterministic order.
+  //
+  // We do this by sorting lexicographically on (file, line number), providing
+  // an order matching what the user can see in the source code.
+  //
+  // In the common case the line number comparison shouldn't be necessary,
+  // because the registrations made by the TEST macro are executed in order
+  // within a translation unit. But this is not true of the manual registration
+  // API, and in more exotic scenarios a single file may be part of multiple
+  // translation units.
+  std::stable_sort(test_info_list_.begin(), test_info_list_.end(),
+                   [](const TestInfo* const a, const TestInfo* const b) {
+                     if (const int result = std::strcmp(a->file(), a->file())) {
+                       return result < 0;
+                     }
+
+                     return a->line() < b->line();
+                   });
+
   // Call both legacy and the new API
   repeater->OnTestSuiteStart(*this);
 //  Legacy API is deprecated but still available

From 7ee260c54921571b18b15049304426fe151c1265 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Mon, 3 Apr 2023 14:00:54 -0700
Subject: [PATCH 167/336] Rolled back due to breaking existing tests.

PiperOrigin-RevId: 521555658
Change-Id: I09742faceb82b2b7ceb423e850a8b50d532ad6ff
---
 googletest/src/gtest.cc | 20 --------------------
 1 file changed, 20 deletions(-)

diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index c2581fa03..7832492d2 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -44,7 +44,6 @@
 #include   // NOLINT
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -2982,25 +2981,6 @@ void TestSuite::Run() {
 
   TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();
 
-  // Ensure our tests are in a deterministic order.
-  //
-  // We do this by sorting lexicographically on (file, line number), providing
-  // an order matching what the user can see in the source code.
-  //
-  // In the common case the line number comparison shouldn't be necessary,
-  // because the registrations made by the TEST macro are executed in order
-  // within a translation unit. But this is not true of the manual registration
-  // API, and in more exotic scenarios a single file may be part of multiple
-  // translation units.
-  std::stable_sort(test_info_list_.begin(), test_info_list_.end(),
-                   [](const TestInfo* const a, const TestInfo* const b) {
-                     if (const int result = std::strcmp(a->file(), a->file())) {
-                       return result < 0;
-                     }
-
-                     return a->line() < b->line();
-                   });
-
   // Call both legacy and the new API
   repeater->OnTestSuiteStart(*this);
 //  Legacy API is deprecated but still available

From 057b4e904fd754135dc19ff557c14036fd316425 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Wed, 5 Apr 2023 13:18:59 -0700
Subject: [PATCH 168/336] gtest.cc: run tests within a test suite in a
 deterministic order.

Ensure that tests are run in the order specified in the source code, even if
they are registered manually using RegisterTest. There should be no behavior
change for the common case.

PiperOrigin-RevId: 522136303
Change-Id: If155e2666780af0e514fbbf5ff2b157d5fe2fef1
---
 googletest/src/gtest.cc | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 7832492d2..15cee3f08 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -44,6 +44,7 @@
 #include   // NOLINT
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2981,6 +2982,25 @@ void TestSuite::Run() {
 
   TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();
 
+  // Ensure our tests are in a deterministic order.
+  //
+  // We do this by sorting lexicographically on (file, line number), providing
+  // an order matching what the user can see in the source code.
+  //
+  // In the common case the line number comparison shouldn't be necessary,
+  // because the registrations made by the TEST macro are executed in order
+  // within a translation unit. But this is not true of the manual registration
+  // API, and in more exotic scenarios a single file may be part of multiple
+  // translation units.
+  std::stable_sort(test_info_list_.begin(), test_info_list_.end(),
+                   [](const TestInfo* const a, const TestInfo* const b) {
+                     if (const int result = std::strcmp(a->file(), b->file())) {
+                       return result < 0;
+                     }
+
+                     return a->line() < b->line();
+                   });
+
   // Call both legacy and the new API
   repeater->OnTestSuiteStart(*this);
 //  Legacy API is deprecated but still available

From 7f6f9c12adefe8130565b7425dc387d284c009e4 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Tue, 11 Apr 2023 07:41:03 -0700
Subject: [PATCH 169/336] Support --gtest_stream_result_to on macOS

This seems to just have been an oversight. POSIX socket APIs work just
fine on macOS.

Fixes https://github.com/google/googletest/issues/4214.

PiperOrigin-RevId: 523398386
Change-Id: I9d56cd9c6933318c1f0b0024f7fef44122fd0c83
---
 googletest/include/gtest/internal/gtest-port.h | 2 +-
 googletest/test/gtest_help_test.py             | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index 7846c9e10..656a2618a 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -693,7 +693,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
 #if defined(GTEST_OS_LINUX) || defined(GTEST_OS_GNU_KFREEBSD) || \
     defined(GTEST_OS_DRAGONFLY) || defined(GTEST_OS_FREEBSD) ||  \
     defined(GTEST_OS_NETBSD) || defined(GTEST_OS_OPENBSD) ||     \
-    defined(GTEST_OS_GNU_HURD)
+    defined(GTEST_OS_GNU_HURD) || defined(GTEST_OS_MAC)
 #define GTEST_CAN_STREAM_RESULTS_ 1
 #else
 #define GTEST_CAN_STREAM_RESULTS_ 0
diff --git a/googletest/test/gtest_help_test.py b/googletest/test/gtest_help_test.py
index fda40bffc..9261b87a5 100755
--- a/googletest/test/gtest_help_test.py
+++ b/googletest/test/gtest_help_test.py
@@ -43,6 +43,7 @@ import sys
 from googletest.test import gtest_test_utils
 
 
+IS_DARWIN = os.name == 'posix' and os.uname()[0] == 'Darwin'
 IS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux'
 IS_GNUHURD = os.name == 'posix' and os.uname()[0] == 'GNU'
 IS_GNUKFREEBSD = os.name == 'posix' and os.uname()[0] == 'GNU/kFreeBSD'
@@ -136,7 +137,7 @@ class GTestHelpTest(gtest_test_utils.TestCase):
 
     self.assertTrue(HELP_REGEX.search(output), output)
 
-    if IS_LINUX or IS_GNUHURD or IS_GNUKFREEBSD or IS_OPENBSD:
+    if IS_DARWIN or IS_LINUX or IS_GNUHURD or IS_GNUKFREEBSD or IS_OPENBSD:
       self.assertIn(STREAM_RESULT_TO_FLAG, output)
     else:
       self.assertNotIn(STREAM_RESULT_TO_FLAG, output)

From 8fa9461cc28e053d66f17132808d287ae51575e2 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Tue, 11 Apr 2023 10:54:26 -0700
Subject: [PATCH 170/336] Fix FunctionMocker compilation slowdown in
 9d21db9e0a60a1ea61ec19331c9bc0dd33e907b1

The slowdown appears to be due to an implicit conversion of distinct (yet semantically identical) lambdas to `std::function`. Lifting out the lambdas into functors that don't get re-instantiated reduces compilation times by nearly half.

Fixes #4156

PiperOrigin-RevId: 523447948
Change-Id: Ib0ae0761a54d7b1f2b706b14b2858eedf47e2297
---
 .../include/gmock/gmock-spec-builders.h       | 73 ++++++++++++++-----
 1 file changed, 55 insertions(+), 18 deletions(-)

diff --git a/googlemock/include/gmock/gmock-spec-builders.h b/googlemock/include/gmock/gmock-spec-builders.h
index 4e498d8f5..2a33acb19 100644
--- a/googlemock/include/gmock/gmock-spec-builders.h
+++ b/googlemock/include/gmock/gmock-spec-builders.h
@@ -204,6 +204,9 @@ class GTEST_API_ UntypedFunctionMockerBase {
 
   using UntypedExpectations = std::vector>;
 
+  struct UninterestingCallCleanupHandler;
+  struct FailureCleanupHandler;
+
   // Returns an Expectation object that references and co-owns exp,
   // which must be an expectation on this mock function.
   Expectation GetHandleOf(ExpectationBase* exp);
@@ -1396,6 +1399,41 @@ class Cleanup final {
   std::function f_;
 };
 
+struct UntypedFunctionMockerBase::UninterestingCallCleanupHandler {
+  CallReaction reaction;
+  std::stringstream& ss;
+
+  ~UninterestingCallCleanupHandler() {
+    ReportUninterestingCall(reaction, ss.str());
+  }
+};
+
+struct UntypedFunctionMockerBase::FailureCleanupHandler {
+  std::stringstream& ss;
+  std::stringstream& why;
+  std::stringstream& loc;
+  const ExpectationBase* untyped_expectation;
+  bool found;
+  bool is_excessive;
+
+  ~FailureCleanupHandler() {
+    ss << "\n" << why.str();
+
+    if (!found) {
+      // No expectation matches this call - reports a failure.
+      Expect(false, nullptr, -1, ss.str());
+    } else if (is_excessive) {
+      // We had an upper-bound violation and the failure message is in ss.
+      Expect(false, untyped_expectation->file(), untyped_expectation->line(),
+             ss.str());
+    } else {
+      // We had an expected call and the matching expectation is
+      // described in ss.
+      Log(kInfo, loc.str() + ss.str(), 2);
+    }
+  }
+};
+
 template 
 class FunctionMocker;
 
@@ -1794,8 +1832,15 @@ R FunctionMocker::InvokeWith(ArgumentTuple&& args)
     //
     // We use RAII to do the latter in case R is void or a non-moveable type. In
     // either case we can't assign it to a local variable.
-    const Cleanup report_uninteresting_call(
-        [&] { ReportUninterestingCall(reaction, ss.str()); });
+    //
+    // Note that std::bind() is essential here.
+    // We *don't* use any local callback types (like lambdas).
+    // Doing so slows down compilation dramatically because the *constructor* of
+    // std::function is re-instantiated with different template
+    // parameters each time.
+    const UninterestingCallCleanupHandler report_uninteresting_call = {
+        reaction, ss
+    };
 
     return PerformActionAndPrintResult(nullptr, std::move(args), ss.str(), ss);
   }
@@ -1839,22 +1884,14 @@ R FunctionMocker::InvokeWith(ArgumentTuple&& args)
   //
   // We use RAII to do the latter in case R is void or a non-moveable type. In
   // either case we can't assign it to a local variable.
-  const Cleanup handle_failures([&] {
-    ss << "\n" << why.str();
-
-    if (!found) {
-      // No expectation matches this call - reports a failure.
-      Expect(false, nullptr, -1, ss.str());
-    } else if (is_excessive) {
-      // We had an upper-bound violation and the failure message is in ss.
-      Expect(false, untyped_expectation->file(), untyped_expectation->line(),
-             ss.str());
-    } else {
-      // We had an expected call and the matching expectation is
-      // described in ss.
-      Log(kInfo, loc.str() + ss.str(), 2);
-    }
-  });
+  //
+  // Note that we *don't* use any local callback types (like lambdas) here.
+  // Doing so slows down compilation dramatically because the *constructor* of
+  // std::function is re-instantiated with different template
+  // parameters each time.
+  const FailureCleanupHandler handle_failures = {
+      ss, why, loc, untyped_expectation, found, is_excessive
+  };
 
   return PerformActionAndPrintResult(untyped_action, std::move(args), ss.str(),
                                      ss);

From 952560d3ec06eae08347d5e54faa8e3192d41b4d Mon Sep 17 00:00:00 2001
From: Jeryl Vaz 
Date: Fri, 14 Apr 2023 11:15:21 +0200
Subject: [PATCH 171/336] Suppress a clang-tidy warning in the MATCHER_P macro

---
 googlemock/include/gmock/gmock-matchers.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h
index 7c5d65cf1..8936e4974 100644
--- a/googlemock/include/gmock/gmock-matchers.h
+++ b/googlemock/include/gmock/gmock-matchers.h
@@ -5544,6 +5544,7 @@ PolymorphicMatcher> ThrowsMessage(
                                                                                \
      private:                                                                  \
       ::std::string FormatDescription(bool negation) const {                   \
+        /* NOLINTNEXTLINE readability-redundant-string-init */                 \
         ::std::string gmock_description = (description);                       \
         if (!gmock_description.empty()) {                                      \
           return gmock_description;                                            \

From 922e0b7d805f5668b68762552f5cca9b3225acd5 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Mon, 17 Apr 2023 09:30:58 -0700
Subject: [PATCH 172/336] Update gMock Cookbook to reflect deprecation of
 testing::ByMove

PiperOrigin-RevId: 524868227
Change-Id: I702ede27570e3d3f06d534d6ccf8b39689105d07
---
 docs/gmock_cook_book.md | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/docs/gmock_cook_book.md b/docs/gmock_cook_book.md
index d11282fa6..d57be58dd 100644
--- a/docs/gmock_cook_book.md
+++ b/docs/gmock_cook_book.md
@@ -2781,26 +2781,21 @@ action:
 If you are not happy with the default action, you can tweak it as usual; see
 [Setting Default Actions](#OnCall).
 
-If you just need to return a pre-defined move-only value, you can use the
-`Return(ByMove(...))` action:
+If you just need to return a move-only value, you can use it in combination with
+`WillOnce`. For example:
 
 ```cpp
-  // When this fires, the unique_ptr<> specified by ByMove(...) will
-  // be returned.
-  EXPECT_CALL(mock_buzzer_, MakeBuzz("world"))
-      .WillOnce(Return(ByMove(std::make_unique(AccessLevel::kInternal))));
-
-  EXPECT_NE(nullptr, mock_buzzer_.MakeBuzz("world"));
+  EXPECT_CALL(mock_buzzer_, MakeBuzz("hello"))
+      .WillOnce(Return(std::make_unique(AccessLevel::kInternal)));
+  EXPECT_NE(nullptr, mock_buzzer_.MakeBuzz("hello"));
 ```
 
-Note that `ByMove()` is essential here - if you drop it, the code won’t compile.
-
-Quiz time! What do you think will happen if a `Return(ByMove(...))` action is
-performed more than once (e.g. you write `...
-.WillRepeatedly(Return(ByMove(...)));`)? Come think of it, after the first time
-the action runs, the source value will be consumed (since it’s a move-only
-value), so the next time around, there’s no value to move from -- you’ll get a
-run-time error that `Return(ByMove(...))` can only be run once.
+Quiz time! What do you think will happen if a `Return` action is performed more
+than once (e.g. you write `... .WillRepeatedly(Return(std::move(...)));`)? Come
+think of it, after the first time the action runs, the source value will be
+consumed (since it’s a move-only value), so the next time around, there’s no
+value to move from -- you’ll get a run-time error that `Return(std::move(...))`
+can only be run once.
 
 If you need your mock method to do more than just moving a pre-defined value,
 remember that you can always use a lambda or a callable object, which can do
@@ -2817,7 +2812,7 @@ pretty much anything you want:
 ```
 
 Every time this `EXPECT_CALL` fires, a new `unique_ptr` will be created
-and returned. You cannot do this with `Return(ByMove(...))`.
+and returned. You cannot do this with `Return(std::make_unique<...>(...))`.
 
 That covers returning move-only values; but how do we work with methods
 accepting move-only arguments? The answer is that they work normally, although
@@ -4298,7 +4293,7 @@ particular type than to dump the bytes.
 ### Mock std::function {#MockFunction}
 
 `std::function` is a general function type introduced in C++11. It is a
-preferred way of passing callbacks to new interfaces. Functions are copiable,
+preferred way of passing callbacks to new interfaces. Functions are copyable,
 and are not usually passed around by pointer, which makes them tricky to mock.
 But fear not - `MockFunction` can help you with that.
 

From 01bcf8c70dc0e4609d71540cb50ada3850b7a54e Mon Sep 17 00:00:00 2001
From: Tom Hughes 
Date: Thu, 20 Apr 2023 08:21:57 -0700
Subject: [PATCH 173/336] Make parameter names in function declaration match
 the names in the definitions

https://clang.llvm.org/extra/clang-tidy/checks/readability/inconsistent-declaration-parameter-name.html

PiperOrigin-RevId: 525752102
Change-Id: Ibf9d3d1dbae8f95cfc7c6ad29fe4b677f4ee19cf
---
 googletest/src/gtest.cc | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 15cee3f08..da52b1d15 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -3782,28 +3782,28 @@ class TestEventRepeater : public TestEventListener {
   bool forwarding_enabled() const { return forwarding_enabled_; }
   void set_forwarding_enabled(bool enable) { forwarding_enabled_ = enable; }
 
-  void OnTestProgramStart(const UnitTest& unit_test) override;
+  void OnTestProgramStart(const UnitTest& parameter) override;
   void OnTestIterationStart(const UnitTest& unit_test, int iteration) override;
-  void OnEnvironmentsSetUpStart(const UnitTest& unit_test) override;
-  void OnEnvironmentsSetUpEnd(const UnitTest& unit_test) override;
+  void OnEnvironmentsSetUpStart(const UnitTest& parameter) override;
+  void OnEnvironmentsSetUpEnd(const UnitTest& parameter) override;
 //  Legacy API is deprecated but still available
 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
   void OnTestCaseStart(const TestSuite& parameter) override;
 #endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_
   void OnTestSuiteStart(const TestSuite& parameter) override;
-  void OnTestStart(const TestInfo& test_info) override;
-  void OnTestDisabled(const TestInfo& test_info) override;
-  void OnTestPartResult(const TestPartResult& result) override;
-  void OnTestEnd(const TestInfo& test_info) override;
+  void OnTestStart(const TestInfo& parameter) override;
+  void OnTestDisabled(const TestInfo& parameter) override;
+  void OnTestPartResult(const TestPartResult& parameter) override;
+  void OnTestEnd(const TestInfo& parameter) override;
 //  Legacy API is deprecated but still available
 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
   void OnTestCaseEnd(const TestCase& parameter) override;
 #endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_
   void OnTestSuiteEnd(const TestSuite& parameter) override;
-  void OnEnvironmentsTearDownStart(const UnitTest& unit_test) override;
-  void OnEnvironmentsTearDownEnd(const UnitTest& unit_test) override;
+  void OnEnvironmentsTearDownStart(const UnitTest& parameter) override;
+  void OnEnvironmentsTearDownEnd(const UnitTest& parameter) override;
   void OnTestIterationEnd(const UnitTest& unit_test, int iteration) override;
-  void OnTestProgramEnd(const UnitTest& unit_test) override;
+  void OnTestProgramEnd(const UnitTest& parameter) override;
 
  private:
   // Controls whether events will be forwarded to listeners_. Set to false

From d8a5fb7ee6373b9f4429a2beb5c1ef22d9f8b5b3 Mon Sep 17 00:00:00 2001
From: Tom Hughes 
Date: Thu, 20 Apr 2023 11:01:16 -0700
Subject: [PATCH 174/336] Add missing std includes

PiperOrigin-RevId: 525794940
Change-Id: Ib2639058610c91cbffbb0f22a5e71573e0cbd651
---
 .../test/googletest-json-outfiles-test.py     |  2 +-
 .../test/googletest-json-output-unittest.py   | 54 ++++++++---------
 googletest/test/googletest-output-test_.cc    |  3 +
 googletest/test/gtest_xml_outfile2_test_.cc   |  2 +
 googletest/test/gtest_xml_outfiles_test.py    |  2 +-
 googletest/test/gtest_xml_output_unittest.py  | 60 +++++++++----------
 googletest/test/gtest_xml_output_unittest_.cc |  2 +
 7 files changed, 66 insertions(+), 59 deletions(-)

diff --git a/googletest/test/googletest-json-outfiles-test.py b/googletest/test/googletest-json-outfiles-test.py
index ff1572234..5626004ed 100644
--- a/googletest/test/googletest-json-outfiles-test.py
+++ b/googletest/test/googletest-json-outfiles-test.py
@@ -90,7 +90,7 @@ EXPECTED_2 = {
         'testsuite': [{
             'name': 'TestInt64ConvertibleProperties',
             'file': 'gtest_xml_outfile2_test_.cc',
-            'line': 41,
+            'line': 43,
             'status': 'RUN',
             'result': 'COMPLETED',
             'timestamp': '*',
diff --git a/googletest/test/googletest-json-output-unittest.py b/googletest/test/googletest-json-output-unittest.py
index e955e7b00..cb9769452 100644
--- a/googletest/test/googletest-json-output-unittest.py
+++ b/googletest/test/googletest-json-output-unittest.py
@@ -77,7 +77,7 @@ EXPECTED_NON_EMPTY = {
             'testsuite': [{
                 'name': 'Succeeds',
                 'file': 'gtest_xml_output_unittest_.cc',
-                'line': 51,
+                'line': 53,
                 'status': 'RUN',
                 'result': 'COMPLETED',
                 'time': '*',
@@ -96,7 +96,7 @@ EXPECTED_NON_EMPTY = {
             'testsuite': [{
                 'name': 'Fails',
                 'file': 'gtest_xml_output_unittest_.cc',
-                'line': 59,
+                'line': 61,
                 'status': 'RUN',
                 'result': 'COMPLETED',
                 'time': '*',
@@ -124,7 +124,7 @@ EXPECTED_NON_EMPTY = {
             'testsuite': [{
                 'name': 'DISABLED_test_not_run',
                 'file': 'gtest_xml_output_unittest_.cc',
-                'line': 66,
+                'line': 68,
                 'status': 'NOTRUN',
                 'result': 'SUPPRESSED',
                 'time': '*',
@@ -144,7 +144,7 @@ EXPECTED_NON_EMPTY = {
                 {
                     'name': 'Skipped',
                     'file': 'gtest_xml_output_unittest_.cc',
-                    'line': 73,
+                    'line': 75,
                     'status': 'RUN',
                     'result': 'SKIPPED',
                     'time': '*',
@@ -154,7 +154,7 @@ EXPECTED_NON_EMPTY = {
                 {
                     'name': 'SkippedWithMessage',
                     'file': 'gtest_xml_output_unittest_.cc',
-                    'line': 77,
+                    'line': 79,
                     'status': 'RUN',
                     'result': 'SKIPPED',
                     'time': '*',
@@ -164,7 +164,7 @@ EXPECTED_NON_EMPTY = {
                 {
                     'name': 'SkippedAfterFailure',
                     'file': 'gtest_xml_output_unittest_.cc',
-                    'line': 81,
+                    'line': 83,
                     'status': 'RUN',
                     'result': 'COMPLETED',
                     'time': '*',
@@ -194,7 +194,7 @@ EXPECTED_NON_EMPTY = {
                 {
                     'name': 'Succeeds',
                     'file': 'gtest_xml_output_unittest_.cc',
-                    'line': 86,
+                    'line': 88,
                     'status': 'RUN',
                     'result': 'COMPLETED',
                     'time': '*',
@@ -204,7 +204,7 @@ EXPECTED_NON_EMPTY = {
                 {
                     'name': 'Fails',
                     'file': 'gtest_xml_output_unittest_.cc',
-                    'line': 91,
+                    'line': 93,
                     'status': 'RUN',
                     'result': 'COMPLETED',
                     'time': '*',
@@ -234,7 +234,7 @@ EXPECTED_NON_EMPTY = {
                 {
                     'name': 'DISABLED_test',
                     'file': 'gtest_xml_output_unittest_.cc',
-                    'line': 96,
+                    'line': 98,
                     'status': 'NOTRUN',
                     'result': 'SUPPRESSED',
                     'time': '*',
@@ -254,7 +254,7 @@ EXPECTED_NON_EMPTY = {
             'testsuite': [{
                 'name': 'OutputsCData',
                 'file': 'gtest_xml_output_unittest_.cc',
-                'line': 100,
+                'line': 102,
                 'status': 'RUN',
                 'result': 'COMPLETED',
                 'time': '*',
@@ -282,7 +282,7 @@ EXPECTED_NON_EMPTY = {
             'testsuite': [{
                 'name': 'InvalidCharactersInMessage',
                 'file': 'gtest_xml_output_unittest_.cc',
-                'line': 107,
+                'line': 109,
                 'status': 'RUN',
                 'result': 'COMPLETED',
                 'time': '*',
@@ -313,7 +313,7 @@ EXPECTED_NON_EMPTY = {
                 {
                     'name': 'OneProperty',
                     'file': 'gtest_xml_output_unittest_.cc',
-                    'line': 119,
+                    'line': 121,
                     'status': 'RUN',
                     'result': 'COMPLETED',
                     'time': '*',
@@ -324,7 +324,7 @@ EXPECTED_NON_EMPTY = {
                 {
                     'name': 'IntValuedProperty',
                     'file': 'gtest_xml_output_unittest_.cc',
-                    'line': 123,
+                    'line': 125,
                     'status': 'RUN',
                     'result': 'COMPLETED',
                     'time': '*',
@@ -335,7 +335,7 @@ EXPECTED_NON_EMPTY = {
                 {
                     'name': 'ThreeProperties',
                     'file': 'gtest_xml_output_unittest_.cc',
-                    'line': 127,
+                    'line': 129,
                     'status': 'RUN',
                     'result': 'COMPLETED',
                     'time': '*',
@@ -348,7 +348,7 @@ EXPECTED_NON_EMPTY = {
                 {
                     'name': 'TwoValuesForOneKeyUsesLastValue',
                     'file': 'gtest_xml_output_unittest_.cc',
-                    'line': 133,
+                    'line': 135,
                     'status': 'RUN',
                     'result': 'COMPLETED',
                     'time': '*',
@@ -370,7 +370,7 @@ EXPECTED_NON_EMPTY = {
                 {
                     'name': 'RecordProperty',
                     'file': 'gtest_xml_output_unittest_.cc',
-                    'line': 138,
+                    'line': 140,
                     'status': 'RUN',
                     'result': 'COMPLETED',
                     'time': '*',
@@ -381,7 +381,7 @@ EXPECTED_NON_EMPTY = {
                 {
                     'name': 'ExternalUtilityThatCallsRecordIntValuedProperty',
                     'file': 'gtest_xml_output_unittest_.cc',
-                    'line': 151,
+                    'line': 153,
                     'status': 'RUN',
                     'result': 'COMPLETED',
                     'time': '*',
@@ -394,7 +394,7 @@ EXPECTED_NON_EMPTY = {
                         'ExternalUtilityThatCallsRecordStringValuedProperty'
                     ),
                     'file': 'gtest_xml_output_unittest_.cc',
-                    'line': 155,
+                    'line': 157,
                     'status': 'RUN',
                     'result': 'COMPLETED',
                     'time': '*',
@@ -416,7 +416,7 @@ EXPECTED_NON_EMPTY = {
                 'name': 'HasTypeParamAttribute',
                 'type_param': 'int',
                 'file': 'gtest_xml_output_unittest_.cc',
-                'line': 171,
+                'line': 173,
                 'status': 'RUN',
                 'result': 'COMPLETED',
                 'time': '*',
@@ -436,7 +436,7 @@ EXPECTED_NON_EMPTY = {
                 'name': 'HasTypeParamAttribute',
                 'type_param': 'long',
                 'file': 'gtest_xml_output_unittest_.cc',
-                'line': 171,
+                'line': 173,
                 'status': 'RUN',
                 'result': 'COMPLETED',
                 'time': '*',
@@ -456,7 +456,7 @@ EXPECTED_NON_EMPTY = {
                 'name': 'HasTypeParamAttribute',
                 'type_param': 'int',
                 'file': 'gtest_xml_output_unittest_.cc',
-                'line': 178,
+                'line': 180,
                 'status': 'RUN',
                 'result': 'COMPLETED',
                 'time': '*',
@@ -476,7 +476,7 @@ EXPECTED_NON_EMPTY = {
                 'name': 'HasTypeParamAttribute',
                 'type_param': 'long',
                 'file': 'gtest_xml_output_unittest_.cc',
-                'line': 178,
+                'line': 180,
                 'status': 'RUN',
                 'result': 'COMPLETED',
                 'time': '*',
@@ -497,7 +497,7 @@ EXPECTED_NON_EMPTY = {
                     'name': 'HasValueParamAttribute/0',
                     'value_param': '33',
                     'file': 'gtest_xml_output_unittest_.cc',
-                    'line': 162,
+                    'line': 164,
                     'status': 'RUN',
                     'result': 'COMPLETED',
                     'time': '*',
@@ -508,7 +508,7 @@ EXPECTED_NON_EMPTY = {
                     'name': 'HasValueParamAttribute/1',
                     'value_param': '42',
                     'file': 'gtest_xml_output_unittest_.cc',
-                    'line': 162,
+                    'line': 164,
                     'status': 'RUN',
                     'result': 'COMPLETED',
                     'time': '*',
@@ -519,7 +519,7 @@ EXPECTED_NON_EMPTY = {
                     'name': 'AnotherTestThatHasValueParamAttribute/0',
                     'value_param': '33',
                     'file': 'gtest_xml_output_unittest_.cc',
-                    'line': 163,
+                    'line': 165,
                     'status': 'RUN',
                     'result': 'COMPLETED',
                     'time': '*',
@@ -530,7 +530,7 @@ EXPECTED_NON_EMPTY = {
                     'name': 'AnotherTestThatHasValueParamAttribute/1',
                     'value_param': '42',
                     'file': 'gtest_xml_output_unittest_.cc',
-                    'line': 163,
+                    'line': 165,
                     'status': 'RUN',
                     'result': 'COMPLETED',
                     'time': '*',
@@ -562,7 +562,7 @@ EXPECTED_FILTERED = {
         'testsuite': [{
             'name': 'Succeeds',
             'file': 'gtest_xml_output_unittest_.cc',
-            'line': 51,
+            'line': 53,
             'status': 'RUN',
             'result': 'COMPLETED',
             'time': '*',
diff --git a/googletest/test/googletest-output-test_.cc b/googletest/test/googletest-output-test_.cc
index 44d0fc137..f1facf570 100644
--- a/googletest/test/googletest-output-test_.cc
+++ b/googletest/test/googletest-output-test_.cc
@@ -35,6 +35,9 @@
 
 #include 
 
+#include 
+#include 
+
 #include "gtest/gtest-spi.h"
 #include "gtest/gtest.h"
 #include "src/gtest-internal-inl.h"
diff --git a/googletest/test/gtest_xml_outfile2_test_.cc b/googletest/test/gtest_xml_outfile2_test_.cc
index ed58dc8df..4a76429c5 100644
--- a/googletest/test/gtest_xml_outfile2_test_.cc
+++ b/googletest/test/gtest_xml_outfile2_test_.cc
@@ -30,6 +30,8 @@
 // gtest_xml_outfile2_test_ writes some xml via TestProperty used by
 // gtest_xml_outfiles_test.py
 
+#include 
+
 #include "gtest/gtest.h"
 
 class PropertyTwo : public testing::Test {
diff --git a/googletest/test/gtest_xml_outfiles_test.py b/googletest/test/gtest_xml_outfiles_test.py
index 50291b0a8..d17cc0c9a 100755
--- a/googletest/test/gtest_xml_outfiles_test.py
+++ b/googletest/test/gtest_xml_outfiles_test.py
@@ -57,7 +57,7 @@ EXPECTED_XML_1 = """
 EXPECTED_XML_2 = """
 
   
-    
+    
       
         
         
diff --git a/googletest/test/gtest_xml_output_unittest.py b/googletest/test/gtest_xml_output_unittest.py
index e7e44fc16..422569e48 100755
--- a/googletest/test/gtest_xml_output_unittest.py
+++ b/googletest/test/gtest_xml_output_unittest.py
@@ -69,10 +69,10 @@ else:
 EXPECTED_NON_EMPTY_XML = """
 
   
-    
+    
   
   
-    
+    
       
   
   
-    
-    
+    
+    
       
     
-    
+    
   
   
-    
+    
       ]]>%(stack)s]]>
     
   
   
-    
+    
       
     
   
   
-    
+    
   
   
-    
+    
       
     
-    
+    
       
     
-    
+    
       
 
   
   
-    
+    
       
         
       
     
-    
+    
       
         
       
     
-    
+    
       
         
         
         
       
     
-    
+    
       
         
       
     
   
   
-     
+     
        
          
        
      
-     
+     
        
          
        
      
-     
+     
        
          
        
      
   
   
-    
-    
-    
-    
+    
+    
+    
+    
   
   
-    
+    
   
   
-    
+    
   
   
-    
+    
   
   
-    
+    
   
 """ % {
     'stack': STACK_TRACE_TEMPLATE,
@@ -198,24 +198,24 @@ EXPECTED_FILTERED_TEST_XML = """
             timestamp="*" name="AllTests" ad_hoc_property="42">
   
-    
+    
   
 """
 
 EXPECTED_SHARDED_TEST_XML = """
 
   
-    
+    
   
   
-    
+    
       
         
       
     
   
   
-    
+    
   
 """
 
diff --git a/googletest/test/gtest_xml_output_unittest_.cc b/googletest/test/gtest_xml_output_unittest_.cc
index 4bdb0c7e8..0ab33022e 100644
--- a/googletest/test/gtest_xml_output_unittest_.cc
+++ b/googletest/test/gtest_xml_output_unittest_.cc
@@ -37,6 +37,8 @@
 // directly.
 // clang-format off
 
+#include 
+
 #include "gtest/gtest.h"
 
 using ::testing::InitGoogleTest;

From d7fb5e1af4a4840f28e442cb5414766d4fb17522 Mon Sep 17 00:00:00 2001
From: Tom Hughes 
Date: Thu, 20 Apr 2023 12:35:42 -0700
Subject: [PATCH 175/336] Fix spelling

PiperOrigin-RevId: 525820426
Change-Id: Ib5baa8da4a54ebb17b6ace12240ed03eedb46091
---
 googletest/test/googletest-port-test.cc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/googletest/test/googletest-port-test.cc b/googletest/test/googletest-port-test.cc
index 1ba3f502c..94bb8e388 100644
--- a/googletest/test/googletest-port-test.cc
+++ b/googletest/test/googletest-port-test.cc
@@ -979,14 +979,14 @@ TEST(ThreadLocalTest, SingleParamConstructorInitializesToParam) {
   EXPECT_EQ(&i, t2.get());
 }
 
-class NoDefaultContructor {
+class NoDefaultConstructor {
  public:
-  explicit NoDefaultContructor(const char*) {}
-  NoDefaultContructor(const NoDefaultContructor&) {}
+  explicit NoDefaultConstructor(const char*) {}
+  NoDefaultConstructor(const NoDefaultConstructor&) {}
 };
 
 TEST(ThreadLocalTest, ValueDefaultContructorIsNotRequiredForParamVersion) {
-  ThreadLocal bar(NoDefaultContructor("foo"));
+  ThreadLocal bar(NoDefaultConstructor("foo"));
   bar.pointer();
 }
 

From 9c1efac2a1b6d836ef35e1dfb87b7addca361afe Mon Sep 17 00:00:00 2001
From: Tom Hughes 
Date: Thu, 20 Apr 2023 13:08:47 -0700
Subject: [PATCH 176/336] Use std::make_unique

PiperOrigin-RevId: 525828947
Change-Id: I66f47c835bc93ba171eba0da8df09eff89c6c77b
---
 googletest/include/gtest/gtest-assertion-result.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/googletest/include/gtest/gtest-assertion-result.h b/googletest/include/gtest/gtest-assertion-result.h
index 62fbea6e3..56fe128f2 100644
--- a/googletest/include/gtest/gtest-assertion-result.h
+++ b/googletest/include/gtest/gtest-assertion-result.h
@@ -204,7 +204,7 @@ class GTEST_API_ AssertionResult {
  private:
   // Appends the contents of message to message_.
   void AppendMessage(const Message& a_message) {
-    if (message_ == nullptr) message_.reset(new ::std::string);
+    if (message_ == nullptr) message_ = ::std::make_unique<::std::string>();
     message_->append(a_message.GetString().c_str());
   }
 

From a5308bb992c049b16b763f8910da70c208c5cede Mon Sep 17 00:00:00 2001
From: Tom Hughes 
Date: Thu, 20 Apr 2023 14:28:27 -0700
Subject: [PATCH 177/336] Add missing std includes

PiperOrigin-RevId: 525850646
Change-Id: I64387f5b933beb79cd05636dca81b7a75213383e
---
 googlemock/include/gmock/gmock-matchers.h            |  1 +
 googlemock/src/gmock-internal-utils.cc               |  1 +
 googlemock/src/gmock-spec-builders.cc                |  1 +
 googlemock/src/gmock.cc                              |  2 ++
 googlemock/test/gmock-actions_test.cc                |  3 +++
 googlemock/test/gmock-cardinalities_test.cc          |  2 ++
 googlemock/test/gmock-internal-utils_test.cc         |  1 +
 googlemock/test/gmock-matchers-arithmetic_test.cc    |  3 +++
 googlemock/test/gmock-matchers-comparisons_test.cc   |  3 +++
 googlemock/test/gmock-matchers-containers_test.cc    | 12 ++++++++++++
 googlemock/test/gmock-matchers-misc_test.cc          |  8 ++++++++
 googlemock/test/gmock-more-actions_test.cc           |  4 ++++
 googlemock/test/gmock_ex_test.cc                     |  2 ++
 googletest/samples/sample8_unittest.cc               |  2 ++
 googletest/src/gtest-death-test.cc                   |  2 ++
 googletest/src/gtest-filepath.cc                     |  3 +++
 googletest/src/gtest-port.cc                         |  4 ++++
 googletest/src/gtest-printers.cc                     |  2 ++
 googletest/src/gtest-test-part.cc                    |  3 +++
 googletest/src/gtest-typed-test.cc                   |  4 ++++
 googletest/src/gtest.cc                              |  3 +++
 googletest/test/googletest-death-test-test.cc        |  3 +++
 googletest/test/googletest-list-tests-unittest_.cc   |  3 +++
 googletest/test/googletest-listener-test.cc          |  1 +
 .../googletest-param-test-invalid-name2-test_.cc     |  2 ++
 googletest/test/googletest-printers-test.cc          |  2 ++
 googletest/test/gtest_stress_test.cc                 |  2 ++
 googletest/test/gtest_unittest.cc                    |  1 +
 28 files changed, 80 insertions(+)

diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h
index fb9f15e8d..0f6771377 100644
--- a/googlemock/include/gmock/gmock-matchers.h
+++ b/googlemock/include/gmock/gmock-matchers.h
@@ -257,6 +257,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/googlemock/src/gmock-internal-utils.cc b/googlemock/src/gmock-internal-utils.cc
index 774cce334..5c2ce0d57 100644
--- a/googlemock/src/gmock-internal-utils.cc
+++ b/googlemock/src/gmock-internal-utils.cc
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 #include   // NOLINT
 #include 
 #include 
diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc
index 5a98fafd1..df0660b13 100644
--- a/googlemock/src/gmock-spec-builders.cc
+++ b/googlemock/src/gmock-spec-builders.cc
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/googlemock/src/gmock.cc b/googlemock/src/gmock.cc
index 5025656a0..b5e714da7 100644
--- a/googlemock/src/gmock.cc
+++ b/googlemock/src/gmock.cc
@@ -29,6 +29,8 @@
 
 #include "gmock/gmock.h"
 
+#include 
+
 #include "gmock/internal/gmock-port.h"
 
 GMOCK_DEFINE_bool_(catch_leaked_mocks, true,
diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc
index ee9b889bd..f2305e528 100644
--- a/googlemock/test/gmock-actions_test.cc
+++ b/googlemock/test/gmock-actions_test.cc
@@ -37,8 +37,11 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
+#include 
 #include 
 
 #include "gmock/gmock.h"
diff --git a/googlemock/test/gmock-cardinalities_test.cc b/googlemock/test/gmock-cardinalities_test.cc
index cdd995635..77196d7a2 100644
--- a/googlemock/test/gmock-cardinalities_test.cc
+++ b/googlemock/test/gmock-cardinalities_test.cc
@@ -31,6 +31,8 @@
 //
 // This file tests the built-in cardinalities.
 
+#include 
+
 #include "gmock/gmock.h"
 #include "gtest/gtest-spi.h"
 #include "gtest/gtest.h"
diff --git a/googlemock/test/gmock-internal-utils_test.cc b/googlemock/test/gmock-internal-utils_test.cc
index 360d02ae5..6c769a882 100644
--- a/googlemock/test/gmock-internal-utils_test.cc
+++ b/googlemock/test/gmock-internal-utils_test.cc
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "gmock/gmock.h"
diff --git a/googlemock/test/gmock-matchers-arithmetic_test.cc b/googlemock/test/gmock-matchers-arithmetic_test.cc
index 2c5f4d0bd..062e2ab3d 100644
--- a/googlemock/test/gmock-matchers-arithmetic_test.cc
+++ b/googlemock/test/gmock-matchers-arithmetic_test.cc
@@ -31,7 +31,10 @@
 //
 // This file tests some commonly used argument matchers.
 
+#include 
 #include 
+#include 
+#include 
 
 #include "test/gmock-matchers_test.h"
 
diff --git a/googlemock/test/gmock-matchers-comparisons_test.cc b/googlemock/test/gmock-matchers-comparisons_test.cc
index b849990d8..cf85eb56e 100644
--- a/googlemock/test/gmock-matchers-comparisons_test.cc
+++ b/googlemock/test/gmock-matchers-comparisons_test.cc
@@ -31,7 +31,10 @@
 //
 // This file tests some commonly used argument matchers.
 
+#include 
 #include 
+#include 
+#include 
 #include 
 
 #include "test/gmock-matchers_test.h"
diff --git a/googlemock/test/gmock-matchers-containers_test.cc b/googlemock/test/gmock-matchers-containers_test.cc
index c8d8ea378..654a011a2 100644
--- a/googlemock/test/gmock-matchers-containers_test.cc
+++ b/googlemock/test/gmock-matchers-containers_test.cc
@@ -31,6 +31,18 @@
 //
 // This file tests some commonly used argument matchers.
 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
 #include "gtest/gtest.h"
 
 // Silence warning C4244: 'initializing': conversion from 'int' to 'short',
diff --git a/googlemock/test/gmock-matchers-misc_test.cc b/googlemock/test/gmock-matchers-misc_test.cc
index 0c7aa4994..b8f64587d 100644
--- a/googlemock/test/gmock-matchers-misc_test.cc
+++ b/googlemock/test/gmock-matchers-misc_test.cc
@@ -31,6 +31,14 @@
 //
 // This file tests some commonly used argument matchers.
 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
 #include "gtest/gtest.h"
 
 // Silence warning C4244: 'initializing': conversion from 'int' to 'short',
diff --git a/googlemock/test/gmock-more-actions_test.cc b/googlemock/test/gmock-more-actions_test.cc
index 866e1aba1..ec7aea614 100644
--- a/googlemock/test/gmock-more-actions_test.cc
+++ b/googlemock/test/gmock-more-actions_test.cc
@@ -33,10 +33,14 @@
 
 #include "gmock/gmock-more-actions.h"
 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include "gmock/gmock.h"
 #include "gtest/gtest-spi.h"
diff --git a/googlemock/test/gmock_ex_test.cc b/googlemock/test/gmock_ex_test.cc
index 44e5e35f6..e174122d9 100644
--- a/googlemock/test/gmock_ex_test.cc
+++ b/googlemock/test/gmock_ex_test.cc
@@ -29,6 +29,8 @@
 
 // Tests Google Mock's functionality that depends on exceptions.
 
+#include 
+
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
diff --git a/googletest/samples/sample8_unittest.cc b/googletest/samples/sample8_unittest.cc
index 9717e2860..4df81df0c 100644
--- a/googletest/samples/sample8_unittest.cc
+++ b/googletest/samples/sample8_unittest.cc
@@ -32,6 +32,8 @@
 // and each test is given one combination as a parameter.
 
 // Use class definitions to test from this header.
+#include 
+
 #include "prime_tables.h"
 #include "gtest/gtest.h"
 namespace {
diff --git a/googletest/src/gtest-death-test.cc b/googletest/src/gtest-death-test.cc
index 0b87ba5bc..55b957827 100644
--- a/googletest/src/gtest-death-test.cc
+++ b/googletest/src/gtest-death-test.cc
@@ -34,6 +34,8 @@
 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 
diff --git a/googletest/src/gtest-filepath.cc b/googletest/src/gtest-filepath.cc
index 48dee13ef..75f52bcfc 100644
--- a/googletest/src/gtest-filepath.cc
+++ b/googletest/src/gtest-filepath.cc
@@ -31,6 +31,9 @@
 
 #include 
 
+#include 
+#include 
+
 #include "gtest/gtest-message.h"
 #include "gtest/internal/gtest-port.h"
 
diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc
index 994fabd44..77b618c40 100644
--- a/googletest/src/gtest-port.cc
+++ b/googletest/src/gtest-port.cc
@@ -37,6 +37,10 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
 
 #ifdef GTEST_OS_WINDOWS
 #include 
diff --git a/googletest/src/gtest-printers.cc b/googletest/src/gtest-printers.cc
index de740e7dc..2b4706782 100644
--- a/googletest/src/gtest-printers.cc
+++ b/googletest/src/gtest-printers.cc
@@ -47,6 +47,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include   // NOLINT
 #include 
 #include 
diff --git a/googletest/src/gtest-test-part.cc b/googletest/src/gtest-test-part.cc
index df677e6f6..6f8ddd7c4 100644
--- a/googletest/src/gtest-test-part.cc
+++ b/googletest/src/gtest-test-part.cc
@@ -32,6 +32,9 @@
 
 #include "gtest/gtest-test-part.h"
 
+#include 
+#include 
+
 #include "gtest/internal/gtest-port.h"
 #include "src/gtest-internal-inl.h"
 
diff --git a/googletest/src/gtest-typed-test.cc b/googletest/src/gtest-typed-test.cc
index 9941306f0..b251c09de 100644
--- a/googletest/src/gtest-typed-test.cc
+++ b/googletest/src/gtest-typed-test.cc
@@ -29,6 +29,10 @@
 
 #include "gtest/gtest-typed-test.h"
 
+#include 
+#include 
+#include 
+
 #include "gtest/gtest.h"
 
 namespace testing {
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index da52b1d15..01c0220b7 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -48,13 +48,16 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include   // NOLINT
+#include 
 #include 
 #include 
+#include 
 #include 
 
 #include "gtest/gtest-assertion-result.h"
diff --git a/googletest/test/googletest-death-test-test.cc b/googletest/test/googletest-death-test-test.cc
index 3579ce880..4cc81b723 100644
--- a/googletest/test/googletest-death-test-test.cc
+++ b/googletest/test/googletest-death-test-test.cc
@@ -52,6 +52,9 @@ using testing::internal::AlwaysTrue;
 #include 
 #include 
 
+#include 
+#include 
+
 #ifdef GTEST_OS_LINUX
 #include 
 #endif  // GTEST_OS_LINUX
diff --git a/googletest/test/googletest-list-tests-unittest_.cc b/googletest/test/googletest-list-tests-unittest_.cc
index 5577e8961..a1ea6cf4b 100644
--- a/googletest/test/googletest-list-tests-unittest_.cc
+++ b/googletest/test/googletest-list-tests-unittest_.cc
@@ -36,6 +36,9 @@
 // This program will be invoked from a Python unit test.
 // Don't run it directly.
 
+#include 
+#include 
+
 #include "gtest/gtest.h"
 
 // Several different test cases and tests that will be listed.
diff --git a/googletest/test/googletest-listener-test.cc b/googletest/test/googletest-listener-test.cc
index 654486d78..d7c47c214 100644
--- a/googletest/test/googletest-listener-test.cc
+++ b/googletest/test/googletest-listener-test.cc
@@ -32,6 +32,7 @@
 // This file verifies Google Test event listeners receive events at the
 // right times.
 
+#include 
 #include 
 
 #include "gtest/gtest.h"
diff --git a/googletest/test/googletest-param-test-invalid-name2-test_.cc b/googletest/test/googletest-param-test-invalid-name2-test_.cc
index d0c44da54..6d88a9ce3 100644
--- a/googletest/test/googletest-param-test-invalid-name2-test_.cc
+++ b/googletest/test/googletest-param-test-invalid-name2-test_.cc
@@ -27,6 +27,8 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+#include 
+
 #include "gtest/gtest.h"
 
 namespace {
diff --git a/googletest/test/googletest-printers-test.cc b/googletest/test/googletest-printers-test.cc
index 7fa82d087..e667e8f00 100644
--- a/googletest/test/googletest-printers-test.cc
+++ b/googletest/test/googletest-printers-test.cc
@@ -42,9 +42,11 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/googletest/test/gtest_stress_test.cc b/googletest/test/gtest_stress_test.cc
index 0cf218529..af8e757dc 100644
--- a/googletest/test/gtest_stress_test.cc
+++ b/googletest/test/gtest_stress_test.cc
@@ -30,7 +30,9 @@
 // Tests that SCOPED_TRACE() and various Google Test assertions can be
 // used in a large number of threads concurrently.
 
+#include 
 #include 
+#include 
 #include 
 
 #include "gtest/gtest.h"
diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc
index bd4fc60a6..57041f058 100644
--- a/googletest/test/gtest_unittest.cc
+++ b/googletest/test/gtest_unittest.cc
@@ -63,6 +63,7 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

From baf182e006bcb82ef5e0b407e350a1d4c444b76a Mon Sep 17 00:00:00 2001
From: Tom Hughes 
Date: Fri, 21 Apr 2023 08:42:11 -0700
Subject: [PATCH 178/336] Use the empty method to check for emptiness

PiperOrigin-RevId: 526046714
Change-Id: I6ad0deff2a7f6dfef75a643c95ad914c83b9ba38
---
 googlemock/test/gmock_test.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/googlemock/test/gmock_test.cc b/googlemock/test/gmock_test.cc
index 8f1bd5d03..8cfff3066 100644
--- a/googlemock/test/gmock_test.cc
+++ b/googlemock/test/gmock_test.cc
@@ -174,6 +174,6 @@ TEST(WideInitGoogleMockTest, ParsesGoogleMockFlagAndUnrecognizedFlag) {
 // Makes sure Google Mock flags can be accessed in code.
 TEST(FlagTest, IsAccessibleInCode) {
   bool dummy =
-      GMOCK_FLAG_GET(catch_leaked_mocks) && GMOCK_FLAG_GET(verbose) == "";
+      GMOCK_FLAG_GET(catch_leaked_mocks) && GMOCK_FLAG_GET(verbose).empty();
   (void)dummy;  // Avoids the "unused local variable" warning.
 }

From 783d00fd19865fcbc3065e3fb3e17144761fcf5a Mon Sep 17 00:00:00 2001
From: Tom Hughes 
Date: Fri, 21 Apr 2023 10:40:36 -0700
Subject: [PATCH 179/336] Use '=default' to define trivial
 constructor/destructors

https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-equals-default.html

PiperOrigin-RevId: 526079054
Change-Id: Ia4db21e3e5f58b90de05d52fd94b291ed06d785d
---
 googlemock/include/gmock/gmock-actions.h      |  8 +++---
 .../include/gmock/gmock-cardinalities.h       |  4 +--
 .../include/gmock/gmock-spec-builders.h       |  4 +--
 .../gmock/internal/gmock-internal-utils.h     |  2 +-
 googlemock/src/gmock-spec-builders.cc         |  8 +++---
 googlemock/test/gmock-actions_test.cc         |  2 +-
 googlemock/test/gmock-cardinalities_test.cc   |  2 +-
 googlemock/test/gmock-function-mocker_test.cc | 24 ++++++++---------
 .../test/gmock-matchers-arithmetic_test.cc    |  4 +--
 .../test/gmock-matchers-comparisons_test.cc   |  4 +--
 .../test/gmock-matchers-containers_test.cc    |  2 +-
 googlemock/test/gmock-nice-strict_test.cc     |  8 +++---
 googlemock/test/gmock-spec-builders_test.cc   | 14 +++++-----
 googlemock/test/gmock_leak_test_.cc           |  4 +--
 googlemock/test/gmock_link_test.h             |  4 +--
 googlemock/test/gmock_output_test_.cc         |  2 +-
 googletest/include/gtest/gtest-matchers.h     | 12 ++++-----
 googletest/include/gtest/gtest-test-part.h    |  4 +--
 googletest/include/gtest/gtest.h              |  6 ++---
 .../internal/gtest-death-test-internal.h      |  4 +--
 .../include/gtest/internal/gtest-internal.h   |  2 +-
 .../include/gtest/internal/gtest-param-util.h | 26 +++++++++----------
 .../include/gtest/internal/gtest-port.h       | 10 +++----
 googletest/samples/prime_tables.h             |  2 +-
 googletest/src/gtest-internal-inl.h           |  8 +++---
 googletest/src/gtest.cc                       |  8 +++---
 googletest/test/googletest-port-test.cc       |  4 +--
 googletest/test/googletest-printers-test.cc   |  6 ++---
 googletest/test/gtest_repeat_test.cc          |  2 +-
 googletest/test/gtest_unittest.cc             |  2 +-
 30 files changed, 96 insertions(+), 96 deletions(-)

diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h
index c0bb8a9c6..bd9ba73ee 100644
--- a/googlemock/include/gmock/gmock-actions.h
+++ b/googlemock/include/gmock/gmock-actions.h
@@ -611,7 +611,7 @@ class DefaultValue {
  private:
   class ValueProducer {
    public:
-    virtual ~ValueProducer() {}
+    virtual ~ValueProducer() = default;
     virtual T Produce() = 0;
   };
 
@@ -699,8 +699,8 @@ class ActionInterface {
   typedef typename internal::Function::Result Result;
   typedef typename internal::Function::ArgumentTuple ArgumentTuple;
 
-  ActionInterface() {}
-  virtual ~ActionInterface() {}
+  ActionInterface() = default;
+  virtual ~ActionInterface() = default;
 
   // Performs the action.  This method is not const, as in general an
   // action can have side effects and be stateful.  For example, a
@@ -749,7 +749,7 @@ class Action {
 
   // Constructs a null Action.  Needed for storing Action objects in
   // STL containers.
-  Action() {}
+  Action() = default;
 
   // Construct an Action from a specified callable.
   // This cannot take std::function directly, because then Action would not be
diff --git a/googlemock/include/gmock/gmock-cardinalities.h b/googlemock/include/gmock/gmock-cardinalities.h
index b6ab648e5..533e604f3 100644
--- a/googlemock/include/gmock/gmock-cardinalities.h
+++ b/googlemock/include/gmock/gmock-cardinalities.h
@@ -65,7 +65,7 @@ namespace testing {
 // The implementation of a cardinality.
 class CardinalityInterface {
  public:
-  virtual ~CardinalityInterface() {}
+  virtual ~CardinalityInterface() = default;
 
   // Conservative estimate on the lower/upper bound of the number of
   // calls allowed.
@@ -92,7 +92,7 @@ class GTEST_API_ Cardinality {
  public:
   // Constructs a null cardinality.  Needed for storing Cardinality
   // objects in STL containers.
-  Cardinality() {}
+  Cardinality() = default;
 
   // Constructs a Cardinality from its implementation.
   explicit Cardinality(const CardinalityInterface* impl) : impl_(impl) {}
diff --git a/googlemock/include/gmock/gmock-spec-builders.h b/googlemock/include/gmock/gmock-spec-builders.h
index 2a33acb19..78ca15d05 100644
--- a/googlemock/include/gmock/gmock-spec-builders.h
+++ b/googlemock/include/gmock/gmock-spec-builders.h
@@ -566,7 +566,7 @@ class ExpectationSet {
   typedef Expectation::Set::value_type value_type;
 
   // Constructs an empty set.
-  ExpectationSet() {}
+  ExpectationSet() = default;
 
   // This single-argument ctor must not be explicit, in order to support the
   //   ExpectationSet es = EXPECT_CALL(...);
@@ -1446,7 +1446,7 @@ class FunctionMocker final : public UntypedFunctionMockerBase {
   using ArgumentTuple = std::tuple;
   using ArgumentMatcherTuple = std::tuple...>;
 
-  FunctionMocker() {}
+  FunctionMocker() = default;
 
   // There is no generally useful and implementable semantics of
   // copying a mock object, so copying a mock is usually a user error.
diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h
index d34443866..ead6d7c80 100644
--- a/googlemock/include/gmock/internal/gmock-internal-utils.h
+++ b/googlemock/include/gmock/internal/gmock-internal-utils.h
@@ -224,7 +224,7 @@ class FailureReporterInterface {
   // The type of a failure (either non-fatal or fatal).
   enum FailureType { kNonfatal, kFatal };
 
-  virtual ~FailureReporterInterface() {}
+  virtual ~FailureReporterInterface() = default;
 
   // Reports a failure that occurred at the given source file location.
   virtual void ReportFailure(FailureType type, const char* file, int line,
diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc
index df0660b13..de8947163 100644
--- a/googlemock/src/gmock-spec-builders.cc
+++ b/googlemock/src/gmock-spec-builders.cc
@@ -96,7 +96,7 @@ ExpectationBase::ExpectationBase(const char* a_file, int a_line,
       action_count_checked_(false) {}
 
 // Destructs an ExpectationBase object.
-ExpectationBase::~ExpectationBase() {}
+ExpectationBase::~ExpectationBase() = default;
 
 // Explicitly specifies the cardinality of this expectation.  Used by
 // the subclasses to implement the .Times() clause.
@@ -309,7 +309,7 @@ void ReportUninterestingCall(CallReaction reaction, const std::string& msg) {
 UntypedFunctionMockerBase::UntypedFunctionMockerBase()
     : mock_obj_(nullptr), name_("") {}
 
-UntypedFunctionMockerBase::~UntypedFunctionMockerBase() {}
+UntypedFunctionMockerBase::~UntypedFunctionMockerBase() = default;
 
 // Sets the mock object this mock method belongs to, and registers
 // this information in the global mock registry.  Will be called
@@ -746,13 +746,13 @@ void Mock::ClearDefaultActionsLocked(void* mock_obj)
   // needed by VerifyAndClearExpectationsLocked().
 }
 
-Expectation::Expectation() {}
+Expectation::Expectation() = default;
 
 Expectation::Expectation(
     const std::shared_ptr& an_expectation_base)
     : expectation_base_(an_expectation_base) {}
 
-Expectation::~Expectation() {}
+Expectation::~Expectation() = default;
 
 // Adds an expectation to a sequence.
 void Sequence::AddExpectation(const Expectation& expectation) const {
diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc
index f2305e528..f569e834e 100644
--- a/googlemock/test/gmock-actions_test.cc
+++ b/googlemock/test/gmock-actions_test.cc
@@ -985,7 +985,7 @@ TEST(ReturnRoundRobinTest, WorksForVector) {
 
 class MockClass {
  public:
-  MockClass() {}
+  MockClass() = default;
 
   MOCK_METHOD1(IntFunc, int(bool flag));  // NOLINT
   MOCK_METHOD0(Foo, MyNonDefaultConstructible());
diff --git a/googlemock/test/gmock-cardinalities_test.cc b/googlemock/test/gmock-cardinalities_test.cc
index 77196d7a2..ad49752e1 100644
--- a/googlemock/test/gmock-cardinalities_test.cc
+++ b/googlemock/test/gmock-cardinalities_test.cc
@@ -52,7 +52,7 @@ using testing::MakeCardinality;
 
 class MockFoo {
  public:
-  MockFoo() {}
+  MockFoo() = default;
   MOCK_METHOD0(Bar, int());  // NOLINT
 
  private:
diff --git a/googlemock/test/gmock-function-mocker_test.cc b/googlemock/test/gmock-function-mocker_test.cc
index 4db498d85..f7b31ae33 100644
--- a/googlemock/test/gmock-function-mocker_test.cc
+++ b/googlemock/test/gmock-function-mocker_test.cc
@@ -70,7 +70,7 @@ using testing::TypedEq;
 template 
 class TemplatedCopyable {
  public:
-  TemplatedCopyable() {}
+  TemplatedCopyable() = default;
 
   template 
   TemplatedCopyable(const U& other) {}  // NOLINT
@@ -78,7 +78,7 @@ class TemplatedCopyable {
 
 class FooInterface {
  public:
-  virtual ~FooInterface() {}
+  virtual ~FooInterface() = default;
 
   virtual void VoidReturning(int x) = 0;
 
@@ -137,7 +137,7 @@ class FooInterface {
 GTEST_DISABLE_MSC_WARNINGS_PUSH_(4373)
 class MockFoo : public FooInterface {
  public:
-  MockFoo() {}
+  MockFoo() = default;
 
   // Makes sure that a mock function parameter can be named.
   MOCK_METHOD(void, VoidReturning, (int n));  // NOLINT
@@ -208,7 +208,7 @@ class MockFoo : public FooInterface {
 
 class LegacyMockFoo : public FooInterface {
  public:
-  LegacyMockFoo() {}
+  LegacyMockFoo() = default;
 
   // Makes sure that a mock function parameter can be named.
   MOCK_METHOD1(VoidReturning, void(int n));  // NOLINT
@@ -487,7 +487,7 @@ TEST(FunctionMockerTest, RefQualified) {
 
 class MockB {
  public:
-  MockB() {}
+  MockB() = default;
 
   MOCK_METHOD(void, DoB, ());
 
@@ -498,7 +498,7 @@ class MockB {
 
 class LegacyMockB {
  public:
-  LegacyMockB() {}
+  LegacyMockB() = default;
 
   MOCK_METHOD0(DoB, void());
 
@@ -534,7 +534,7 @@ TYPED_TEST(ExpectCallTest, UnmentionedFunctionCanBeCalledAnyNumberOfTimes) {
 template 
 class StackInterface {
  public:
-  virtual ~StackInterface() {}
+  virtual ~StackInterface() = default;
 
   // Template parameter appears in function parameter.
   virtual void Push(const T& value) = 0;
@@ -547,7 +547,7 @@ class StackInterface {
 template 
 class MockStack : public StackInterface {
  public:
-  MockStack() {}
+  MockStack() = default;
 
   MOCK_METHOD(void, Push, (const T& elem), ());
   MOCK_METHOD(void, Pop, (), (final));
@@ -566,7 +566,7 @@ class MockStack : public StackInterface {
 template 
 class LegacyMockStack : public StackInterface {
  public:
-  LegacyMockStack() {}
+  LegacyMockStack() = default;
 
   MOCK_METHOD1_T(Push, void(const T& elem));
   MOCK_METHOD0_T(Pop, void());
@@ -711,7 +711,7 @@ TYPED_TEST(TemplateMockTestWithCallType, Works) {
 
 class MockOverloadedOnArgNumber {
  public:
-  MockOverloadedOnArgNumber() {}
+  MockOverloadedOnArgNumber() = default;
 
   MY_MOCK_METHODS1_;
 
@@ -723,7 +723,7 @@ class MockOverloadedOnArgNumber {
 
 class LegacyMockOverloadedOnArgNumber {
  public:
-  LegacyMockOverloadedOnArgNumber() {}
+  LegacyMockOverloadedOnArgNumber() = default;
 
   LEGACY_MY_MOCK_METHODS1_;
 
@@ -758,7 +758,7 @@ TYPED_TEST(OverloadedMockMethodTest, CanOverloadOnArgNumberInMacroBody) {
 
 class MockOverloadedOnConstness {
  public:
-  MockOverloadedOnConstness() {}
+  MockOverloadedOnConstness() = default;
 
   MY_MOCK_METHODS2_;
 
diff --git a/googlemock/test/gmock-matchers-arithmetic_test.cc b/googlemock/test/gmock-matchers-arithmetic_test.cc
index 062e2ab3d..f17696285 100644
--- a/googlemock/test/gmock-matchers-arithmetic_test.cc
+++ b/googlemock/test/gmock-matchers-arithmetic_test.cc
@@ -955,7 +955,7 @@ TEST(AllArgsTest, WorksForNonTuple) {
 
 class AllArgsHelper {
  public:
-  AllArgsHelper() {}
+  AllArgsHelper() = default;
 
   MOCK_METHOD2(Helper, int(char x, int y));
 
@@ -976,7 +976,7 @@ TEST(AllArgsTest, WorksInWithClause) {
 
 class OptionalMatchersHelper {
  public:
-  OptionalMatchersHelper() {}
+  OptionalMatchersHelper() = default;
 
   MOCK_METHOD0(NoArgs, int());
 
diff --git a/googlemock/test/gmock-matchers-comparisons_test.cc b/googlemock/test/gmock-matchers-comparisons_test.cc
index cf85eb56e..b2ce99e18 100644
--- a/googlemock/test/gmock-matchers-comparisons_test.cc
+++ b/googlemock/test/gmock-matchers-comparisons_test.cc
@@ -589,8 +589,8 @@ TEST(MatcherCastTest, ValueIsNotCopied) {
 
 class Base {
  public:
-  virtual ~Base() {}
-  Base() {}
+  virtual ~Base() = default;
+  Base() = default;
 
  private:
   Base(const Base&) = delete;
diff --git a/googlemock/test/gmock-matchers-containers_test.cc b/googlemock/test/gmock-matchers-containers_test.cc
index 654a011a2..38fd9a5dd 100644
--- a/googlemock/test/gmock-matchers-containers_test.cc
+++ b/googlemock/test/gmock-matchers-containers_test.cc
@@ -2788,7 +2788,7 @@ TEST(ElementsAreTest, WorksWithNativeArrayPassedByReference) {
 
 class NativeArrayPassedAsPointerAndSize {
  public:
-  NativeArrayPassedAsPointerAndSize() {}
+  NativeArrayPassedAsPointerAndSize() = default;
 
   MOCK_METHOD(void, Helper, (int* array, int size));
 
diff --git a/googlemock/test/gmock-nice-strict_test.cc b/googlemock/test/gmock-nice-strict_test.cc
index 08254e1ac..95f096903 100644
--- a/googlemock/test/gmock-nice-strict_test.cc
+++ b/googlemock/test/gmock-nice-strict_test.cc
@@ -40,7 +40,7 @@
 // clash with ::testing::Mock.
 class Mock {
  public:
-  Mock() {}
+  Mock() = default;
 
   MOCK_METHOD0(DoThis, void());
 
@@ -78,7 +78,7 @@ class CallsMockMethodInDestructor {
 
 class Foo {
  public:
-  virtual ~Foo() {}
+  virtual ~Foo() = default;
 
   virtual void DoThis() = 0;
   virtual int DoThat(bool flag) = 0;
@@ -86,7 +86,7 @@ class Foo {
 
 class MockFoo : public Foo {
  public:
-  MockFoo() {}
+  MockFoo() = default;
   void Delete() { delete this; }
 
   MOCK_METHOD0(DoThis, void());
@@ -109,7 +109,7 @@ class MockBar {
            (a10 ? 'T' : 'F');
   }
 
-  virtual ~MockBar() {}
+  virtual ~MockBar() = default;
 
   const std::string& str() const { return str_; }
 
diff --git a/googlemock/test/gmock-spec-builders_test.cc b/googlemock/test/gmock-spec-builders_test.cc
index d53196b35..7ba591a17 100644
--- a/googlemock/test/gmock-spec-builders_test.cc
+++ b/googlemock/test/gmock-spec-builders_test.cc
@@ -98,7 +98,7 @@ class NonDefaultConstructible {
 
 class MockA {
  public:
-  MockA() {}
+  MockA() = default;
 
   MOCK_METHOD1(DoA, void(int n));
   MOCK_METHOD1(ReturnResult, Result(int n));
@@ -113,7 +113,7 @@ class MockA {
 
 class MockB {
  public:
-  MockB() {}
+  MockB() = default;
 
   MOCK_CONST_METHOD0(DoB, int());  // NOLINT
   MOCK_METHOD1(DoB, int(int n));   // NOLINT
@@ -125,7 +125,7 @@ class MockB {
 
 class ReferenceHoldingMock {
  public:
-  ReferenceHoldingMock() {}
+  ReferenceHoldingMock() = default;
 
   MOCK_METHOD1(AcceptReference, void(std::shared_ptr*));
 
@@ -143,12 +143,12 @@ class ReferenceHoldingMock {
 
 class CC {
  public:
-  virtual ~CC() {}
+  virtual ~CC() = default;
   virtual int Method() = 0;
 };
 class MockCC : public CC {
  public:
-  MockCC() {}
+  MockCC() = default;
 
   MOCK_METHOD0(Method, int());
 
@@ -1881,7 +1881,7 @@ struct Unprintable {
 
 class MockC {
  public:
-  MockC() {}
+  MockC() = default;
 
   MOCK_METHOD6(VoidMethod, void(bool cond, int n, std::string s, void* p,
                                 const Printable& x, Unprintable y));
@@ -2121,7 +2121,7 @@ void PrintTo(PrintMeNot /* dummy */, ::std::ostream* /* os */) {
 
 class LogTestHelper {
  public:
-  LogTestHelper() {}
+  LogTestHelper() = default;
 
   MOCK_METHOD1(Foo, PrintMeNot(PrintMeNot));
 
diff --git a/googlemock/test/gmock_leak_test_.cc b/googlemock/test/gmock_leak_test_.cc
index fa645916f..a6bb33921 100644
--- a/googlemock/test/gmock_leak_test_.cc
+++ b/googlemock/test/gmock_leak_test_.cc
@@ -40,13 +40,13 @@ using ::testing::Return;
 
 class FooInterface {
  public:
-  virtual ~FooInterface() {}
+  virtual ~FooInterface() = default;
   virtual void DoThis() = 0;
 };
 
 class MockFoo : public FooInterface {
  public:
-  MockFoo() {}
+  MockFoo() = default;
 
   MOCK_METHOD0(DoThis, void());
 
diff --git a/googlemock/test/gmock_link_test.h b/googlemock/test/gmock_link_test.h
index 8d2abb1a6..db11c2d24 100644
--- a/googlemock/test/gmock_link_test.h
+++ b/googlemock/test/gmock_link_test.h
@@ -194,7 +194,7 @@ using testing::MatchesRegex;
 
 class Interface {
  public:
-  virtual ~Interface() {}
+  virtual ~Interface() = default;
   virtual void VoidFromString(char* str) = 0;
   virtual char* StringFromString(char* str) = 0;
   virtual int IntFromString(char* str) = 0;
@@ -208,7 +208,7 @@ class Interface {
 
 class Mock : public Interface {
  public:
-  Mock() {}
+  Mock() = default;
 
   MOCK_METHOD1(VoidFromString, void(char* str));
   MOCK_METHOD1(StringFromString, char*(char* str));
diff --git a/googlemock/test/gmock_output_test_.cc b/googlemock/test/gmock_output_test_.cc
index ca5a646f3..04a6e8b40 100644
--- a/googlemock/test/gmock_output_test_.cc
+++ b/googlemock/test/gmock_output_test_.cc
@@ -53,7 +53,7 @@ using testing::Value;
 
 class MockFoo {
  public:
-  MockFoo() {}
+  MockFoo() = default;
 
   MOCK_METHOD3(Bar, char(const std::string& s, int i, double x));
   MOCK_METHOD2(Bar2, bool(int x, int y));
diff --git a/googletest/include/gtest/gtest-matchers.h b/googletest/include/gtest/gtest-matchers.h
index d73d83414..eae210e99 100644
--- a/googletest/include/gtest/gtest-matchers.h
+++ b/googletest/include/gtest/gtest-matchers.h
@@ -107,13 +107,13 @@ class MatchResultListener {
   MatchResultListener& operator=(const MatchResultListener&) = delete;
 };
 
-inline MatchResultListener::~MatchResultListener() {}
+inline MatchResultListener::~MatchResultListener() = default;
 
 // An instance of a subclass of this knows how to describe itself as a
 // matcher.
 class GTEST_API_ MatcherDescriberInterface {
  public:
-  virtual ~MatcherDescriberInterface() {}
+  virtual ~MatcherDescriberInterface() = default;
 
   // Describes this matcher to an ostream.  The function should print
   // a verb phrase that describes the property a value matching this
@@ -494,7 +494,7 @@ template <>
 class GTEST_API_ Matcher
     : public internal::MatcherBase {
  public:
-  Matcher() {}
+  Matcher() = default;
 
   explicit Matcher(const MatcherInterface* impl)
       : internal::MatcherBase(impl) {}
@@ -516,7 +516,7 @@ template <>
 class GTEST_API_ Matcher
     : public internal::MatcherBase {
  public:
-  Matcher() {}
+  Matcher() = default;
 
   explicit Matcher(const MatcherInterface* impl)
       : internal::MatcherBase(impl) {}
@@ -544,7 +544,7 @@ template <>
 class GTEST_API_ Matcher
     : public internal::MatcherBase {
  public:
-  Matcher() {}
+  Matcher() = default;
 
   explicit Matcher(const MatcherInterface* impl)
       : internal::MatcherBase(impl) {}
@@ -570,7 +570,7 @@ template <>
 class GTEST_API_ Matcher
     : public internal::MatcherBase {
  public:
-  Matcher() {}
+  Matcher() = default;
 
   explicit Matcher(const MatcherInterface* impl)
       : internal::MatcherBase(impl) {}
diff --git a/googletest/include/gtest/gtest-test-part.h b/googletest/include/gtest/gtest-test-part.h
index 8290b4d65..41c8a9a0d 100644
--- a/googletest/include/gtest/gtest-test-part.h
+++ b/googletest/include/gtest/gtest-test-part.h
@@ -133,7 +133,7 @@ std::ostream& operator<<(std::ostream& os, const TestPartResult& result);
 // virtual.
 class GTEST_API_ TestPartResultArray {
  public:
-  TestPartResultArray() {}
+  TestPartResultArray() = default;
 
   // Appends the given TestPartResult to the array.
   void Append(const TestPartResult& result);
@@ -154,7 +154,7 @@ class GTEST_API_ TestPartResultArray {
 // This interface knows how to report a test part result.
 class GTEST_API_ TestPartResultReporterInterface {
  public:
-  virtual ~TestPartResultReporterInterface() {}
+  virtual ~TestPartResultReporterInterface() = default;
 
   virtual void ReportTestPartResult(const TestPartResult& result) = 0;
 };
diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h
index e54382683..841250349 100644
--- a/googletest/include/gtest/gtest.h
+++ b/googletest/include/gtest/gtest.h
@@ -894,7 +894,7 @@ class GTEST_API_ TestSuite {
 class Environment {
  public:
   // The d'tor is virtual as we need to subclass Environment.
-  virtual ~Environment() {}
+  virtual ~Environment() = default;
 
   // Override this to define how to set up the environment.
   virtual void SetUp() {}
@@ -925,7 +925,7 @@ class GTEST_API_ AssertionException
 // the order the corresponding events are fired.
 class TestEventListener {
  public:
-  virtual ~TestEventListener() {}
+  virtual ~TestEventListener() = default;
 
   // Fired before any test activity starts.
   virtual void OnTestProgramStart(const UnitTest& unit_test) = 0;
@@ -1671,7 +1671,7 @@ template 
 class WithParamInterface {
  public:
   typedef T ParamType;
-  virtual ~WithParamInterface() {}
+  virtual ~WithParamInterface() = default;
 
   // The current parameter value. Is also available in the test fixture's
   // constructor.
diff --git a/googletest/include/gtest/internal/gtest-death-test-internal.h b/googletest/include/gtest/internal/gtest-death-test-internal.h
index 522eed854..8e9c988b9 100644
--- a/googletest/include/gtest/internal/gtest-death-test-internal.h
+++ b/googletest/include/gtest/internal/gtest-death-test-internal.h
@@ -88,7 +88,7 @@ class GTEST_API_ DeathTest {
   static bool Create(const char* statement, Matcher matcher,
                      const char* file, int line, DeathTest** test);
   DeathTest();
-  virtual ~DeathTest() {}
+  virtual ~DeathTest() = default;
 
   // A helper class that aborts a death test when it's deleted.
   class ReturnSentinel {
@@ -153,7 +153,7 @@ GTEST_DISABLE_MSC_WARNINGS_POP_()  //  4251
 // Factory interface for death tests.  May be mocked out for testing.
 class DeathTestFactory {
  public:
-  virtual ~DeathTestFactory() {}
+  virtual ~DeathTestFactory() = default;
   virtual bool Create(const char* statement,
                       Matcher matcher, const char* file,
                       int line, DeathTest** test) = 0;
diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h
index ae2ca95ef..317894e73 100644
--- a/googletest/include/gtest/internal/gtest-internal.h
+++ b/googletest/include/gtest/internal/gtest-internal.h
@@ -435,7 +435,7 @@ GTEST_API_ TypeId GetTestTypeId();
 // of a Test object.
 class TestFactoryBase {
  public:
-  virtual ~TestFactoryBase() {}
+  virtual ~TestFactoryBase() = default;
 
   // Creates a test instance to run. The instance is both created and destroyed
   // within TestInfoImpl::Run()
diff --git a/googletest/include/gtest/internal/gtest-param-util.h b/googletest/include/gtest/internal/gtest-param-util.h
index 50435f500..6a81c37fa 100644
--- a/googletest/include/gtest/internal/gtest-param-util.h
+++ b/googletest/include/gtest/internal/gtest-param-util.h
@@ -97,7 +97,7 @@ class ParamGenerator;
 template 
 class ParamIteratorInterface {
  public:
-  virtual ~ParamIteratorInterface() {}
+  virtual ~ParamIteratorInterface() = default;
   // A pointer to the base generator instance.
   // Used only for the purposes of iterator comparison
   // to make sure that two iterators belong to the same generator.
@@ -171,7 +171,7 @@ class ParamGeneratorInterface {
  public:
   typedef T ParamType;
 
-  virtual ~ParamGeneratorInterface() {}
+  virtual ~ParamGeneratorInterface() = default;
 
   // Generator interface definition
   virtual ParamIteratorInterface* Begin() const = 0;
@@ -215,7 +215,7 @@ class RangeGenerator : public ParamGeneratorInterface {
         end_(end),
         step_(step),
         end_index_(CalculateEndIndex(begin, end, step)) {}
-  ~RangeGenerator() override {}
+  ~RangeGenerator() override = default;
 
   ParamIteratorInterface* Begin() const override {
     return new Iterator(this, begin_, 0, step_);
@@ -230,7 +230,7 @@ class RangeGenerator : public ParamGeneratorInterface {
     Iterator(const ParamGeneratorInterface* base, T value, int index,
              IncrementT step)
         : base_(base), value_(value), index_(index), step_(step) {}
-    ~Iterator() override {}
+    ~Iterator() override = default;
 
     const ParamGeneratorInterface* BaseGenerator() const override {
       return base_;
@@ -299,7 +299,7 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface {
   template 
   ValuesInIteratorRangeGenerator(ForwardIterator begin, ForwardIterator end)
       : container_(begin, end) {}
-  ~ValuesInIteratorRangeGenerator() override {}
+  ~ValuesInIteratorRangeGenerator() override = default;
 
   ParamIteratorInterface* Begin() const override {
     return new Iterator(this, container_.begin());
@@ -316,7 +316,7 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface {
     Iterator(const ParamGeneratorInterface* base,
              typename ContainerType::const_iterator iterator)
         : base_(base), iterator_(iterator) {}
-    ~Iterator() override {}
+    ~Iterator() override = default;
 
     const ParamGeneratorInterface* BaseGenerator() const override {
       return base_;
@@ -420,7 +420,7 @@ class ParameterizedTestFactory : public TestFactoryBase {
 template 
 class TestMetaFactoryBase {
  public:
-  virtual ~TestMetaFactoryBase() {}
+  virtual ~TestMetaFactoryBase() = default;
 
   virtual TestFactoryBase* CreateTestFactory(ParamType parameter) = 0;
 };
@@ -439,7 +439,7 @@ class TestMetaFactory
  public:
   using ParamType = typename TestSuite::ParamType;
 
-  TestMetaFactory() {}
+  TestMetaFactory() = default;
 
   TestFactoryBase* CreateTestFactory(ParamType parameter) override {
     return new ParameterizedTestFactory(parameter);
@@ -462,7 +462,7 @@ class TestMetaFactory
 // and calls RegisterTests() on each of them when asked.
 class ParameterizedTestSuiteInfoBase {
  public:
-  virtual ~ParameterizedTestSuiteInfoBase() {}
+  virtual ~ParameterizedTestSuiteInfoBase() = default;
 
   // Base part of test suite name for display purposes.
   virtual const std::string& GetTestSuiteName() const = 0;
@@ -691,7 +691,7 @@ using ParameterizedTestCaseInfo = ParameterizedTestSuiteInfo;
 // ParameterizedTestSuiteInfo descriptors.
 class ParameterizedTestSuiteRegistry {
  public:
-  ParameterizedTestSuiteRegistry() {}
+  ParameterizedTestSuiteRegistry() = default;
   ~ParameterizedTestSuiteRegistry() {
     for (auto& test_suite_info : test_suite_infos_) {
       delete test_suite_info;
@@ -825,7 +825,7 @@ class CartesianProductGenerator
 
   CartesianProductGenerator(const std::tuple...>& g)
       : generators_(g) {}
-  ~CartesianProductGenerator() override {}
+  ~CartesianProductGenerator() override = default;
 
   ParamIteratorInterface* Begin() const override {
     return new Iterator(this, generators_, false);
@@ -850,7 +850,7 @@ class CartesianProductGenerator
           current_(is_end ? end_ : begin_) {
       ComputeCurrentValue();
     }
-    ~IteratorImpl() override {}
+    ~IteratorImpl() override = default;
 
     const ParamGeneratorInterface* BaseGenerator() const override {
       return base_;
@@ -969,7 +969,7 @@ class ParamGeneratorConverter : public ParamGeneratorInterface {
         : base_(base), it_(it), end_(end) {
       if (it_ != end_) value_ = std::make_shared(static_cast(*it_));
     }
-    ~Iterator() override {}
+    ~Iterator() override = default;
 
     const ParamGeneratorInterface* BaseGenerator() const override {
       return base_;
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index 656a2618a..c6bc2d76a 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -1328,7 +1328,7 @@ GTEST_DISABLE_MSC_WARNINGS_POP_()  // 4251
 // problem.
 class ThreadWithParamBase {
  public:
-  virtual ~ThreadWithParamBase() {}
+  virtual ~ThreadWithParamBase() = default;
   virtual void Run() = 0;
 };
 
@@ -1790,7 +1790,7 @@ typedef GTestMutexLock MutexLock;
 // ThreadLocalValueHolderBase.
 class GTEST_API_ ThreadLocalValueHolderBase {
  public:
-  virtual ~ThreadLocalValueHolderBase() {}
+  virtual ~ThreadLocalValueHolderBase() = default;
 };
 
 // Called by pthread to delete thread-local data stored by
@@ -1862,8 +1862,8 @@ class GTEST_API_ ThreadLocal {
 
   class ValueHolderFactory {
    public:
-    ValueHolderFactory() {}
-    virtual ~ValueHolderFactory() {}
+    ValueHolderFactory() = default;
+    virtual ~ValueHolderFactory() = default;
     virtual ValueHolder* MakeNewHolder() const = 0;
 
    private:
@@ -1873,7 +1873,7 @@ class GTEST_API_ ThreadLocal {
 
   class DefaultValueHolderFactory : public ValueHolderFactory {
    public:
-    DefaultValueHolderFactory() {}
+    DefaultValueHolderFactory() = default;
     ValueHolder* MakeNewHolder() const override { return new ValueHolder(); }
 
    private:
diff --git a/googletest/samples/prime_tables.h b/googletest/samples/prime_tables.h
index 08ad94939..14c016adc 100644
--- a/googletest/samples/prime_tables.h
+++ b/googletest/samples/prime_tables.h
@@ -39,7 +39,7 @@
 // The prime table interface.
 class PrimeTable {
  public:
-  virtual ~PrimeTable() {}
+  virtual ~PrimeTable() = default;
 
   // Returns true if and only if n is a prime number.
   virtual bool IsPrime(int n) const = 0;
diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h
index 16841b55c..008497179 100644
--- a/googletest/src/gtest-internal-inl.h
+++ b/googletest/src/gtest-internal-inl.h
@@ -407,8 +407,8 @@ GTEST_API_ FilePath GetCurrentExecutableName();
 // The role interface for getting the OS stack trace as a string.
 class OsStackTraceGetterInterface {
  public:
-  OsStackTraceGetterInterface() {}
-  virtual ~OsStackTraceGetterInterface() {}
+  OsStackTraceGetterInterface() = default;
+  virtual ~OsStackTraceGetterInterface() = default;
 
   // Returns the current OS stack trace as an std::string.  Parameters:
   //
@@ -436,7 +436,7 @@ class OsStackTraceGetterInterface {
 // A working implementation of the OsStackTraceGetterInterface interface.
 class OsStackTraceGetter : public OsStackTraceGetterInterface {
  public:
-  OsStackTraceGetter() {}
+  OsStackTraceGetter() = default;
 
   std::string CurrentStackTrace(int max_depth, int skip_count) override;
   void UponLeavingGTest() override;
@@ -1064,7 +1064,7 @@ class StreamingListener : public EmptyTestEventListener {
   // Abstract base class for writing strings to a socket.
   class AbstractSocketWriter {
    public:
-    virtual ~AbstractSocketWriter() {}
+    virtual ~AbstractSocketWriter() = default;
 
     // Sends a string to the socket.
     virtual void Send(const std::string& message) = 0;
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 01c0220b7..9fdca40ed 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -2241,7 +2241,7 @@ TestResult::TestResult()
     : death_test_count_(0), start_timestamp_(0), elapsed_time_(0) {}
 
 // D'tor.
-TestResult::~TestResult() {}
+TestResult::~TestResult() = default;
 
 // Returns the i-th test part result among all the results. i can
 // range from 0 to total_part_count() - 1. If i is not in that range,
@@ -2450,7 +2450,7 @@ Test::Test() : gtest_flag_saver_(new GTEST_FLAG_SAVER_) {}
 // The d'tor restores the states of all flags.  The actual work is
 // done by the d'tor of the gtest_flag_saver_ field, and thus not
 // visible here.
-Test::~Test() {}
+Test::~Test() = default;
 
 // Sets up the test fixture.
 //
@@ -3362,7 +3362,7 @@ static void PrintFullTestCommentIfPresent(const TestInfo& test_info) {
 // Class PrettyUnitTestResultPrinter is copyable.
 class PrettyUnitTestResultPrinter : public TestEventListener {
  public:
-  PrettyUnitTestResultPrinter() {}
+  PrettyUnitTestResultPrinter() = default;
   static void PrintTestName(const char* test_suite, const char* test) {
     printf("%s.%s", test_suite, test);
   }
@@ -3670,7 +3670,7 @@ void PrettyUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
 // Class BriefUnitTestResultPrinter is copyable.
 class BriefUnitTestResultPrinter : public TestEventListener {
  public:
-  BriefUnitTestResultPrinter() {}
+  BriefUnitTestResultPrinter() = default;
   static void PrintTestName(const char* test_suite, const char* test) {
     printf("%s.%s", test_suite, test);
   }
diff --git a/googletest/test/googletest-port-test.cc b/googletest/test/googletest-port-test.cc
index 94bb8e388..32a2a7b4d 100644
--- a/googletest/test/googletest-port-test.cc
+++ b/googletest/test/googletest-port-test.cc
@@ -97,7 +97,7 @@ class Base {
   explicit Base(int n) : member_(n) {}
   Base(const Base&) = default;
   Base& operator=(const Base&) = default;
-  virtual ~Base() {}
+  virtual ~Base() = default;
   int member() { return member_; }
 
  private:
@@ -982,7 +982,7 @@ TEST(ThreadLocalTest, SingleParamConstructorInitializesToParam) {
 class NoDefaultConstructor {
  public:
   explicit NoDefaultConstructor(const char*) {}
-  NoDefaultConstructor(const NoDefaultConstructor&) {}
+  NoDefaultConstructor(const NoDefaultConstructor&) = default;
 };
 
 TEST(ThreadLocalTest, ValueDefaultContructorIsNotRequiredForParamVersion) {
diff --git a/googletest/test/googletest-printers-test.cc b/googletest/test/googletest-printers-test.cc
index e667e8f00..f44f29a56 100644
--- a/googletest/test/googletest-printers-test.cc
+++ b/googletest/test/googletest-printers-test.cc
@@ -108,7 +108,7 @@ class UnprintableTemplateInGlobal {
 // A user-defined streamable type in the global namespace.
 class StreamableInGlobal {
  public:
-  virtual ~StreamableInGlobal() {}
+  virtual ~StreamableInGlobal() = default;
 };
 
 inline void operator<<(::std::ostream& os, const StreamableInGlobal& /* x */) {
@@ -216,7 +216,7 @@ class PathLike {
   using value_type = char;
   using const_iterator = iterator;
 
-  PathLike() {}
+  PathLike() = default;
 
   iterator begin() const { return iterator(); }
   iterator end() const { return iterator(); }
@@ -749,7 +749,7 @@ AssertionResult HasPrefix(const StringType& str, const StringType& prefix) {
 
 struct Foo {
  public:
-  virtual ~Foo() {}
+  virtual ~Foo() = default;
   int MyMethod(char x) { return x + 1; }
   virtual char MyVirtualMethod(int /* n */) { return 'a'; }
 
diff --git a/googletest/test/gtest_repeat_test.cc b/googletest/test/gtest_repeat_test.cc
index 73fb8dc90..f67b7886e 100644
--- a/googletest/test/gtest_repeat_test.cc
+++ b/googletest/test/gtest_repeat_test.cc
@@ -61,7 +61,7 @@ int g_environment_tear_down_count = 0;
 
 class MyEnvironment : public testing::Environment {
  public:
-  MyEnvironment() {}
+  MyEnvironment() = default;
   void SetUp() override { g_environment_set_up_count++; }
   void TearDown() override { g_environment_tear_down_count++; }
 };
diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc
index 57041f058..1fde827ed 100644
--- a/googletest/test/gtest_unittest.cc
+++ b/googletest/test/gtest_unittest.cc
@@ -4951,7 +4951,7 @@ TEST(ComparisonAssertionTest, AcceptsUnprintableArgs) {
 // both in a TEST and in a TEST_F.
 class Foo {
  public:
-  Foo() {}
+  Foo() = default;
 
  private:
   int Bar() const { return 1; }

From 51eeae5a5520166a385ce457b410d6309ac20968 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Patryk=20Gawro=C5=84ski?= 
Date: Tue, 25 Apr 2023 01:45:26 +0200
Subject: [PATCH 180/336] gmock: fix issue #4222

Rename 'Result' struct to 'NonMoveableStruct' in
gmock-spec-builders_test.cc in ExpectCallTest.NonMoveableType test
---
 googlemock/test/gmock-spec-builders_test.cc | 26 ++++++++++-----------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/googlemock/test/gmock-spec-builders_test.cc b/googlemock/test/gmock-spec-builders_test.cc
index 7ba591a17..d07cb5cb1 100644
--- a/googlemock/test/gmock-spec-builders_test.cc
+++ b/googlemock/test/gmock-spec-builders_test.cc
@@ -811,32 +811,32 @@ TEST(ExpectCallTest, InfersCardinality1WhenThereIsWillRepeatedly) {
 // from a prvalue returned from a function.
 TEST(ExpectCallTest, NonMoveableType) {
   // Define a non-moveable result type.
-  struct Result {
-    explicit Result(int x_in) : x(x_in) {}
-    Result(Result&&) = delete;
+  struct NonMoveableStruct {
+    explicit NonMoveableStruct(int x_in) : x(x_in) {}
+    NonMoveableStruct(NonMoveableStruct&&) = delete;
 
     int x;
   };
 
-  static_assert(!std::is_move_constructible_v);
-  static_assert(!std::is_copy_constructible_v);
+  static_assert(!std::is_move_constructible_v);
+  static_assert(!std::is_copy_constructible_v);
 
-  static_assert(!std::is_move_assignable_v);
-  static_assert(!std::is_copy_assignable_v);
+  static_assert(!std::is_move_assignable_v);
+  static_assert(!std::is_copy_assignable_v);
 
   // We should be able to use a callable that returns that result as both a
   // OnceAction and an Action, whether the callable ignores arguments or not.
-  const auto return_17 = [] { return Result(17); };
+  const auto return_17 = [] { return NonMoveableStruct(17); };
 
-  static_cast(OnceAction{return_17});
-  static_cast(Action{return_17});
+  static_cast(OnceAction{return_17});
+  static_cast(Action{return_17});
 
-  static_cast(OnceAction{return_17});
-  static_cast(Action{return_17});
+  static_cast(OnceAction{return_17});
+  static_cast(Action{return_17});
 
   // It should be possible to return the result end to end through an
   // EXPECT_CALL statement, with both WillOnce and WillRepeatedly.
-  MockFunction mock;
+  MockFunction mock;
   EXPECT_CALL(mock, Call)   //
       .WillOnce(return_17)  //
       .WillRepeatedly(return_17);

From 97408cae552bde8609aabfa7c3647a52fb21f8c9 Mon Sep 17 00:00:00 2001
From: Vertexwahn 
Date: Tue, 25 Apr 2023 20:20:01 +0200
Subject: [PATCH 181/336] Fix spelling

---
 googletest/src/gtest-death-test.cc          | 2 +-
 googletest/src/gtest-internal-inl.h         | 2 +-
 googletest/test/googletest-filepath-test.cc | 2 +-
 googletest/test/gtest_xml_test_utils.py     | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/googletest/src/gtest-death-test.cc b/googletest/src/gtest-death-test.cc
index 55b957827..c3b7820ef 100644
--- a/googletest/src/gtest-death-test.cc
+++ b/googletest/src/gtest-death-test.cc
@@ -1029,7 +1029,7 @@ DeathTest::TestRole FuchsiaDeathTest::AssumeRole() {
   // Note: The test component must have `fuchsia.process.Launcher` declared
   // in its manifest. (Fuchsia integration tests require creating a
   // "Fuchsia Test Component" which contains a "Fuchsia Component Manifest")
-  // Launching processes is a privileged operation in Fuschia, and the
+  // Launching processes is a privileged operation in Fuchsia, and the
   // declaration indicates that the ability is required for the component.
   std::unique_ptr argv = CreateArgvFromArgs(args);
   status = fdio_spawn_etc(child_job, FDIO_SPAWN_CLONE_ALL, argv[0], argv.get(),
diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h
index 008497179..5ba557fe1 100644
--- a/googletest/src/gtest-internal-inl.h
+++ b/googletest/src/gtest-internal-inl.h
@@ -93,7 +93,7 @@ GTEST_API_ TimeInMillis GetTimeInMillis();
 GTEST_API_ bool ShouldUseColor(bool stdout_is_tty);
 
 // Formats the given time in milliseconds as seconds. If the input is an exact N
-// seconds, the output has a trailing decimal point (e.g., "N." intead of "N").
+// seconds, the output has a trailing decimal point (e.g., "N." instead of "N").
 GTEST_API_ std::string FormatTimeInMillisAsSeconds(TimeInMillis ms);
 
 // Converts the given time in milliseconds to a date string in the ISO 8601
diff --git a/googletest/test/googletest-filepath-test.cc b/googletest/test/googletest-filepath-test.cc
index 0a33d7140..3e9c79f03 100644
--- a/googletest/test/googletest-filepath-test.cc
+++ b/googletest/test/googletest-filepath-test.cc
@@ -515,7 +515,7 @@ class DirectoryCreationTest : public Test {
   }
 
   // Strings representing a directory and a file, with identical paths
-  // except for the trailing separator character that distinquishes
+  // except for the trailing separator character that distinguishes
   // a directory named 'test' from a file named 'test'. Example names:
   FilePath testdata_path_;  // "/tmp/directory_creation/test/"
   FilePath testdata_file_;  // "/tmp/directory_creation/test"
diff --git a/googletest/test/gtest_xml_test_utils.py b/googletest/test/gtest_xml_test_utils.py
index 8fcb6933c..74e0f4a08 100755
--- a/googletest/test/gtest_xml_test_utils.py
+++ b/googletest/test/gtest_xml_test_utils.py
@@ -218,7 +218,7 @@ class GTestXMLTestCase(gtest_test_utils.TestCase):
       )
     if element.tagName in ('testsuites', 'testsuite', 'testcase'):
       time = element.getAttributeNode('time')
-      # The value for exact N seconds has a traling decimal point (e.g., "10."
+      # The value for exact N seconds has a trailing decimal point (e.g., "10."
       # instead of "10")
       time.value = re.sub(r'^\d+\.(\d+)?$', '*', time.value)
       type_param = element.getAttributeNode('type_param')

From dea0484e4d3b6a2c50055c24c5617cd662a50c5f Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Wed, 26 Apr 2023 07:13:23 -0700
Subject: [PATCH 182/336] Use Abseil Flag public API for flag parsing.

This change brings InitGoogleTest semantic in accordance with the official documentation: only GoogleTest flags are removed from argc/argv. The rest of the flags remains in place. We do nothing special for flags with unrecognized gunit_/gtest_ prefix and we do not report them.

PiperOrigin-RevId: 527257221
Change-Id: Ibb29a1bda1a44251a4ee579c0fb5bbdfd9965c21
---
 googletest/src/gtest.cc            | 69 +++++++++++++++++++++++-------
 googletest/test/gtest_help_test.py | 11 -----
 googletest/test/gtest_unittest.cc  |  9 ++++
 googletest_deps.bzl                |  8 ++--
 4 files changed, 67 insertions(+), 30 deletions(-)

diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 9fdca40ed..fb7512c1b 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -44,6 +44,7 @@
 #include   // NOLINT
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -140,6 +141,7 @@
 #endif
 
 #ifdef GTEST_HAS_ABSL
+#include "absl/container/flat_hash_set.h"
 #include "absl/debugging/failure_signal_handler.h"
 #include "absl/debugging/stacktrace.h"
 #include "absl/debugging/symbolize.h"
@@ -147,6 +149,8 @@
 #include "absl/flags/usage.h"
 #include "absl/strings/str_cat.h"
 #include "absl/strings/str_replace.h"
+#include "absl/strings/string_view.h"
+#include "absl/strings/strip.h"
 #endif  // GTEST_HAS_ABSL
 
 // Checks builtin compiler feature |x| while avoiding an extra layer of #ifdefs
@@ -6686,25 +6690,60 @@ void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {
 }
 
 // Parses the command line for Google Test flags, without initializing
-// other parts of Google Test.
+// other parts of Google Test. This function updates argc and argv by removing
+// flags that are known to GoogleTest (including other user flags defined using
+// ABSL_FLAG if GoogleTest is built with GTEST_USE_ABSL). Other arguments
+// 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
-  if (*argc > 0) {
-    // absl::ParseCommandLine() requires *argc > 0.
-    auto positional_args = absl::flags_internal::ParseCommandLineImpl(
-        *argc, argv, absl::flags_internal::UsageFlagsAction::kHandleUsage,
-        absl::flags_internal::OnUndefinedFlag::kReportUndefined);
-    // Any command-line positional arguments not part of any command-line flag
-    // (or arguments to a flag) are copied back out to argv, with the program
-    // invocation name at position 0, and argc is resized. This includes
-    // positional arguments after the flag-terminating delimiter '--'.
-    // See https://abseil.io/docs/cpp/guides/flags.
-    std::copy(positional_args.begin(), positional_args.end(), argv);
-    if (static_cast(positional_args.size()) < *argc) {
-      argv[positional_args.size()] = nullptr;
-      *argc = static_cast(positional_args.size());
+  if (*argc <= 0) return;
+
+  std::vector positional_args;
+  std::vector unrecognized_flags;
+  absl::ParseAbseilFlagsOnly(*argc, argv, positional_args, unrecognized_flags);
+  absl::flat_hash_set unrecognized;
+  for (const auto& flag : unrecognized_flags) {
+    unrecognized.insert(flag.flag_name);
+  }
+  absl::flat_hash_set positional;
+  for (const auto& arg : positional_args) {
+    positional.insert(arg);
+  }
+
+  int out_pos = 1;
+  int in_pos = 1;
+  for (; in_pos < *argc; ++in_pos) {
+    char* arg = argv[in_pos];
+    absl::string_view arg_str(arg);
+    if (absl::ConsumePrefix(&arg_str, "--")) {
+      // Flag-like argument. If the flag was unrecognized, keep it.
+      // If it was a GoogleTest flag, remove it.
+      if (unrecognized.contains(arg_str)) {
+        argv[out_pos++] = argv[in_pos];
+        continue;
+      }
+    }
+
+    if (arg_str.empty()) {
+      ++in_pos;
+      break;  // '--' indicates that the rest of the arguments are positional
+    }
+
+    // Probably a positional argument. If it is in fact positional, keep it.
+    // If it was a value for the flag argument, remove it.
+    if (positional.contains(arg)) {
+      argv[out_pos++] = arg;
     }
   }
+
+  // The rest are positional args for sure.
+  while (in_pos < *argc) {
+    argv[out_pos++] = argv[in_pos++];
+  }
+
+  *argc = out_pos;
+  argv[out_pos] = nullptr;
 #else
   ParseGoogleTestFlagsOnlyImpl(argc, argv);
 #endif
diff --git a/googletest/test/gtest_help_test.py b/googletest/test/gtest_help_test.py
index 9261b87a5..85a0c33c9 100755
--- a/googletest/test/gtest_help_test.py
+++ b/googletest/test/gtest_help_test.py
@@ -54,7 +54,6 @@ PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath('gtest_help_test_')
 FLAG_PREFIX = '--gtest_'
 DEATH_TEST_STYLE_FLAG = FLAG_PREFIX + 'death_test_style'
 STREAM_RESULT_TO_FLAG = FLAG_PREFIX + 'stream_result_to'
-UNKNOWN_GTEST_PREFIXED_FLAG = FLAG_PREFIX + 'unknown_flag_for_testing'
 LIST_TESTS_FLAG = FLAG_PREFIX + 'list_tests'
 INTERNAL_FLAG_FOR_TESTING = FLAG_PREFIX + 'internal_flag_for_testing'
 
@@ -177,16 +176,6 @@ class GTestHelpTest(gtest_test_utils.TestCase):
   def testPrintsHelpWithFullFlag(self):
     self.TestHelpFlag('--help')
 
-  def testPrintsHelpWithUnrecognizedGoogleTestFlag(self):
-    # The behavior is slightly different when Abseil flags is
-    # used. Abseil flags rejects all unknown flags, while the builtin
-    # GTest flags implementation interprets an unknown flag with a
-    # '--gtest_' prefix as a request for help.
-    if HAS_ABSL_FLAGS:
-      self.TestUnknownFlagWithAbseil(UNKNOWN_GTEST_PREFIXED_FLAG)
-    else:
-      self.TestHelpFlag(UNKNOWN_GTEST_PREFIXED_FLAG)
-
   def testRunsTestsWithoutHelpFlag(self):
     """Verifies correct behavior when no help flag is specified.
 
diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc
index 1fde827ed..9b4b83331 100644
--- a/googletest/test/gtest_unittest.cc
+++ b/googletest/test/gtest_unittest.cc
@@ -6220,6 +6220,15 @@ TEST_F(ParseFlagsTest, AbseilPositionalFlags) {
 }
 #endif
 
+TEST_F(ParseFlagsTest, UnrecognizedFlags) {
+  const char* argv[] = {"foo.exe", "--gtest_filter=abcd", "--other_flag",
+                        nullptr};
+
+  const char* argv2[] = {"foo.exe", "--other_flag", nullptr};
+
+  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter("abcd"), false);
+}
+
 #ifdef GTEST_OS_WINDOWS
 // Tests parsing wide strings.
 TEST_F(ParseFlagsTest, WideStrings) {
diff --git a/googletest_deps.bzl b/googletest_deps.bzl
index 7fe809616..65e56abb5 100644
--- a/googletest_deps.bzl
+++ b/googletest_deps.bzl
@@ -15,8 +15,8 @@ def googletest_deps():
 
     if not native.existing_rule("com_google_absl"):
         http_archive(
-            name = "com_google_absl",  # 2023-02-27T15:50:25Z
-            sha256 = "baf8e734ac3ce213a889ce7c248b981ee1730e2093e32808e0f0a910dc985f76",
-            strip_prefix = "abseil-cpp-0c1114c4fb83c844c7fd74708338cca1d3d9b0dc",
-            urls = ["https://github.com/abseil/abseil-cpp/archive/0c1114c4fb83c844c7fd74708338cca1d3d9b0dc.zip"],
+            name = "com_google_absl",  # 2023-04-06T14:42:25Z
+            sha256 = "a50452f02402262f9a61a8eedda60f76dda6b9538d36b34b55bce9f74a4d5ef8",
+            strip_prefix = "abseil-cpp-e73b9139ee9b853a4bd7812531442c138da09084",
+            urls = ["https://github.com/abseil/abseil-cpp/archive/e73b9139ee9b853a4bd7812531442c138da09084.zip"],
         )

From 0bdaac5a1401fffac6b64581efc639734aded793 Mon Sep 17 00:00:00 2001
From: Tom Hughes 
Date: Thu, 27 Apr 2023 18:17:19 -0700
Subject: [PATCH 183/336] Add qualifier to avoid argument dependent lookup

PiperOrigin-RevId: 527740306
Change-Id: I61308cc232c346d5ff8b0548d4c552a59633fffc
---
 googlemock/test/gmock-more-actions_test.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/googlemock/test/gmock-more-actions_test.cc b/googlemock/test/gmock-more-actions_test.cc
index ec7aea614..9980f3bc4 100644
--- a/googlemock/test/gmock-more-actions_test.cc
+++ b/googlemock/test/gmock-more-actions_test.cc
@@ -677,7 +677,7 @@ TEST(SetArrayArgumentTest, SetsTheNthArrayWithIteratorArgument) {
   Action a = SetArrayArgument<1>(letters.begin(), letters.end());
 
   std::string s;
-  a.Perform(std::make_tuple(true, back_inserter(s)));
+  a.Perform(std::make_tuple(true, std::back_inserter(s)));
   EXPECT_EQ(letters, s);
 }
 

From 797b0ad2a3a45608ecf5c67e6e289d377a3521ca Mon Sep 17 00:00:00 2001
From: Dino Radakovic 
Date: Fri, 28 Apr 2023 10:15:31 -0700
Subject: [PATCH 184/336] Use GTEST_INTERNAL_CPLUSPLUS_LANG instead of
 __cplusplus

Some versions of MSVC provide incorrect values for the latter and rely on _MSVC_LANG instead.
Fixes #4226.

PiperOrigin-RevId: 527919195
Change-Id: Ifcca4612074f5ebc5337094426866a187f79f90a
---
 googlemock/test/gmock-actions_test.cc          |  4 +++-
 googlemock/test/gmock-spec-builders_test.cc    |  3 ++-
 googletest/include/gtest/internal/gtest-port.h | 17 +++++++++--------
 3 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc
index f569e834e..da1675c52 100644
--- a/googlemock/test/gmock-actions_test.cc
+++ b/googlemock/test/gmock-actions_test.cc
@@ -48,6 +48,7 @@
 #include "gmock/internal/gmock-port.h"
 #include "gtest/gtest-spi.h"
 #include "gtest/gtest.h"
+#include "gtest/internal/gtest-port.h"
 
 // Silence C4100 (unreferenced formal parameter) and C4503 (decorated name
 // length exceeded) for MSVC.
@@ -221,7 +222,8 @@ TEST(TypeTraits, IsInvocableRV) {
   // In C++17 and above, where it's guaranteed that functions can return
   // non-moveable objects, everything should work fine for non-moveable rsult
   // types too.
-#if defined(__cplusplus) && __cplusplus >= 201703L
+#if defined(GTEST_INTERNAL_CPLUSPLUS_LANG) && \
+    GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
   {
     struct NonMoveable {
       NonMoveable() = default;
diff --git a/googlemock/test/gmock-spec-builders_test.cc b/googlemock/test/gmock-spec-builders_test.cc
index d07cb5cb1..221de2d20 100644
--- a/googlemock/test/gmock-spec-builders_test.cc
+++ b/googlemock/test/gmock-spec-builders_test.cc
@@ -804,7 +804,8 @@ TEST(ExpectCallTest, InfersCardinality1WhenThereIsWillRepeatedly) {
       "to be called at least once");
 }
 
-#if defined(__cplusplus) && __cplusplus >= 201703L
+#if defined(GTEST_INTERNAL_CPLUSPLUS_LANG) && \
+    GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
 
 // It should be possible to return a non-moveable type from a mock action in
 // C++17 and above, where it's guaranteed that such a type can be initialized
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index c6bc2d76a..d71110c0c 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -2398,7 +2398,7 @@ using Any = ::absl::any;
 }  // namespace testing
 #else
 #ifdef __has_include
-#if __has_include() && __cplusplus >= 201703L && \
+#if __has_include() && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L && \
     (!defined(_MSC_VER) || GTEST_HAS_RTTI)
 // Otherwise for C++17 and higher use std::any for UniversalPrinter<>
 // specializations.
@@ -2411,7 +2411,7 @@ using Any = ::std::any;
 }  // namespace testing
 // The case where absl is configured NOT to alias std::any is not
 // supported.
-#endif  // __has_include() && __cplusplus >= 201703L
+#endif  // __has_include() && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
 #endif  // __has_include
 #endif  // GTEST_HAS_ABSL
 
@@ -2433,7 +2433,7 @@ inline ::absl::nullopt_t Nullopt() { return ::absl::nullopt; }
 }  // namespace testing
 #else
 #ifdef __has_include
-#if __has_include() && __cplusplus >= 201703L
+#if __has_include() && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
 // Otherwise for C++17 and higher use std::optional for UniversalPrinter<>
 // specializations.
 #define GTEST_INTERNAL_HAS_OPTIONAL 1
@@ -2447,7 +2447,7 @@ inline ::std::nullopt_t Nullopt() { return ::std::nullopt; }
 }  // namespace testing
 // The case where absl is configured NOT to alias std::optional is not
 // supported.
-#endif  // __has_include() && __cplusplus >= 201703L
+#endif  // __has_include() && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
 #endif  // __has_include
 #endif  // GTEST_HAS_ABSL
 
@@ -2467,7 +2467,7 @@ using StringView = ::absl::string_view;
 }  // namespace testing
 #else
 #ifdef __has_include
-#if __has_include() && __cplusplus >= 201703L
+#if __has_include() && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
 // Otherwise for C++17 and higher use std::string_view for Matcher<>
 // specializations.
 #define GTEST_INTERNAL_HAS_STRING_VIEW 1
@@ -2479,7 +2479,8 @@ using StringView = ::std::string_view;
 }  // namespace testing
 // The case where absl is configured NOT to alias std::string_view is not
 // supported.
-#endif  // __has_include() && __cplusplus >= 201703L
+#endif  // __has_include() && GTEST_INTERNAL_CPLUSPLUS_LANG >=
+        // 201703L
 #endif  // __has_include
 #endif  // GTEST_HAS_ABSL
 
@@ -2500,7 +2501,7 @@ using Variant = ::absl::variant;
 }  // namespace testing
 #else
 #ifdef __has_include
-#if __has_include() && __cplusplus >= 201703L
+#if __has_include() && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
 // Otherwise for C++17 and higher use std::variant for UniversalPrinter<>
 // specializations.
 #define GTEST_INTERNAL_HAS_VARIANT 1
@@ -2512,7 +2513,7 @@ using Variant = ::std::variant;
 }  // namespace internal
 }  // namespace testing
 // The case where absl is configured NOT to alias std::variant is not supported.
-#endif  // __has_include() && __cplusplus >= 201703L
+#endif  // __has_include() && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
 #endif  // __has_include
 #endif  // GTEST_HAS_ABSL
 

From bc860af08783b8113005ca7697da5f5d49a8056f Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Fri, 5 May 2023 11:04:05 -0700
Subject: [PATCH 185/336] This trips up when compiling with -Wvla otherwise.

PiperOrigin-RevId: 529762901
Change-Id: I6ce4d630191bf265f847aef2d5dcc12a712faa60
---
 googletest/src/gtest-port.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc
index 77b618c40..2aaf2bcc2 100644
--- a/googletest/src/gtest-port.cc
+++ b/googletest/src/gtest-port.cc
@@ -199,8 +199,8 @@ size_t GetThreadCount() {
   mib[5] = static_cast(size / static_cast(mib[4]));
 
   // populate array of structs
-  struct kinfo_proc info[mib[5]];
-  if (sysctl(mib, miblen, &info, &size, NULL, 0)) {
+  std::vector info(mib[5]);
+  if (sysctl(mib, miblen, info.data(), &size, NULL, 0)) {
     return 0;
   }
 

From a7fa9b37082993107a98181e631cafcdbe484f22 Mon Sep 17 00:00:00 2001
From: yagneshprajapati <131433627+yagneshprajapati@users.noreply.github.com>
Date: Sun, 7 May 2023 15:22:54 +0530
Subject: [PATCH 186/336] Update README.md

---
 README.md | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/README.md b/README.md
index 23eb5026d..1284b8d32 100644
--- a/README.md
+++ b/README.md
@@ -41,7 +41,7 @@ This repository is a merger of the formerly separate GoogleTest and GoogleMock
 projects. These were so closely related that it makes sense to maintain and
 release them together.
 
-### Getting Started
+### | Getting Started |
 
 See the [GoogleTest User's Guide](https://google.github.io/googletest/) for
 documentation. We recommend starting with the
@@ -50,18 +50,19 @@ documentation. We recommend starting with the
 More information about building GoogleTest can be found at
 [googletest/README.md](googletest/README.md).
 
-## Features
+| Feature | Description |
+| --- | --- |
+| xUnit test framework | Googletest is based on the 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 |
+| XML test report generation | Googletest can generate XML test reports, which can be used by tools like Jenkins to track the results of your tests |
 
-*   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.
 
 ## Supported Platforms
 

From 0eb33cfa5c232f190efc6bb5fc215d5f35cca9d7 Mon Sep 17 00:00:00 2001
From: pateldeev 
Date: Mon, 8 May 2023 13:02:56 -0700
Subject: [PATCH 187/336] Add missing absl dependency from build.

---
 BUILD.bazel | 1 +
 1 file changed, 1 insertion(+)

diff --git a/BUILD.bazel b/BUILD.bazel
index ac62251e1..b1e3b7fba 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -132,6 +132,7 @@ cc_library(
     }),
     deps = select({
         ":has_absl": [
+            "@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",

From 88295d64a7832408be57825720fcf44e007a4199 Mon Sep 17 00:00:00 2001
From: yagneshprajapati <131433627+yagneshprajapati@users.noreply.github.com>
Date: Thu, 11 May 2023 14:52:16 +0530
Subject: [PATCH 188/336] Update README.md

xunit link
---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 1284b8d32..55ec8f25c 100644
--- a/README.md
+++ b/README.md
@@ -52,7 +52,7 @@ More information about building GoogleTest can be found at
 
 | Feature | Description |
 | --- | --- |
-| xUnit test framework | Googletest is based on the xUnit testing framework, a popular architecture for unit testing |
+| [xUnit](https://en.wikipedia.org/wiki/XUnit) test framework | Googletest is based on the 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 |

From 7345a66cbd7149fa4126e526a94708b3f5d7d3b4 Mon Sep 17 00:00:00 2001
From: yagneshprajapati <131433627+yagneshprajapati@users.noreply.github.com>
Date: Thu, 11 May 2023 14:54:04 +0530
Subject: [PATCH 189/336] Update README.md

xUnit link
---
 README.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 55ec8f25c..ce9a82bea 100644
--- a/README.md
+++ b/README.md
@@ -41,7 +41,7 @@ This repository is a merger of the formerly separate GoogleTest and GoogleMock
 projects. These were so closely related that it makes sense to maintain and
 release them together.
 
-### | Getting Started |
+### Getting Started 
 
 See the [GoogleTest User's Guide](https://google.github.io/googletest/) for
 documentation. We recommend starting with the
@@ -52,7 +52,7 @@ More information about building GoogleTest can be found at
 
 | Feature | Description |
 | --- | --- |
-| [xUnit](https://en.wikipedia.org/wiki/XUnit) test framework | Googletest is based on the xUnit testing framework, a popular architecture for unit testing |
+| 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 |

From a8e067ae5f4e08cc16e24d1ed9f37971c971b8c9 Mon Sep 17 00:00:00 2001
From: yagneshprajapati <131433627+yagneshprajapati@users.noreply.github.com>
Date: Thu, 11 May 2023 14:57:47 +0530
Subject: [PATCH 190/336] Update README.md

xml report gan removed
---
 README.md | 1 -
 1 file changed, 1 deletion(-)

diff --git a/README.md b/README.md
index ce9a82bea..54f534e0d 100644
--- a/README.md
+++ b/README.md
@@ -61,7 +61,6 @@ More information about building GoogleTest can be found at
 | 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 |
-| XML test report generation | Googletest can generate XML test reports, which can be used by tools like Jenkins to track the results of your tests |
 
 
 ## Supported Platforms

From bb2941fcc611b9e4eaf16f156e8c723348bf0931 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Thu, 11 May 2023 08:27:42 -0700
Subject: [PATCH 191/336] Give CreateArgvFromArgs internal linkage

It isn't declared in any header or referenced from any other file.

PiperOrigin-RevId: 531209642
Change-Id: I9e7df37f737b00994f8845ed38c3b775879cb25c
---
 googletest/src/gtest-death-test.cc | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/googletest/src/gtest-death-test.cc b/googletest/src/gtest-death-test.cc
index c3b7820ef..4cf78e71a 100644
--- a/googletest/src/gtest-death-test.cc
+++ b/googletest/src/gtest-death-test.cc
@@ -625,9 +625,11 @@ bool DeathTestImpl::Passed(bool status_ok) {
   return success;
 }
 
+#ifndef GTEST_OS_WINDOWS
 // Note: The return value points into args, so the return value's lifetime is
 // bound to that of args.
-std::unique_ptr CreateArgvFromArgs(std::vector& args) {
+static std::unique_ptr CreateArgvFromArgs(
+    std::vector& args) {
   auto result = std::make_unique(args.size() + 1);
   for (size_t i = 0; i < args.size(); ++i) {
     result[i] = &args[i][0];
@@ -635,6 +637,7 @@ std::unique_ptr CreateArgvFromArgs(std::vector& args) {
   result[args.size()] = nullptr;  // extra null terminator
   return result;
 }
+#endif
 
 #ifdef GTEST_OS_WINDOWS
 // WindowsDeathTest implements death tests on Windows. Due to the

From d6fb5e3bf76c0363d7519373a07c2435e57c1073 Mon Sep 17 00:00:00 2001
From: Dino Radakovic 
Date: Tue, 16 May 2023 07:05:07 -0700
Subject: [PATCH 192/336] Explicitly document googletest release tag format

Fixes #4235

PiperOrigin-RevId: 532446854
Change-Id: If7e1dade02a80d9a30813c136bba3f20c796f0fa
---
 README.md | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/README.md b/README.md
index 14bb9e316..a3bd4bd85 100644
--- a/README.md
+++ b/README.md
@@ -8,6 +8,8 @@ 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. `v.1.13.0`).
 
 #### Documentation Updates
 

From cb455a71fb23303e37ce8ee5b1cde6a2c18f66a5 Mon Sep 17 00:00:00 2001
From: Dino Radakovic 
Date: Wed, 17 May 2023 08:30:21 -0700
Subject: [PATCH 193/336] Fix typo in version number example in README

PiperOrigin-RevId: 532796425
Change-Id: If81029216cf12b9b05f8e2d79671ba106ebd28fb
---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index a3bd4bd85..10d1f86f1 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@ GoogleTest now follows the
 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. `v.1.13.0`).
+`v${major}.${minor}.${patch}` (e.g. `v1.13.0`).
 
 #### Documentation Updates
 

From aa99ce5a0db4215bb8e2cda3ee68b6b8d4896815 Mon Sep 17 00:00:00 2001
From: Shlomi Nissan 
Date: Sun, 21 May 2023 16:40:06 -0700
Subject: [PATCH 194/336] Add CXX_STANDARD_REQUIRED to CMake quickstart

---
 docs/quickstart-cmake.md | 1 +
 googletest/README.md     | 8 ++++----
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/docs/quickstart-cmake.md b/docs/quickstart-cmake.md
index 5abe50441..4e422b74f 100644
--- a/docs/quickstart-cmake.md
+++ b/docs/quickstart-cmake.md
@@ -54,6 +54,7 @@ project(my_project)
 
 # GoogleTest requires at least C++14
 set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
 
 include(FetchContent)
 FetchContent_Declare(
diff --git a/googletest/README.md b/googletest/README.md
index 995834e46..dc605716a 100644
--- a/googletest/README.md
+++ b/googletest/README.md
@@ -126,10 +126,10 @@ match the project in which it is included.
 
 An environment that supports C++11 is required in order to successfully build
 GoogleTest. One way to ensure this is to specify the standard in the top-level
-project, for example by using the `set(CMAKE_CXX_STANDARD 11)` command. If this
-is not feasible, for example in a C project using GoogleTest for validation,
-then it can be specified by adding it to the options for cmake via the
-`DCMAKE_CXX_FLAGS` option.
+project, for example by using the `set(CMAKE_CXX_STANDARD 11)` command along
+with `set(CMAKE_CXX_STANDARD_REQUIRED ON). If this is not feasible, for example
+in a C project using GoogleTest for validation, then it can be specified by
+adding it to the options for cmake via the `-DCMAKE_CXX_FLAGS` option.
 
 ### Tweaking GoogleTest
 

From e032d57642d2a042b9445b2199277bb24fee2eb5 Mon Sep 17 00:00:00 2001
From: Niranjan Nilakantan 
Date: Wed, 24 May 2023 12:48:51 -0700
Subject: [PATCH 195/336] Build googletest with IntelLLVM compilers.

Use the same flags as Clang if the compiler id is IntelLLVM.

IntelLLVM warns if a double constant is assigned to a float.

```
[build] .../googletest/googletest/include/gtest/gtest-printers.h:516:17: warning: implicit conversion between floating point types of different sizes [-Wimplicit-float-size-conversion]
[build]       mulfor6 = 1e1;
```

IntelLLVM uses fp-model=fast by default, breaking IsNan and IsInf tests.
Use -ffp-model=precise to fix this.

IntelLLVM does not support -Wchar-subscripts

Fixes #4255
---
 googletest/cmake/internal_utils.cmake | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake
index fa7da4e68..f45a3be00 100644
--- a/googletest/cmake/internal_utils.cmake
+++ b/googletest/cmake/internal_utils.cmake
@@ -94,12 +94,18 @@ macro(config_compiler_and_linker)
     if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
       set(cxx_base_flags "${cxx_base_flags} -utf-8")
     endif()
-  elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+  elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
+      CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
     set(cxx_base_flags "-Wall -Wshadow -Wconversion -Wundef")
     set(cxx_exception_flags "-fexceptions")
     set(cxx_no_exception_flags "-fno-exceptions")
-    set(cxx_strict_flags "-W -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wredundant-decls")
+    set(cxx_strict_flags "-W -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wunused-parameter -Wcast-align -Winline -Wredundant-decls")
     set(cxx_no_rtti_flags "-fno-rtti")
+    if (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
+      set(cxx_base_flags "${cxx_base_flags} -Wno-implicit-float-size-conversion -ffp-model=precise")
+    else()
+      set(cxx_strict_flags "${cxx_strict_flags} -Wchar-subscripts")
+    endif()
   elseif (CMAKE_COMPILER_IS_GNUCXX)
     set(cxx_base_flags "-Wall -Wshadow -Wundef")
     if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0.0)

From 029d3dddd4ba2788c5203490e63a24c02328bff8 Mon Sep 17 00:00:00 2001
From: niranjan 
Date: Wed, 24 May 2023 17:33:46 -0700
Subject: [PATCH 196/336] Disable some warnings for IntelLLVM on Windows.

Use /fp:precise to override IntelLLVM's default of /fp:fast.
This makes IsInf and IsNan work as expected by googletest.

```
[build]...\googletest\googlemock\test\gmock-function-mocker_test.cc(143,21): error: 'VoidReturning' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override]
[build]   MOCK_METHOD(void, VoidReturning, (int n));  // NOLINT
```

```
[build] ...\googletest\googlemock\test\gmock-function-mocker_test.cc(182,20): error: exception specification of overriding function is more lax than base version [-Werror,-Wmicrosoft-exception-spec]
[build]   MOCK_METHOD(int, CTNullary, (), (Calltype(STDMETHODCALLTYPE)));
```

```
[build] ...\googletest\googletest\test\googletest-death-test-test.cc(209,5): error: unused function 'DieInCRTDebugElse12' [-Werror,-Wunused-function]
[build] int DieInCRTDebugElse12(int* sideeffect) {
[build]     ^
```

```
[build] ...\googletest\googletest\test\gtest_unittest.cc(4096,7): error: variable 'n' set but not used [-Werror,-Wunused-but-set-variable]
[build]   int n = 0;
```
---
 googletest/cmake/internal_utils.cmake | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake
index f45a3be00..e7927a353 100644
--- a/googletest/cmake/internal_utils.cmake
+++ b/googletest/cmake/internal_utils.cmake
@@ -94,6 +94,9 @@ macro(config_compiler_and_linker)
     if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
       set(cxx_base_flags "${cxx_base_flags} -utf-8")
     endif()
+    if (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
+      set(cxx_base_flags "${cxx_base_flags} /fp:precise -Wno-inconsistent-missing-override -Wno-microsoft-exception-spec -Wno-unused-function -Wno-unused-but-set-variable")
+    endif()
   elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
       CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
     set(cxx_base_flags "-Wall -Wshadow -Wconversion -Wundef")

From ded275d75e0756e9659226f94bd4b8399af721d7 Mon Sep 17 00:00:00 2001
From: Pro3757 
Date: Tue, 30 May 2023 13:50:23 +0530
Subject: [PATCH 197/336] fix README table

---
 README.md | 46 +++++++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/README.md b/README.md
index 10d1f86f1..c53a5ecee 100644
--- a/README.md
+++ b/README.md
@@ -55,37 +55,37 @@ More information about building GoogleTest can be found at
 | Feature                      | Description                                   |
 | ---------------------------- | --------------------------------------------- |
 | xUnit test framework         | Googletest is based on the                    |
-:                              : [xUnit](https\://en.wikipedia.org/wiki/XUnit) :
-:                              : testing framework, a popular architecture for :
-:                              : unit testing                                  :
+|                              | [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                           :
+|                              | 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        :
+|                              | 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                :
+|                              | 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     :
+|                              | 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              :
+|                              | 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  :
+|                              | 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                :
+|                              | tests, which run with different data types,   |
+|                              | making it useful for testing functions that   |
+|                              | work with different data types                |
 | Various options for running  | Googletest provides many options for running  |
-: tests                        : tests, including running individual tests,    :
-:                              : running tests in a specific order, and        :
-:                              : running tests in parallel                     :
+| tests                        | tests, including running individual tests,    |
+|                              | running tests in a specific order, and        |
+|                              | running tests in parallel                     |
 
 ## Supported Platforms
 

From a7833a19bda5e3c7e0dc226875752514cf77645b Mon Sep 17 00:00:00 2001
From: Paul Wankadia 
Date: Wed, 31 May 2023 09:32:35 -0700
Subject: [PATCH 198/336] Update GoogleTest to RE2 release `2023-06-01`.

Note that RE2 has taken a dependency on Abseil, so the `main` branch
should be used from now on. The `abseil` branch will go away soon...

PiperOrigin-RevId: 536737543
Change-Id: I0e595ee8e754b924881f997f286cdec3822763bf
---
 googletest_deps.bzl | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/googletest_deps.bzl b/googletest_deps.bzl
index 65e56abb5..5e807d72d 100644
--- a/googletest_deps.bzl
+++ b/googletest_deps.bzl
@@ -7,10 +7,10 @@ def googletest_deps():
 
     if not native.existing_rule("com_googlesource_code_re2"):
         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"],
+            name = "com_googlesource_code_re2",  # 2023-06-01
+            sha256 = "1726508efc93a50854c92e3f7ac66eb28f0e57652e413f11d7c1e28f97d997ba",
+            strip_prefix = "re2-03da4fc0857c285e3a26782f6bc8931c4c950df4",
+            urls = ["https://github.com/google/re2/archive/03da4fc0857c285e3a26782f6bc8931c4c950df4.zip"],
         )
 
     if not native.existing_rule("com_google_absl"):

From 04cf2989168a3f9218d463bea6f15f8ade2032fd Mon Sep 17 00:00:00 2001
From: Dino Radakovic 
Date: Wed, 31 May 2023 10:45:02 -0700
Subject: [PATCH 199/336] Provide example for setting C++ language standard in
 GoogleTest's Bazel quickstart and readme. An equivalent for CMake was merged
 in
 https://github.com/google/googletest/commit/aa99ce5a0db4215bb8e2cda3ee68b6b8d4896815

Fixes #4254

PiperOrigin-RevId: 536759641
Change-Id: I8400064a24e0d78f17a0720046f505efa1167b4f
---
 docs/quickstart-bazel.md | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/docs/quickstart-bazel.md b/docs/quickstart-bazel.md
index 15c27a22e..4f693dbe7 100644
--- a/docs/quickstart-bazel.md
+++ b/docs/quickstart-bazel.md
@@ -105,10 +105,17 @@ file (`@com_google_googletest`). For more information about Bazel `BUILD` files,
 see the
 [Bazel C++ Tutorial](https://docs.bazel.build/versions/main/tutorial/cpp.html).
 
+{: .callout .note}
+NOTE: In the example below, we assume Clang or GCC and set `--cxxopt=-std=c++14`
+to ensure that GoogleTest is compiled as C++14 instead of the compiler's default
+setting (which could be C++11). For MSVC, the equivalent would be
+`--cxxopt=/std:c++14`. See [Supported Platforms](platforms.md) for more details
+on supported language versions.
+
 Now you can build and run your test:
 
 
-my_workspace$ bazel test --test_output=all //:hello_test
+my_workspace$ bazel test --cxxopt=-std=c++14 --test_output=all //:hello_test
 INFO: Analyzed target //:hello_test (26 packages loaded, 362 targets configured).
 INFO: Found 1 test target...
 INFO: From Testing //:hello_test:

From 06f44bc951046150f1348598854b211afdcf37fc Mon Sep 17 00:00:00 2001
From: Dino Radakovic 
Date: Thu, 1 Jun 2023 07:28:00 -0700
Subject: [PATCH 200/336] Copy supported platforms from README onto
 https://google.github.io/googletest/platforms.html

PiperOrigin-RevId: 537016664
Change-Id: Ie62891a1061465a009b90feba0ccb91d85591160
---
 docs/platforms.md | 39 ++++++---------------------------------
 1 file changed, 6 insertions(+), 33 deletions(-)

diff --git a/docs/platforms.md b/docs/platforms.md
index eba6ef805..d35a7be05 100644
--- a/docs/platforms.md
+++ b/docs/platforms.md
@@ -1,35 +1,8 @@
 # Supported Platforms
 
-GoogleTest requires a codebase and compiler compliant with the C++11 standard or
-newer.
-
-The GoogleTest code is officially supported on the following platforms.
-Operating systems or tools not listed below are community-supported. For
-community-supported platforms, patches that do not complicate the code may be
-considered.
-
-If you notice any problems on your platform, please file an issue on the
-[GoogleTest GitHub Issue Tracker](https://github.com/google/googletest/issues).
-Pull requests containing fixes are welcome!
-
-### Operating systems
-
-*   Linux
-*   macOS
-*   Windows
-
-### Compilers
-
-*   gcc 5.0+
-*   clang 5.0+
-*   MSVC 2015+
-
-**macOS users:** Xcode 9.3+ provides clang 5.0+.
-
-### Build systems
-
-*   [Bazel](https://bazel.build/)
-*   [CMake](https://cmake.org/)
-
-Bazel is the build system used by the team internally and in tests. CMake is
-supported on a best-effort basis and by the community.
+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
+tools.

From a5b94f6819d2c296958ae1f6b9130df99a37ec6d Mon Sep 17 00:00:00 2001
From: Niranjan Nilakantan 
Date: Thu, 1 Jun 2023 09:48:54 -0700
Subject: [PATCH 201/336] Ignore the .cache directory create by VSCode.

This is populated by the clangd language service provider.

Also ignore the cmake-variants.yaml file.
This can be created locally to select various build/test configurations.

Fixes #4266
---
 .gitignore | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/.gitignore b/.gitignore
index f08cb72a3..fede02f65 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,6 +24,10 @@ Win32-Release/
 x64-Debug/
 x64-Release/
 
+# VSCode files
+.cache/
+cmake-variants.yaml
+
 # Ignore autoconf / automake files
 Makefile.in
 aclocal.m4

From 5ca3ab833168674ff417845941fc46691769ed36 Mon Sep 17 00:00:00 2001
From: Pro3757 
Date: Fri, 2 Jun 2023 00:58:00 +0530
Subject: [PATCH 202/336] change table to unordered list

---
 README.md | 66 +++++++++++++++++++++++++++----------------------------
 1 file changed, 32 insertions(+), 34 deletions(-)

diff --git a/README.md b/README.md
index c53a5ecee..927222713 100644
--- a/README.md
+++ b/README.md
@@ -52,40 +52,38 @@ documentation. We recommend starting with the
 More information about building GoogleTest can be found at
 [googletest/README.md](googletest/README.md).
 
-| Feature                      | Description                                   |
-| ---------------------------- | --------------------------------------------- |
-| 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  | Googletest provides many options for running  |
-| tests                        | tests, including running individual tests,    |
-|                              | running tests in a specific order, and        |
-|                              | running tests in parallel                     |
+## Features
+*   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
 

From 001f281926c74a819e9266bb4ec525515ff39418 Mon Sep 17 00:00:00 2001
From: Joakim Plate 
Date: Fri, 2 Jun 2023 12:17:43 +0200
Subject: [PATCH 203/336] Check for file system for current directory

Check for current directory instead of death test to get original directory.

A port may support filesystems but not death tests.
---
 googletest/src/gtest-internal-inl.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h
index 5ba557fe1..be821662c 100644
--- a/googletest/src/gtest-internal-inl.h
+++ b/googletest/src/gtest-internal-inl.h
@@ -672,7 +672,7 @@ class GTEST_API_ UnitTestImpl {
   void AddTestInfo(internal::SetUpTestSuiteFunc set_up_tc,
                    internal::TearDownTestSuiteFunc tear_down_tc,
                    TestInfo* test_info) {
-#ifdef GTEST_HAS_DEATH_TEST
+#ifdef GTEST_HAS_FILE_SYSTEM
     // In order to support thread-safe death tests, we need to
     // remember the original working directory when the test program
     // was first invoked.  We cannot do this in RUN_ALL_TESTS(), as
@@ -685,7 +685,7 @@ class GTEST_API_ UnitTestImpl {
       GTEST_CHECK_(!original_working_dir_.IsEmpty())
           << "Failed to get the current working directory.";
     }
-#endif  // GTEST_HAS_DEATH_TEST
+#endif  // GTEST_HAS_FILE_SYSTEM
 
     GetTestSuite(test_info->test_suite_name(), test_info->type_param(),
                  set_up_tc, tear_down_tc)

From 65cfeca1a1eebca291b59395f79a60a4497d0f73 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Fri, 9 Jun 2023 11:28:44 -0700
Subject: [PATCH 204/336] internal g3doc documentation change.

PiperOrigin-RevId: 539134110
Change-Id: I28041f77e18bc67aa0ffabdc7205e350deed22c8
---
 docs/primer.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/primer.md b/docs/primer.md
index 31d63160e..c3aee3cc6 100644
--- a/docs/primer.md
+++ b/docs/primer.md
@@ -42,7 +42,7 @@ Since GoogleTest is based on the popular xUnit architecture, you'll feel right
 at home if you've used JUnit or PyUnit before. If not, it will take you about 10
 minutes to learn the basics and get started. So let's go!
 
-## Beware of the nomenclature
+## Beware of the Nomenclature
 
 {: .callout .note}
 *Note:* There might be some confusion arising from different definitions of the

From 4c7aee827e16aa338189b88f6e3aa6d3d927dba4 Mon Sep 17 00:00:00 2001
From: Dino Radakovic 
Date: Wed, 14 Jun 2023 06:40:34 -0700
Subject: [PATCH 205/336] Skip entire test suite with `GTEST_SKIP()` in
 `SetUpTestSuite`

Fixes #4273

PiperOrigin-RevId: 540254167
Change-Id: I2555740d10284223539035bf73f88554fcf73f8a
---
 googletest/src/gtest.cc                          |  3 ++-
 .../test/googletest-output-test-golden-lin.txt   | 16 +++++++++++++---
 googletest/test/googletest-output-test_.cc       |  6 ++++++
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index fb7512c1b..a88ac2557 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -3019,7 +3019,8 @@ void TestSuite::Run() {
   internal::HandleExceptionsInMethodIfSupported(
       this, &TestSuite::RunSetUpTestSuite, "SetUpTestSuite()");
 
-  const bool skip_all = ad_hoc_test_result().Failed();
+  const bool skip_all =
+      ad_hoc_test_result().Failed() || ad_hoc_test_result().Skipped();
 
   start_timestamp_ = internal::GetTimeInMillis();
   internal::Timer timer;
diff --git a/googletest/test/googletest-output-test-golden-lin.txt b/googletest/test/googletest-output-test-golden-lin.txt
index 1f24fb791..6ddf822ff 100644
--- a/googletest/test/googletest-output-test-golden-lin.txt
+++ b/googletest/test/googletest-output-test-golden-lin.txt
@@ -12,7 +12,7 @@ Expected equality of these values:
   3
 Stack trace: (omitted)
 
-[==========] Running 89 tests from 42 test suites.
+[==========] Running 90 tests from 43 test suites.
 [----------] Global test environment set-up.
 FooEnvironment::SetUp() called.
 BarEnvironment::SetUp() called.
@@ -967,6 +967,15 @@ Stack trace: (omitted)
 googletest-output-test_.cc:#: Skipped
 
 [  SKIPPED ] TestSuiteThatFailsToSetUp.ShouldNotRun
+[----------] 1 test from TestSuiteThatSkipsInSetUp
+googletest-output-test_.cc:#: Skipped
+Skip entire test suite
+Stack trace: (omitted)
+
+[ RUN      ] TestSuiteThatSkipsInSetUp.ShouldNotRun
+googletest-output-test_.cc:#: Skipped
+
+[  SKIPPED ] TestSuiteThatSkipsInSetUp.ShouldNotRun
 [----------] 1 test from PrintingFailingParams/FailingParamTest
 [ RUN      ] PrintingFailingParams/FailingParamTest.Fails/0
 googletest-output-test_.cc:#: Failure
@@ -1043,10 +1052,11 @@ Failed
 Expected fatal failure.
 Stack trace: (omitted)
 
-[==========] 89 tests from 42 test suites ran.
+[==========] 90 tests from 43 test suites ran.
 [  PASSED  ] 31 tests.
-[  SKIPPED ] 1 test, listed below:
+[  SKIPPED ] 2 tests, listed below:
 [  SKIPPED ] TestSuiteThatFailsToSetUp.ShouldNotRun
+[  SKIPPED ] TestSuiteThatSkipsInSetUp.ShouldNotRun
 [  FAILED  ] 57 tests, listed below:
 [  FAILED  ] NonfatalFailureTest.EscapesStringOperands
 [  FAILED  ] NonfatalFailureTest.DiffForLongStrings
diff --git a/googletest/test/googletest-output-test_.cc b/googletest/test/googletest-output-test_.cc
index f1facf570..e3560c018 100644
--- a/googletest/test/googletest-output-test_.cc
+++ b/googletest/test/googletest-output-test_.cc
@@ -1007,6 +1007,12 @@ class TestSuiteThatFailsToSetUp : public testing::Test {
 };
 TEST_F(TestSuiteThatFailsToSetUp, ShouldNotRun) { std::abort(); }
 
+class TestSuiteThatSkipsInSetUp : public testing::Test {
+ public:
+  static void SetUpTestSuite() { GTEST_SKIP() << "Skip entire test suite"; }
+};
+TEST_F(TestSuiteThatSkipsInSetUp, ShouldNotRun) { std::abort(); }
+
 // The main function.
 //
 // The idea is to use Google Test to run all the tests we have defined (some

From 18fa6a4db32a30675c0b19bf72f8b5f693d21a23 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Thu, 15 Jun 2023 07:52:03 -0700
Subject: [PATCH 206/336] Allow clients to un-suppress output from gUnit
 EXPECT_EXIT tests.

This is useful for running individual tests in a separate process, which is
useful for testing e.g. flag changes which have a process-global effect.

PiperOrigin-RevId: 540580573
Change-Id: I18a5d24d79425a9d595be3369efc44e2f655f6f8
---
 googletest/include/gtest/gtest.h   | 5 ++++-
 googletest/src/gtest-death-test.cc | 2 +-
 googletest/src/gtest.cc            | 6 +++---
 googletest/test/gtest_unittest.cc  | 2 +-
 4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h
index 841250349..86777c854 100644
--- a/googletest/include/gtest/gtest.h
+++ b/googletest/include/gtest/gtest.h
@@ -1055,6 +1055,10 @@ class GTEST_API_ TestEventListeners {
     return default_xml_generator_;
   }
 
+  // Controls whether events will be forwarded by the repeater to the
+  // listeners in the list.
+  void SuppressEventForwarding(bool);
+
  private:
   friend class TestSuite;
   friend class TestInfo;
@@ -1084,7 +1088,6 @@ class GTEST_API_ TestEventListeners {
   // Controls whether events will be forwarded by the repeater to the
   // listeners in the list.
   bool EventForwardingEnabled() const;
-  void SuppressEventForwarding();
 
   // The actual list of listeners.
   internal::TestEventRepeater* repeater_;
diff --git a/googletest/src/gtest-death-test.cc b/googletest/src/gtest-death-test.cc
index 4cf78e71a..0eb6e38b2 100644
--- a/googletest/src/gtest-death-test.cc
+++ b/googletest/src/gtest-death-test.cc
@@ -1128,7 +1128,7 @@ DeathTest::TestRole NoExecDeathTest::AssumeRole() {
     LogToStderr();
     // Event forwarding to the listeners of event listener API mush be shut
     // down in death test subprocesses.
-    GetUnitTestImpl()->listeners()->SuppressEventForwarding();
+    GetUnitTestImpl()->listeners()->SuppressEventForwarding(true);
     g_in_fast_death_test_child = true;
     return EXECUTE_TEST;
   } else {
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index a88ac2557..d9fd27709 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -5156,8 +5156,8 @@ bool TestEventListeners::EventForwardingEnabled() const {
   return repeater_->forwarding_enabled();
 }
 
-void TestEventListeners::SuppressEventForwarding() {
-  repeater_->set_forwarding_enabled(false);
+void TestEventListeners::SuppressEventForwarding(bool suppress) {
+  repeater_->set_forwarding_enabled(!suppress);
 }
 
 // class UnitTest
@@ -5635,7 +5635,7 @@ void UnitTestImpl::RecordProperty(const TestProperty& test_property) {
 // subprocess. Must not be called before InitGoogleTest.
 void UnitTestImpl::SuppressTestEventsIfInSubprocess() {
   if (internal_run_death_test_flag_ != nullptr)
-    listeners()->SuppressEventForwarding();
+    listeners()->SuppressEventForwarding(true);
 }
 #endif  // GTEST_HAS_DEATH_TEST
 
diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc
index 77d968a72..dd049a00d 100644
--- a/googletest/test/gtest_unittest.cc
+++ b/googletest/test/gtest_unittest.cc
@@ -173,7 +173,7 @@ class TestEventListenersAccessor {
   }
 
   static void SuppressEventForwarding(TestEventListeners* listeners) {
-    listeners->SuppressEventForwarding();
+    listeners->SuppressEventForwarding(true);
   }
 };
 

From 148b327ffa6f7f97cffd1606342a136cf497210b Mon Sep 17 00:00:00 2001
From: Kasra Hashemi <73937934+zencatalyst@users.noreply.github.com>
Date: Fri, 16 Jun 2023 13:59:16 +0330
Subject: [PATCH 207/336] Update README.md

Fixed punctuation issues
---
 README.md | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index ef0c288d5..443e02069 100644
--- a/README.md
+++ b/README.md
@@ -27,8 +27,8 @@ The 1.13.x branch requires at least C++14.
 #### 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
+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.
 
 #### Coming Soon
@@ -83,7 +83,7 @@ More information about building GoogleTest can be found at
     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
+    individual tests, running tests in a specific order and running tests in
     parallel
 
 ## Supported Platforms
@@ -92,7 +92,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?

From 124bc587f0f6157f0bf49a05deb68956db307732 Mon Sep 17 00:00:00 2001
From: Ryan Schmidt 
Date: Mon, 19 Jun 2023 06:18:12 -0500
Subject: [PATCH 208/336] Change C++11 requirement to C++14

Version 1.13.x and later require C++14.

Also fix missing closing backtick.
---
 googletest/README.md | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/googletest/README.md b/googletest/README.md
index 4cad12f75..6bbd7f875 100644
--- a/googletest/README.md
+++ b/googletest/README.md
@@ -124,10 +124,10 @@ match the project in which it is included.
 
 #### C++ Standard Version
 
-An environment that supports C++11 is required in order to successfully build
+An environment that supports C++14 is required in order to successfully build
 GoogleTest. One way to ensure this is to specify the standard in the top-level
-project, for example by using the `set(CMAKE_CXX_STANDARD 11)` command along
-with `set(CMAKE_CXX_STANDARD_REQUIRED ON). If this is not feasible, for example
+project, for example by using the `set(CMAKE_CXX_STANDARD 14)` command along
+with `set(CMAKE_CXX_STANDARD_REQUIRED ON)`. If this is not feasible, for example
 in a C project using GoogleTest for validation, then it can be specified by
 adding it to the options for cmake via the`-DCMAKE_CXX_FLAGS` option.
 

From 4fed5f285030085b096c930ff03e42c7814739b2 Mon Sep 17 00:00:00 2001
From: Juan Ramos 
Date: Mon, 19 Jun 2023 11:21:44 -0600
Subject: [PATCH 209/336] cmake: Raise min to 3.6

From the CMake 3.27 release notes:
Compatibility with versions of CMake older than 3.5 is now
deprecated and will be removed from a future version. Calls to
cmake_minimum_required() or cmake_policy() that set the policy
version to an older value now issue a deprecation diagnostic.

This PR also removes manually setting policy CMP0048. This is
redundant since the CMake min is already 3.X
---
 CMakeLists.txt            |  6 +-----
 docs/pkgconfig.md         | 14 +++++---------
 googlemock/CMakeLists.txt |  3 +--
 googletest/CMakeLists.txt |  3 +--
 4 files changed, 8 insertions(+), 18 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6af414371..33a6c6ff4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,11 +1,7 @@
 # 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)
+cmake_minimum_required(VERSION 3.6)
 
 if (POLICY CMP0069)
   cmake_policy(SET CMP0069 NEW)
diff --git a/docs/pkgconfig.md b/docs/pkgconfig.md
index 18a2546a3..bf05d5931 100644
--- a/docs/pkgconfig.md
+++ b/docs/pkgconfig.md
@@ -19,19 +19,15 @@ examples here we assume you want to compile the sample
 Using `pkg-config` in CMake is fairly easy:
 
 ```cmake
-cmake_minimum_required(VERSION 3.0)
-
-cmake_policy(SET CMP0048 NEW)
-project(my_gtest_pkgconfig VERSION 0.0.1 LANGUAGES CXX)
-
 find_package(PkgConfig)
 pkg_search_module(GTEST REQUIRED gtest_main)
 
-add_executable(testapp samples/sample3_unittest.cc)
-target_link_libraries(testapp ${GTEST_LDFLAGS})
-target_compile_options(testapp PUBLIC ${GTEST_CFLAGS})
+add_executable(testapp)
+target_sources(testapp PRIVATE samples/sample3_unittest.cc)
+target_link_libraries(testapp PRIVATE ${GTEST_LDFLAGS})
+target_compile_options(testapp PRIVATE ${GTEST_CFLAGS})
 
-include(CTest)
+enable_testing()
 add_test(first_and_only_test testapp)
 ```
 
diff --git a/googlemock/CMakeLists.txt b/googlemock/CMakeLists.txt
index 5c1f0dafe..444c5ae80 100644
--- a/googlemock/CMakeLists.txt
+++ b/googlemock/CMakeLists.txt
@@ -36,8 +36,7 @@ endif()
 # as ${gmock_SOURCE_DIR} and to the root binary directory as
 # ${gmock_BINARY_DIR}.
 # Language "C" is required for find_package(Threads).
-cmake_minimum_required(VERSION 3.5)
-cmake_policy(SET CMP0048 NEW)
+cmake_minimum_required(VERSION 3.6)
 project(gmock VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C)
 
 if (COMMAND set_up_hermetic_build)
diff --git a/googletest/CMakeLists.txt b/googletest/CMakeLists.txt
index d06c14797..efc2c3cbe 100644
--- a/googletest/CMakeLists.txt
+++ b/googletest/CMakeLists.txt
@@ -46,8 +46,7 @@ endif()
 
 # Project version:
 
-cmake_minimum_required(VERSION 3.5)
-cmake_policy(SET CMP0048 NEW)
+cmake_minimum_required(VERSION 3.6)
 project(gtest VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C)
 
 if (POLICY CMP0063) # Visibility

From efd8db1627631079dec02de2622071d8ec9ff5fa Mon Sep 17 00:00:00 2001
From: Juan Ramos 
Date: Tue, 20 Jun 2023 13:03:00 -0600
Subject: [PATCH 210/336] cmake: Clean up policy code

Now that the min is 3.13 these policies don't need to be set
manually anymore.

CMP0054 - 3.1
CMP0063 - 3.3
CMP0069 - 3.9
CMP0077 - 3.13
---
 CMakeLists.txt                        |  8 --------
 googletest/CMakeLists.txt             |  4 ----
 googletest/cmake/internal_utils.cmake | 14 --------------
 3 files changed, 26 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 890e495ef..3b5cf3c48 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,14 +3,6 @@
 
 cmake_minimum_required(VERSION 3.13)
 
-if (POLICY CMP0069)
-  cmake_policy(SET CMP0069 NEW)
-endif (POLICY CMP0069)
-
-if (POLICY CMP0077)
-  cmake_policy(SET CMP0077 NEW)
-endif (POLICY CMP0077)
-
 project(googletest-distribution)
 set(GOOGLETEST_VERSION 1.13.0)
 
diff --git a/googletest/CMakeLists.txt b/googletest/CMakeLists.txt
index e76b8c8a5..a944dddbe 100644
--- a/googletest/CMakeLists.txt
+++ b/googletest/CMakeLists.txt
@@ -49,10 +49,6 @@ endif()
 cmake_minimum_required(VERSION 3.13)
 project(gtest VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C)
 
-if (POLICY CMP0063) # Visibility
-  cmake_policy(SET CMP0063 NEW)
-endif (POLICY CMP0063)
-
 if (COMMAND set_up_hermetic_build)
   set_up_hermetic_build()
 endif()
diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake
index 6573d3003..481091135 100644
--- a/googletest/cmake/internal_utils.cmake
+++ b/googletest/cmake/internal_utils.cmake
@@ -12,14 +12,6 @@
 #   Test and Google Mock's option() definitions, and thus must be
 #   called *after* the options have been defined.
 
-if (POLICY CMP0054)
-  cmake_policy(SET CMP0054 NEW)
-endif (POLICY CMP0054)
-
-if (POLICY CMP0069)
-  cmake_policy(SET CMP0069 NEW)
-endif (POLICY CMP0069)
-
 # Tweaks CMake's default compiler/linker settings to suit Google Test's needs.
 #
 # This must be a macro(), as inside a function string() can only
@@ -264,12 +256,6 @@ function(cxx_executable name dir libs)
     ${name} "${cxx_default}" "${libs}" "${dir}/${name}.cc" ${ARGN})
 endfunction()
 
-# CMP0094 policy enables finding a Python executable in the LOCATION order, as
-# specified by the PATH environment variable.
-if (POLICY CMP0094)
-  cmake_policy(SET CMP0094 NEW)
-endif()
-
 # Sets PYTHONINTERP_FOUND and PYTHON_EXECUTABLE.
 if ("${CMAKE_VERSION}" VERSION_LESS "3.12.0")
   find_package(PythonInterp)

From 812f35b26b88ab1607a806b87539175591bba8c2 Mon Sep 17 00:00:00 2001
From: Juan Ramos 
Date: Tue, 20 Jun 2023 19:02:23 -0600
Subject: [PATCH 211/336] cmake: Remove remaining checks for CMAKE_VERSION

Remove conditional code that doesn't need to exist anymore.
---
 googlemock/CMakeLists.txt             | 26 ++++------
 googletest/CMakeLists.txt             | 19 +++-----
 googletest/cmake/internal_utils.cmake | 68 ++++++++-------------------
 3 files changed, 35 insertions(+), 78 deletions(-)

diff --git a/googlemock/CMakeLists.txt b/googlemock/CMakeLists.txt
index 5833d20c1..a9aa0723f 100644
--- a/googlemock/CMakeLists.txt
+++ b/googlemock/CMakeLists.txt
@@ -100,18 +100,14 @@ else()
   target_link_libraries(gmock_main PUBLIC gmock)
   set_target_properties(gmock_main PROPERTIES VERSION ${GOOGLETEST_VERSION})
 endif()
-# If the CMake version supports it, attach header directory information
-# to the targets for when we are part of a parent build (ie being pulled
-# in via add_subdirectory() rather than being a standalone build).
-if (DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
-  string(REPLACE ";" "$" dirs "${gmock_build_include_dirs}")
-  target_include_directories(gmock SYSTEM INTERFACE
-    "$"
-    "$/${CMAKE_INSTALL_INCLUDEDIR}>")
-  target_include_directories(gmock_main SYSTEM INTERFACE
-    "$"
-    "$/${CMAKE_INSTALL_INCLUDEDIR}>")
-endif()
+
+string(REPLACE ";" "$" dirs "${gmock_build_include_dirs}")
+target_include_directories(gmock SYSTEM INTERFACE
+  "$"
+  "$/${CMAKE_INSTALL_INCLUDEDIR}>")
+target_include_directories(gmock_main SYSTEM INTERFACE
+  "$"
+  "$/${CMAKE_INSTALL_INCLUDEDIR}>")
 
 ########################################################################
 #
@@ -135,11 +131,7 @@ if (gmock_build_tests)
   enable_testing()
 
   if (MINGW OR CYGWIN)
-    if (CMAKE_VERSION VERSION_LESS "2.8.12")
-      add_compile_options("-Wa,-mbig-obj")
-    else()
-      add_definitions("-Wa,-mbig-obj")
-    endif()
+    add_compile_options("-Wa,-mbig-obj")
   endif()
 
   ############################################################
diff --git a/googletest/CMakeLists.txt b/googletest/CMakeLists.txt
index a944dddbe..caafa8c76 100644
--- a/googletest/CMakeLists.txt
+++ b/googletest/CMakeLists.txt
@@ -140,18 +140,13 @@ if(GTEST_HAS_ABSL)
 endif()
 cxx_library(gtest_main "${cxx_strict}" src/gtest_main.cc)
 set_target_properties(gtest_main PROPERTIES VERSION ${GOOGLETEST_VERSION})
-# If the CMake version supports it, attach header directory information
-# to the targets for when we are part of a parent build (ie being pulled
-# in via add_subdirectory() rather than being a standalone build).
-if (DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
-  string(REPLACE ";" "$" dirs "${gtest_build_include_dirs}")
-  target_include_directories(gtest SYSTEM INTERFACE
-    "$"
-    "$/${CMAKE_INSTALL_INCLUDEDIR}>")
-  target_include_directories(gtest_main SYSTEM INTERFACE
-    "$"
-    "$/${CMAKE_INSTALL_INCLUDEDIR}>")
-endif()
+string(REPLACE ";" "$" dirs "${gtest_build_include_dirs}")
+target_include_directories(gtest SYSTEM INTERFACE
+  "$"
+  "$/${CMAKE_INSTALL_INCLUDEDIR}>")
+target_include_directories(gtest_main SYSTEM INTERFACE
+  "$"
+  "$/${CMAKE_INSTALL_INCLUDEDIR}>")
 if(CMAKE_SYSTEM_NAME MATCHES "QNX")
   target_link_libraries(gtest PUBLIC regex)
 endif()
diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake
index 481091135..e57207791 100644
--- a/googletest/cmake/internal_utils.cmake
+++ b/googletest/cmake/internal_utils.cmake
@@ -188,23 +188,14 @@ function(cxx_library_with_type name type cxx_flags)
     set_target_properties(${name}
       PROPERTIES
       COMPILE_DEFINITIONS "GTEST_CREATE_SHARED_LIBRARY=1")
-    if (NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
       target_compile_definitions(${name} INTERFACE
         $)
-    endif()
   endif()
   if (DEFINED GTEST_HAS_PTHREAD)
-    if ("${CMAKE_VERSION}" VERSION_LESS "3.1.0")
-      set(threads_spec ${CMAKE_THREAD_LIBS_INIT})
-    else()
-      set(threads_spec Threads::Threads)
-    endif()
-    target_link_libraries(${name} PUBLIC ${threads_spec})
+    target_link_libraries(${name} PUBLIC Threads::Threads)
   endif()
 
-  if (NOT "${CMAKE_VERSION}" VERSION_LESS "3.8")
-    target_compile_features(${name} PUBLIC cxx_std_14)
-  endif()
+  target_compile_features(${name} PUBLIC cxx_std_14)
 endfunction()
 
 ########################################################################
@@ -256,16 +247,7 @@ function(cxx_executable name dir libs)
     ${name} "${cxx_default}" "${libs}" "${dir}/${name}.cc" ${ARGN})
 endfunction()
 
-# Sets PYTHONINTERP_FOUND and PYTHON_EXECUTABLE.
-if ("${CMAKE_VERSION}" VERSION_LESS "3.12.0")
-  find_package(PythonInterp)
-  set(PYTHONINTERP_FOUND ${PYTHONINTERP_FOUND} CACHE INTERNAL "")
-  set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE INTERNAL "")
-else()
-  find_package(Python COMPONENTS Interpreter)
-  set(PYTHONINTERP_FOUND ${Python_Interpreter_FOUND} CACHE INTERNAL "")
-  set(PYTHON_EXECUTABLE ${Python_EXECUTABLE} CACHE INTERNAL "")
-endif()
+find_package(Python3)
 
 # cxx_test_with_flags(name cxx_flags libs srcs...)
 #
@@ -291,34 +273,22 @@ endfunction()
 # creates a Python test with the given name whose main module is in
 # test/name.py.  It does nothing if Python is not installed.
 function(py_test name)
-  if (PYTHONINTERP_FOUND)
-    if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER 3.1)
-      if (CMAKE_CONFIGURATION_TYPES)
-        # Multi-configuration build generators as for Visual Studio save
-        # output in a subdirectory of CMAKE_CURRENT_BINARY_DIR (Debug,
-        # Release etc.), so we have to provide it here.
-        add_test(NAME ${name}
-          COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
-              --build_dir=${CMAKE_CURRENT_BINARY_DIR}/$ ${ARGN})
-      else (CMAKE_CONFIGURATION_TYPES)
-        # Single-configuration build generators like Makefile generators
-        # don't have subdirs below CMAKE_CURRENT_BINARY_DIR.
-        add_test(NAME ${name}
-          COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
-            --build_dir=${CMAKE_CURRENT_BINARY_DIR} ${ARGN})
-      endif (CMAKE_CONFIGURATION_TYPES)
-    else()
-      # ${CMAKE_CURRENT_BINARY_DIR} is known at configuration time, so we can
-      # directly bind it from cmake. ${CTEST_CONFIGURATION_TYPE} is known
-      # only at ctest runtime (by calling ctest -c ), so
-      # we have to escape $ to delay variable substitution here.
-      add_test(NAME ${name}
-        COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
-          --build_dir=${CMAKE_CURRENT_BINARY_DIR}/\${CTEST_CONFIGURATION_TYPE} ${ARGN})
-    endif()
-    # Make the Python import path consistent between Bazel and CMake.
-    set_tests_properties(${name} PROPERTIES ENVIRONMENT PYTHONPATH=${CMAKE_SOURCE_DIR})
-  endif(PYTHONINTERP_FOUND)
+  if (NOT Python3_Interpreter_FOUND)
+    return()
+  endif()
+
+  get_cmake_property(is_multi "GENERATOR_IS_MULTI_CONFIG")
+  set(build_dir "${CMAKE_CURRENT_BINARY_DIR}")
+  if (is_multi)
+    set(build_dir "${CMAKE_CURRENT_BINARY_DIR}/$")
+  endif()
+
+  add_test(NAME ${name}
+      COMMAND Python3::Interpreter ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
+          --build_dir=${build_dir} ${ARGN})
+
+  # Make the Python import path consistent between Bazel and CMake.
+  set_tests_properties(${name} PROPERTIES ENVIRONMENT PYTHONPATH=${CMAKE_SOURCE_DIR})
 endfunction()
 
 # install_project(targets...)

From ec4fed93217bc2830959bb8e86798c1d86956949 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Thu, 22 Jun 2023 08:14:44 -0700
Subject: [PATCH 212/336] Update code examples in the gMock Cookbook following
 C++ best practices.

PiperOrigin-RevId: 542564354
Change-Id: Ia3307f13f845c662c88fb7303112f41ef8c56b28
---
 docs/gmock_cook_book.md | 46 +++++++++++++++++++++--------------------
 1 file changed, 24 insertions(+), 22 deletions(-)

diff --git a/docs/gmock_cook_book.md b/docs/gmock_cook_book.md
index d57be58dd..f736b9fb8 100644
--- a/docs/gmock_cook_book.md
+++ b/docs/gmock_cook_book.md
@@ -697,9 +697,9 @@ TEST(AbcTest, Xyz) {
   EXPECT_CALL(foo, DoThat(_, _));
 
   int n = 0;
-  EXPECT_EQ('+', foo.DoThis(5));  // FakeFoo::DoThis() is invoked.
+  EXPECT_EQ(foo.DoThis(5), '+');  // FakeFoo::DoThis() is invoked.
   foo.DoThat("Hi", &n);  // FakeFoo::DoThat() is invoked.
-  EXPECT_EQ(2, n);
+  EXPECT_EQ(n, 2);
 }
 ```
 
@@ -1129,11 +1129,11 @@ using STL's `` header is just painful). For example, here's a
 predicate that's satisfied by any number that is >= 0, <= 100, and != 50:
 
 ```cpp
-using testing::AllOf;
-using testing::Ge;
-using testing::Le;
-using testing::Matches;
-using testing::Ne;
+using ::testing::AllOf;
+using ::testing::Ge;
+using ::testing::Le;
+using ::testing::Matches;
+using ::testing::Ne;
 ...
 Matches(AllOf(Ge(0), Le(100), Ne(50)))
 ```
@@ -1861,7 +1861,7 @@ error. So, what shall you do?
 Though you may be tempted, DO NOT use `std::ref()`:
 
 ```cpp
-using testing::Return;
+using ::testing::Return;
 
 class MockFoo : public Foo {
  public:
@@ -1873,7 +1873,7 @@ class MockFoo : public Foo {
   EXPECT_CALL(foo, GetValue())
       .WillRepeatedly(Return(std::ref(x)));  // Wrong!
   x = 42;
-  EXPECT_EQ(42, foo.GetValue());
+  EXPECT_EQ(foo.GetValue(), 42);
 ```
 
 Unfortunately, it doesn't work here. The above code will fail with error:
@@ -1895,14 +1895,14 @@ the expectation is set, and `Return(std::ref(x))` will always return 0.
 returns the value pointed to by `pointer` at the time the action is *executed*:
 
 ```cpp
-using testing::ReturnPointee;
+using ::testing::ReturnPointee;
 ...
   int x = 0;
   MockFoo foo;
   EXPECT_CALL(foo, GetValue())
       .WillRepeatedly(ReturnPointee(&x));  // Note the & here.
   x = 42;
-  EXPECT_EQ(42, foo.GetValue());  // This will succeed now.
+  EXPECT_EQ(foo.GetValue(), 42);  // This will succeed now.
 ```
 
 ### Combining Actions
@@ -2264,7 +2264,7 @@ TEST_F(FooTest, Test) {
 
   EXPECT_CALL(foo, DoThis(2))
       .WillOnce(Invoke(NewPermanentCallback(SignOfSum, 5)));
-  EXPECT_EQ('+', foo.DoThis(2));  // Invokes SignOfSum(5, 2).
+  EXPECT_EQ(foo.DoThis(2), '+');  // Invokes SignOfSum(5, 2).
 }
 ```
 
@@ -2771,11 +2771,13 @@ returns a null `unique_ptr`, that’s what you’ll get if you don’t specify a
 action:
 
 ```cpp
+using ::testing::IsNull;
+...
   // Use the default action.
   EXPECT_CALL(mock_buzzer_, MakeBuzz("hello"));
 
   // Triggers the previous EXPECT_CALL.
-  EXPECT_EQ(nullptr, mock_buzzer_.MakeBuzz("hello"));
+  EXPECT_THAT(mock_buzzer_.MakeBuzz("hello"), IsNull());
 ```
 
 If you are not happy with the default action, you can tweak it as usual; see
@@ -3194,9 +3196,9 @@ flag. For example, given the test program:
 ```cpp
 #include "gmock/gmock.h"
 
-using testing::_;
-using testing::HasSubstr;
-using testing::Return;
+using ::testing::_;
+using ::testing::HasSubstr;
+using ::testing::Return;
 
 class MockFoo {
  public:
@@ -3817,15 +3819,15 @@ If the built-in actions don't work for you, you can easily define your own one.
 All you need is a call operator with a signature compatible with the mocked
 function. So you can use a lambda:
 
-```
+```cpp
 MockFunction mock;
 EXPECT_CALL(mock, Call).WillOnce([](const int input) { return input * 7; });
-EXPECT_EQ(14, mock.AsStdFunction()(2));
+EXPECT_EQ(mock.AsStdFunction()(2), 14);
 ```
 
 Or a struct with a call operator (even a templated one):
 
-```
+```cpp
 struct MultiplyBy {
   template 
   T operator()(T arg) { return arg * multiplier; }
@@ -3840,16 +3842,16 @@ struct MultiplyBy {
 It's also fine for the callable to take no arguments, ignoring the arguments
 supplied to the mock function:
 
-```
+```cpp
 MockFunction mock;
 EXPECT_CALL(mock, Call).WillOnce([] { return 17; });
-EXPECT_EQ(17, mock.AsStdFunction()(0));
+EXPECT_EQ(mock.AsStdFunction()(0), 17);
 ```
 
 When used with `WillOnce`, the callable can assume it will be called at most
 once and is allowed to be a move-only type:
 
-```
+```cpp
 // An action that contains move-only types and has an &&-qualified operator,
 // demanding in the type system that it be called at most once. This can be
 // used with WillOnce, but the compiler will reject it if handed to

From 1361c77c4d0027f52a7a8e205b79d572909b5587 Mon Sep 17 00:00:00 2001
From: Ikko Eltociear Ashimine 
Date: Fri, 23 Jun 2023 01:20:10 +0900
Subject: [PATCH 213/336] Fix typo in googletest-catch-exceptions-test.py

FITLER_OUT_SEH_TESTS_FLAG -> FILTER_OUT_SEH_TESTS_FLAG
---
 googletest/test/googletest-catch-exceptions-test.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/googletest/test/googletest-catch-exceptions-test.py b/googletest/test/googletest-catch-exceptions-test.py
index ee4dc9ae6..428b5b77f 100755
--- a/googletest/test/googletest-catch-exceptions-test.py
+++ b/googletest/test/googletest-catch-exceptions-test.py
@@ -297,10 +297,10 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase):
   def testUnhandledCxxExceptionsAbortTheProgram(self):
     # Filters out SEH exception tests on Windows. Unhandled SEH exceptions
     # cause tests to show pop-up windows there.
-    FITLER_OUT_SEH_TESTS_FLAG = FILTER_FLAG + '=-*Seh*'
+    FILTER_OUT_SEH_TESTS_FLAG = FILTER_FLAG + '=-*Seh*'
     # By default, Google Test doesn't catch the exceptions.
     uncaught_exceptions_ex_binary_output = gtest_test_utils.Subprocess(
-        [EX_EXE_PATH, NO_CATCH_EXCEPTIONS_FLAG, FITLER_OUT_SEH_TESTS_FLAG],
+        [EX_EXE_PATH, NO_CATCH_EXCEPTIONS_FLAG, FILTER_OUT_SEH_TESTS_FLAG],
         env=environ,
     ).output
 

From e3d405f62b61a228e5359208b1fa933e03eadc65 Mon Sep 17 00:00:00 2001
From: Chris Johnson 
Date: Thu, 22 Jun 2023 11:52:54 -0500
Subject: [PATCH 214/336] add support for nxp qn9090 mcu

Added additional defines to correctly detect the NXP QN9090 MCU platform
and allow for native googletest compability.
---
 googletest/include/gtest/internal/gtest-port-arch.h | 2 ++
 googletest/include/gtest/internal/gtest-port.h      | 3 ++-
 googletest/src/gtest-filepath.cc                    | 4 ++--
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/googletest/include/gtest/internal/gtest-port-arch.h b/googletest/include/gtest/internal/gtest-port-arch.h
index 04064606f..34964932d 100644
--- a/googletest/include/gtest/internal/gtest-port-arch.h
+++ b/googletest/include/gtest/internal/gtest-port-arch.h
@@ -113,6 +113,8 @@
 #define GTEST_OS_XTENSA 1
 #elif defined(__hexagon__)
 #define GTEST_OS_QURT 1
+#elif defined(CPU_QN9090) || defined(CPU_QN9090HN)
+#define GTEST_OS_NXP_QN9090 1
 #endif  // __CYGWIN__
 
 #endif  // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index d71110c0c..8b6671459 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -505,7 +505,8 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
 #if (!(defined(GTEST_OS_LINUX_ANDROID) || defined(GTEST_OS_CYGWIN) || \
        defined(GTEST_OS_SOLARIS) || defined(GTEST_OS_HAIKU) ||        \
        defined(GTEST_OS_ESP32) || defined(GTEST_OS_ESP8266) ||        \
-       defined(GTEST_OS_XTENSA) || defined(GTEST_OS_QURT)))
+       defined(GTEST_OS_XTENSA) || defined(GTEST_OS_QURT) ||          \
+       defined(GTEST_OS_NXP_QN9090)))
 #define GTEST_HAS_STD_WSTRING 1
 #else
 #define GTEST_HAS_STD_WSTRING 0
diff --git a/googletest/src/gtest-filepath.cc b/googletest/src/gtest-filepath.cc
index 75f52bcfc..1d30c9564 100644
--- a/googletest/src/gtest-filepath.cc
+++ b/googletest/src/gtest-filepath.cc
@@ -102,7 +102,7 @@ FilePath FilePath::GetCurrentDir() {
 #if defined(GTEST_OS_WINDOWS_MOBILE) || defined(GTEST_OS_WINDOWS_PHONE) || \
     defined(GTEST_OS_WINDOWS_RT) || defined(GTEST_OS_ESP8266) ||           \
     defined(GTEST_OS_ESP32) || defined(GTEST_OS_XTENSA) ||                 \
-    defined(GTEST_OS_QURT)
+    defined(GTEST_OS_QURT) || defined(GTEST_OS_NXP_QN9090)
   // These platforms do not have a current directory, so we just return
   // something reasonable.
   return FilePath(kCurrentDirectoryString);
@@ -356,7 +356,7 @@ bool FilePath::CreateFolder() const {
 #elif defined(GTEST_OS_WINDOWS)
   int result = _mkdir(pathname_.c_str());
 #elif defined(GTEST_OS_ESP8266) || defined(GTEST_OS_XTENSA) || \
-    defined(GTEST_OS_QURT)
+    defined(GTEST_OS_QURT) || defined(GTEST_OS_NXP_QN9090)
   // do nothing
   int result = 0;
 #else

From 091d7eb897d5671449efb348834e5c78d36f6459 Mon Sep 17 00:00:00 2001
From: Chris Johnson 
Date: Thu, 11 May 2023 14:28:16 -0500
Subject: [PATCH 215/336] add support for nrf52

Added support for Nordic nRF52 series of MCUs
---
 googlemock/src/gmock_main.cc                        | 2 +-
 googletest/include/gtest/internal/gtest-port-arch.h | 2 ++
 googletest/include/gtest/internal/gtest-port.h      | 2 +-
 googletest/src/gtest-filepath.cc                    | 6 ++++--
 googletest/src/gtest_main.cc                        | 2 +-
 5 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/googlemock/src/gmock_main.cc b/googlemock/src/gmock_main.cc
index fb37b53a3..327e6fa6a 100644
--- a/googlemock/src/gmock_main.cc
+++ b/googlemock/src/gmock_main.cc
@@ -32,7 +32,7 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
-#if defined(GTEST_OS_ESP8266) || defined(GTEST_OS_ESP32)
+#if defined(GTEST_OS_ESP8266) || defined(GTEST_OS_ESP32) || (defined(GTEST_OS_NRF52) && defined(ARDUINO))
 #ifdef GTEST_OS_ESP8266
 extern "C" {
 #endif
diff --git a/googletest/include/gtest/internal/gtest-port-arch.h b/googletest/include/gtest/internal/gtest-port-arch.h
index 34964932d..3162f2b1c 100644
--- a/googletest/include/gtest/internal/gtest-port-arch.h
+++ b/googletest/include/gtest/internal/gtest-port-arch.h
@@ -115,6 +115,8 @@
 #define GTEST_OS_QURT 1
 #elif defined(CPU_QN9090) || defined(CPU_QN9090HN)
 #define GTEST_OS_NXP_QN9090 1
+#elif defined(NRF52)
+#define GTEST_OS_NRF52 1
 #endif  // __CYGWIN__
 
 #endif  // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index 8b6671459..24f1d81a9 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -506,7 +506,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
        defined(GTEST_OS_SOLARIS) || defined(GTEST_OS_HAIKU) ||        \
        defined(GTEST_OS_ESP32) || defined(GTEST_OS_ESP8266) ||        \
        defined(GTEST_OS_XTENSA) || defined(GTEST_OS_QURT) ||          \
-       defined(GTEST_OS_NXP_QN9090)))
+       defined(GTEST_OS_NXP_QN9090) || defined(GTEST_OS_NRF52)))
 #define GTEST_HAS_STD_WSTRING 1
 #else
 #define GTEST_HAS_STD_WSTRING 0
diff --git a/googletest/src/gtest-filepath.cc b/googletest/src/gtest-filepath.cc
index 1d30c9564..d43f2e5d5 100644
--- a/googletest/src/gtest-filepath.cc
+++ b/googletest/src/gtest-filepath.cc
@@ -102,7 +102,8 @@ FilePath FilePath::GetCurrentDir() {
 #if defined(GTEST_OS_WINDOWS_MOBILE) || defined(GTEST_OS_WINDOWS_PHONE) || \
     defined(GTEST_OS_WINDOWS_RT) || defined(GTEST_OS_ESP8266) ||           \
     defined(GTEST_OS_ESP32) || defined(GTEST_OS_XTENSA) ||                 \
-    defined(GTEST_OS_QURT) || defined(GTEST_OS_NXP_QN9090)
+    defined(GTEST_OS_QURT) || defined(GTEST_OS_NXP_QN9090) ||              \
+    defined(GTEST_OS_NRF52)
   // These platforms do not have a current directory, so we just return
   // something reasonable.
   return FilePath(kCurrentDirectoryString);
@@ -356,7 +357,8 @@ bool FilePath::CreateFolder() const {
 #elif defined(GTEST_OS_WINDOWS)
   int result = _mkdir(pathname_.c_str());
 #elif defined(GTEST_OS_ESP8266) || defined(GTEST_OS_XTENSA) || \
-    defined(GTEST_OS_QURT) || defined(GTEST_OS_NXP_QN9090)
+    defined(GTEST_OS_QURT) || defined(GTEST_OS_NXP_QN9090) || \
+    defined(GTEST_OS_NRF52)
   // do nothing
   int result = 0;
 #else
diff --git a/googletest/src/gtest_main.cc b/googletest/src/gtest_main.cc
index c2e3b3cc9..2a9271f75 100644
--- a/googletest/src/gtest_main.cc
+++ b/googletest/src/gtest_main.cc
@@ -31,7 +31,7 @@
 
 #include "gtest/gtest.h"
 
-#if defined(GTEST_OS_ESP8266) || defined(GTEST_OS_ESP32)
+#if defined(GTEST_OS_ESP8266) || defined(GTEST_OS_ESP32) || (defined(GTEST_OS_NRF52) && defined(ARDUINO))
 // Arduino-like platforms: program entry points are setup/loop instead of main.
 
 #ifdef GTEST_OS_ESP8266

From f269e15c5cafa4ba7f4b543e0c395646bbbbd32d Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Tue, 27 Jun 2023 11:14:33 -0700
Subject: [PATCH 216/336] Resolve an issue where the resolution of `operator<<`
 overloads would attempt to instantiate the incomplete
 `testing::internal::Secret` type.

PiperOrigin-RevId: 543799815
Change-Id: Ic0a4f48d825bef26cb8cc74d8a0117b3a5ef3f14
---
 googletest/include/gtest/internal/gtest-port.h |  6 ++++--
 googletest/test/gtest_unittest.cc              | 16 ++++++++++++++++
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index 8b6671459..52215409a 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -925,9 +925,11 @@ using std::tuple_size;
 namespace internal {
 
 // A secret type that Google Test users don't know about.  It has no
-// definition on purpose.  Therefore it's impossible to create a
+// accessible constructors on purpose.  Therefore it's impossible to create a
 // Secret object, which is what we want.
-class Secret;
+class Secret {
+  Secret(const Secret&) = delete;
+};
 
 // A helper for suppressing warnings on constant condition.  It just
 // returns 'condition'.
diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc
index dd049a00d..6caa03fd3 100644
--- a/googletest/test/gtest_unittest.cc
+++ b/googletest/test/gtest_unittest.cc
@@ -67,11 +67,27 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "gtest/gtest-spi.h"
 #include "src/gtest-internal-inl.h"
 
+struct ConvertibleGlobalType {
+  // The inner enable_if is to ensure invoking is_constructible doesn't fail.
+  // The outer enable_if is to ensure the overload resolution doesn't encounter
+  // an ambiguity.
+  template <
+      class T,
+      std::enable_if_t<
+          false, std::enable_if_t::value, int>> = 0>
+  operator T() const;  // NOLINT(google-explicit-constructor)
+};
+void operator<<(ConvertibleGlobalType&, int);
+static_assert(sizeof(decltype(std::declval()
+                              << 1)(*)()) > 0,
+              "error in operator<< overload resolution");
+
 namespace testing {
 namespace internal {
 

From 2acd53824402affcf473b2355d7323047e660e86 Mon Sep 17 00:00:00 2001
From: Derek Mauro 
Date: Tue, 27 Jun 2023 20:46:32 -0700
Subject: [PATCH 217/336] On platforms without a file system, don't log an
 error when no alternative output format is requested.

Fixes #4299

PiperOrigin-RevId: 543932266
Change-Id: Ide78c313ecf6829e4910f4a8407275c81edb3848
---
 googletest/src/gtest.cc | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index d9fd27709..d1eddf103 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -5655,8 +5655,10 @@ void UnitTestImpl::ConfigureXmlOutput() {
                         << output_format << "\" ignored.";
   }
 #else
-  GTEST_LOG_(ERROR) << "ERROR: alternative output formats require "
-                    << "GTEST_HAS_FILE_SYSTEM to be enabled";
+  if (!output_format.empty()) {
+    GTEST_LOG_(ERROR) << "ERROR: alternative output formats require "
+                      << "GTEST_HAS_FILE_SYSTEM to be enabled";
+  }
 #endif  // GTEST_HAS_FILE_SYSTEM
 }
 

From 687c589949eaf8734484491a6882a7fc56aebc12 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Wed, 28 Jun 2023 11:44:27 -0700
Subject: [PATCH 218/336] Print stack traces on SEH exceptions on Windows

Also tidies up a couple of things:
- Prevent handling of stack overflows, which cannot be done safely
- `exception_code` is a macro, so we rename it
- The `std::string` heap allocation was unnecessary

Fixes #4298

PiperOrigin-RevId: 544117790
Change-Id: I8ba61f87119d5fbdb1f653700d9867ca6f8c28ce
---
 googletest/src/gtest.cc | 39 +++++++++++++++++++++------------------
 1 file changed, 21 insertions(+), 18 deletions(-)

diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index d1eddf103..704e1aca3 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -866,7 +866,7 @@ bool UnitTestOptions::FilterMatchesTest(const std::string& test_suite_name,
 // Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the
 // given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise.
 // This function is useful as an __except condition.
-int UnitTestOptions::GTestShouldProcessSEH(DWORD exception_code) {
+int UnitTestOptions::GTestShouldProcessSEH(DWORD seh_code) {
   // Google Test should handle a SEH exception if:
   //   1. the user wants it to, AND
   //   2. this is not a breakpoint exception, AND
@@ -881,9 +881,11 @@ int UnitTestOptions::GTestShouldProcessSEH(DWORD exception_code) {
 
   if (!GTEST_FLAG_GET(catch_exceptions))
     should_handle = false;
-  else if (exception_code == EXCEPTION_BREAKPOINT)
+  else if (seh_code == EXCEPTION_BREAKPOINT)
     should_handle = false;
-  else if (exception_code == kCxxExceptionCode)
+  else if (seh_code == EXCEPTION_STACK_OVERFLOW)
+    should_handle = false;
+  else if (seh_code == kCxxExceptionCode)
     should_handle = false;
 
   return should_handle ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH;
@@ -2555,17 +2557,12 @@ bool Test::HasSameFixtureClass() {
 
 #if GTEST_HAS_SEH
 
-// Adds an "exception thrown" fatal failure to the current test.  This
-// function returns its result via an output parameter pointer because VC++
-// prohibits creation of objects with destructors on stack in functions
-// using __try (see error C2712).
-static std::string* FormatSehExceptionMessage(DWORD exception_code,
-                                              const char* location) {
+static std::string FormatSehExceptionMessage(DWORD exception_code,
+                                             const char* location) {
   Message message;
   message << "SEH exception with code 0x" << std::setbase(16) << exception_code
           << std::setbase(10) << " thrown in " << location << ".";
-
-  return new std::string(message.GetString());
+  return message.GetString();
 }
 
 #endif  // GTEST_HAS_SEH
@@ -2613,14 +2610,20 @@ Result HandleSehExceptionsInMethodIfSupported(T* object, Result (T::*method)(),
     return (object->*method)();
   } __except (internal::UnitTestOptions::GTestShouldProcessSEH(  // NOLINT
       GetExceptionCode())) {
-    // We create the exception message on the heap because VC++ prohibits
-    // creation of objects with destructors on stack in functions using __try
+    // We wrap an inner function because VC++ prohibits direct creation of
+    // objects with destructors on stack in functions using __try
     // (see error C2712).
-    std::string* exception_message =
-        FormatSehExceptionMessage(GetExceptionCode(), location);
-    internal::ReportFailureInUnknownLocation(TestPartResult::kFatalFailure,
-                                             *exception_message);
-    delete exception_message;
+    struct Wrapper {
+      static void ReportFailure(DWORD code, const char* location) {
+        return internal::ReportFailureInUnknownLocation(
+            TestPartResult::kFatalFailure,
+            FormatSehExceptionMessage(code, location) +
+                "\n"
+                "Stack trace:\n" +
+                ::testing::internal::GetCurrentOsStackTraceExceptTop(1));
+      }
+    };
+    Wrapper::ReportFailure(GetExceptionCode(), location);
     return static_cast(0);
   }
 #else

From 251e720391e92ab1aec845c7fd8ecdda35737f39 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Thu, 29 Jun 2023 14:39:44 -0700
Subject: [PATCH 219/336] Change `::testing` to `testing` in Testing Reference
 doc

PiperOrigin-RevId: 544466397
Change-Id: Icb4d5fae38361cd75d47f908886831696eb2b1c9
---
 docs/reference/testing.md | 70 +++++++++++++++++++--------------------
 1 file changed, 35 insertions(+), 35 deletions(-)

diff --git a/docs/reference/testing.md b/docs/reference/testing.md
index 877dfa322..17225a682 100644
--- a/docs/reference/testing.md
+++ b/docs/reference/testing.md
@@ -122,8 +122,8 @@ custom function can be used for more control:
 ```cpp
 INSTANTIATE_TEST_SUITE_P(
     MyInstantiation, MyTestSuite,
-    ::testing::Values(...),
-    [](const ::testing::TestParamInfo& info) {
+    testing::Values(...),
+    [](const testing::TestParamInfo& info) {
       // Can use info.param here to generate the test suffix
       std::string name = ...
       return name;
@@ -148,7 +148,7 @@ type, for example:
 
 ```cpp
 template 
-class MyFixture : public ::testing::Test {
+class MyFixture : public testing::Test {
  public:
   ...
   using List = std::list;
@@ -324,7 +324,7 @@ Then the test code should look like:
 ```cpp
 namespace my_namespace {
 
-class MyClassTest : public ::testing::Test {
+class MyClassTest : public testing::Test {
   ...
 };
 
@@ -387,7 +387,7 @@ GoogleTest defines the following classes and types to help with writing tests.
 
 ### AssertionResult {#AssertionResult}
 
-`::testing::AssertionResult`
+`testing::AssertionResult`
 
 A class for indicating whether an assertion was successful.
 
@@ -401,14 +401,14 @@ To create an instance of this class, use one of the factory functions
 
 ### AssertionException {#AssertionException}
 
-`::testing::AssertionException`
+`testing::AssertionException`
 
 Exception which can be thrown from
 [`TestEventListener::OnTestPartResult`](#TestEventListener::OnTestPartResult).
 
 ### EmptyTestEventListener {#EmptyTestEventListener}
 
-`::testing::EmptyTestEventListener`
+`testing::EmptyTestEventListener`
 
 Provides an empty implementation of all methods in the
 [`TestEventListener`](#TestEventListener) interface, such that a subclass only
@@ -416,7 +416,7 @@ needs to override the methods it cares about.
 
 ### Environment {#Environment}
 
-`::testing::Environment`
+`testing::Environment`
 
 Represents a global test environment. See
 [Global Set-Up and Tear-Down](../advanced.md#global-set-up-and-tear-down).
@@ -437,7 +437,7 @@ Override this to define how to tear down the environment.
 
 ### ScopedTrace {#ScopedTrace}
 
-`::testing::ScopedTrace`
+`testing::ScopedTrace`
 
 An instance of this class causes a trace to be included in every test failure
 message generated by code in the scope of the lifetime of the `ScopedTrace`
@@ -453,7 +453,7 @@ ScopedTrace(const char* file, int line, const T& message)
 Example usage:
 
 ```cpp
-::testing::ScopedTrace trace("file.cc", 123, "message");
+testing::ScopedTrace trace("file.cc", 123, "message");
 ```
 
 The resulting trace includes the given source file path and line number, and the
@@ -464,7 +464,7 @@ See also [`SCOPED_TRACE`](#SCOPED_TRACE).
 
 ### Test {#Test}
 
-`::testing::Test`
+`testing::Test`
 
 The abstract class that all tests inherit from. `Test` is not copyable.
 
@@ -552,7 +552,7 @@ after running each individual test.
 
 ### TestWithParam {#TestWithParam}
 
-`::testing::TestWithParam`
+`testing::TestWithParam`
 
 A convenience class which inherits from both [`Test`](#Test) and
 [`WithParamInterface`](#WithParamInterface).
@@ -672,7 +672,7 @@ during execution of `SetUpTestSuite` and `TearDownTestSuite`.
 
 ### TestInfo {#TestInfo}
 
-`::testing::TestInfo`
+`testing::TestInfo`
 
 Stores information about a test.
 
@@ -751,7 +751,7 @@ Returns the result of the test. See [`TestResult`](#TestResult).
 
 ### TestParamInfo {#TestParamInfo}
 
-`::testing::TestParamInfo`
+`testing::TestParamInfo`
 
 Describes a parameter to a value-parameterized test. The type `T` is the type of
 the parameter.
@@ -761,7 +761,7 @@ and its integer index respectively.
 
 ### UnitTest {#UnitTest}
 
-`::testing::UnitTest`
+`testing::UnitTest`
 
 This class contains information about the test program.
 
@@ -929,7 +929,7 @@ GoogleTest. See [`TestEventListeners`](#TestEventListeners).
 
 ### TestEventListener {#TestEventListener}
 
-`::testing::TestEventListener`
+`testing::TestEventListener`
 
 The interface for tracing execution of tests. The methods below are listed in
 the order the corresponding events are fired.
@@ -1027,7 +1027,7 @@ Fired after all test activities have ended.
 
 ### TestEventListeners {#TestEventListeners}
 
-`::testing::TestEventListeners`
+`testing::TestEventListeners`
 
 Lets users add listeners to track events in GoogleTest.
 
@@ -1072,7 +1072,7 @@ the caller and makes this function return `NULL` the next time.
 
 ### TestPartResult {#TestPartResult}
 
-`::testing::TestPartResult`
+`testing::TestPartResult`
 
 A copyable object representing the result of a test part (i.e. an assertion or
 an explicit `FAIL()`, `ADD_FAILURE()`, or `SUCCESS()`).
@@ -1154,7 +1154,7 @@ Returns true if and only if the test part failed.
 
 ### TestProperty {#TestProperty}
 
-`::testing::TestProperty`
+`testing::TestProperty`
 
 A copyable object representing a user-specified test property which can be
 output as a key/value string pair.
@@ -1181,7 +1181,7 @@ Sets a new value, overriding the previous one.
 
 ### TestResult {#TestResult}
 
-`::testing::TestResult`
+`testing::TestResult`
 
 Contains information about the result of a single test.
 
@@ -1262,20 +1262,20 @@ range, aborts the program.
 
 ### TimeInMillis {#TimeInMillis}
 
-`::testing::TimeInMillis`
+`testing::TimeInMillis`
 
 An integer type representing time in milliseconds.
 
 ### Types {#Types}
 
-`::testing::Types`
+`testing::Types`
 
 Represents a list of types for use in typed tests and type-parameterized tests.
 
 The template argument `T...` can be any number of types, for example:
 
 ```
-::testing::Types
+testing::Types
 ```
 
 See [Typed Tests](../advanced.md#typed-tests) and
@@ -1284,7 +1284,7 @@ information.
 
 ### WithParamInterface {#WithParamInterface}
 
-`::testing::WithParamInterface`
+`testing::WithParamInterface`
 
 The pure interface class that all value-parameterized tests inherit from.
 
@@ -1310,9 +1310,9 @@ tests.
 
 ### InitGoogleTest {#InitGoogleTest}
 
-`void ::testing::InitGoogleTest(int* argc, char** argv)` \
-`void ::testing::InitGoogleTest(int* argc, wchar_t** argv)` \
-`void ::testing::InitGoogleTest()`
+`void testing::InitGoogleTest(int* argc, char** argv)` \
+`void testing::InitGoogleTest(int* argc, wchar_t** argv)` \
+`void testing::InitGoogleTest()`
 
 Initializes GoogleTest. This must be called before calling
 [`RUN_ALL_TESTS()`](#RUN_ALL_TESTS). In particular, it parses the command line
@@ -1329,7 +1329,7 @@ platforms where there is no `argc`/`argv`.
 
 ### AddGlobalTestEnvironment {#AddGlobalTestEnvironment}
 
-`Environment* ::testing::AddGlobalTestEnvironment(Environment* env)`
+`Environment* testing::AddGlobalTestEnvironment(Environment* env)`
 
 Adds a test environment to the test program. Must be called before
 [`RUN_ALL_TESTS()`](#RUN_ALL_TESTS) is called. See
@@ -1342,7 +1342,7 @@ See also [`Environment`](#Environment).
 
 ```cpp
 template 
-TestInfo* ::testing::RegisterTest(const char* test_suite_name, const char* test_name,
+TestInfo* testing::RegisterTest(const char* test_suite_name, const char* test_name,
                                   const char* type_param, const char* value_param,
                                   const char* file, int line, Factory factory)
 ```
@@ -1381,27 +1381,27 @@ an all-caps name.
 
 ### AssertionSuccess {#AssertionSuccess}
 
-`AssertionResult ::testing::AssertionSuccess()`
+`AssertionResult testing::AssertionSuccess()`
 
 Creates a successful assertion result. See
 [`AssertionResult`](#AssertionResult).
 
 ### AssertionFailure {#AssertionFailure}
 
-`AssertionResult ::testing::AssertionFailure()`
+`AssertionResult testing::AssertionFailure()`
 
 Creates a failed assertion result. Use the `<<` operator to store a failure
 message:
 
 ```cpp
-::testing::AssertionFailure() << "My failure message";
+testing::AssertionFailure() << "My failure message";
 ```
 
 See [`AssertionResult`](#AssertionResult).
 
 ### StaticAssertTypeEq {#StaticAssertTypeEq}
 
-`::testing::StaticAssertTypeEq()`
+`testing::StaticAssertTypeEq()`
 
 Compile-time assertion for type equality. Compiles if and only if `T1` and `T2`
 are the same type. The value it returns is irrelevant.
@@ -1410,7 +1410,7 @@ See [Type Assertions](../advanced.md#type-assertions) for more information.
 
 ### PrintToString {#PrintToString}
 
-`std::string ::testing::PrintToString(x)`
+`std::string testing::PrintToString(x)`
 
 Prints any value `x` using GoogleTest's value printer.
 
@@ -1420,7 +1420,7 @@ for more information.
 
 ### PrintToStringParamName {#PrintToStringParamName}
 
-`std::string ::testing::PrintToStringParamName(TestParamInfo& info)`
+`std::string testing::PrintToStringParamName(TestParamInfo& info)`
 
 A built-in parameterized test name generator which returns the result of
 [`PrintToString`](#PrintToString) called on `info.param`. Does not work when the

From 1f531be3a19055d1402ec6476c5cab80492d3c68 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Fri, 30 Jun 2023 10:32:13 -0700
Subject: [PATCH 220/336] Make GoogleTest handle SEH exceptions before stack
 unwinding rather than afterward

This ensure the erroring stack frame is visible and accessible when the handler is invoked.

Fixes #4298

PiperOrigin-RevId: 544692549
Change-Id: Ia165a8c293e8edc820da5f5ad4416546fffe2493
---
 googletest/src/gtest-internal-inl.h |  6 +--
 googletest/src/gtest.cc             | 67 +++++++++++------------------
 2 files changed, 27 insertions(+), 46 deletions(-)

diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h
index be821662c..1e9b5c266 100644
--- a/googletest/src/gtest-internal-inl.h
+++ b/googletest/src/gtest-internal-inl.h
@@ -387,10 +387,10 @@ class GTEST_API_ UnitTestOptions {
 #ifdef GTEST_OS_WINDOWS
   // Function for supporting the gtest_catch_exception flag.
 
-  // Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the
-  // given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise.
+  // Returns EXCEPTION_EXECUTE_HANDLER if given SEH exception was handled, or
+  // EXCEPTION_CONTINUE_SEARCH otherwise.
   // This function is useful as an __except condition.
-  static int GTestShouldProcessSEH(DWORD exception_code);
+  static int GTestProcessSEH(DWORD seh_code, const char* location);
 #endif  // GTEST_OS_WINDOWS
 
   // Returns true if "name" matches the ':' separated list of glob-style
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 704e1aca3..30a5cc3f8 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -863,13 +863,18 @@ bool UnitTestOptions::FilterMatchesTest(const std::string& test_suite_name,
 }
 
 #if GTEST_HAS_SEH
-// Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the
-// given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise.
-// This function is useful as an __except condition.
-int UnitTestOptions::GTestShouldProcessSEH(DWORD seh_code) {
+static std::string FormatSehExceptionMessage(DWORD exception_code,
+                                             const char* location) {
+  Message message;
+  message << "SEH exception with code 0x" << std::setbase(16) << exception_code
+          << std::setbase(10) << " thrown in " << location << ".";
+  return message.GetString();
+}
+
+int UnitTestOptions::GTestProcessSEH(DWORD seh_code, const char* location) {
   // Google Test should handle a SEH exception if:
   //   1. the user wants it to, AND
-  //   2. this is not a breakpoint exception, AND
+  //   2. this is not a breakpoint exception or stack overflow, AND
   //   3. this is not a C++ exception (VC++ implements them via SEH,
   //      apparently).
   //
@@ -877,18 +882,20 @@ int UnitTestOptions::GTestShouldProcessSEH(DWORD seh_code) {
   // (see http://support.microsoft.com/kb/185294 for more information).
   const DWORD kCxxExceptionCode = 0xe06d7363;
 
-  bool should_handle = true;
+  if (!GTEST_FLAG_GET(catch_exceptions) || seh_code == kCxxExceptionCode ||
+      seh_code == EXCEPTION_BREAKPOINT ||
+      seh_code == EXCEPTION_STACK_OVERFLOW) {
+    return EXCEPTION_CONTINUE_SEARCH;  // Don't handle these exceptions
+  }
 
-  if (!GTEST_FLAG_GET(catch_exceptions))
-    should_handle = false;
-  else if (seh_code == EXCEPTION_BREAKPOINT)
-    should_handle = false;
-  else if (seh_code == EXCEPTION_STACK_OVERFLOW)
-    should_handle = false;
-  else if (seh_code == kCxxExceptionCode)
-    should_handle = false;
+  internal::ReportFailureInUnknownLocation(
+      TestPartResult::kFatalFailure,
+      FormatSehExceptionMessage(seh_code, location) +
+          "\n"
+          "Stack trace:\n" +
+          ::testing::internal::GetCurrentOsStackTraceExceptTop(1));
 
-  return should_handle ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH;
+  return EXCEPTION_EXECUTE_HANDLER;
 }
 #endif  // GTEST_HAS_SEH
 
@@ -2555,18 +2562,6 @@ bool Test::HasSameFixtureClass() {
   return true;
 }
 
-#if GTEST_HAS_SEH
-
-static std::string FormatSehExceptionMessage(DWORD exception_code,
-                                             const char* location) {
-  Message message;
-  message << "SEH exception with code 0x" << std::setbase(16) << exception_code
-          << std::setbase(10) << " thrown in " << location << ".";
-  return message.GetString();
-}
-
-#endif  // GTEST_HAS_SEH
-
 namespace internal {
 
 #if GTEST_HAS_EXCEPTIONS
@@ -2608,22 +2603,8 @@ Result HandleSehExceptionsInMethodIfSupported(T* object, Result (T::*method)(),
 #if GTEST_HAS_SEH
   __try {
     return (object->*method)();
-  } __except (internal::UnitTestOptions::GTestShouldProcessSEH(  // NOLINT
-      GetExceptionCode())) {
-    // We wrap an inner function because VC++ prohibits direct creation of
-    // objects with destructors on stack in functions using __try
-    // (see error C2712).
-    struct Wrapper {
-      static void ReportFailure(DWORD code, const char* location) {
-        return internal::ReportFailureInUnknownLocation(
-            TestPartResult::kFatalFailure,
-            FormatSehExceptionMessage(code, location) +
-                "\n"
-                "Stack trace:\n" +
-                ::testing::internal::GetCurrentOsStackTraceExceptTop(1));
-      }
-    };
-    Wrapper::ReportFailure(GetExceptionCode(), location);
+  } __except (internal::UnitTestOptions::GTestProcessSEH(  // NOLINT
+      GetExceptionCode(), location)) {
     return static_cast(0);
   }
 #else

From be03d00f5f0cc3a997d1a368bee8a1fe93651f48 Mon Sep 17 00:00:00 2001
From: Mike Kruskal 
Date: Fri, 30 Jun 2023 18:49:33 -0700
Subject: [PATCH 221/336] Fix C++20 compatibility bug.

This was shown to work for C++14, C++17, and C++20 after patched into googletest for the protobuf repo's CI.

Closes #3659

PiperOrigin-RevId: 544795507
Change-Id: I3e0a94f675e78a6ee9aeccae86c23d940efed8eb
---
 googletest/include/gtest/gtest-printers.h      | 6 +++---
 googletest/include/gtest/internal/gtest-port.h | 2 +-
 googletest/src/gtest-printers.cc               | 8 ++++----
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h
index 539d99c40..9a765fd79 100644
--- a/googletest/include/gtest/gtest-printers.h
+++ b/googletest/include/gtest/gtest-printers.h
@@ -475,7 +475,7 @@ GTEST_API_ void PrintTo(char32_t c, ::std::ostream* os);
 inline void PrintTo(char16_t c, ::std::ostream* os) {
   PrintTo(ImplicitCast_(c), os);
 }
-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
 inline void PrintTo(char8_t c, ::std::ostream* os) {
   PrintTo(ImplicitCast_(c), os);
 }
@@ -588,7 +588,7 @@ inline void PrintTo(const unsigned char* s, ::std::ostream* os) {
 inline void PrintTo(unsigned char* s, ::std::ostream* os) {
   PrintTo(ImplicitCast_(s), os);
 }
-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
 // Overloads for u8 strings.
 GTEST_API_ void PrintTo(const char8_t* s, ::std::ostream* os);
 inline void PrintTo(char8_t* s, ::std::ostream* os) {
@@ -908,7 +908,7 @@ void UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) {
 GTEST_API_ void UniversalPrintArray(const char* begin, size_t len,
                                     ::std::ostream* os);
 
-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
 // This overload prints a (const) char8_t array compactly.
 GTEST_API_ void UniversalPrintArray(const char8_t* begin, size_t len,
                                     ::std::ostream* os);
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index 52215409a..26e4cc3d3 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -1998,7 +1998,7 @@ inline bool IsUpper(char ch) {
 inline bool IsXDigit(char ch) {
   return isxdigit(static_cast(ch)) != 0;
 }
-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
 inline bool IsXDigit(char8_t ch) {
   return isxdigit(static_cast(ch)) != 0;
 }
diff --git a/googletest/src/gtest-printers.cc b/googletest/src/gtest-printers.cc
index 2b4706782..e3acecba8 100644
--- a/googletest/src/gtest-printers.cc
+++ b/googletest/src/gtest-printers.cc
@@ -216,7 +216,7 @@ static const char* GetCharWidthPrefix(signed char) { return ""; }
 
 static const char* GetCharWidthPrefix(unsigned char) { return ""; }
 
-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
 static const char* GetCharWidthPrefix(char8_t) { return "u8"; }
 #endif
 
@@ -232,7 +232,7 @@ static CharFormat PrintAsStringLiteralTo(char c, ostream* os) {
   return PrintAsStringLiteralTo(ToChar32(c), os);
 }
 
-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
 static CharFormat PrintAsStringLiteralTo(char8_t c, ostream* os) {
   return PrintAsStringLiteralTo(ToChar32(c), os);
 }
@@ -395,7 +395,7 @@ void UniversalPrintArray(const char* begin, size_t len, ostream* os) {
   UniversalPrintCharArray(begin, len, os);
 }
 
-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
 // Prints a (const) char8_t array of 'len' elements, starting at address
 // 'begin'.
 void UniversalPrintArray(const char8_t* begin, size_t len, ostream* os) {
@@ -438,7 +438,7 @@ void PrintCStringTo(const Char* s, ostream* os) {
 
 void PrintTo(const char* s, ostream* os) { PrintCStringTo(s, os); }
 
-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
 void PrintTo(const char8_t* s, ostream* os) { PrintCStringTo(s, os); }
 #endif
 

From 3044657e7afa759ce875a8161cd4bff0fd2e22bc Mon Sep 17 00:00:00 2001
From: Steve Robbins 
Date: Mon, 3 Jul 2023 21:23:18 -0500
Subject: [PATCH 222/336] Use template type FloatType in the cast.

---
 googletest/include/gtest/gtest-printers.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h
index 9a765fd79..e69a0a60a 100644
--- a/googletest/include/gtest/gtest-printers.h
+++ b/googletest/include/gtest/gtest-printers.h
@@ -531,7 +531,7 @@ int AppropriateResolution(FloatType val) {
     } else if (val >= 0.0001) {
       mulfor6 = 1e9;
     }
-    if (static_cast(static_cast(val * mulfor6 + 0.5)) /
+    if (static_cast(static_cast(val * mulfor6 + 0.5)) /
             mulfor6 ==
         val)
       return 6;
@@ -546,7 +546,7 @@ int AppropriateResolution(FloatType val) {
     } else if (val >= 1e6) {  // 1,000,000 to 9,999,999
       divfor6 = 10;
     }
-    if (static_cast(static_cast(val / divfor6 + 0.5)) *
+    if (static_cast(static_cast(val / divfor6 + 0.5)) *
             divfor6 ==
         val)
       return 6;

From 4a1a299b206ba250a4318f74938ea67c75c3c0c9 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Fri, 7 Jul 2023 13:42:49 -0700
Subject: [PATCH 223/336] Update docstring of PrintWithFallback(..) to reflect
 the recently changed ordering.

PiperOrigin-RevId: 546373360
Change-Id: I2538b45d8c7710592071cc352da6771480c324e6
---
 googletest/include/gtest/gtest-printers.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h
index 9a765fd79..bcdecd109 100644
--- a/googletest/include/gtest/gtest-printers.h
+++ b/googletest/include/gtest/gtest-printers.h
@@ -298,8 +298,8 @@ struct FindFirstPrinter<
 //  - Print containers (they have begin/end/etc).
 //  - Print function pointers.
 //  - Print object pointers.
-//  - Use the stream operator, if available.
 //  - Print protocol buffers.
+//  - Use the stream operator, if available.
 //  - Print types convertible to BiggestInt.
 //  - Print types convertible to StringView, if available.
 //  - Fallback to printing the raw bytes of the object.

From c88e0b4673f9b08818e0e74c4ed718db5f9b809c Mon Sep 17 00:00:00 2001
From: kimvaleen 
Date: Tue, 11 Jul 2023 12:05:05 +0300
Subject: [PATCH 224/336] Fixed variables that could be declared 'const'

---
 googletest/include/gtest/gtest.h                   | 2 +-
 googletest/include/gtest/internal/gtest-internal.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h
index 86777c854..bee2aca5c 100644
--- a/googletest/include/gtest/gtest.h
+++ b/googletest/include/gtest/gtest.h
@@ -2102,7 +2102,7 @@ class GTEST_API_ ScopedTrace {
 // Therefore, a SCOPED_TRACE() would (correctly) only affect the
 // assertions in its own thread.
 #define SCOPED_TRACE(message)                                         \
-  ::testing::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)( \
+  const ::testing::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)( \
       __FILE__, __LINE__, (message))
 
 // Compile-time assertion for type equality.
diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h
index 317894e73..a816ec2a4 100644
--- a/googletest/include/gtest/internal/gtest-internal.h
+++ b/googletest/include/gtest/internal/gtest-internal.h
@@ -1500,7 +1500,7 @@ class NeverThrown {
 #define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail)                          \
   GTEST_AMBIGUOUS_ELSE_BLOCKER_                                                \
   if (::testing::internal::AlwaysTrue()) {                                     \
-    ::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_checker; \
+    const ::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_checker; \
     GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement);                 \
     if (gtest_fatal_failure_checker.has_new_fatal_failure()) {                 \
       goto GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__);            \

From f014396910d397b4f408c0c867aa8ca6a000ef7f Mon Sep 17 00:00:00 2001
From: Anton Sosnin 
Date: Wed, 19 Jul 2023 18:08:41 +0300
Subject: [PATCH 225/336] Fix typo in gmock_cook_book.md

---
 docs/gmock_cook_book.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/docs/gmock_cook_book.md b/docs/gmock_cook_book.md
index f736b9fb8..e319bf636 100644
--- a/docs/gmock_cook_book.md
+++ b/docs/gmock_cook_book.md
@@ -2640,8 +2640,8 @@ action will exhibit different behaviors. Example:
       .WillRepeatedly(IncrementCounter(0));
   foo.DoThis();  // Returns 1.
   foo.DoThis();  // Returns 2.
-  foo.DoThat();  // Returns 1 - Blah() uses a different
-                 // counter than Bar()'s.
+  foo.DoThat();  // Returns 1 - DoThat() uses a different
+                 // counter than DoThis()'s.
 ```
 
 versus

From 1ed6a8c67a0bd675149ece27bbec0ef1759854cf Mon Sep 17 00:00:00 2001
From: Derek Mauro 
Date: Wed, 19 Jul 2023 16:21:08 -0700
Subject: [PATCH 226/336] Remove unused cast implementation

PiperOrigin-RevId: 549456180
Change-Id: I10862e6de981087a5c590cccf6152255e9a176a0
---
 .../include/gtest/internal/gtest-port.h       | 41 -------------------
 1 file changed, 41 deletions(-)

diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index 514b1cc7d..656df2606 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -1146,47 +1146,6 @@ inline To ImplicitCast_(To x) {
   return x;
 }
 
-// When you upcast (that is, cast a pointer from type Foo to type
-// SuperclassOfFoo), it's fine to use ImplicitCast_<>, since upcasts
-// always succeed.  When you downcast (that is, cast a pointer from
-// type Foo to type SubclassOfFoo), static_cast<> isn't safe, because
-// how do you know the pointer is really of type SubclassOfFoo?  It
-// could be a bare Foo, or of type DifferentSubclassOfFoo.  Thus,
-// when you downcast, you should use this macro.  In debug mode, we
-// use dynamic_cast<> to double-check the downcast is legal (we die
-// if it's not).  In normal mode, we do the efficient static_cast<>
-// instead.  Thus, it's important to test in debug mode to make sure
-// the cast is legal!
-//    This is the only place in the code we should use dynamic_cast<>.
-// In particular, you SHOULDN'T be using dynamic_cast<> in order to
-// do RTTI (eg code like this:
-//    if (dynamic_cast(foo)) HandleASubclass1Object(foo);
-//    if (dynamic_cast(foo)) HandleASubclass2Object(foo);
-// You should design the code some other way not to need this.
-//
-// This relatively ugly name is intentional. It prevents clashes with
-// similar functions users may have (e.g., down_cast). The internal
-// namespace alone is not enough because the function can be found by ADL.
-template   // use like this: DownCast_(foo);
-inline To DownCast_(From* f) {         // so we only accept pointers
-  // Ensures that To is a sub-type of From *.  This test is here only
-  // for compile-time type checking, and has no overhead in an
-  // optimized build at run-time, as it will be optimized away
-  // completely.
-  GTEST_INTENTIONAL_CONST_COND_PUSH_()
-  if (false) {
-    GTEST_INTENTIONAL_CONST_COND_POP_()
-    const To to = nullptr;
-    ::testing::internal::ImplicitCast_(to);
-  }
-
-#if GTEST_HAS_RTTI
-  // RTTI: debug mode only!
-  GTEST_CHECK_(f == nullptr || dynamic_cast(f) != nullptr);
-#endif
-  return static_cast(f);
-}
-
 // Downcasts the pointer of type Base to Derived.
 // Derived must be a subclass of Base. The parameter MUST
 // point to a class of type Derived, not any subclass of it.

From 01e18376efe643a82cff468734f87f8c60e314b6 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Fri, 21 Jul 2023 10:35:31 -0700
Subject: [PATCH 227/336] Make `AbslStringify` usage public in GoogleTest

Fixes #4314

PiperOrigin-RevId: 549986457
Change-Id: Iff74f02ab1c106696f288540e9c623d56b76e3f7
---
 googletest/include/gtest/gtest-printers.h   | 22 ++++++++++++++++
 googletest/test/googletest-printers-test.cc | 28 +++++++++++++++++++++
 2 files changed, 50 insertions(+)

diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h
index 1ba5178e1..d1766e640 100644
--- a/googletest/include/gtest/gtest-printers.h
+++ b/googletest/include/gtest/gtest-printers.h
@@ -43,6 +43,9 @@
 //   1. foo::PrintTo(const T&, ostream*)
 //   2. operator<<(ostream&, const T&) defined in either foo or the
 //      global namespace.
+// * Prefer AbslStringify(..) to operator<<(..), per https://abseil.io/tips/215.
+// * Define foo::PrintTo(..) if the type already has AbslStringify(..), but an
+//   alternative presentation in test results is of interest.
 //
 // However if T is an STL-style container then it is printed element-wise
 // unless foo::PrintTo(const T&, ostream*) is defined. Note that
@@ -112,6 +115,10 @@
 #include 
 #include 
 
+#ifdef GTEST_HAS_ABSL
+#include "absl/strings/internal/has_absl_stringify.h"
+#include "absl/strings/str_cat.h"
+#endif  // GTEST_HAS_ABSL
 #include "gtest/internal/gtest-internal.h"
 #include "gtest/internal/gtest-port.h"
 
@@ -260,6 +267,18 @@ struct ConvertibleToStringViewPrinter {
 #endif
 };
 
+#ifdef GTEST_HAS_ABSL
+struct ConvertibleToAbslStringifyPrinter {
+  template <
+      typename T,
+      typename = typename std::enable_if<
+          absl::strings_internal::HasAbslStringify::value>::type>  // NOLINT
+  static void PrintValue(const T& value, ::std::ostream* os) {
+    *os << absl::StrCat(value);
+  }
+};
+#endif  // GTEST_HAS_ABSL
+
 // Prints the given number of bytes in the given object to the given
 // ostream.
 GTEST_API_ void PrintBytesInObjectTo(const unsigned char* obj_bytes,
@@ -308,6 +327,9 @@ void PrintWithFallback(const T& value, ::std::ostream* os) {
   using Printer = typename FindFirstPrinter<
       T, void, ContainerPrinter, FunctionPointerPrinter, PointerPrinter,
       ProtobufPrinter,
+#ifdef GTEST_HAS_ABSL
+      ConvertibleToAbslStringifyPrinter,
+#endif  // GTEST_HAS_ABSL
       internal_stream_operator_without_lexical_name_lookup::StreamPrinter,
       ConvertibleToIntegerPrinter, ConvertibleToStringViewPrinter,
       RawBytesPrinter, FallbackPrinter>::type;
diff --git a/googletest/test/googletest-printers-test.cc b/googletest/test/googletest-printers-test.cc
index f44f29a56..bee0ca4ab 100644
--- a/googletest/test/googletest-printers-test.cc
+++ b/googletest/test/googletest-printers-test.cc
@@ -55,6 +55,10 @@
 #include "gtest/gtest-printers.h"
 #include "gtest/gtest.h"
 
+#ifdef GTEST_HAS_ABSL
+#include "absl/strings/str_format.h"
+#endif
+
 // Some user-defined types for testing the universal value printer.
 
 // An anonymous enum type.
@@ -119,6 +123,19 @@ void operator<<(::std::ostream& os, const StreamableInGlobal* /* x */) {
   os << "StreamableInGlobal*";
 }
 
+#ifdef GTEST_HAS_ABSL
+// A user-defined type with AbslStringify
+struct Point {
+  template 
+  friend void AbslStringify(Sink& sink, const Point& p) {
+    absl::Format(&sink, "(%d, %d)", p.x, p.y);
+  }
+
+  int x = 10;
+  int y = 20;
+};
+#endif
+
 namespace foo {
 
 // A user-defined unprintable type in a user namespace.
@@ -317,6 +334,11 @@ TEST(PrintEnumTest, EnumWithPrintTo) {
   EXPECT_EQ("invalid", Print(static_cast(0)));
 }
 
+#ifdef GTEST_HAS_ABSL
+// Tests printing a class that defines AbslStringify
+TEST(PrintClassTest, AbslStringify) { EXPECT_EQ("(10, 20)", Print(Point())); }
+#endif
+
 // Tests printing a class implicitly convertible to BiggestInt.
 
 TEST(PrintClassTest, BiggestIntConvertible) {
@@ -1636,6 +1658,12 @@ TEST(PrintToStringTest, PrintReferenceToStreamableInGlobal) {
   EXPECT_STREQ("StreamableInGlobal", PrintToString(r).c_str());
 }
 
+#ifdef GTEST_HAS_ABSL
+TEST(PrintToStringTest, AbslStringify) {
+  EXPECT_PRINT_TO_STRING_(Point(), "(10, 20)");
+}
+#endif
+
 TEST(IsValidUTF8Test, IllFormedUTF8) {
   // The following test strings are ill-formed UTF-8 and are printed
   // as hex only (or ASCII, in case of ASCII bytes) because IsValidUTF8() is

From 2f83a6e8f8aa56335f8b6a4d72c0a6841dcfa985 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Patryk=20Gawro=C5=84ski?= 
Date: Thu, 27 Jul 2023 01:45:41 +0200
Subject: [PATCH 228/336] gtest: Supress warning about set unused variable

Modified test ExpectThrowTest.DoesNotGenerateUnreachableCodeWarning
---
 googletest/test/gtest_unittest.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc
index 6caa03fd3..b1cbddfe2 100644
--- a/googletest/test/gtest_unittest.cc
+++ b/googletest/test/gtest_unittest.cc
@@ -4109,7 +4109,7 @@ TEST(AssertionSyntaxTest, BasicAssertionsBehavesLikeSingleStatement) {
 // Tests that the compiler will not complain about unreachable code in the
 // EXPECT_THROW/EXPECT_ANY_THROW/EXPECT_NO_THROW macros.
 TEST(ExpectThrowTest, DoesNotGenerateUnreachableCodeWarning) {
-  int n = 0;
+  [[maybe_unused]] int n{0};
 
   EXPECT_THROW(throw 1, int);
   EXPECT_NONFATAL_FAILURE(EXPECT_THROW(n++, int), "");

From c875c4e2249ec124c24f72141b3780c22256fd44 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Fri, 28 Jul 2023 09:50:50 -0700
Subject: [PATCH 229/336] Adjust includes to use <> instead of "", consistent
 with quickstart pages.

Right now, gtest documentation uses different #include syntax. The quickstart
pages (e.g., http://google.github.io/googletest/quickstart-bazel.html#create-and-run-a-binary) are checked in with `#include ` However, other
documentation (such as the primer) uses `#include "gtest/gtest.h"` (e.g.,
https://google.github.io/googletest/primer.html#writing-the-main-function).

PiperOrigin-RevId: 551878641
Change-Id: Iab93cc1da3ef4870a07b624071b75d6e9d3568c1
---
 docs/gmock_cheat_sheet.md    | 2 +-
 docs/gmock_cook_book.md      | 2 +-
 docs/gmock_for_dummies.md    | 6 +++---
 docs/primer.md               | 2 +-
 docs/reference/assertions.md | 2 +-
 googletest/README.md         | 2 +-
 6 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/docs/gmock_cheat_sheet.md b/docs/gmock_cheat_sheet.md
index 2fb0403e6..ddafaaa22 100644
--- a/docs/gmock_cheat_sheet.md
+++ b/docs/gmock_cheat_sheet.md
@@ -20,7 +20,7 @@ class Foo {
 (note that `~Foo()` **must** be virtual) we can define its mock as
 
 ```cpp
-#include "gmock/gmock.h"
+#include 
 
 class MockFoo : public Foo {
  public:
diff --git a/docs/gmock_cook_book.md b/docs/gmock_cook_book.md
index e319bf636..da10918c9 100644
--- a/docs/gmock_cook_book.md
+++ b/docs/gmock_cook_book.md
@@ -3194,7 +3194,7 @@ You can unlock this power by running your test with the `--gmock_verbose=info`
 flag. For example, given the test program:
 
 ```cpp
-#include "gmock/gmock.h"
+#include 
 
 using ::testing::_;
 using ::testing::HasSubstr;
diff --git a/docs/gmock_for_dummies.md b/docs/gmock_for_dummies.md
index b7264d358..43f907aaa 100644
--- a/docs/gmock_for_dummies.md
+++ b/docs/gmock_for_dummies.md
@@ -164,7 +164,7 @@ follow:
 After the process, you should have something like:
 
 ```cpp
-#include "gmock/gmock.h"  // Brings in gMock.
+#include   // Brings in gMock.
 
 class MockTurtle : public Turtle {
  public:
@@ -224,8 +224,8 @@ Here's an example:
 
 ```cpp
 #include "path/to/mock-turtle.h"
-#include "gmock/gmock.h"
-#include "gtest/gtest.h"
+#include 
+#include 
 
 using ::testing::AtLeast;                         // #1
 
diff --git a/docs/primer.md b/docs/primer.md
index c3aee3cc6..f2a97a726 100644
--- a/docs/primer.md
+++ b/docs/primer.md
@@ -395,7 +395,7 @@ You can start from this boilerplate:
 ```c++
 #include "this/package/foo.h"
 
-#include "gtest/gtest.h"
+#include 
 
 namespace my {
 namespace project {
diff --git a/docs/reference/assertions.md b/docs/reference/assertions.md
index 1cdff266e..aa1dbc04b 100644
--- a/docs/reference/assertions.md
+++ b/docs/reference/assertions.md
@@ -88,7 +88,7 @@ For example, the following code verifies that the string `value1` starts with
 10:
 
 ```cpp
-#include "gmock/gmock.h"
+#include 
 
 using ::testing::AllOf;
 using ::testing::Gt;
diff --git a/googletest/README.md b/googletest/README.md
index 6bbd7f875..815f3fc02 100644
--- a/googletest/README.md
+++ b/googletest/README.md
@@ -145,7 +145,7 @@ We list the most frequently used macros below. For a complete list, see file
 ### Multi-threaded Tests
 
 GoogleTest is thread-safe where the pthread library is available. After
-`#include "gtest/gtest.h"`, you can check the
+`#include `, you can check the
 `GTEST_IS_THREADSAFE` macro to see whether this is the case (yes if the macro is
 `#defined` to 1, no if it's undefined.).
 

From efe6bb1db894556b5125b3b3147d6c37fbaffa51 Mon Sep 17 00:00:00 2001
From: Julien Combattelli 
Date: Thu, 27 Jul 2023 10:19:12 +0200
Subject: [PATCH 230/336] Use #if and not #ifdef to check filesystem support

---
 googletest/src/gtest-internal-inl.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h
index 1e9b5c266..5b7fcbd06 100644
--- a/googletest/src/gtest-internal-inl.h
+++ b/googletest/src/gtest-internal-inl.h
@@ -672,7 +672,7 @@ class GTEST_API_ UnitTestImpl {
   void AddTestInfo(internal::SetUpTestSuiteFunc set_up_tc,
                    internal::TearDownTestSuiteFunc tear_down_tc,
                    TestInfo* test_info) {
-#ifdef GTEST_HAS_FILE_SYSTEM
+#if GTEST_HAS_FILE_SYSTEM
     // In order to support thread-safe death tests, we need to
     // remember the original working directory when the test program
     // was first invoked.  We cannot do this in RUN_ALL_TESTS(), as

From 717d8ab5e0f7d925ad3076dc53aebe7a7bcb8aaf Mon Sep 17 00:00:00 2001
From: Derek Mauro 
Date: Tue, 1 Aug 2023 13:56:21 -0700
Subject: [PATCH 231/336] Update GoogleTest dependencies

PiperOrigin-RevId: 552912819
Change-Id: If1b6278f7fe5a8fc41fc3bc390356a94387d0091
---
 WORKSPACE           | 24 ++++++++++++------------
 googletest_deps.bzl | 16 ++++++++--------
 2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/WORKSPACE b/WORKSPACE
index 1c8ea24d3..f819ffe61 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -6,22 +6,22 @@ googletest_deps()
 load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
 
 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 = "rules_python",  # 2023-07-31T20:39:27Z
+  sha256 = "1250b59a33c591a1c4ba68c62e95fc88a84c334ec35a2e23f46cbc1b9a5a8b55",
+  strip_prefix = "rules_python-e355becc30275939d87116a4ec83dad4bb50d9e1",
+  urls = ["https://github.com/bazelbuild/rules_python/archive/e355becc30275939d87116a4ec83dad4bb50d9e1.zip"],
 )
 
 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"],
+  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",  # 2022-11-09T19:18:22Z
-    sha256 = "b4a3b45dc4202e2b3e34e3bc49d2b5b37295fc23ea58d88fb9e01f3642ad9b55",
-    strip_prefix = "platforms-3fbc687756043fb58a407c2ea8c944bc2fe1d922",
-    urls = ["https://github.com/bazelbuild/platforms/archive/3fbc687756043fb58a407c2ea8c944bc2fe1d922.zip"],
+  name = "platforms",  # 2023-07-28T19:44:27Z
+  sha256 = "40eb313613ff00a5c03eed20aba58890046f4d38dec7344f00bb9a8867853526",
+  strip_prefix = "platforms-4ad40ef271da8176d4fc0194d2089b8a76e19d7b",
+  urls = ["https://github.com/bazelbuild/platforms/archive/4ad40ef271da8176d4fc0194d2089b8a76e19d7b.zip"],
 )
diff --git a/googletest_deps.bzl b/googletest_deps.bzl
index 5e807d72d..e25f5a1ad 100644
--- a/googletest_deps.bzl
+++ b/googletest_deps.bzl
@@ -7,16 +7,16 @@ def googletest_deps():
 
     if not native.existing_rule("com_googlesource_code_re2"):
         http_archive(
-            name = "com_googlesource_code_re2",  # 2023-06-01
-            sha256 = "1726508efc93a50854c92e3f7ac66eb28f0e57652e413f11d7c1e28f97d997ba",
-            strip_prefix = "re2-03da4fc0857c285e3a26782f6bc8931c4c950df4",
-            urls = ["https://github.com/google/re2/archive/03da4fc0857c285e3a26782f6bc8931c4c950df4.zip"],
+            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"],
         )
 
     if not native.existing_rule("com_google_absl"):
         http_archive(
-            name = "com_google_absl",  # 2023-04-06T14:42:25Z
-            sha256 = "a50452f02402262f9a61a8eedda60f76dda6b9538d36b34b55bce9f74a4d5ef8",
-            strip_prefix = "abseil-cpp-e73b9139ee9b853a4bd7812531442c138da09084",
-            urls = ["https://github.com/abseil/abseil-cpp/archive/e73b9139ee9b853a4bd7812531442c138da09084.zip"],
+            name = "com_google_absl",  # 2023-08-01T14:59:13Z
+            sha256 = "d2c09bf3b3aba57ad87a56082020bee2948445407756e92ddaf3595396086853",
+            strip_prefix = "abseil-cpp-22091f4c0d6626b3ef40446ce3d4ccab19425ca3",
+            urls = ["https://github.com/abseil/abseil-cpp/archive/22091f4c0d6626b3ef40446ce3d4ccab19425ca3.zip"],
         )

From e7fd109b536a8e22cc9e8aad84b35221c3d36042 Mon Sep 17 00:00:00 2001
From: Phoebe Liang 
Date: Tue, 1 Aug 2023 14:01:00 -0700
Subject: [PATCH 232/336] Make testing::Message support streamed AbslStringify
 values

This allows types that provide an AbslStringify definition to be streamed into GoogleTest macros.

PiperOrigin-RevId: 552914482
Change-Id: I5fb386980d4d24873f95f0a8ef83067a6a3c86ac
---
 googletest/include/gtest/gtest-message.h   | 36 ++++++++++++++++++++--
 googletest/test/googletest-message-test.cc | 23 ++++++++++++++
 2 files changed, 57 insertions(+), 2 deletions(-)

diff --git a/googletest/include/gtest/gtest-message.h b/googletest/include/gtest/gtest-message.h
index 4d4b152b1..59b805e4e 100644
--- a/googletest/include/gtest/gtest-message.h
+++ b/googletest/include/gtest/gtest-message.h
@@ -56,6 +56,13 @@
 
 #include "gtest/internal/gtest-port.h"
 
+#ifdef GTEST_HAS_ABSL
+#include 
+
+#include "absl/strings/internal/has_absl_stringify.h"
+#include "absl/strings/str_cat.h"
+#endif  // GTEST_HAS_ABSL
+
 GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
 /* class A needs to have dll-interface to be used by clients of class B */)
 
@@ -111,8 +118,17 @@ class GTEST_API_ Message {
     *ss_ << str;
   }
 
-  // Streams a non-pointer value to this object.
-  template 
+  // Streams a non-pointer value to this object. If building a version of
+  // GoogleTest with ABSL, this overload is only enabled if the value does not
+  // have an AbslStringify definition.
+  template ::value,  // NOLINT
+                int>::type = 0
+#endif  // GTEST_HAS_ABSL
+            >
   inline Message& operator<<(const T& val) {
         // Some libraries overload << for STL containers.  These
     // overloads are defined in the global namespace instead of ::std.
@@ -133,6 +149,22 @@ class GTEST_API_ Message {
     return *this;
   }
 
+#ifdef GTEST_HAS_ABSL
+  // Streams a non-pointer value with an AbslStringify definition to this
+  // object.
+  template ::value,  // NOLINT
+                int>::type = 0>
+  inline Message& operator<<(const T& val) {
+    // ::operator<< is needed here for a similar reason as with the non-Abseil
+    // version above
+    using ::operator<<;
+    *ss_ << absl::StrCat(val);
+    return *this;
+  }
+#endif  // GTEST_HAS_ABSL
+
   // Streams a pointer value to this object.
   //
   // This function is an overload of the previous one.  When you
diff --git a/googletest/test/googletest-message-test.cc b/googletest/test/googletest-message-test.cc
index 54e9d43c9..bf1f094c9 100644
--- a/googletest/test/googletest-message-test.cc
+++ b/googletest/test/googletest-message-test.cc
@@ -36,10 +36,26 @@
 #include "gtest/gtest-message.h"
 #include "gtest/gtest.h"
 
+#ifdef GTEST_HAS_ABSL
+#include "absl/strings/str_format.h"
+#endif  // GTEST_HAS_ABSL
+
 namespace {
 
 using ::testing::Message;
 
+#ifdef GTEST_HAS_ABSL
+struct AbslStringifiablePoint {
+  template 
+  friend void AbslStringify(Sink& sink, const AbslStringifiablePoint& p) {
+    absl::Format(&sink, "(%d, %d)", p.x, p.y);
+  }
+
+  int x;
+  int y;
+};
+#endif  // GTEST_HAS_ABSL
+
 // Tests the testing::Message class
 
 // Tests the default constructor.
@@ -128,6 +144,13 @@ TEST(MessageTest, StreamsInt) {
   EXPECT_EQ("123", (Message() << 123).GetString());
 }
 
+#ifdef GTEST_HAS_ABSL
+// Tests streaming a type with an AbslStringify definition.
+TEST(MessageTest, StreamsAbslStringify) {
+  EXPECT_EQ("(1, 2)", (Message() << AbslStringifiablePoint{1, 2}).GetString());
+}
+#endif  // GTEST_HAS_ABSL
+
 // Tests that basic IO manipulators (endl, ends, and flush) can be
 // streamed to Message.
 TEST(MessageTest, StreamsBasicIoManip) {

From 58e37f7e99152a28a092028294a6ca587e6657c5 Mon Sep 17 00:00:00 2001
From: Derek Mauro 
Date: Wed, 2 Aug 2023 07:40:26 -0700
Subject: [PATCH 233/336] Add googletest-message-test to the Bazel tests It
 appears to have been unintentionally left out

PiperOrigin-RevId: 553141410
Change-Id: I8adac55a3df0ec12d6fe03446f71858fc702e178
---
 googletest/test/BUILD.bazel | 1 +
 1 file changed, 1 insertion(+)

diff --git a/googletest/test/BUILD.bazel b/googletest/test/BUILD.bazel
index 7754c1303..1890b6ff9 100644
--- a/googletest/test/BUILD.bazel
+++ b/googletest/test/BUILD.bazel
@@ -64,6 +64,7 @@ cc_test(
             "googletest-global-environment-unittest_.cc",
             "googletest-break-on-failure-unittest_.cc",
             "googletest-listener-test.cc",
+            "googletest-message-test.cc",
             "googletest-output-test_.cc",
             "googletest-list-tests-unittest_.cc",
             "googletest-shuffle-test_.cc",

From 96683ee6680e433a53e7deda976640ae3268012d Mon Sep 17 00:00:00 2001
From: Derek Mauro 
Date: Wed, 2 Aug 2023 08:18:56 -0700
Subject: [PATCH 234/336] Remove the GTEST_HAS_DOWNCAST_ customization point.

PiperOrigin-RevId: 553150809
Change-Id: I10d19a45a85c5f63a5e65dc322413307116e1c25
---
 googletest/include/gtest/internal/gtest-port.h | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index 656df2606..b887e24ed 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -220,7 +220,6 @@
 //   GTEST_HAS_ALT_PATH_SEP_ - Always defined to 0 or 1.
 //   GTEST_WIDE_STRING_USES_UTF16_ - Always defined to 0 or 1.
 //   GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ - Always defined to 0 or 1.
-//   GTEST_HAS_DOWNCAST_ - Always defined to 0 or 1.
 //   GTEST_HAS_NOTIFICATION_- Always defined to 0 or 1.
 //
 // Synchronization:
@@ -313,10 +312,6 @@
 #include "gtest/internal/custom/gtest-port.h"
 #include "gtest/internal/gtest-port-arch.h"
 
-#ifndef GTEST_HAS_DOWNCAST_
-#define GTEST_HAS_DOWNCAST_ 0
-#endif
-
 #ifndef GTEST_HAS_MUTEX_AND_THREAD_LOCAL_
 #define GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ 0
 #endif
@@ -1153,17 +1148,12 @@ inline To ImplicitCast_(To x) {
 // check to enforce this.
 template 
 Derived* CheckedDowncastToActualType(Base* base) {
+  static_assert(std::is_base_of::value,
+                "target type not derived from source type");
 #if GTEST_HAS_RTTI
-  GTEST_CHECK_(typeid(*base) == typeid(Derived));
-#endif
-
-#if GTEST_HAS_DOWNCAST_
-  return ::down_cast(base);
-#elif GTEST_HAS_RTTI
-  return dynamic_cast(base);  // NOLINT
-#else
-  return static_cast(base);  // Poor man's downcast.
+  GTEST_CHECK_(base == nullptr || dynamic_cast(base) != nullptr);
 #endif
+  return static_cast(base);
 }
 
 #if GTEST_HAS_STREAM_REDIRECTION

From f8d7d77c06936315286eb55f8de22cd23c188571 Mon Sep 17 00:00:00 2001
From: Derek Mauro 
Date: Wed, 2 Aug 2023 08:24:13 -0700
Subject: [PATCH 235/336] Bump version to v1.14 in preparation for release

PiperOrigin-RevId: 553152072
Change-Id: I0bfbb2da6b3902fc3e41a8e1c4aacb291ffdd098
---
 CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3b5cf3c48..089ac987f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,7 +4,7 @@
 cmake_minimum_required(VERSION 3.13)
 
 project(googletest-distribution)
-set(GOOGLETEST_VERSION 1.13.0)
+set(GOOGLETEST_VERSION 1.14.0)
 
 if(NOT CYGWIN AND NOT MSYS AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL QNX)
   set(CMAKE_CXX_EXTENSIONS OFF)

From 843976e4f582ccb76cf87e0f128585324335779b Mon Sep 17 00:00:00 2001
From: Derek Mauro 
Date: Wed, 2 Aug 2023 09:44:39 -0700
Subject: [PATCH 236/336] Update documentation to refer to v1.14

PiperOrigin-RevId: 553172719
Change-Id: Ie09afa3788c8ed5c95913d8ca0b436f1df28241a
---
 README.md            | 8 ++++----
 googletest/README.md | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md
index 443e02069..1bca4d1ff 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@ GoogleTest now follows the
 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.13.0`).
+`v${major}.${minor}.${patch}` (e.g. `v1.14.0`).
 
 #### Documentation Updates
 
@@ -17,12 +17,12 @@ 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.14.0
 
-[Release 1.13.0](https://github.com/google/googletest/releases/tag/v1.13.0) is
+[Release 1.14.0](https://github.com/google/googletest/releases/tag/v1.14.0) is
 now available.
 
-The 1.13.x branch requires at least C++14.
+The 1.14.x branch requires at least C++14.
 
 #### Continuous Integration
 
diff --git a/googletest/README.md b/googletest/README.md
index 815f3fc02..9331fce3b 100644
--- a/googletest/README.md
+++ b/googletest/README.md
@@ -25,7 +25,7 @@ When building GoogleTest as a standalone project, the typical workflow starts
 with
 
 ```
-git clone https://github.com/google/googletest.git -b v1.13.0
+git clone https://github.com/google/googletest.git -b v1.14.0
 cd googletest        # Main directory of the cloned repository.
 mkdir build          # Create a directory to hold the build output.
 cd build

From 429432e341b3d68a8a9be079e739a587d41b48b8 Mon Sep 17 00:00:00 2001
From: Robert Shade 
Date: Wed, 2 Aug 2023 14:09:54 -0400
Subject: [PATCH 237/336] Avoid unreachable code warning

---
 googlemock/include/gmock/gmock-actions.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h
index bd9ba73ee..f20258bca 100644
--- a/googlemock/include/gmock/gmock-actions.h
+++ b/googlemock/include/gmock/gmock-actions.h
@@ -175,9 +175,15 @@ struct BuiltInDefaultValueGetter {
   static T Get() {
     Assert(false, __FILE__, __LINE__,
            "Default action undefined for the function return type.");
-    return internal::Invalid();
+#if defined(__GNUC__) || defined(__clang__)
+    __builtin_unreachable();
+#elif defined(_MSC_VER)
+    __assume(0);
+#else
+    return Invalid();
     // The above statement will never be reached, but is required in
     // order for this function to compile.
+#endif
   }
 };
 

From 9ef5e8226919b56d6760b48258e706d819409994 Mon Sep 17 00:00:00 2001
From: Elliot Goodrich 
Date: Thu, 3 Aug 2023 21:22:23 +0100
Subject: [PATCH 238/336] Remove public includes of ``

This commit removes `` from public GoogleTest header files.

As `` is not a common included file, its content is unlikely
to be included in translation units other than through GoogleTest
includes.

By reducing the number of include directives public headers in
GoogleTest, this may reduce the time taken to compile tests as it would
reduce the amount of work that the preprocessor and compiler front-end
need to do.
---
 googletest/include/gtest/gtest.h                   | 9 ++++-----
 googletest/include/gtest/internal/gtest-internal.h | 1 -
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h
index 86777c854..894f1e0af 100644
--- a/googletest/include/gtest/gtest.h
+++ b/googletest/include/gtest/gtest.h
@@ -51,7 +51,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -1574,12 +1573,12 @@ AssertionResult CmpHelperFloatingPointEQ(const char* lhs_expression,
   }
 
   ::std::stringstream lhs_ss;
-  lhs_ss << std::setprecision(std::numeric_limits::digits10 + 2)
-         << lhs_value;
+  lhs_ss.precision(std::numeric_limits::digits10 + 2);
+  lhs_ss << lhs_value;
 
   ::std::stringstream rhs_ss;
-  rhs_ss << std::setprecision(std::numeric_limits::digits10 + 2)
-         << rhs_value;
+  rhs_ss.precision(std::numeric_limits::digits10 + 2);
+  rhs_ss << rhs_value;
 
   return EqFailure(lhs_expression, rhs_expression,
                    StringStreamToString(&lhs_ss), StringStreamToString(&rhs_ss),
diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h
index 317894e73..e5cfa44c4 100644
--- a/googletest/include/gtest/internal/gtest-internal.h
+++ b/googletest/include/gtest/internal/gtest-internal.h
@@ -58,7 +58,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 

From 6abc9e3d791ecac53361832bc4c14b6203daff4b Mon Sep 17 00:00:00 2001
From: Dino Radakovic 
Date: Mon, 7 Aug 2023 12:44:13 -0700
Subject: [PATCH 239/336] Make references to `#include`s consistent across docs

PiperOrigin-RevId: 554561504
Change-Id: Ia02ab6ac646bf6637d6f500a4aaedd14e0a04798
---
 docs/reference/assertions.md | 2 +-
 docs/reference/mocking.md    | 3 +--
 docs/reference/testing.md    | 2 +-
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/docs/reference/assertions.md b/docs/reference/assertions.md
index aa1dbc04b..492ff5ef6 100644
--- a/docs/reference/assertions.md
+++ b/docs/reference/assertions.md
@@ -1,7 +1,7 @@
 # Assertions Reference
 
 This page lists the assertion macros provided by GoogleTest for verifying code
-behavior. To use them, include the header `gtest/gtest.h`.
+behavior. To use them, add `#include `.
 
 The majority of the macros listed below come as a pair with an `EXPECT_` variant
 and an `ASSERT_` variant. Upon failure, `EXPECT_` macros generate nonfatal
diff --git a/docs/reference/mocking.md b/docs/reference/mocking.md
index e414ffbd0..ab37ebf36 100644
--- a/docs/reference/mocking.md
+++ b/docs/reference/mocking.md
@@ -1,8 +1,7 @@
 # Mocking Reference
 
 This page lists the facilities provided by GoogleTest for creating and working
-with mock objects. To use them, include the header
-`gmock/gmock.h`.
+with mock objects. To use them, add `#include `.
 
 ## Macros {#macros}
 
diff --git a/docs/reference/testing.md b/docs/reference/testing.md
index 17225a682..ead66b362 100644
--- a/docs/reference/testing.md
+++ b/docs/reference/testing.md
@@ -3,7 +3,7 @@
 
 
 This page lists the facilities provided by GoogleTest for writing test programs.
-To use them, include the header `gtest/gtest.h`.
+To use them, add `#include `.
 
 ## Macros
 

From 22eb2de1efab758bebf8e0142fb0c4a999925b3b Mon Sep 17 00:00:00 2001
From: Enji Cooper 
Date: Mon, 7 Aug 2023 20:17:58 -0700
Subject: [PATCH 240/336] Fix GTestHelpTest.TestHelpFlag on FreeBSD

The test supported a variety of BSDs, including kFreeBSD, but not FreeBSD.

Move the BSD checks to a separate function and support checking for
FreeBSD, in addition to kFreeBSD.

Signed-off-by: Enji Cooper 
---
 googletest/test/gtest_help_test.py | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/googletest/test/gtest_help_test.py b/googletest/test/gtest_help_test.py
index 85a0c33c9..a4c7991d0 100755
--- a/googletest/test/gtest_help_test.py
+++ b/googletest/test/gtest_help_test.py
@@ -43,11 +43,21 @@ import sys
 from googletest.test import gtest_test_utils
 
 
+FREEBSD = ('FreeBSD', 'GNU/kFreeBSD')
+NETBSD = ('NetBSD', )
+OPENBSD = ('OpenBSD', )
+
+def is_bsd_based_os() -> bool:
+  """Determine whether or not the OS is BSD-based."""
+  if os.name != 'posix':
+      return False
+
+  return os.uname()[0] in (FREEBSD + NETBSD + OPENBSD)
+
+
 IS_DARWIN = os.name == 'posix' and os.uname()[0] == 'Darwin'
 IS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux'
 IS_GNUHURD = os.name == 'posix' and os.uname()[0] == 'GNU'
-IS_GNUKFREEBSD = os.name == 'posix' and os.uname()[0] == 'GNU/kFreeBSD'
-IS_OPENBSD = os.name == 'posix' and os.uname()[0] == 'OpenBSD'
 IS_WINDOWS = os.name == 'nt'
 
 PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath('gtest_help_test_')
@@ -136,7 +146,7 @@ class GTestHelpTest(gtest_test_utils.TestCase):
 
     self.assertTrue(HELP_REGEX.search(output), output)
 
-    if IS_DARWIN or IS_LINUX or IS_GNUHURD or IS_GNUKFREEBSD or IS_OPENBSD:
+    if IS_DARWIN or IS_LINUX or IS_GNUHURD or is_bsd_based_os():
       self.assertIn(STREAM_RESULT_TO_FLAG, output)
     else:
       self.assertNotIn(STREAM_RESULT_TO_FLAG, output)

From 77485ff0046136f89f14d5e7a51e98849dc00691 Mon Sep 17 00:00:00 2001
From: Enji Cooper 
Date: Mon, 7 Aug 2023 21:36:44 -0700
Subject: [PATCH 241/336] Fix RETest/1.ImplicitConstructorWorks on non-ABSL
 platforms

The last regular expression specified in the test is not technically
POSIX compatible. Use `[[:alnum:]_]` instead of `\w+`; the latter is a
Perl-compatible regular expression.

Signed-off-by: Enji Cooper 
---
 googletest/test/googletest-port-test.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/googletest/test/googletest-port-test.cc b/googletest/test/googletest-port-test.cc
index 32a2a7b4d..e0793bad3 100644
--- a/googletest/test/googletest-port-test.cc
+++ b/googletest/test/googletest-port-test.cc
@@ -418,8 +418,8 @@ TYPED_TEST(RETest, ImplicitConstructorWorks) {
   const RE simple(TypeParam("hello"));
   EXPECT_STREQ("hello", simple.pattern());
 
-  const RE normal(TypeParam(".*(\\w+)"));
-  EXPECT_STREQ(".*(\\w+)", normal.pattern());
+  const RE normal(TypeParam(".*([[:alnum:]_]+)"));
+  EXPECT_STREQ(".*([[:alnum:]_]+)", normal.pattern());
 }
 
 // Tests that RE's constructors reject invalid regular expressions.

From 7e33b6a1c497ced1e98fc60175aeb4678419281c Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Thu, 10 Aug 2023 11:26:23 -0700
Subject: [PATCH 242/336] Specify SetUpTestSuite is required to be public.

PiperOrigin-RevId: 555578256
Change-Id: I9366fc99ae953c29e468fcddb4be203c9c05661b
---
 docs/advanced.md | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/docs/advanced.md b/docs/advanced.md
index 3871db13b..344d5418b 100644
--- a/docs/advanced.md
+++ b/docs/advanced.md
@@ -899,10 +899,10 @@ also supports per-test-suite set-up/tear-down. To use it:
     variables to hold the shared resources.
 2.  Outside your test fixture class (typically just below it), define those
     member variables, optionally giving them initial values.
-3.  In the same test fixture class, define a `static void SetUpTestSuite()`
-    function (remember not to spell it as **`SetupTestSuite`** with a small
-    `u`!) to set up the shared resources and a `static void TearDownTestSuite()`
-    function to tear them down.
+3.  In the same test fixture class, define a public member function `static void
+    SetUpTestSuite()` (remember not to spell it as **`SetupTestSuite`** with a
+    small `u`!) to set up the shared resources and a `static void
+    TearDownTestSuite()` function to tear them down.
 
 That's it! GoogleTest automatically calls `SetUpTestSuite()` before running the
 *first test* in the `FooTest` test suite (i.e. before creating the first

From 619601c5e26eb0cc763082e026b130a35e63deba Mon Sep 17 00:00:00 2001
From: sthd 
Date: Fri, 11 Aug 2023 11:01:14 +0300
Subject: [PATCH 243/336] Changed 3 public links from http to https

---
 README.md | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index 1bca4d1ff..111801eab 100644
--- a/README.md
+++ b/README.md
@@ -100,12 +100,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
+*   The [Chromium projects](https://www.chromium.org/) (behind the Chrome browser
     and Chrome OS).
-*   The [LLVM](http://llvm.org/) compiler.
+*   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
 

From 622ee5cf2998a6b2c2f24a95069e2748b26c4a2c Mon Sep 17 00:00:00 2001
From: sthd 
Date: Fri, 11 Aug 2023 11:06:25 +0300
Subject: [PATCH 244/336] Changed 2 public links from http to https

---
 CONTRIBUTING.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 8bed14b26..93d8b2fd1 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -47,9 +47,9 @@ 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
+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.

From 5b5ef299500701c9d0df782c7432219f8d97f8cc Mon Sep 17 00:00:00 2001
From: sthd 
Date: Fri, 11 Aug 2023 11:21:47 +0300
Subject: [PATCH 245/336] Changed 3 public links from http to https

---
 docs/faq.md | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/docs/faq.md b/docs/faq.md
index 192809729..90c249781 100644
--- a/docs/faq.md
+++ b/docs/faq.md
@@ -607,7 +607,7 @@ defined such that we can print a value of `FooType`.
 
 In addition, if `FooType` is declared in a name space, the `<<` operator also
 needs to be defined in the *same* name space. See
-[Tip of the Week #49](http://abseil.io/tips/49) for details.
+[Tip of the Week #49](https://abseil.io/tips/49) for details.
 
 ## How do I suppress the memory leak messages on Windows?
 
@@ -628,10 +628,10 @@ mistake in production. Such cleverness also leads to
 advise against the practice, and GoogleTest doesn't provide a way to do it.
 
 In general, the recommended way to cause the code to behave differently under
-test is [Dependency Injection](http://en.wikipedia.org/wiki/Dependency_injection). You can inject
+test is [Dependency Injection](https://en.wikipedia.org/wiki/Dependency_injection). You can inject
 different functionality from the test and from the production code. Since your
 production code doesn't link in the for-test logic at all (the
-[`testonly`](http://docs.bazel.build/versions/master/be/common-definitions.html#common.testonly) attribute for BUILD targets helps to ensure
+[`testonly`](https://docs.bazel.build/versions/master/be/common-definitions.html#common.testonly) attribute for BUILD targets helps to ensure
 that), there is no danger in accidentally running it.
 
 However, if you *really*, *really*, *really* have no choice, and if you follow

From 8ca57f194af05c0f5211e8d5d350c871b0551612 Mon Sep 17 00:00:00 2001
From: sthd 
Date: Fri, 11 Aug 2023 11:26:59 +0300
Subject: [PATCH 246/336] Changed 2 public links from http to https

---
 docs/advanced.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/docs/advanced.md b/docs/advanced.md
index 344d5418b..2a7c48275 100644
--- a/docs/advanced.md
+++ b/docs/advanced.md
@@ -508,9 +508,9 @@ TEST_F(FooDeathTest, DoesThat) {
 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](http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html#tag_09_04)
+[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](http://en.wikipedia.org/wiki/Regular_expression#POSIX_extended).
+[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

From d76e9e0dd93a9921e4054c71f23e7c8fa8da864d Mon Sep 17 00:00:00 2001
From: Dino Radakovic 
Date: Tue, 15 Aug 2023 06:42:01 -0700
Subject: [PATCH 247/336] gtest_help_test: Delete obsolete helper
 `TestUnknownFlagWithAbseil`

PiperOrigin-RevId: 557116814
Change-Id: I91e06b0d6001952366c50201b67491475a1f98af
---
 googletest/test/gtest_help_test.py | 13 -------------
 1 file changed, 13 deletions(-)

diff --git a/googletest/test/gtest_help_test.py b/googletest/test/gtest_help_test.py
index 85a0c33c9..a76f220ca 100755
--- a/googletest/test/gtest_help_test.py
+++ b/googletest/test/gtest_help_test.py
@@ -146,19 +146,6 @@ class GTestHelpTest(gtest_test_utils.TestCase):
     else:
       self.assertNotIn(DEATH_TEST_STYLE_FLAG, output)
 
-  def TestUnknownFlagWithAbseil(self, flag):
-    """Verifies correct behavior when an unknown flag is specified.
-
-    The right message must be printed and the tests must
-    skipped when the given flag is specified.
-
-    Args:
-      flag:  A flag to pass to the binary or None.
-    """
-    exit_code, output = RunWithFlag(flag)
-    self.assertEqual(1, exit_code)
-    self.assertIn('ERROR: Unknown command line flag', output)
-
   def TestNonHelpFlag(self, flag):
     """Verifies correct behavior when no help flag is specified.
 

From 6513d0272d8bd2062cf4549fe2b0adb1fc862486 Mon Sep 17 00:00:00 2001
From: Dino Radakovic 
Date: Tue, 15 Aug 2023 07:11:18 -0700
Subject: [PATCH 248/336] gtest_help_test: Inline test helper functions

`TestNonHelpFlag` is only a few asserts with no logic, which is easier to read in line, and helper `TestHelpFlag` is used in a single test case.

PiperOrigin-RevId: 557122793
Change-Id: I7367424abfbb883c10c260fae066a2071e5dfa0e
---
 googletest/test/gtest_help_test.py | 32 ++++++++----------------------
 1 file changed, 8 insertions(+), 24 deletions(-)

diff --git a/googletest/test/gtest_help_test.py b/googletest/test/gtest_help_test.py
index a76f220ca..3f7849605 100755
--- a/googletest/test/gtest_help_test.py
+++ b/googletest/test/gtest_help_test.py
@@ -116,17 +116,14 @@ def RunWithFlag(flag):
 class GTestHelpTest(gtest_test_utils.TestCase):
   """Tests the --help flag and its equivalent forms."""
 
-  def TestHelpFlag(self, flag):
+  def testPrintsHelpWithFullFlag(self):
     """Verifies correct behavior when help flag is specified.
 
     The right message must be printed and the tests must
     skipped when the given flag is specified.
-
-    Args:
-      flag:  A flag to pass to the binary or None.
     """
 
-    exit_code, output = RunWithFlag(flag)
+    exit_code, output = RunWithFlag('--help')
     if HAS_ABSL_FLAGS:
       # The Abseil flags library prints the ProgramUsageMessage() with
       # --help and returns 1.
@@ -146,23 +143,6 @@ class GTestHelpTest(gtest_test_utils.TestCase):
     else:
       self.assertNotIn(DEATH_TEST_STYLE_FLAG, output)
 
-  def TestNonHelpFlag(self, flag):
-    """Verifies correct behavior when no help flag is specified.
-
-    Verifies that when no help flag is specified, the tests are run
-    and the help message is not printed.
-
-    Args:
-      flag:  A flag to pass to the binary or None.
-    """
-
-    exit_code, output = RunWithFlag(flag)
-    self.assertNotEqual(exit_code, 0)
-    self.assertFalse(HELP_REGEX.search(output), output)
-
-  def testPrintsHelpWithFullFlag(self):
-    self.TestHelpFlag('--help')
-
   def testRunsTestsWithoutHelpFlag(self):
     """Verifies correct behavior when no help flag is specified.
 
@@ -170,7 +150,9 @@ class GTestHelpTest(gtest_test_utils.TestCase):
     and the help message is not printed.
     """
 
-    self.TestNonHelpFlag(None)
+    exit_code, output = RunWithFlag(None)
+    self.assertNotEqual(exit_code, 0)
+    self.assertFalse(HELP_REGEX.search(output), output)
 
   def testRunsTestsWithGtestInternalFlag(self):
     """Verifies correct behavior when internal testing flag is specified.
@@ -179,7 +161,9 @@ class GTestHelpTest(gtest_test_utils.TestCase):
     a flag starting with Google Test prefix and 'internal_' is supplied.
     """
 
-    self.TestNonHelpFlag(INTERNAL_FLAG_FOR_TESTING)
+    exit_code, output = RunWithFlag(INTERNAL_FLAG_FOR_TESTING)
+    self.assertNotEqual(exit_code, 0)
+    self.assertFalse(HELP_REGEX.search(output), output)
 
 
 if __name__ == '__main__':

From dd9a9569041c1551613d116ff0d092b356c836b1 Mon Sep 17 00:00:00 2001
From: Dino Radakovic 
Date: Tue, 15 Aug 2023 07:59:51 -0700
Subject: [PATCH 249/336] gtest_help_test: Make method names `snake_case`,
 conforming with [the style
 guide](https://google.github.io/styleguide/pyguide#316-naming)

PiperOrigin-RevId: 557133618
Change-Id: I27202ee91ee81b3d2e4c28102190d2bde8efba05
---
 googletest/test/gtest_help_test.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/googletest/test/gtest_help_test.py b/googletest/test/gtest_help_test.py
index 3f7849605..b3b740d96 100755
--- a/googletest/test/gtest_help_test.py
+++ b/googletest/test/gtest_help_test.py
@@ -96,7 +96,7 @@ HELP_REGEX = re.compile(
 )
 
 
-def RunWithFlag(flag):
+def run_with_flag(flag):
   """Runs gtest_help_test_ with the given flag.
 
   Returns:
@@ -116,14 +116,14 @@ def RunWithFlag(flag):
 class GTestHelpTest(gtest_test_utils.TestCase):
   """Tests the --help flag and its equivalent forms."""
 
-  def testPrintsHelpWithFullFlag(self):
+  def test_prints_help_with_full_flag(self):
     """Verifies correct behavior when help flag is specified.
 
     The right message must be printed and the tests must
     skipped when the given flag is specified.
     """
 
-    exit_code, output = RunWithFlag('--help')
+    exit_code, output = run_with_flag('--help')
     if HAS_ABSL_FLAGS:
       # The Abseil flags library prints the ProgramUsageMessage() with
       # --help and returns 1.
@@ -143,25 +143,25 @@ class GTestHelpTest(gtest_test_utils.TestCase):
     else:
       self.assertNotIn(DEATH_TEST_STYLE_FLAG, output)
 
-  def testRunsTestsWithoutHelpFlag(self):
+  def test_runs_tests_without_help_flag(self):
     """Verifies correct behavior when no help flag is specified.
 
     Verifies that when no help flag is specified, the tests are run
     and the help message is not printed.
     """
 
-    exit_code, output = RunWithFlag(None)
+    exit_code, output = run_with_flag(None)
     self.assertNotEqual(exit_code, 0)
     self.assertFalse(HELP_REGEX.search(output), output)
 
-  def testRunsTestsWithGtestInternalFlag(self):
+  def test_runs_tests_with_gtest_internal_flag(self):
     """Verifies correct behavior when internal testing flag is specified.
 
     Verifies that the tests are run and no help message is printed when
     a flag starting with Google Test prefix and 'internal_' is supplied.
     """
 
-    exit_code, output = RunWithFlag(INTERNAL_FLAG_FOR_TESTING)
+    exit_code, output = run_with_flag(INTERNAL_FLAG_FOR_TESTING)
     self.assertNotEqual(exit_code, 0)
     self.assertFalse(HELP_REGEX.search(output), output)
 

From e24cced08d658222c903b36c713d2265e3e83345 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Patryk=20Gawro=C5=84ski?= 
Date: Wed, 26 Jul 2023 00:58:06 +0200
Subject: [PATCH 250/336] googletest: ansi color fix

Adds prevents from returning
nullptr by choosing default color.

Issue: #4321
---
 googletest/src/gtest.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 30a5cc3f8..e56ee1a17 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -3228,7 +3228,8 @@ static const char* GetAnsiColorCode(GTestColor color) {
     case GTestColor::kYellow:
       return "3";
     default:
-      return nullptr;
+      assert(false);
+      return "9" ;
   }
 }
 

From f42da0e4431a14260946323bff4d856f20973b2c Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Thu, 17 Aug 2023 12:55:43 -0700
Subject: [PATCH 251/336] Improve error message for invalid parameterized test
 names.

PiperOrigin-RevId: 557910190
Change-Id: Ia965a6c96e4cc5997d8af2611abc62c42e81653e
---
 googletest/include/gtest/internal/gtest-param-util.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/googletest/include/gtest/internal/gtest-param-util.h b/googletest/include/gtest/internal/gtest-param-util.h
index 6a81c37fa..dd39e98a1 100644
--- a/googletest/include/gtest/internal/gtest-param-util.h
+++ b/googletest/include/gtest/internal/gtest-param-util.h
@@ -584,7 +584,9 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
 
           GTEST_CHECK_(IsValidParamName(param_name))
               << "Parameterized test name '" << param_name
-              << "' is invalid, in " << file << " line " << line << std::endl;
+              << "' is invalid (contains spaces, dashes, underscores, or "
+                 "non-alphanumeric characters), in "
+              << file << " line " << line << "" << std::endl;
 
           GTEST_CHECK_(test_param_names.count(param_name) == 0)
               << "Duplicate parameterized test name '" << param_name << "', in "

From 14d05f4708c97d1efc0db917dd32ef2f2013686a Mon Sep 17 00:00:00 2001
From: Tanzinul Islam 
Date: Fri, 18 Aug 2023 19:44:48 +0100
Subject: [PATCH 252/336] Prefer $TMPDIR to /data/local/tmp on Android

Newer devices can have the latter location read-only. (I observed this with Termux on a non-rooted Pixel 6.)
---
 googletest/src/gtest-port.cc | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc
index 2aaf2bcc2..589ace5e7 100644
--- a/googletest/src/gtest-port.cc
+++ b/googletest/src/gtest-port.cc
@@ -1064,7 +1064,13 @@ class CapturedStream {
     // The location /data/local/tmp is directly accessible from native code.
     // '/sdcard' and other variants cannot be relied on, as they are not
     // guaranteed to be mounted, or may have a delay in mounting.
-    name_template = "/data/local/tmp/";
+    //
+    // However, prefer using the TMPDIR environment variable if set, as newer
+    // devices may have /data/local/tmp read-only.
+    if (auto tmpdir = ::getenv("TMPDIR"))
+      name_template.assign(tmpdir) += '/';
+    else
+      name_template = "/data/local/tmp/";
 #elif defined(GTEST_OS_IOS)
     char user_temp_dir[PATH_MAX + 1];
 

From 722daa3da6e2864afdb6fe5b2bf03a5989c01a5c Mon Sep 17 00:00:00 2001
From: Elior Schneider 
Date: Sun, 20 Aug 2023 09:38:57 +0300
Subject: [PATCH 253/336] Update advanced.md

http to https
---
 docs/advanced.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/advanced.md b/docs/advanced.md
index 2a7c48275..0e1f812b9 100644
--- a/docs/advanced.md
+++ b/docs/advanced.md
@@ -2171,7 +2171,7 @@ The report format conforms to the following JSON Schema:
 
 ```json
 {
-  "$schema": "http://json-schema.org/schema#",
+  "$schema": "https://json-schema.org/schema#",
   "type": "object",
   "definitions": {
     "TestCase": {

From 762d3a7f6681ec2f0882f79ce89da11589cac91b Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Mon, 21 Aug 2023 08:47:04 -0700
Subject: [PATCH 254/336] Clean up typos: Exhaused => Exhausted

PiperOrigin-RevId: 558801066
Change-Id: Ia225d12014748db87639414f4c8c28a0d0e9e489
---
 googlemock/test/gmock-spec-builders_test.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/googlemock/test/gmock-spec-builders_test.cc b/googlemock/test/gmock-spec-builders_test.cc
index 221de2d20..aaf88d74e 100644
--- a/googlemock/test/gmock-spec-builders_test.cc
+++ b/googlemock/test/gmock-spec-builders_test.cc
@@ -906,7 +906,7 @@ TEST(ExpectCallTest, TakesDefaultActionWhenWillListIsExhausted) {
                         " - returning default value."));
 }
 
-TEST(FunctionMockerMessageTest, ReportsExpectCallLocationForExhausedActions) {
+TEST(FunctionMockerMessageTest, ReportsExpectCallLocationForExhaustedActions) {
   MockB b;
   std::string expect_call_location = FormatFileLocation(__FILE__, __LINE__ + 1);
   EXPECT_CALL(b, DoB()).Times(AnyNumber()).WillOnce(Return(1));

From 61332bd7e8810edd7ff9febfa71ece2e25b18df0 Mon Sep 17 00:00:00 2001
From: Derek Mauro 
Date: Mon, 21 Aug 2023 09:49:59 -0700
Subject: [PATCH 255/336] CI: Update the Linux hybrid-latest docker container
 used for testing

The following are the major updates
  * LLVM 17 branch (https://github.com/llvm/llvm-project b744f4c99cf91155c74a3c92db6f1335232ff3d)
  * GCC 13.2
  * CMake 3.27.1
  * Bazel 6.2.1

PiperOrigin-RevId: 558818264
Change-Id: Ib08d8331e2a8b2d68a702670451beaaac5d266f4
---
 ci/linux-presubmit.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ci/linux-presubmit.sh b/ci/linux-presubmit.sh
index 6bac88787..a1caa2720 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:20230217"
+readonly LINUX_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20230816"
 readonly LINUX_GCC_FLOOR_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-floor:20230120"
 
 if [[ -z ${GTEST_ROOT:-} ]]; then

From c374da15c57ba6056fedd34c68442f3e2a20c1d7 Mon Sep 17 00:00:00 2001
From: Dino Radakovic 
Date: Tue, 22 Aug 2023 09:20:18 -0700
Subject: [PATCH 256/336] googletest: Replace http with https in links to docs

This is a prerequisite for #4341

PiperOrigin-RevId: 559132807
Change-Id: Iadc961913e0ff107c5333dae17be5f8638663836
---
 docs/faq.md               | 6 +++---
 docs/gmock_for_dummies.md | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/docs/faq.md b/docs/faq.md
index 192809729..90c249781 100644
--- a/docs/faq.md
+++ b/docs/faq.md
@@ -607,7 +607,7 @@ defined such that we can print a value of `FooType`.
 
 In addition, if `FooType` is declared in a name space, the `<<` operator also
 needs to be defined in the *same* name space. See
-[Tip of the Week #49](http://abseil.io/tips/49) for details.
+[Tip of the Week #49](https://abseil.io/tips/49) for details.
 
 ## How do I suppress the memory leak messages on Windows?
 
@@ -628,10 +628,10 @@ mistake in production. Such cleverness also leads to
 advise against the practice, and GoogleTest doesn't provide a way to do it.
 
 In general, the recommended way to cause the code to behave differently under
-test is [Dependency Injection](http://en.wikipedia.org/wiki/Dependency_injection). You can inject
+test is [Dependency Injection](https://en.wikipedia.org/wiki/Dependency_injection). You can inject
 different functionality from the test and from the production code. Since your
 production code doesn't link in the for-test logic at all (the
-[`testonly`](http://docs.bazel.build/versions/master/be/common-definitions.html#common.testonly) attribute for BUILD targets helps to ensure
+[`testonly`](https://docs.bazel.build/versions/master/be/common-definitions.html#common.testonly) attribute for BUILD targets helps to ensure
 that), there is no danger in accidentally running it.
 
 However, if you *really*, *really*, *really* have no choice, and if you follow
diff --git a/docs/gmock_for_dummies.md b/docs/gmock_for_dummies.md
index 43f907aaa..06c87256c 100644
--- a/docs/gmock_for_dummies.md
+++ b/docs/gmock_for_dummies.md
@@ -97,7 +97,7 @@ tests like this are expensive to run and fragile (What if you just upgraded to a
 shiny new graphics card that has better anti-aliasing? Suddenly you have to
 update all your golden images.). It would be too painful if all your tests are
 like this. Fortunately, you learned about
-[Dependency Injection](http://en.wikipedia.org/wiki/Dependency_injection) and know the right thing
+[Dependency Injection](https://en.wikipedia.org/wiki/Dependency_injection) and know the right thing
 to do: instead of having your application talk to the system API directly, wrap
 the API in an interface (say, `Turtle`) and code to that interface:
 

From f0eae4b3995b77cfbb49cc91f98da5d1f3c4fe05 Mon Sep 17 00:00:00 2001
From: sthd 
Date: Tue, 22 Aug 2023 20:58:34 +0300
Subject: [PATCH 257/336] changed http to https

---
 docs/gmock_for_dummies.md                          |  2 +-
 docs/primer.md                                     |  8 ++++----
 googlemock/README.md                               |  8 ++++----
 googlemock/src/gmock-matchers.cc                   |  2 +-
 googletest/README.md                               |  2 +-
 googletest/cmake/internal_utils.cmake              |  2 +-
 googletest/include/gtest/internal/gtest-internal.h | 10 +++++-----
 googletest/include/gtest/internal/gtest-port.h     |  2 +-
 googletest/src/gtest-death-test.cc                 |  2 +-
 googletest/src/gtest-internal-inl.h                |  2 +-
 googletest/src/gtest.cc                            |  2 +-
 11 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/docs/gmock_for_dummies.md b/docs/gmock_for_dummies.md
index 06c87256c..9f24dcae5 100644
--- a/docs/gmock_for_dummies.md
+++ b/docs/gmock_for_dummies.md
@@ -90,7 +90,7 @@ gMock is bundled with googletest.
 ## A Case for Mock Turtles
 
 Let's look at an example. Suppose you are developing a graphics program that
-relies on a [LOGO](http://en.wikipedia.org/wiki/Logo_programming_language)-like
+relies on a [LOGO](https://en.wikipedia.org/wiki/Logo_programming_language)-like
 API for drawing. How would you test that it does the right thing? Well, you can
 run it and compare the screen with a golden screen snapshot, but let's admit it:
 tests like this are expensive to run and fragile (What if you just upgraded to a
diff --git a/docs/primer.md b/docs/primer.md
index f2a97a726..4901e1ab0 100644
--- a/docs/primer.md
+++ b/docs/primer.md
@@ -50,7 +50,7 @@ terms *Test*, *Test Case* and *Test Suite*, so beware of misunderstanding these.
 
 Historically, GoogleTest started to use the term *Test Case* for grouping
 related tests, whereas current publications, including International Software
-Testing Qualifications Board ([ISTQB](http://www.istqb.org/)) materials and
+Testing Qualifications Board ([ISTQB](https://www.istqb.org/)) materials and
 various textbooks on software quality, use the term
 *[Test Suite][istqb test suite]* for this.
 
@@ -68,13 +68,13 @@ deprecated and refactored away.
 So please be aware of the different definitions of the terms:
 
 
-Meaning                                                                              | GoogleTest Term         | [ISTQB](http://www.istqb.org/) Term
+Meaning                                                                              | GoogleTest Term         | [ISTQB](https://www.istqb.org/) Term
 :----------------------------------------------------------------------------------- | :---------------------- | :----------------------------------
 Exercise a particular program path with specific input values and verify the results | [TEST()](#simple-tests) | [Test Case][istqb test case]
 
 
-[istqb test case]: http://glossary.istqb.org/en/search/test%20case
-[istqb test suite]: http://glossary.istqb.org/en/search/test%20suite
+[istqb test case]: https://glossary.istqb.org/en/search/test%20case
+[istqb test suite]: https://glossary.istqb.org/en/search/test%20suite
 
 ## Basic Concepts
 
diff --git a/googlemock/README.md b/googlemock/README.md
index 7da60655d..9a6dea300 100644
--- a/googlemock/README.md
+++ b/googlemock/README.md
@@ -7,9 +7,9 @@ derive better designs of your system and write better tests.
 
 It is inspired by:
 
-*   [jMock](http://www.jmock.org/)
-*   [EasyMock](http://www.easymock.org/)
-*   [Hamcrest](http://code.google.com/p/hamcrest/)
+*   [jMock](https://www.jmock.org/)
+*   [EasyMock](https://www.easymock.org/)
+*   [Hamcrest](https://code.google.com/p/hamcrest/)
 
 It is designed with C++'s specifics in mind.
 
@@ -36,5 +36,5 @@ Details and examples can be found here:
 *   [gMock Cheat Sheet](https://google.github.io/googletest/gmock_cheat_sheet.html)
 
 GoogleMock is a part of
-[GoogleTest C++ testing framework](http://github.com/google/googletest/) and a
+[GoogleTest C++ testing framework](https://github.com/google/googletest/) and a
 subject to the same requirements.
diff --git a/googlemock/src/gmock-matchers.cc b/googlemock/src/gmock-matchers.cc
index 07bba4f01..81a5b7ea5 100644
--- a/googlemock/src/gmock-matchers.cc
+++ b/googlemock/src/gmock-matchers.cc
@@ -120,7 +120,7 @@ GTEST_API_ std::string FormatMatcherDescription(
 //   [1] Cormen, et al (2001). "Section 26.2: The Ford-Fulkerson method".
 //       "Introduction to Algorithms (Second ed.)", pp. 651-664.
 //   [2] "Ford-Fulkerson algorithm", Wikipedia,
-//       'http://en.wikipedia.org/wiki/Ford%E2%80%93Fulkerson_algorithm'
+//       'https://en.wikipedia.org/wiki/Ford%E2%80%93Fulkerson_algorithm'
 class MaxBipartiteMatchState {
  public:
   explicit MaxBipartiteMatchState(const MatchMatrix& graph)
diff --git a/googletest/README.md b/googletest/README.md
index 9331fce3b..140a057ae 100644
--- a/googletest/README.md
+++ b/googletest/README.md
@@ -12,7 +12,7 @@ GoogleTest comes with a CMake build script
 ([CMakeLists.txt](https://github.com/google/googletest/blob/main/CMakeLists.txt))
 that can be used on a wide range of platforms ("C" stands for cross-platform.).
 If you don't have CMake installed already, you can download it for free from
-.
+.
 
 CMake works by generating native makefiles or build projects that can be used in
 the compiler environment of your choice. You can either build GoogleTest as a
diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake
index 64fa340fd..d4f67f43a 100644
--- a/googletest/cmake/internal_utils.cmake
+++ b/googletest/cmake/internal_utils.cmake
@@ -80,7 +80,7 @@ macro(config_compiler_and_linker)
     set(cxx_no_exception_flags "-EHs-c- -D_HAS_EXCEPTIONS=0")
     set(cxx_no_rtti_flags "-GR-")
     # Suppress "unreachable code" warning
-    # http://stackoverflow.com/questions/3232669 explains the issue.
+    # https://stackoverflow.com/questions/3232669 explains the issue.
     set(cxx_base_flags "${cxx_base_flags} -wd4702")
     # Ensure MSVC treats source files as UTF-8 encoded.
     if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h
index 97a983393..4f077fcfb 100644
--- a/googletest/include/gtest/internal/gtest-internal.h
+++ b/googletest/include/gtest/internal/gtest-internal.h
@@ -78,7 +78,7 @@
 //
 // will result in the token foo__LINE__, instead of foo followed by
 // the current line number.  For more details, see
-// http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.6
+// https://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.6
 #define GTEST_CONCAT_TOKEN_(foo, bar) GTEST_CONCAT_TOKEN_IMPL_(foo, bar)
 #define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo##bar
 
@@ -169,7 +169,7 @@ namespace edit_distance {
 // All edits cost the same, with replace having lower priority than
 // add/remove.
 // Simple implementation of the Wagner-Fischer algorithm.
-// See http://en.wikipedia.org/wiki/Wagner-Fischer_algorithm
+// See https://en.wikipedia.org/wiki/Wagner-Fischer_algorithm
 enum EditType { kMatch, kAdd, kRemove, kReplace };
 GTEST_API_ std::vector CalculateOptimalEdits(
     const std::vector& left, const std::vector& right);
@@ -236,7 +236,7 @@ GTEST_API_ std::string GetBoolAssertionFailureMessage(
 //   For double, there are 11 exponent bits and 52 fraction bits.
 //
 //   More details can be found at
-//   http://en.wikipedia.org/wiki/IEEE_floating-point_standard.
+//   https://en.wikipedia.org/wiki/IEEE_floating-point_standard.
 //
 // Template parameter:
 //
@@ -281,7 +281,7 @@ class FloatingPoint {
   // bits.  Therefore, 4 should be enough for ordinary use.
   //
   // See the following article for more details on ULP:
-  // http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
+  // https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
   static const uint32_t kMaxUlps = 4;
 
   // Constructs a FloatingPoint from a raw floating-point number.
@@ -362,7 +362,7 @@ class FloatingPoint {
   //   N - 1  (the biggest number representable using
   //          sign-and-magnitude) is represented by 2N - 1.
   //
-  // Read http://en.wikipedia.org/wiki/Signed_number_representations
+  // Read https://en.wikipedia.org/wiki/Signed_number_representations
   // for more details on signed number representations.
   static Bits SignAndMagnitudeToBiased(const Bits& sam) {
     if (kSignBitMask & sam) {
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index b887e24ed..b5570b8bc 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -609,7 +609,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
 // Determines whether clone(2) is supported.
 // Usually it will only be available on Linux, excluding
 // Linux on the Itanium architecture.
-// Also see http://linux.die.net/man/2/clone.
+// Also see https://linux.die.net/man/2/clone.
 #ifndef GTEST_HAS_CLONE
 // The user didn't tell us, so we need to figure it out.
 
diff --git a/googletest/src/gtest-death-test.cc b/googletest/src/gtest-death-test.cc
index 0eb6e38b2..8417a300f 100644
--- a/googletest/src/gtest-death-test.cc
+++ b/googletest/src/gtest-death-test.cc
@@ -783,7 +783,7 @@ DeathTest::TestRole WindowsDeathTest::AssumeRole() {
       StreamableToString(static_cast(::GetCurrentProcessId())) +
       // size_t has the same width as pointers on both 32-bit and 64-bit
       // Windows platforms.
-      // See http://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx.
+      // See https://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx.
       "|" + StreamableToString(reinterpret_cast(write_handle)) + "|" +
       StreamableToString(reinterpret_cast(event_handle_.Get()));
 
diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h
index 5b7fcbd06..4799a1e7b 100644
--- a/googletest/src/gtest-internal-inl.h
+++ b/googletest/src/gtest-internal-inl.h
@@ -312,7 +312,7 @@ void ShuffleRange(internal::Random* random, int begin, int end,
       << begin << ", " << size << "].";
 
   // Fisher-Yates shuffle, from
-  // http://en.wikipedia.org/wiki/Fisher-Yates_shuffle
+  // https://en.wikipedia.org/wiki/Fisher-Yates_shuffle
   for (int range_width = end - begin; range_width >= 2; range_width--) {
     const int last_in_range = begin + range_width - 1;
     const int selected =
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 66a315e51..62dfef664 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -879,7 +879,7 @@ int UnitTestOptions::GTestProcessSEH(DWORD seh_code, const char* location) {
   //      apparently).
   //
   // SEH exception code for C++ exceptions.
-  // (see http://support.microsoft.com/kb/185294 for more information).
+  // (see https://support.microsoft.com/kb/185294 for more information).
   const DWORD kCxxExceptionCode = 0xe06d7363;
 
   if (!GTEST_FLAG_GET(catch_exceptions) || seh_code == kCxxExceptionCode ||

From 8a6feabf04bec8fb125e0df0ad1195c42350725f Mon Sep 17 00:00:00 2001
From: Dino Radakovic 
Date: Fri, 25 Aug 2023 07:45:33 -0700
Subject: [PATCH 258/336] googletest: Add universal printer for `std::span`

Fixes #4318

PiperOrigin-RevId: 560089120
Change-Id: I9d0d098140033520266747a1689e953ee8307c47
---
 googletest/include/gtest/gtest-printers.h     | 27 +++++++++++++++++--
 .../include/gtest/internal/gtest-port.h       | 12 +++++++++
 googletest/test/googletest-printers-test.cc   | 16 +++++++++++
 3 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h
index d1766e640..9ccbff7da 100644
--- a/googletest/include/gtest/gtest-printers.h
+++ b/googletest/include/gtest/gtest-printers.h
@@ -122,6 +122,10 @@
 #include "gtest/internal/gtest-internal.h"
 #include "gtest/internal/gtest-port.h"
 
+#if GTEST_INTERNAL_HAS_STD_SPAN
+#include   // NOLINT
+#endif  // GTEST_INTERNAL_HAS_STD_SPAN
+
 namespace testing {
 
 // Definitions in the internal* namespaces are subject to change without notice.
@@ -131,13 +135,32 @@ namespace internal {
 template 
 void UniversalPrint(const T& value, ::std::ostream* os);
 
+template 
+struct IsStdSpan {
+  static constexpr bool value = false;
+};
+
+#if GTEST_INTERNAL_HAS_STD_SPAN
+template 
+struct IsStdSpan> {
+  static constexpr bool value = true;
+};
+#endif  // GTEST_INTERNAL_HAS_STD_SPAN
+
 // Used to print an STL-style container when the user doesn't define
 // a PrintTo() for it.
+//
+// NOTE: Since std::span does not have const_iterator until C++23, it would
+// fail IsContainerTest before C++23. However, IsContainerTest only uses
+// the presence of const_iterator to avoid treating iterators as containers
+// because of iterator::iterator. Which means std::span satisfies the *intended*
+// condition of IsContainerTest.
 struct ContainerPrinter {
   template (0)) == sizeof(IsContainer)) &&
-                !IsRecursiveContainer::value>::type>
+                ((sizeof(IsContainerTest(0)) == sizeof(IsContainer)) &&
+                 !IsRecursiveContainer::value) ||
+                IsStdSpan::value>::type>
   static void PrintValue(const T& container, std::ostream* os) {
     const size_t kMaxCount = 32;  // The maximum number of elements to print.
     *os << '{';
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index b5570b8bc..35544a08a 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -208,6 +208,8 @@
 //   or
 //                                 UniversalPrinter
 //                                 specializations. Always defined to 0 or 1.
+//   GTEST_INTERNAL_HAS_STD_SPAN - for enabling UniversalPrinter
+//                                 specializations. Always defined to 0 or 1
 //   GTEST_INTERNAL_HAS_STRING_VIEW - for enabling Matcher or
 //                                    Matcher
 //                                    specializations. Always defined to 0 or 1.
@@ -2407,6 +2409,16 @@ inline ::std::nullopt_t Nullopt() { return ::std::nullopt; }
 #define GTEST_INTERNAL_HAS_OPTIONAL 0
 #endif
 
+#ifdef __has_include
+#if __has_include() && GTEST_INTERNAL_CPLUSPLUS_LANG >= 202002L
+#define GTEST_INTERNAL_HAS_STD_SPAN 1
+#endif  // __has_include() && GTEST_INTERNAL_CPLUSPLUS_LANG >= 202002L
+#endif  // __has_include
+
+#ifndef GTEST_INTERNAL_HAS_STD_SPAN
+#define GTEST_INTERNAL_HAS_STD_SPAN 0
+#endif
+
 #ifdef GTEST_HAS_ABSL
 // Always use absl::string_view for Matcher<> specializations if googletest
 // is built with absl support.
diff --git a/googletest/test/googletest-printers-test.cc b/googletest/test/googletest-printers-test.cc
index bee0ca4ab..d5061bef2 100644
--- a/googletest/test/googletest-printers-test.cc
+++ b/googletest/test/googletest-printers-test.cc
@@ -54,11 +54,16 @@
 
 #include "gtest/gtest-printers.h"
 #include "gtest/gtest.h"
+#include "gtest/internal/gtest-port.h"
 
 #ifdef GTEST_HAS_ABSL
 #include "absl/strings/str_format.h"
 #endif
 
+#if GTEST_INTERNAL_HAS_STD_SPAN
+#include   // NOLINT
+#endif  // GTEST_INTERNAL_HAS_STD_SPAN
+
 // Some user-defined types for testing the universal value printer.
 
 // An anonymous enum type.
@@ -1179,6 +1184,17 @@ TEST(PrintStlContainerTest, Vector) {
   EXPECT_EQ("{ 1, 2 }", Print(v));
 }
 
+TEST(PrintStlContainerTest, StdSpan) {
+#if GTEST_INTERNAL_HAS_STD_SPAN
+  int a[] = {3, 6, 5};
+  std::span s = a;
+
+  EXPECT_EQ("{ 3, 6, 5 }", Print(s));
+#else
+  GTEST_SKIP() << "Does not have std::span.";
+#endif  // GTEST_INTERNAL_HAS_STD_SPAN
+}
+
 TEST(PrintStlContainerTest, LongSequence) {
   const int a[100] = {1, 2, 3};
   const vector v(a, a + 100);

From edf9b4964d28f0f18552ff39c8f182b7903e19e3 Mon Sep 17 00:00:00 2001
From: Tanzinul Islam 
Date: Sat, 26 Aug 2023 08:53:45 +0100
Subject: [PATCH 259/336] Reuse TempDir() function

---
 googletest/src/gtest-port.cc | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc
index 589ace5e7..628ab3dbf 100644
--- a/googletest/src/gtest-port.cc
+++ b/googletest/src/gtest-port.cc
@@ -1067,10 +1067,7 @@ class CapturedStream {
     //
     // However, prefer using the TMPDIR environment variable if set, as newer
     // devices may have /data/local/tmp read-only.
-    if (auto tmpdir = ::getenv("TMPDIR"))
-      name_template.assign(tmpdir) += '/';
-    else
-      name_template = "/data/local/tmp/";
+    name_template = TempDir();
 #elif defined(GTEST_OS_IOS)
     char user_temp_dir[PATH_MAX + 1];
 

From b86bf840d1d562d12efd4e0790ce14455f5fa271 Mon Sep 17 00:00:00 2001
From: Tanzinul Islam 
Date: Sun, 3 Sep 2023 15:39:19 +0100
Subject: [PATCH 260/336] Count threads after thread-creation while still
 holding mutex lock

The `Mutex` is locked with the `MutexLock` before spawning the thread, so that the thread is prevented from completing (by being blocked on `Mutex`) before the new thread count is obtained. However, the existing bug (introduced in 22e6055) releases `Mutex` before obtaining the new thread count, which allows the thread to run to completion in the meantime.

Also, since the `(thread_count_after_create != starting_count + 1)` condition (line 328) skips the remainder of the `for`-loop body on every iteration, `thread_count_after_join` stays uninitialized.

I believe this is why [this test failed][1] on the macOS CI with this trace:

```
[----------] 1 test from GetThreadCountTest
[ RUN      ] GetThreadCountTest.ReturnsCorrectValue
googletest/test/googletest-port-test.cc:350: Failure
Expected equality of these values:
  thread_count_after_create
    Which is: 1
  starting_count + 1
    Which is: 2

googletest/test/googletest-port-test.cc:351: Failure
Expected equality of these values:
  thread_count_after_join
    Which is: 140493185949400
  starting_count
    Which is: 1

[  FAILED  ] GetThreadCountTest.ReturnsCorrectValue (2 ms)
[----------] 1 test from GetThreadCountTest (2 ms total)
```

[1]: https://github.com/google/googletest/actions/runs/6064919420/job/16453860690?pr=3049
---
 googletest/test/googletest-port-test.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/googletest/test/googletest-port-test.cc b/googletest/test/googletest-port-test.cc
index e0793bad3..8d210260f 100644
--- a/googletest/test/googletest-port-test.cc
+++ b/googletest/test/googletest-port-test.cc
@@ -296,7 +296,7 @@ void* ThreadFunc(void* data) {
 TEST(GetThreadCountTest, ReturnsCorrectValue) {
   size_t starting_count;
   size_t thread_count_after_create;
-  size_t thread_count_after_join;
+  size_t thread_count_after_join = 0;
 
   // We can't guarantee that no other thread was created or destroyed between
   // any two calls to GetThreadCount(). We make multiple attempts, hoping that
@@ -316,9 +316,9 @@ TEST(GetThreadCountTest, ReturnsCorrectValue) {
       const int status = pthread_create(&thread_id, &attr, &ThreadFunc, &mutex);
       ASSERT_EQ(0, pthread_attr_destroy(&attr));
       ASSERT_EQ(0, status);
-    }
 
-    thread_count_after_create = GetThreadCount();
+      thread_count_after_create = GetThreadCount();
+    }
 
     void* dummy;
     ASSERT_EQ(0, pthread_join(thread_id, &dummy));

From 728ec52d2167f61fad5672c3073d72d49a4482df Mon Sep 17 00:00:00 2001
From: Michael Hirshleifer 
Date: Thu, 14 Sep 2023 07:12:44 -0700
Subject: [PATCH 261/336] Remove Googletest FAQ entry for obsolete
 `ProtocolMessageEquals` and `ProtocolMessageEquiv`

* These long-dead variants of the proto matchers don't exist in the current version of Googletest.
* No evidence of external usage: [the only external references I see](https://www.google.com/search?q=%22protocolmessageequals%22+OR+%22protocolmessageequals%22) are copies of this guide. Possibly they were already removed by the time Googletest was publicly released.

PiperOrigin-RevId: 565358401
Change-Id: I61379b7333fa8ee19cd5520caedf2c539f54c2d7
---
 docs/faq.md | 21 ---------------------
 1 file changed, 21 deletions(-)

diff --git a/docs/faq.md b/docs/faq.md
index 90c249781..c942b5dcc 100644
--- a/docs/faq.md
+++ b/docs/faq.md
@@ -128,27 +128,6 @@ both approaches a try. Practice is a much better way to grasp the subtle
 differences between the two tools. Once you have some concrete experience, you
 can much more easily decide which one to use the next time.
 
-## I got some run-time errors about invalid proto descriptors when using `ProtocolMessageEquals`. Help!
-
-{: .callout .note}
-**Note:** `ProtocolMessageEquals` and `ProtocolMessageEquiv` are *deprecated*
-now. Please use `EqualsProto`, etc instead.
-
-`ProtocolMessageEquals` and `ProtocolMessageEquiv` were redefined recently and
-are now less tolerant of invalid protocol buffer definitions. In particular, if
-you have a `foo.proto` that doesn't fully qualify the type of a protocol message
-it references (e.g. `message` where it should be `message`), you
-will now get run-time errors like:
-
-```
-... descriptor.cc:...] Invalid proto descriptor for file "path/to/foo.proto":
-... descriptor.cc:...]  blah.MyMessage.my_field: ".Bar" is not defined.
-```
-
-If you see this, your `.proto` file is broken and needs to be fixed by making
-the types fully qualified. The new definition of `ProtocolMessageEquals` and
-`ProtocolMessageEquiv` just happen to reveal your bug.
-
 ## My death test modifies some state, but the change seems lost after the death test finishes. Why?
 
 Death tests (`EXPECT_DEATH`, etc) are executed in a sub-process s.t. the

From d1467f5813f4d363cfd11aba99c4e9fe47a85e99 Mon Sep 17 00:00:00 2001
From: Michael Hirshleifer 
Date: Thu, 14 Sep 2023 10:36:23 -0700
Subject: [PATCH 262/336] GoogleTest FAQ: minor punctuation fixes

PiperOrigin-RevId: 565411290
Change-Id: I57e94c679183e39eec2a2835f330b52fc9302767
---
 docs/faq.md | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/docs/faq.md b/docs/faq.md
index c942b5dcc..c7d10b500 100644
--- a/docs/faq.md
+++ b/docs/faq.md
@@ -3,7 +3,7 @@
 ## Why should test suite names and test names not contain underscore?
 
 {: .callout .note}
-Note: GoogleTest reserves underscore (`_`) for special purpose keywords, such as
+Note: GoogleTest reserves underscore (`_`) for special-purpose keywords, such as
 [the `DISABLED_` prefix](advanced.md#temporarily-disabling-tests), in addition
 to the following rationale.
 
@@ -33,9 +33,9 @@ contains `_`?
     `TestSuiteName_Bar__Test`, which is invalid.
 
 So clearly `TestSuiteName` and `TestName` cannot start or end with `_`
-(Actually, `TestSuiteName` can start with `_` -- as long as the `_` isn't
-followed by an upper-case letter. But that's getting complicated. So for
-simplicity we just say that it cannot start with `_`.).
+(Actually, `TestSuiteName` can start with `_`—as long as the `_` isn't followed
+by an upper-case letter. But that's getting complicated. So for simplicity we
+just say that it cannot start with `_`.).
 
 It may seem fine for `TestSuiteName` and `TestName` to contain `_` in the
 middle. However, consider this:
@@ -130,7 +130,7 @@ can much more easily decide which one to use the next time.
 
 ## My death test modifies some state, but the change seems lost after the death test finishes. Why?
 
-Death tests (`EXPECT_DEATH`, etc) are executed in a sub-process s.t. the
+Death tests (`EXPECT_DEATH`, etc.) are executed in a sub-process s.t. the
 expected crash won't kill the test program (i.e. the parent process). As a
 result, any in-memory side effects they incur are observable in their respective
 sub-processes, but not in the parent process. You can think of them as running
@@ -171,16 +171,16 @@ class Foo {
 };
 ```
 
-You also need to define it *outside* of the class body in `foo.cc`:
+you also need to define it *outside* of the class body in `foo.cc`:
 
 ```c++
 const int Foo::kBar;  // No initializer here.
 ```
 
 Otherwise your code is **invalid C++**, and may break in unexpected ways. In
-particular, using it in GoogleTest comparison assertions (`EXPECT_EQ`, etc) will
-generate an "undefined reference" linker error. The fact that "it used to work"
-doesn't mean it's valid. It just means that you were lucky. :-)
+particular, using it in GoogleTest comparison assertions (`EXPECT_EQ`, etc.)
+will generate an "undefined reference" linker error. The fact that "it used to
+work" doesn't mean it's valid. It just means that you were lucky. :-)
 
 If the declaration of the static data member is `constexpr` then it is
 implicitly an `inline` definition, and a separate definition in `foo.cc` is not
@@ -290,7 +290,7 @@ a **fresh** test fixture object, immediately call `SetUp()`, run the test body,
 call `TearDown()`, and then delete the test fixture object.
 
 When you need to write per-test set-up and tear-down logic, you have the choice
-between using the test fixture constructor/destructor or `SetUp()/TearDown()`.
+between using the test fixture constructor/destructor or `SetUp()`/`TearDown()`.
 The former is usually preferred, as it has the following benefits:
 
 *   By initializing a member variable in the constructor, we have the option to
@@ -331,7 +331,7 @@ You may still want to use `SetUp()/TearDown()` in the following cases:
     GoogleTest assertions in a destructor if your code could run on such a
     platform.
 
-## The compiler complains "no matching function to call" when I use ASSERT_PRED*. How do I fix it?
+## The compiler complains "no matching function to call" when I use `ASSERT_PRED*`. How do I fix it?
 
 See details for [`EXPECT_PRED*`](reference/assertions.md#EXPECT_PRED) in the
 Assertions Reference.
@@ -389,7 +389,7 @@ C++ is case-sensitive. Did you spell it as `Setup()`?
 Similarly, sometimes people spell `SetUpTestSuite()` as `SetupTestSuite()` and
 wonder why it's never called.
 
-## I have several test suites which share the same test fixture logic, do I have to define a new test fixture class for each of them? This seems pretty tedious.
+## I have several test suites which share the same test fixture logic; do I have to define a new test fixture class for each of them? This seems pretty tedious.
 
 You don't have to. Instead of
 
@@ -524,7 +524,7 @@ 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?
+## 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
 runs all tests in one test suite first, and then runs all tests in the next test
@@ -549,7 +549,7 @@ interleave tests from different test suites, we need to run all tests in the
 `FooTest` case before running any test in the `BarTest` case. This contradicts
 with the requirement to run `BarTest.DefDeathTest` before `FooTest.Uvw`.
 
-## But I don't like calling my entire test suite \*DeathTest when it contains both death tests and non-death tests. What do I do?
+## But I don't like calling my entire test suite `*DeathTest` when it contains both death tests and non-death tests. What do I do?
 
 You don't have to, but if you like, you may split up the test suite into
 `FooTest` and `FooDeathTest`, where the names make it clear that they are
@@ -633,7 +633,7 @@ the `--gtest_also_run_disabled_tests` flag.
 Yes.
 
 The rule is **all test methods in the same test suite must use the same fixture
-class.** This means that the following is **allowed** because both tests use the
+class**. This means that the following is **allowed** because both tests use the
 same fixture class (`::testing::Test`).
 
 ```c++

From 8be20cce6931433c8bc3124beea91922cd621423 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Mon, 18 Sep 2023 03:17:14 -0700
Subject: [PATCH 263/336] Use the `empty()` method to check for emptiness
 instead of `length()`

PiperOrigin-RevId: 566247438
Change-Id: I8199ef53310a057abbe23f8f4295507b60d6b707
---
 googletest/src/gtest-filepath.cc | 2 +-
 googletest/src/gtest.cc          | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/googletest/src/gtest-filepath.cc b/googletest/src/gtest-filepath.cc
index 513e947f5..902d8c7f6 100644
--- a/googletest/src/gtest-filepath.cc
+++ b/googletest/src/gtest-filepath.cc
@@ -336,7 +336,7 @@ bool FilePath::CreateDirectoriesRecursively() const {
     return false;
   }
 
-  if (pathname_.length() == 0 || this->DirectoryExists()) {
+  if (pathname_.empty() || this->DirectoryExists()) {
     return true;
   }
 
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 62dfef664..99b22ed32 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -5400,7 +5400,7 @@ void UnitTest::RecordProperty(const std::string& key,
 int UnitTest::Run() {
 #ifdef GTEST_HAS_DEATH_TEST
   const bool in_death_test_child_process =
-      GTEST_FLAG_GET(internal_run_death_test).length() > 0;
+      !GTEST_FLAG_GET(internal_run_death_test).empty();
 
   // Google Test implements this protocol for catching that a test
   // program exits before returning control to Google Test:

From adc514538678a61b13c240f7b41babbc03b2ac24 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Mon, 18 Sep 2023 15:03:24 -0700
Subject: [PATCH 264/336] Update code with IWYU annotations.

PiperOrigin-RevId: 566424331
Change-Id: I0e16d979b9d79643c882c5082e154842983a5317
---
 googlemock/include/gmock/gmock.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/googlemock/include/gmock/gmock.h b/googlemock/include/gmock/gmock.h
index 568c8c71d..2ca4f7ac6 100644
--- a/googlemock/include/gmock/gmock.h
+++ b/googlemock/include/gmock/gmock.h
@@ -53,13 +53,13 @@
 //
 // where all clauses are optional and WillOnce() can be repeated.
 
-#include "gmock/gmock-actions.h"
-#include "gmock/gmock-cardinalities.h"
-#include "gmock/gmock-function-mocker.h"
-#include "gmock/gmock-matchers.h"
-#include "gmock/gmock-more-actions.h"
-#include "gmock/gmock-more-matchers.h"
-#include "gmock/gmock-nice-strict.h"
+#include "gmock/gmock-actions.h"  // IWYU pragma: export
+#include "gmock/gmock-cardinalities.h"  // IWYU pragma: export
+#include "gmock/gmock-function-mocker.h"  // IWYU pragma: export
+#include "gmock/gmock-matchers.h"  // IWYU pragma: export
+#include "gmock/gmock-more-actions.h"  // IWYU pragma: export
+#include "gmock/gmock-more-matchers.h"  // IWYU pragma: export
+#include "gmock/gmock-nice-strict.h"  // IWYU pragma: export
 #include "gmock/internal/gmock-internal-utils.h"
 #include "gmock/internal/gmock-port.h"
 

From e27b194c2702f02cf033a32bb49978b8ff32aa15 Mon Sep 17 00:00:00 2001
From: Mitja Spes 
Date: Thu, 21 Sep 2023 10:06:21 +0200
Subject: [PATCH 265/336] Fix compile warnings in gmock-function-mocker.h
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Template type int changed to size_t.
This fixes compile warning `conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result` in gmock-function-mocker.h.
---
 googlemock/include/gmock/gmock-function-mocker.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/googlemock/include/gmock/gmock-function-mocker.h b/googlemock/include/gmock/gmock-function-mocker.h
index 1a1f126e4..30355fedf 100644
--- a/googlemock/include/gmock/gmock-function-mocker.h
+++ b/googlemock/include/gmock/gmock-function-mocker.h
@@ -69,22 +69,22 @@ constexpr bool PrefixOf(const char* a, const char* b) {
   return *a == 0 || (*a == *b && internal::PrefixOf(a + 1, b + 1));
 }
 
-template 
+template 
 constexpr bool StartsWith(const char (&prefix)[N], const char (&str)[M]) {
   return N <= M && internal::PrefixOf(prefix, str);
 }
 
-template 
+template 
 constexpr bool EndsWith(const char (&suffix)[N], const char (&str)[M]) {
   return N <= M && internal::PrefixOf(suffix, str + M - N);
 }
 
-template 
+template 
 constexpr bool Equals(const char (&a)[N], const char (&b)[M]) {
   return N == M && internal::PrefixOf(a, b);
 }
 
-template 
+template 
 constexpr bool ValidateSpec(const char (&spec)[N]) {
   return internal::Equals("const", spec) ||
          internal::Equals("override", spec) ||

From 167a2255aef1420735dbe7eeabd4691709f8114a Mon Sep 17 00:00:00 2001
From: Dino Radakovic 
Date: Thu, 21 Sep 2023 09:07:18 -0700
Subject: [PATCH 266/336] googletest: Update absl to version with
 HasAbslStringify

https://github.com/abseil/abseil-cpp/commit/9e1789ffea47fdeb3133aa42aa9592f3673fb6ed

PiperOrigin-RevId: 567324946
Change-Id: I8adc5803a81075a635dad79aa0312d4455e1ad63
---
 googletest_deps.bzl | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/googletest_deps.bzl b/googletest_deps.bzl
index e25f5a1ad..8f19cbed7 100644
--- a/googletest_deps.bzl
+++ b/googletest_deps.bzl
@@ -15,8 +15,8 @@ def googletest_deps():
 
     if not native.existing_rule("com_google_absl"):
         http_archive(
-            name = "com_google_absl",  # 2023-08-01T14:59:13Z
-            sha256 = "d2c09bf3b3aba57ad87a56082020bee2948445407756e92ddaf3595396086853",
-            strip_prefix = "abseil-cpp-22091f4c0d6626b3ef40446ce3d4ccab19425ca3",
-            urls = ["https://github.com/abseil/abseil-cpp/archive/22091f4c0d6626b3ef40446ce3d4ccab19425ca3.zip"],
+            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"],
         )

From 80306a7b5ec8ddaabd26540f2827b903d69e7a02 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Thu, 21 Sep 2023 10:31:33 -0700
Subject: [PATCH 267/336] Use `absl::HasAbslStringify`, instead of the internal
 version.

PiperOrigin-RevId: 567349341
Change-Id: I35f2679901aecbe9cb90d2e78ff28c5e383e7257
---
 googletest/include/gtest/gtest-message.h  | 19 +++++++++----------
 googletest/include/gtest/gtest-printers.h |  9 ++++-----
 2 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/googletest/include/gtest/gtest-message.h b/googletest/include/gtest/gtest-message.h
index 59b805e4e..448ac6b7e 100644
--- a/googletest/include/gtest/gtest-message.h
+++ b/googletest/include/gtest/gtest-message.h
@@ -59,7 +59,7 @@
 #ifdef GTEST_HAS_ABSL
 #include 
 
-#include "absl/strings/internal/has_absl_stringify.h"
+#include "absl/strings/has_absl_stringify.h"
 #include "absl/strings/str_cat.h"
 #endif  // GTEST_HAS_ABSL
 
@@ -121,14 +121,14 @@ class GTEST_API_ Message {
   // Streams a non-pointer value to this object. If building a version of
   // GoogleTest with ABSL, this overload is only enabled if the value does not
   // have an AbslStringify definition.
-  template ::value,  // NOLINT
-                int>::type = 0
+      ,
+      typename std::enable_if::value,  // NOLINT
+                              int>::type = 0
 #endif  // GTEST_HAS_ABSL
-            >
+      >
   inline Message& operator<<(const T& val) {
         // Some libraries overload << for STL containers.  These
     // overloads are defined in the global namespace instead of ::std.
@@ -153,9 +153,8 @@ class GTEST_API_ Message {
   // Streams a non-pointer value with an AbslStringify definition to this
   // object.
   template ::value,  // NOLINT
-                int>::type = 0>
+            typename std::enable_if::value,  // NOLINT
+                                    int>::type = 0>
   inline Message& operator<<(const T& val) {
     // ::operator<< is needed here for a similar reason as with the non-Abseil
     // version above
diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h
index 9ccbff7da..1b12ef683 100644
--- a/googletest/include/gtest/gtest-printers.h
+++ b/googletest/include/gtest/gtest-printers.h
@@ -116,7 +116,7 @@
 #include 
 
 #ifdef GTEST_HAS_ABSL
-#include "absl/strings/internal/has_absl_stringify.h"
+#include "absl/strings/has_absl_stringify.h"
 #include "absl/strings/str_cat.h"
 #endif  // GTEST_HAS_ABSL
 #include "gtest/internal/gtest-internal.h"
@@ -292,10 +292,9 @@ struct ConvertibleToStringViewPrinter {
 
 #ifdef GTEST_HAS_ABSL
 struct ConvertibleToAbslStringifyPrinter {
-  template <
-      typename T,
-      typename = typename std::enable_if<
-          absl::strings_internal::HasAbslStringify::value>::type>  // NOLINT
+  template ::value>::type>  // NOLINT
   static void PrintValue(const T& value, ::std::ostream* os) {
     *os << absl::StrCat(value);
   }

From e40661d89b051e9ef4eb8a2420b74bf78b39ef41 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Fri, 22 Sep 2023 10:45:22 -0700
Subject: [PATCH 268/336] Update C++ feature detection in `gtest-port.h` to
 rely on feature test macros where possible.

This also avoids conflating C++ language versions with standard library versions, which don't always align.

PiperOrigin-RevId: 567662118
Change-Id: I7c023bd043c81c540c9430eaeb7b450feaadb206
---
 .../include/gtest/internal/gtest-port.h       | 60 +++++++++++--------
 1 file changed, 36 insertions(+), 24 deletions(-)

diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index 35544a08a..5f741cad3 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -281,6 +281,22 @@
 #error C++ versions less than C++14 are not supported.
 #endif
 
+// MSVC >= 19.11 (VS 2017 Update 3) supports __has_include.
+#ifdef __has_include
+#define GTEST_INTERNAL_HAS_INCLUDE __has_include
+#else
+#define GTEST_INTERNAL_HAS_INCLUDE(...) 0
+#endif
+
+// Detect C++ feature test macros as gracefully as possible.
+// MSVC >= 19.15, Clang >= 3.4.1, and GCC >= 4.1.2 support feature test macros.
+#if GTEST_INTERNAL_CPLUSPLUS_LANG >= 202002L && \
+    (!defined(__has_include) || GTEST_INTERNAL_HAS_INCLUDE())
+#include   // C++20 and later
+#elif (!defined(__has_include) || GTEST_INTERNAL_HAS_INCLUDE())
+#include   // Pre-C++20
+#endif
+
 #include    // for isspace, etc
 #include   // for ptrdiff_t
 #include 
@@ -2351,9 +2367,9 @@ using Any = ::absl::any;
 }  // namespace internal
 }  // namespace testing
 #else
-#ifdef __has_include
-#if __has_include() && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L && \
-    (!defined(_MSC_VER) || GTEST_HAS_RTTI)
+#if defined(__cpp_lib_any) || (GTEST_INTERNAL_HAS_INCLUDE() &&        \
+                               GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L && \
+                               (!defined(_MSC_VER) || GTEST_HAS_RTTI))
 // Otherwise for C++17 and higher use std::any for UniversalPrinter<>
 // specializations.
 #define GTEST_INTERNAL_HAS_ANY 1
@@ -2365,8 +2381,7 @@ using Any = ::std::any;
 }  // namespace testing
 // The case where absl is configured NOT to alias std::any is not
 // supported.
-#endif  // __has_include() && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
-#endif  // __has_include
+#endif  // __cpp_lib_any
 #endif  // GTEST_HAS_ABSL
 
 #ifndef GTEST_INTERNAL_HAS_ANY
@@ -2386,8 +2401,8 @@ inline ::absl::nullopt_t Nullopt() { return ::absl::nullopt; }
 }  // namespace internal
 }  // namespace testing
 #else
-#ifdef __has_include
-#if __has_include() && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
+#if defined(__cpp_lib_optional) || (GTEST_INTERNAL_HAS_INCLUDE() && \
+                                    GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L)
 // Otherwise for C++17 and higher use std::optional for UniversalPrinter<>
 // specializations.
 #define GTEST_INTERNAL_HAS_OPTIONAL 1
@@ -2401,19 +2416,17 @@ inline ::std::nullopt_t Nullopt() { return ::std::nullopt; }
 }  // namespace testing
 // The case where absl is configured NOT to alias std::optional is not
 // supported.
-#endif  // __has_include() && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
-#endif  // __has_include
+#endif  // __cpp_lib_optional
 #endif  // GTEST_HAS_ABSL
 
 #ifndef GTEST_INTERNAL_HAS_OPTIONAL
 #define GTEST_INTERNAL_HAS_OPTIONAL 0
 #endif
 
-#ifdef __has_include
-#if __has_include() && GTEST_INTERNAL_CPLUSPLUS_LANG >= 202002L
+#if defined(__cpp_lib_span) || (GTEST_INTERNAL_HAS_INCLUDE() && \
+                                GTEST_INTERNAL_CPLUSPLUS_LANG >= 202002L)
 #define GTEST_INTERNAL_HAS_STD_SPAN 1
-#endif  // __has_include() && GTEST_INTERNAL_CPLUSPLUS_LANG >= 202002L
-#endif  // __has_include
+#endif  // __cpp_lib_span
 
 #ifndef GTEST_INTERNAL_HAS_STD_SPAN
 #define GTEST_INTERNAL_HAS_STD_SPAN 0
@@ -2430,8 +2443,9 @@ using StringView = ::absl::string_view;
 }  // namespace internal
 }  // namespace testing
 #else
-#ifdef __has_include
-#if __has_include() && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
+#if defined(__cpp_lib_string_view) ||             \
+    (GTEST_INTERNAL_HAS_INCLUDE() && \
+     GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L)
 // Otherwise for C++17 and higher use std::string_view for Matcher<>
 // specializations.
 #define GTEST_INTERNAL_HAS_STRING_VIEW 1
@@ -2443,9 +2457,7 @@ using StringView = ::std::string_view;
 }  // namespace testing
 // The case where absl is configured NOT to alias std::string_view is not
 // supported.
-#endif  // __has_include() && GTEST_INTERNAL_CPLUSPLUS_LANG >=
-        // 201703L
-#endif  // __has_include
+#endif  // __cpp_lib_string_view
 #endif  // GTEST_HAS_ABSL
 
 #ifndef GTEST_INTERNAL_HAS_STRING_VIEW
@@ -2464,8 +2476,8 @@ using Variant = ::absl::variant;
 }  // namespace internal
 }  // namespace testing
 #else
-#ifdef __has_include
-#if __has_include() && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
+#if defined(__cpp_lib_variant) || (GTEST_INTERNAL_HAS_INCLUDE() && \
+                                   GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L)
 // Otherwise for C++17 and higher use std::variant for UniversalPrinter<>
 // specializations.
 #define GTEST_INTERNAL_HAS_VARIANT 1
@@ -2477,16 +2489,16 @@ using Variant = ::std::variant;
 }  // namespace internal
 }  // namespace testing
 // The case where absl is configured NOT to alias std::variant is not supported.
-#endif  // __has_include() && GTEST_INTERNAL_CPLUSPLUS_LANG >= 201703L
-#endif  // __has_include
+#endif  // __cpp_lib_variant
 #endif  // GTEST_HAS_ABSL
 
 #ifndef GTEST_INTERNAL_HAS_VARIANT
 #define GTEST_INTERNAL_HAS_VARIANT 0
 #endif
 
-#if defined(GTEST_INTERNAL_CPLUSPLUS_LANG) && \
-    GTEST_INTERNAL_CPLUSPLUS_LANG < 201703L
+#if (defined(__cpp_constexpr) && !defined(__cpp_inline_variables)) || \
+    (defined(GTEST_INTERNAL_CPLUSPLUS_LANG) &&                        \
+     GTEST_INTERNAL_CPLUSPLUS_LANG < 201703L)
 #define GTEST_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL 1
 #endif
 

From e47544ad31cb3ceecd04cc13e8fe556f8df9fe0b Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Mon, 25 Sep 2023 14:37:34 -0700
Subject: [PATCH 269/336] Resolve `-Wundef` triggering on
 `GTEST_CREATE_SHARED_LIBRARY` and `GTEST_LINKED_AS_SHARED_LIBRARY` with
 shared libraries in GoogleTest

Fixes: #4372
PiperOrigin-RevId: 568327612
Change-Id: Ifc47f1a2a2648c29858a22966331557cc928cc47
---
 googletest/include/gtest/internal/gtest-port.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index 5f741cad3..d061a49b9 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -845,9 +845,9 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
 #ifndef GTEST_API_
 
 #ifdef _MSC_VER
-#if GTEST_LINKED_AS_SHARED_LIBRARY
+#if defined(GTEST_LINKED_AS_SHARED_LIBRARY) && GTEST_LINKED_AS_SHARED_LIBRARY
 #define GTEST_API_ __declspec(dllimport)
-#elif GTEST_CREATE_SHARED_LIBRARY
+#elif defined(GTEST_CREATE_SHARED_LIBRARY) && GTEST_CREATE_SHARED_LIBRARY
 #define GTEST_API_ __declspec(dllexport)
 #endif
 #elif GTEST_HAVE_ATTRIBUTE_(visibility)

From 2d09ed35cfabc8032545a401e883aafd3efda048 Mon Sep 17 00:00:00 2001
From: Dzmitry Ivaniuk 
Date: Fri, 29 Sep 2023 17:26:23 +0300
Subject: [PATCH 270/336] cmake: Fix comments in cmake files

Remove extra spaces. Fix so that the comment line starts with a capital letter and ends with a dot.
---
 CMakeLists.txt                        |  2 +-
 googlemock/CMakeLists.txt             | 20 +++++++--------
 googletest/CMakeLists.txt             | 26 +++++++++----------
 googletest/cmake/internal_utils.cmake | 37 +++++++++++++--------------
 4 files changed, 42 insertions(+), 43 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 089ac987f..24d41c29c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,7 +15,7 @@ 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)
diff --git a/googlemock/CMakeLists.txt b/googlemock/CMakeLists.txt
index a9aa0723f..428bd9f8e 100644
--- a/googlemock/CMakeLists.txt
+++ b/googlemock/CMakeLists.txt
@@ -5,7 +5,7 @@
 # CMake build script for Google Mock.
 #
 # To run the tests for Google Mock itself on Linux, use 'make test' or
-# ctest.  You can select which tests to run using 'ctest -R regex'.
+# ctest. You can select which tests to run using 'ctest -R regex'.
 # For more options, run 'ctest --help'.
 
 option(gmock_build_tests "Build all of Google Mock's own tests." OFF)
@@ -44,7 +44,7 @@ if (COMMAND set_up_hermetic_build)
 endif()
 
 # Instructs CMake to process Google Test's CMakeLists.txt and add its
-# targets to the current scope.  We are placing Google Test's binary
+# targets to the current scope. We are placing Google Test's binary
 # directory in a subdirectory of our own as VC compilation may break
 # if they are the same (the default).
 add_subdirectory("${gtest_dir}" "${gmock_BINARY_DIR}/${gtest_dir}")
@@ -60,9 +60,9 @@ else()
 endif()
 
 # Although Google Test's CMakeLists.txt calls this function, the
-# changes there don't affect the current scope.  Therefore we have to
+# changes there don't affect the current scope. Therefore we have to
 # call it again here.
-config_compiler_and_linker()  # from ${gtest_dir}/cmake/internal_utils.cmake
+config_compiler_and_linker() # from ${gtest_dir}/cmake/internal_utils.cmake
 
 # Adds Google Mock's and Google Test's header directories to the search path.
 set(gmock_build_include_dirs
@@ -75,10 +75,10 @@ include_directories(${gmock_build_include_dirs})
 
 ########################################################################
 #
-# Defines the gmock & gmock_main libraries.  User tests should link
+# Defines the gmock & gmock_main libraries. User tests should link
 # with one of them.
 
-# Google Mock libraries.  We build them using more strict warnings than what
+# Google Mock libraries. We build them using more strict warnings than what
 # are used for other targets, to ensure that Google Mock can be compiled by
 # a user aggressive about warnings.
 if (MSVC)
@@ -111,7 +111,7 @@ target_include_directories(gmock_main SYSTEM INTERFACE
 
 ########################################################################
 #
-# Install rules
+# Install rules.
 install_project(gmock gmock_main)
 
 ########################################################################
@@ -121,8 +121,8 @@ install_project(gmock gmock_main)
 # You can skip this section if you aren't interested in testing
 # Google Mock itself.
 #
-# The tests are not built by default.  To build them, set the
-# gmock_build_tests option to ON.  You can do it by running ccmake
+# The tests are not built by default. To build them, set the
+# gmock_build_tests option to ON. You can do it by running ccmake
 # or specifying the -Dgmock_build_tests=ON flag when running cmake.
 
 if (gmock_build_tests)
@@ -187,7 +187,7 @@ if (gmock_build_tests)
   cxx_shared_library(shared_gmock_main "${cxx_default}"
     "${gtest_dir}/src/gtest-all.cc" src/gmock-all.cc src/gmock_main.cc)
 
-  # Tests that a binary can be built with Google Mock as a shared library.  On
+  # Tests that a binary can be built with Google Mock as a shared library. On
   # some system configurations, it may not possible to run the binary without
   # knowing more details about the system configurations. We do not try to run
   # this binary. To get a more robust shared library coverage, configure with
diff --git a/googletest/CMakeLists.txt b/googletest/CMakeLists.txt
index caafa8c76..51a67c915 100644
--- a/googletest/CMakeLists.txt
+++ b/googletest/CMakeLists.txt
@@ -5,7 +5,7 @@
 # CMake build script for Google Test.
 #
 # To run the tests for Google Test itself on Linux, use 'make test' or
-# ctest.  You can select which tests to run using 'ctest -R regex'.
+# ctest. You can select which tests to run using 'ctest -R regex'.
 # For more options, run 'ctest --help'.
 
 # When other libraries are using a shared version of runtime libraries,
@@ -35,7 +35,7 @@ endif()
 
 ########################################################################
 #
-# Project-wide settings
+# Project-wide settings.
 
 # Name of the project.
 #
@@ -44,7 +44,7 @@ endif()
 # ${gtest_BINARY_DIR}.
 # Language "C" is required for find_package(Threads).
 
-# Project version:
+# Project version.
 
 cmake_minimum_required(VERSION 3.13)
 project(gtest VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C)
@@ -53,7 +53,7 @@ if (COMMAND set_up_hermetic_build)
   set_up_hermetic_build()
 endif()
 
-# These commands only run if this is the main project
+# These commands only run if this is the main project.
 if(CMAKE_PROJECT_NAME STREQUAL "gtest" OR CMAKE_PROJECT_NAME STREQUAL "googletest-distribution")
 
   # BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to
@@ -83,7 +83,7 @@ include(cmake/internal_utils.cmake)
 config_compiler_and_linker()  # Defined in internal_utils.cmake.
 
 # Needed to set the namespace for both the export targets and the
-# alias libraries
+# alias libraries.
 set(cmake_package_name GTest CACHE INTERNAL "")
 
 # Create the CMake package file descriptors.
@@ -114,10 +114,10 @@ include_directories(${gtest_build_include_dirs})
 
 ########################################################################
 #
-# Defines the gtest & gtest_main libraries.  User tests should link
+# Defines the gtest & gtest_main libraries. User tests should link
 # with one of them.
 
-# Google Test libraries.  We build them using more strict warnings than what
+# Google Test libraries. We build them using more strict warnings than what
 # are used for other targets, to ensure that gtest can be compiled by a user
 # aggressive about warnings.
 cxx_library(gtest "${cxx_strict}" src/gtest-all.cc)
@@ -154,15 +154,15 @@ target_link_libraries(gtest_main PUBLIC gtest)
 
 ########################################################################
 #
-# Install rules
+# Install rules.
 install_project(gtest gtest_main)
 
 ########################################################################
 #
 # Samples on how to link user tests with gtest or gtest_main.
 #
-# They are not built by default.  To build them, set the
-# gtest_build_samples option to ON.  You can do it by running ccmake
+# They are not built by default. To build them, set the
+# gtest_build_samples option to ON. You can do it by running ccmake
 # or specifying the -Dgtest_build_samples=ON flag when running cmake.
 
 if (gtest_build_samples)
@@ -185,8 +185,8 @@ endif()
 # You can skip this section if you aren't interested in testing
 # Google Test itself.
 #
-# The tests are not built by default.  To build them, set the
-# gtest_build_tests option to ON.  You can do it by running ccmake
+# The tests are not built by default. To build them, set the
+# gtest_build_tests option to ON. You can do it by running ccmake
 # or specifying the -Dgtest_build_tests=ON flag when running cmake.
 
 if (gtest_build_tests)
@@ -268,7 +268,7 @@ if (gtest_build_tests)
   py_test(gtest_skip_environment_check_output_test)
 
   # Visual Studio .NET 2003 does not support STL with exceptions disabled.
-  if (NOT MSVC OR MSVC_VERSION GREATER 1310)  # 1310 is Visual Studio .NET 2003
+  if (NOT MSVC OR MSVC_VERSION GREATER 1310) # 1310 is Visual Studio .NET 2003
     cxx_executable_with_flags(
       googletest-catch-exceptions-no-ex-test_
       "${cxx_no_exception}"
diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake
index d4f67f43a..d5c82745f 100644
--- a/googletest/cmake/internal_utils.cmake
+++ b/googletest/cmake/internal_utils.cmake
@@ -29,7 +29,7 @@ macro(fix_default_compiler_settings_)
              CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
       if (NOT BUILD_SHARED_LIBS AND NOT gtest_force_shared_crt)
         # When Google Test is built as a shared library, it should also use
-        # shared runtime libraries.  Otherwise, it may end up with multiple
+        # shared runtime libraries. Otherwise, it may end up with multiple
         # copies of runtime library data in different modules, resulting in
         # hard-to-find crashes. When it is built as a static library, it is
         # preferable to use CRT as static libraries, as we don't have to rely
@@ -55,11 +55,11 @@ macro(fix_default_compiler_settings_)
 endmacro()
 
 # Defines the compiler/linker flags used to build Google Test and
-# Google Mock.  You can tweak these definitions to suit your need.  A
+# Google Mock. You can tweak these definitions to suit your need. A
 # variable's value is empty before it's explicitly assigned to.
 macro(config_compiler_and_linker)
   # Note: pthreads on MinGW is not supported, even if available
-  # instead, we use windows threading primitives
+  # instead, we use windows threading primitives.
   unset(GTEST_HAS_PTHREAD)
   if (NOT gtest_disable_pthreads AND NOT MINGW)
     # Defines CMAKE_USE_PTHREADS_INIT and CMAKE_THREAD_LIBS_INIT.
@@ -79,7 +79,7 @@ macro(config_compiler_and_linker)
     set(cxx_exception_flags "-EHsc -D_HAS_EXCEPTIONS=1")
     set(cxx_no_exception_flags "-EHs-c- -D_HAS_EXCEPTIONS=0")
     set(cxx_no_rtti_flags "-GR-")
-    # Suppress "unreachable code" warning
+    # Suppress "unreachable code" warning,
     # https://stackoverflow.com/questions/3232669 explains the issue.
     set(cxx_base_flags "${cxx_base_flags} -wd4702")
     # Ensure MSVC treats source files as UTF-8 encoded.
@@ -110,7 +110,7 @@ macro(config_compiler_and_linker)
     set(cxx_exception_flags "-fexceptions")
     set(cxx_no_exception_flags "-fno-exceptions")
     # Until version 4.3.2, GCC doesn't define a macro to indicate
-    # whether RTTI is enabled.  Therefore we define GTEST_HAS_RTTI
+    # whether RTTI is enabled. Therefore we define GTEST_HAS_RTTI
     # explicitly.
     set(cxx_no_rtti_flags "-fno-rtti -DGTEST_HAS_RTTI=0")
     set(cxx_strict_flags
@@ -127,7 +127,7 @@ macro(config_compiler_and_linker)
     set(cxx_exception_flags "-qeh")
     set(cxx_no_exception_flags "-qnoeh")
     # Until version 9.0, Visual Age doesn't define a macro to indicate
-    # whether RTTI is enabled.  Therefore we define GTEST_HAS_RTTI
+    # whether RTTI is enabled. Therefore we define GTEST_HAS_RTTI
     # explicitly.
     set(cxx_no_rtti_flags "-qnortti -DGTEST_HAS_RTTI=0")
   elseif (CMAKE_CXX_COMPILER_ID STREQUAL "HP")
@@ -157,7 +157,7 @@ macro(config_compiler_and_linker)
   set(cxx_strict "${cxx_default} ${cxx_strict_flags}")
 endmacro()
 
-# Defines the gtest & gtest_main libraries.  User tests should link
+# Defines the gtest & gtest_main libraries. User tests should link
 # with one of them.
 function(cxx_library_with_type name type cxx_flags)
   # type can be either STATIC or SHARED to denote a static or shared library.
@@ -167,15 +167,14 @@ function(cxx_library_with_type name type cxx_flags)
   set_target_properties(${name}
     PROPERTIES
     COMPILE_FLAGS "${cxx_flags}")
-  # Set the output directory for build artifacts
+  # Set the output directory for build artifacts.
   set_target_properties(${name}
     PROPERTIES
     RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
     LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
     ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
     PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
-    COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
-  # make PDBs match library name
+  # Make PDBs match library name.
   get_target_property(pdb_debug_postfix ${name} DEBUG_POSTFIX)
   set_target_properties(${name}
     PROPERTIES
@@ -212,7 +211,7 @@ endfunction()
 
 # cxx_executable_with_flags(name cxx_flags libs srcs...)
 #
-# creates a named C++ executable that depends on the given libraries and
+# Creates a named C++ executable that depends on the given libraries and
 # is built from the given source files with the given compiler flags.
 function(cxx_executable_with_flags name cxx_flags libs)
   add_executable(${name} ${ARGN})
@@ -239,8 +238,8 @@ endfunction()
 
 # cxx_executable(name dir lib srcs...)
 #
-# creates a named target that depends on the given libs and is built
-# from the given source files.  dir/name.cc is implicitly included in
+# Creates a named target that depends on the given libs and is built
+# from the given source files. dir/name.cc is implicitly included in
 # the source file list.
 function(cxx_executable name dir libs)
   cxx_executable_with_flags(
@@ -251,7 +250,7 @@ find_package(Python3)
 
 # cxx_test_with_flags(name cxx_flags libs srcs...)
 #
-# creates a named C++ test that depends on the given libs and is built
+# Creates a named C++ test that depends on the given libs and is built
 # from the given source files with the given compiler flags.
 function(cxx_test_with_flags name cxx_flags libs)
   cxx_executable_with_flags(${name} "${cxx_flags}" "${libs}" ${ARGN})
@@ -260,8 +259,8 @@ endfunction()
 
 # cxx_test(name libs srcs...)
 #
-# creates a named test target that depends on the given libs and is
-# built from the given source files.  Unlike cxx_test_with_flags,
+# Creates a named test target that depends on the given libs and is
+# built from the given source files. Unlike cxx_test_with_flags,
 # test/name.cc is already implicitly included in the source file list.
 function(cxx_test name libs)
   cxx_test_with_flags("${name}" "${cxx_default}" "${libs}"
@@ -270,8 +269,8 @@ endfunction()
 
 # py_test(name)
 #
-# creates a Python test with the given name whose main module is in
-# test/name.py.  It does nothing if Python is not installed.
+# Creates a Python test with the given name whose main module is in
+# test/name.py. It does nothing if Python is not installed.
 function(py_test name)
   if (NOT Python3_Interpreter_FOUND)
     return()
@@ -307,7 +306,7 @@ function(install_project)
       ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
       LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
     if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
-      # Install PDBs
+      # Install PDBs.
       foreach(t ${ARGN})
         get_target_property(t_pdb_name ${t} COMPILE_PDB_NAME)
         get_target_property(t_pdb_name_debug ${t} COMPILE_PDB_NAME_DEBUG)

From beb552fb47e9e8a6ddab20526663c2dddd601ec6 Mon Sep 17 00:00:00 2001
From: Dino Radakovic 
Date: Tue, 3 Oct 2023 11:41:17 -0700
Subject: [PATCH 271/336] gmock_cook_book: Document `DoAll`'s return type
 requirement

The requirement is vaguely  documented by "Only the return value of the last action in the sequence will be used.".
However, this can be misleading, as users could potentially expect default-constructed values to be returned in absence of a matching return type.

PiperOrigin-RevId: 570450839
Change-Id: Ibd98a6e6b2aaf2a8cfc15ed6aeab442526eab98e
---
 docs/gmock_cook_book.md | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/docs/gmock_cook_book.md b/docs/gmock_cook_book.md
index da10918c9..5e9b6647d 100644
--- a/docs/gmock_cook_book.md
+++ b/docs/gmock_cook_book.md
@@ -1927,6 +1927,12 @@ class MockFoo : public Foo {
                       action_n));
 ```
 
+The return value of the last action **must** match the return type of the mocked
+method. In the example above, `action_n` could be `Return(true)`, or a lambda
+that returns a `bool`, but not `SaveArg`, which returns `void`. Otherwise the
+signature of `DoAll` would not match the signature expected by `WillOnce`, which
+is the signature of the mocked method, and it wouldn't compile.
+
 ### Verifying Complex Arguments {#SaveArgVerify}
 
 If you want to verify that a method is called with a particular argument but the

From 2dd1c131950043a8ad5ab0d2dda0e0970596586a Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Thu, 5 Oct 2023 14:12:08 -0700
Subject: [PATCH 272/336] Fix RE::Init for Android and NetBSD.

This is a somewhat recent change for Android (I'm not clear on whether it's a recent change for NetBSD, or if Android was just very behind on its implementation), so while this worked fine as recently as API 32 devices, REG_GNU is required for API 34 (API 33 untested).

A test actually caught this, but https://github.com/google/googletest/pull/4334 "fixed" the test rather than the implementation. This CL also reverts the test change so it can catch the failure.

PiperOrigin-RevId: 571126374
Change-Id: I420dfcedea58f2c8b605f699515d744006c0a9d9
---
 googletest/src/gtest-port.cc            | 15 +++++++++++++--
 googletest/test/googletest-port-test.cc |  4 ++--
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc
index e9d12d92e..3bb7dd450 100644
--- a/googletest/src/gtest-port.cc
+++ b/googletest/src/gtest-port.cc
@@ -697,13 +697,24 @@ bool RE::PartialMatch(const char* str, const RE& re) {
 void RE::Init(const char* regex) {
   pattern_ = regex;
 
+  // NetBSD (and Android, which takes its regex implemntation from NetBSD) does
+  // not include the GNU regex extensions (such as Perl style character classes
+  // like \w) in REG_EXTENDED. REG_EXTENDED is only specified to include the
+  // [[:alpha:]] style character classes. Enable REG_GNU wherever it is defined
+  // so users can use those extensions.
+#if defined(REG_GNU)
+  constexpr int reg_flags = REG_EXTENDED | REG_GNU;
+#else
+  constexpr int reg_flags = REG_EXTENDED;
+#endif
+
   // Reserves enough bytes to hold the regular expression used for a
   // full match.
   const size_t full_regex_len = strlen(regex) + 10;
   char* const full_pattern = new char[full_regex_len];
 
   snprintf(full_pattern, full_regex_len, "^(%s)$", regex);
-  is_valid_ = regcomp(&full_regex_, full_pattern, REG_EXTENDED) == 0;
+  is_valid_ = regcomp(&full_regex_, full_pattern, reg_flags) == 0;
   // We want to call regcomp(&partial_regex_, ...) even if the
   // previous expression returns false.  Otherwise partial_regex_ may
   // not be properly initialized can may cause trouble when it's
@@ -714,7 +725,7 @@ void RE::Init(const char* regex) {
   // regex.  We change it to an equivalent form "()" to be safe.
   if (is_valid_) {
     const char* const partial_regex = (*regex == '\0') ? "()" : regex;
-    is_valid_ = regcomp(&partial_regex_, partial_regex, REG_EXTENDED) == 0;
+    is_valid_ = regcomp(&partial_regex_, partial_regex, reg_flags) == 0;
   }
   EXPECT_TRUE(is_valid_)
       << "Regular expression \"" << regex
diff --git a/googletest/test/googletest-port-test.cc b/googletest/test/googletest-port-test.cc
index 8d210260f..9f05a0199 100644
--- a/googletest/test/googletest-port-test.cc
+++ b/googletest/test/googletest-port-test.cc
@@ -418,8 +418,8 @@ TYPED_TEST(RETest, ImplicitConstructorWorks) {
   const RE simple(TypeParam("hello"));
   EXPECT_STREQ("hello", simple.pattern());
 
-  const RE normal(TypeParam(".*([[:alnum:]_]+)"));
-  EXPECT_STREQ(".*([[:alnum:]_]+)", normal.pattern());
+  const RE normal(TypeParam(".*(\\w+)"));
+  EXPECT_STREQ(".*(\\w+)", normal.pattern());
 }
 
 // Tests that RE's constructors reject invalid regular expressions.

From 829c19901dac454ced475fec6a11e8e1b8a61549 Mon Sep 17 00:00:00 2001
From: Dino Radakovic 
Date: Tue, 17 Oct 2023 09:18:09 -0700
Subject: [PATCH 273/336] gtest-death-test-internal: Delete obsolete string
 constants

These are not used anywhere in googletest and they are in namespace `testing::internal`

PiperOrigin-RevId: 574171727
Change-Id: I5f668157a81ba3efaed77c1302b40cf07eeda52b
---
 googletest/include/gtest/internal/gtest-death-test-internal.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/googletest/include/gtest/internal/gtest-death-test-internal.h b/googletest/include/gtest/internal/gtest-death-test-internal.h
index 8e9c988b9..61536d657 100644
--- a/googletest/include/gtest/internal/gtest-death-test-internal.h
+++ b/googletest/include/gtest/internal/gtest-death-test-internal.h
@@ -52,9 +52,7 @@ GTEST_DECLARE_string_(internal_run_death_test);
 namespace testing {
 namespace internal {
 
-// Names of the flags (needed for parsing Google Test flags).
-const char kDeathTestStyleFlag[] = "death_test_style";
-const char kDeathTestUseFork[] = "death_test_use_fork";
+// Name of the flag (needed for parsing Google Test flag).
 const char kInternalRunDeathTestFlag[] = "internal_run_death_test";
 
 #ifdef GTEST_HAS_DEATH_TEST

From 9bb354fa8325fa31faa1e12627b25ab445e6eed3 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Tue, 17 Oct 2023 23:50:03 -0700
Subject: [PATCH 274/336] s/::testing::/testing::/ in test documentation
 outside of using statements to align with best practice

PiperOrigin-RevId: 574377544
Change-Id: I0ca69a3bf14cc1aab75784eba220a48bf50cef04
---
 docs/primer.md | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/docs/primer.md b/docs/primer.md
index 4901e1ab0..8b98da2a6 100644
--- a/docs/primer.md
+++ b/docs/primer.md
@@ -210,7 +210,7 @@ objects for several different tests.
 
 To create a fixture:
 
-1.  Derive a class from `::testing::Test` . Start its body with `protected:`, as
+1.  Derive a class from `testing::Test` . Start its body with `protected:`, as
     we'll want to access fixture members from sub-classes.
 2.  Inside the class, declare any objects you plan to use.
 3.  If necessary, write a default constructor or `SetUp()` function to prepare
@@ -271,7 +271,7 @@ First, define a fixture class. By convention, you should give it the name
 `FooTest` where `Foo` is the class being tested.
 
 ```c++
-class QueueTest : public ::testing::Test {
+class QueueTest : public testing::Test {
  protected:
   void SetUp() override {
      // q0_ remains empty
@@ -402,7 +402,7 @@ namespace project {
 namespace {
 
 // The fixture for testing class Foo.
-class FooTest : public ::testing::Test {
+class FooTest : public testing::Test {
  protected:
   // You can remove any or all of the following functions if their bodies would
   // be empty.
@@ -450,14 +450,14 @@ TEST_F(FooTest, DoesXyz) {
 }  // namespace my
 
 int main(int argc, char **argv) {
-  ::testing::InitGoogleTest(&argc, argv);
+  testing::InitGoogleTest(&argc, argv);
   return RUN_ALL_TESTS();
 }
 ```
 
-The `::testing::InitGoogleTest()` function parses the command line for
-GoogleTest flags, and removes all recognized flags. This allows the user to
-control a test program's behavior via various flags, which we'll cover in the
+The `testing::InitGoogleTest()` function parses the command line for GoogleTest
+flags, and removes all recognized flags. This allows the user to control a test
+program's behavior via various flags, which we'll cover in the
 [AdvancedGuide](advanced.md). You **must** call this function before calling
 `RUN_ALL_TESTS()`, or the flags won't be properly initialized.
 

From 116b7e55281c4200151524b093ecc03757a4ffda Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Thu, 19 Oct 2023 13:54:41 -0700
Subject: [PATCH 275/336] Improve error message for invalid parameterized test
 names.

PiperOrigin-RevId: 574992011
Change-Id: Id6030a9e5f317966186cc48ef2c09ad97fa15d3e
---
 googletest/include/gtest/internal/gtest-param-util.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/googletest/include/gtest/internal/gtest-param-util.h b/googletest/include/gtest/internal/gtest-param-util.h
index dd39e98a1..b04f70206 100644
--- a/googletest/include/gtest/internal/gtest-param-util.h
+++ b/googletest/include/gtest/internal/gtest-param-util.h
@@ -584,8 +584,8 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
 
           GTEST_CHECK_(IsValidParamName(param_name))
               << "Parameterized test name '" << param_name
-              << "' is invalid (contains spaces, dashes, underscores, or "
-                 "non-alphanumeric characters), in "
+              << "' is invalid (contains spaces, dashes, or any "
+                 "non-alphanumeric characters other than underscores), in "
               << file << " line " << line << "" << std::endl;
 
           GTEST_CHECK_(test_param_names.count(param_name) == 0)

From 518387203b573f35477fa6872dd54620e70d2bdb Mon Sep 17 00:00:00 2001
From: Dino Radakovic 
Date: Mon, 23 Oct 2023 10:10:45 -0700
Subject: [PATCH 276/336] StartsWith: Explicitly construct matcher-typed
 strings from matchee parameter

The current implementation breaks for absl::string_view on gcc, c++14: https://godbolt.org/z/Tzd3q1fqx

Closes #4391

PiperOrigin-RevId: 575853981
Change-Id: I7b782598add480eb69d4ca27ea4a4bf5f758f6a3
---
 googlemock/include/gmock/gmock-matchers.h          | 4 ++--
 googlemock/test/gmock-matchers-comparisons_test.cc | 9 +++++++++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h
index 0f6771377..8052c74a1 100644
--- a/googlemock/include/gmock/gmock-matchers.h
+++ b/googlemock/include/gmock/gmock-matchers.h
@@ -1048,7 +1048,7 @@ class StartsWithMatcher {
   template 
   bool MatchAndExplain(const MatcheeStringType& s,
                        MatchResultListener* /* listener */) const {
-    const StringType& s2(s);
+    const StringType s2(s);
     return s2.length() >= prefix_.length() &&
            s2.substr(0, prefix_.length()) == prefix_;
   }
@@ -1102,7 +1102,7 @@ class EndsWithMatcher {
   template 
   bool MatchAndExplain(const MatcheeStringType& s,
                        MatchResultListener* /* listener */) const {
-    const StringType& s2(s);
+    const StringType s2(s);
     return s2.length() >= suffix_.length() &&
            s2.substr(s2.length() - suffix_.length()) == suffix_;
   }
diff --git a/googlemock/test/gmock-matchers-comparisons_test.cc b/googlemock/test/gmock-matchers-comparisons_test.cc
index b2ce99e18..5b75b457b 100644
--- a/googlemock/test/gmock-matchers-comparisons_test.cc
+++ b/googlemock/test/gmock-matchers-comparisons_test.cc
@@ -1769,6 +1769,15 @@ TEST(StartsWithTest, CanDescribeSelf) {
   EXPECT_EQ("starts with \"Hi\"", Describe(m));
 }
 
+TEST(StartsWithTest, WorksWithStringMatcherOnStringViewMatchee) {
+#if GTEST_INTERNAL_HAS_STRING_VIEW
+  EXPECT_THAT(internal::StringView("talk to me goose"),
+              StartsWith(std::string("talk")));
+#else
+  GTEST_SKIP() << "Not applicable without internal::StringView.";
+#endif  // GTEST_INTERNAL_HAS_STRING_VIEW
+}
+
 // Tests EndsWith(s).
 
 TEST(EndsWithTest, MatchesStringWithGivenSuffix) {

From 7f036c5563af7d0329f20e8bb42effb04629f0c0 Mon Sep 17 00:00:00 2001
From: Theo Buehler 
Date: Wed, 25 Oct 2023 07:17:52 +0200
Subject: [PATCH 277/336] Add missing include for raise(3)

If SIGTRAP is defined, this file may end up using raise(3), which is
defined in csignal, leading to a compilation failure on at least
OpenBSD/sparc64 with gcc 8.
---
 googletest/src/gtest.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 99b22ed32..dcf4e2694 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -43,6 +43,7 @@
 #include 
 #include   // NOLINT
 #include 
+#include 
 #include 
 #include 
 #include 

From 5b7fd63d6d69f1754d5f3be956949484ebac06d5 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Thu, 26 Oct 2023 13:14:13 -0700
Subject: [PATCH 278/336] Export gmock-spec-builders.

gmock.h is the umbrella header to be used for rest of the library, and it also
enables users to export certain details. This wasn't working for some interfaces
like EXPECT_CALL because gmock-spec-builders wasn't explicitly exported.

PiperOrigin-RevId: 576966583
Change-Id: Ie050430cf11384977cd95f4ed6e73235d6857057
---
 googlemock/include/gmock/gmock.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/googlemock/include/gmock/gmock.h b/googlemock/include/gmock/gmock.h
index 2ca4f7ac6..c78fb8ee5 100644
--- a/googlemock/include/gmock/gmock.h
+++ b/googlemock/include/gmock/gmock.h
@@ -60,6 +60,7 @@
 #include "gmock/gmock-more-actions.h"  // IWYU pragma: export
 #include "gmock/gmock-more-matchers.h"  // IWYU pragma: export
 #include "gmock/gmock-nice-strict.h"  // IWYU pragma: export
+#include "gmock/gmock-spec-builders.h"  // IWYU pragma: export
 #include "gmock/internal/gmock-internal-utils.h"
 #include "gmock/internal/gmock-port.h"
 

From 76bb2afb8b522d24496ad1c757a49784fbfa2e42 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Mon, 27 Nov 2023 13:31:59 -0800
Subject: [PATCH 279/336] Implement `testing::Rethrow` to throw exceptions more
 easily via `std::exception_ptr`

We avoid overloading or specializing `testing::Throw` as this is fundamentally a different operation than throwing the object.
However, we disable the corresponding overload of `testing::Throw` to prevent likely mistakes in the usage.

Fixes: #4412
PiperOrigin-RevId: 585745469
Change-Id: I03bb585427ce51983d914e88f2bf65a13545c920
---
 googlemock/include/gmock/gmock-actions.h | 24 +++++++++++++++++++++---
 googlemock/test/gmock_link_test.h        |  9 +++++++++
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h
index f20258bca..fab999338 100644
--- a/googlemock/include/gmock/gmock-actions.h
+++ b/googlemock/include/gmock/gmock-actions.h
@@ -135,6 +135,7 @@
 #endif
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1746,6 +1747,13 @@ struct ThrowAction {
     return [copy](Args...) -> R { throw copy; };
   }
 };
+struct RethrowAction {
+  std::exception_ptr exception;
+  template 
+  operator Action() const {  // NOLINT
+    return [ex = exception](Args...) -> R { std::rethrow_exception(ex); };
+  }
+};
 #endif  // GTEST_HAS_EXCEPTIONS
 
 }  // namespace internal
@@ -2062,13 +2070,23 @@ internal::ReturnPointeeAction ReturnPointee(Ptr pointer) {
   return {pointer};
 }
 
-// Action Throw(exception) can be used in a mock function of any type
-// to throw the given exception.  Any copyable value can be thrown.
 #if GTEST_HAS_EXCEPTIONS
+// Action Throw(exception) can be used in a mock function of any type
+// to throw the given exception.  Any copyable value can be thrown,
+// except for std::exception_ptr, which is likely a mistake if
+// thrown directly.
 template 
-internal::ThrowAction::type> Throw(T&& exception) {
+typename std::enable_if<
+    !std::is_base_of::type>::value,
+    internal::ThrowAction::type>>::type
+Throw(T&& exception) {
   return {std::forward(exception)};
 }
+// Action Rethrow(exception_ptr) can be used in a mock function of any type
+// to rethrow any exception_ptr. Note that the same object is thrown each time.
+inline internal::RethrowAction Rethrow(std::exception_ptr exception) {
+  return {std::move(exception)};
+}
 #endif  // GTEST_HAS_EXCEPTIONS
 
 namespace internal {
diff --git a/googlemock/test/gmock_link_test.h b/googlemock/test/gmock_link_test.h
index db11c2d24..cf0a985b6 100644
--- a/googlemock/test/gmock_link_test.h
+++ b/googlemock/test/gmock_link_test.h
@@ -187,6 +187,7 @@ using testing::SetErrnoAndReturn;
 
 #if GTEST_HAS_EXCEPTIONS
 using testing::Throw;
+using testing::Rethrow;
 #endif
 
 using testing::ContainsRegex;
@@ -416,6 +417,14 @@ TEST(LinkTest, TestThrow) {
   EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Throw(42));
   EXPECT_THROW(mock.VoidFromString(nullptr), int);
 }
+// Tests the linkage of the Rethrow action.
+TEST(LinkTest, TestRethrow) {
+  Mock mock;
+
+  EXPECT_CALL(mock, VoidFromString(_))
+      .WillOnce(Rethrow(std::make_exception_ptr(42)));
+  EXPECT_THROW(mock.VoidFromString(nullptr), int);
+}
 #endif  // GTEST_HAS_EXCEPTIONS
 
 // The ACTION*() macros trigger warning C4100 (unreferenced formal

From 48b373f6e0019cc766b4e088201fc90fe1373fe2 Mon Sep 17 00:00:00 2001
From: Tamas Kenez 
Date: Fri, 1 Dec 2023 23:09:45 +0100
Subject: [PATCH 280/336] Allow using external absl and re2.

---
 CMakeLists.txt                   | 9 +++++++++
 googletest/cmake/Config.cmake.in | 4 ++++
 2 files changed, 13 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 24d41c29c..9e6d6440d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,6 +20,15 @@ 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/googletest/cmake/Config.cmake.in b/googletest/cmake/Config.cmake.in
index 12be4498b..3f706612b 100644
--- a/googletest/cmake/Config.cmake.in
+++ b/googletest/cmake/Config.cmake.in
@@ -4,6 +4,10 @@ if (@GTEST_HAS_PTHREAD@)
   set(THREADS_PREFER_PTHREAD_FLAG @THREADS_PREFER_PTHREAD_FLAG@)
   find_dependency(Threads)
 endif()
+if (@GTEST_HAS_ABSL@)
+  find_dependency(absl)
+  find_dependency(re2)
+endif()
 
 include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake")
 check_required_components("@project_name@")

From 8760db154aec99c70cb487d99aead838212d4986 Mon Sep 17 00:00:00 2001
From: Derek Mauro 
Date: Mon, 4 Dec 2023 13:41:38 -0800
Subject: [PATCH 281/336] Skip find_package(Python3) when not building tests

#4424 claims this saves several seconds of build time
Closes #4424

PiperOrigin-RevId: 587827426
Change-Id: I207779a6539f9af16a39d6b40887770dc930b74f
---
 googletest/cmake/internal_utils.cmake | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake
index 21887b2e0..580ac1cbc 100644
--- a/googletest/cmake/internal_utils.cmake
+++ b/googletest/cmake/internal_utils.cmake
@@ -247,7 +247,9 @@ function(cxx_executable name dir libs)
     ${name} "${cxx_default}" "${libs}" "${dir}/${name}.cc" ${ARGN})
 endfunction()
 
-find_package(Python3)
+if(gtest_build_tests)
+  find_package(Python3)
+endif()
 
 # cxx_test_with_flags(name cxx_flags libs srcs...)
 #

From eb80f759d595874a5e905a3342bd8e2af4c0a12d Mon Sep 17 00:00:00 2001
From: Tom Hughes 
Date: Mon, 11 Dec 2023 16:16:45 -0800
Subject: [PATCH 282/336] Remove unnecessary conversion

`GetAbsolutePathToOutputFile` returns a `std::string` and `OpenFileForWriting`
takes a `std::string&`.

PiperOrigin-RevId: 589984409
Change-Id: I75be9cb105f49b3a279a5d33b1b82dfcfc912cfd
---
 googletest/src/gtest.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 85d45b58e..479b2ee31 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -6203,8 +6203,8 @@ void UnitTestImpl::ListTestsMatchingFilter() {
 #if GTEST_HAS_FILE_SYSTEM
   const std::string& output_format = UnitTestOptions::GetOutputFormat();
   if (output_format == "xml" || output_format == "json") {
-    FILE* fileout = OpenFileForWriting(
-        UnitTestOptions::GetAbsolutePathToOutputFile().c_str());
+    FILE* fileout =
+        OpenFileForWriting(UnitTestOptions::GetAbsolutePathToOutputFile());
     std::stringstream stream;
     if (output_format == "xml") {
       XmlUnitTestResultPrinter(

From 530d5c8c84abd2a46f38583ee817743c9b3a42b4 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Tue, 12 Dec 2023 17:40:15 -0800
Subject: [PATCH 283/336] Add `FAIL_AT` macro variant of `FAIL` matching
 `ADD_FAILURE`, `ADD_FAILURE_AT`

`FAIL_AT` is shorthand for `GTEST_FAIL_AT` like `FAIL` is for `GTEST_FAIL`.

PiperOrigin-RevId: 590393926
Change-Id: I68263af8fa2f98ca0bbef509d475c84e22068018
---
 googletest/include/gtest/gtest.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h
index a932e686a..45400fd0b 100644
--- a/googletest/include/gtest/gtest.h
+++ b/googletest/include/gtest/gtest.h
@@ -1751,6 +1751,7 @@ class TestWithParam : public Test, public WithParamInterface {};
 // generic name and clashes with some other libraries.
 #if !(defined(GTEST_DONT_DEFINE_FAIL) && GTEST_DONT_DEFINE_FAIL)
 #define FAIL() GTEST_FAIL()
+#define FAIL_AT(file, line) GTEST_FAIL_AT(file, line)
 #endif
 
 // Generates a success with a generic message.

From 8495449f075543dbac005d6c33118e58ad770d75 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Mon, 18 Dec 2023 10:14:04 -0800
Subject: [PATCH 284/336] Fix data race in leak detection

TSAN identified a data race between updates to the states_ map (ex. in Mock::UnregisterLocked) and the iteration done in this destructor. Writes to the map use g_gmock_mutex, but the destructor does not acquire it. Acquiring the lock here fixes the data race.

It should only be possible to trigger this TSAN finding in cases where a mock object is deleted by a thread other than the main thread.

PiperOrigin-RevId: 591935393
Change-Id: I9dd1faa40058d78e165a91333346514b4b73365c
---
 googlemock/src/gmock-spec-builders.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc
index de8947163..fb67ab09d 100644
--- a/googlemock/src/gmock-spec-builders.cc
+++ b/googlemock/src/gmock-spec-builders.cc
@@ -490,6 +490,7 @@ class MockObjectRegistry {
   // failure, unless the user explicitly asked us to ignore it.
   ~MockObjectRegistry() {
     if (!GMOCK_FLAG_GET(catch_leaked_mocks)) return;
+    internal::MutexLock l(&internal::g_gmock_mutex);
 
     int leaked_count = 0;
     for (StateMap::const_iterator it = states_.begin(); it != states_.end();

From cde9a745a66dc349dde300cb357974ef4f4b11fc Mon Sep 17 00:00:00 2001
From: Derek Mauro 
Date: Tue, 19 Dec 2023 13:55:58 -0800
Subject: [PATCH 285/336] Fix broken links in primer.md

Closes #4432

PiperOrigin-RevId: 592335698
Change-Id: I9859451981f58f1426255067d702a0767718b1d5
---
 docs/primer.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/docs/primer.md b/docs/primer.md
index 8b98da2a6..0f90c0399 100644
--- a/docs/primer.md
+++ b/docs/primer.md
@@ -73,8 +73,8 @@ Meaning
 Exercise a particular program path with specific input values and verify the results | [TEST()](#simple-tests) | [Test Case][istqb test case]
 
 
-[istqb test case]: https://glossary.istqb.org/en/search/test%20case
-[istqb test suite]: https://glossary.istqb.org/en/search/test%20suite
+[istqb test case]: https://glossary.istqb.org/en_US/term/test-case-2
+[istqb test suite]: https://glossary.istqb.org/en_US/term/test-suite-1-3
 
 ## Basic Concepts
 

From 96eadf659fb75ecda943bd97413c71d4c17c4f43 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Fri, 22 Dec 2023 08:50:31 -0800
Subject: [PATCH 286/336] Minor documentation correction.

PiperOrigin-RevId: 593126348
Change-Id: I78e12ab5dd2e5acc69b21250bdb04e62990b6309
---
 docs/reference/mocking.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/docs/reference/mocking.md b/docs/reference/mocking.md
index ab37ebf36..3ad49527c 100644
--- a/docs/reference/mocking.md
+++ b/docs/reference/mocking.md
@@ -81,8 +81,8 @@ EXPECT_CALL(mock_object, method_name(matchers...))
     .Times(cardinality)            // Can be used at most once
     .InSequence(sequences...)      // Can be used any number of times
     .After(expectations...)        // Can be used any number of times
-    .WillOnce(action)              // Can be used any number of times
-    .WillRepeatedly(action)        // Can be used at most once
+    .WillRepeatedly(action)        // Can be used any number of times
+    .WillOnce(action)              // Can be used at most once
     .RetiresOnSaturation();        // Can be used at most once
 ```
 

From dddb219c3eb96d7f9200f09b0a381f016e6b4562 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Thu, 28 Dec 2023 04:03:13 -0800
Subject: [PATCH 287/336] Accept move-only callables in `InvokeArguments`

PiperOrigin-RevId: 594223533
Change-Id: I491fae7d851d4e0df07fb3627416949071fec8d6
---
 googlemock/include/gmock/gmock-more-actions.h |  2 +-
 googlemock/test/gmock-more-actions_test.cc    | 14 +++++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/googlemock/include/gmock/gmock-more-actions.h b/googlemock/include/gmock/gmock-more-actions.h
index 40300766f..dd90e31fa 100644
--- a/googlemock/include/gmock/gmock-more-actions.h
+++ b/googlemock/include/gmock/gmock-more-actions.h
@@ -606,7 +606,7 @@ struct InvokeArgumentAction {
     internal::FlatTuple args_tuple(FlatTupleConstructTag{},
                                                std::forward(args)...);
     return params.Apply([&](const Params &...unpacked_params) {
-      auto &&callable = args_tuple.template Get();
+      auto &&callable = std::move(args_tuple.template Get());
       return internal::InvokeArgument(
           std::forward(callable), unpacked_params...);
     });
diff --git a/googlemock/test/gmock-more-actions_test.cc b/googlemock/test/gmock-more-actions_test.cc
index 9980f3bc4..16af68928 100644
--- a/googlemock/test/gmock-more-actions_test.cc
+++ b/googlemock/test/gmock-more-actions_test.cc
@@ -85,6 +85,12 @@ struct UnaryFunctor {
   int operator()(bool x) { return x ? 1 : -1; }
 };
 
+struct UnaryMoveOnlyFunctor : UnaryFunctor {
+  UnaryMoveOnlyFunctor() = default;
+  UnaryMoveOnlyFunctor(const UnaryMoveOnlyFunctor&) = delete;
+  UnaryMoveOnlyFunctor(UnaryMoveOnlyFunctor&&) = default;
+};
+
 const char* Binary(const char* input, short n) { return input + n; }  // NOLINT
 
 int Ternary(int x, char y, short z) { return x + y + z; }  // NOLINT
@@ -698,12 +704,18 @@ TEST(InvokeArgumentTest, Function0) {
   EXPECT_EQ(1, a.Perform(std::make_tuple(2, &Nullary)));
 }
 
-// Tests using InvokeArgument with a unary function.
+// Tests using InvokeArgument with a unary functor.
 TEST(InvokeArgumentTest, Functor1) {
   Action a = InvokeArgument<0>(true);  // NOLINT
   EXPECT_EQ(1, a.Perform(std::make_tuple(UnaryFunctor())));
 }
 
+// Tests using InvokeArgument with a unary move-only functor.
+TEST(InvokeArgumentTest, Functor1MoveOnly) {
+  Action a = InvokeArgument<0>(true);  // NOLINT
+  EXPECT_EQ(1, a.Perform(std::make_tuple(UnaryMoveOnlyFunctor())));
+}
+
 // Tests using InvokeArgument with a 5-ary function.
 TEST(InvokeArgumentTest, Function5) {
   Action a =  // NOLINT

From dda72ef32181edbfcd32a8c52b4740cd8061ab6f Mon Sep 17 00:00:00 2001
From: kaswhy 
Date: Fri, 29 Dec 2023 02:05:18 +0900
Subject: [PATCH 288/336] Docs: add conditions for calling TearDown()

---
 docs/advanced.md | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/docs/advanced.md b/docs/advanced.md
index 0e1f812b9..8e1df2a8b 100644
--- a/docs/advanced.md
+++ b/docs/advanced.md
@@ -1006,9 +1006,12 @@ Environment* AddGlobalTestEnvironment(Environment* env);
 
 Now, when `RUN_ALL_TESTS()` is called, it first calls the `SetUp()` method of
 each environment object, then runs the tests if none of the environments
-reported fatal failures and `GTEST_SKIP()` was not called. `RUN_ALL_TESTS()`
-always calls `TearDown()` with each environment object, regardless of whether or
-not the tests were run.
+reported fatal failures and `GTEST_SKIP()` was not called. 
+
+RUN_ALL_TESTS() calls TearDown() for each environment object when they are recreated
+for each iteration. However, if the test environments are not recreated for each iteration,
+TearDown() is called only on the last iteration.
+Additionally, TearDown() is executed regardless of whether the tests were run or not.
 
 It's OK to register multiple environment objects. In this suite, their `SetUp()`
 will be called in the order they are registered, and their `TearDown()` will be

From 3b26f7e53bbe287deb57c75c796f17c9a82229a1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Krzysztof=20Kosi=C5=84ski?= 
Date: Tue, 9 Jan 2024 08:38:41 -0800
Subject: [PATCH 289/336] Disable -Wfloat-equal in AppropriateResolution().

This function makes exact floating point that are correct in this context, but trigger the compiler warning.

PiperOrigin-RevId: 596944060
Change-Id: I4bba3c2abcf3ac189107530978961955ad47d6f0
---
 googletest/include/gtest/gtest-printers.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h
index 1b12ef683..0007a2a9d 100644
--- a/googletest/include/gtest/gtest-printers.h
+++ b/googletest/include/gtest/gtest-printers.h
@@ -552,6 +552,10 @@ int AppropriateResolution(FloatType val) {
   int full = std::numeric_limits::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
@@ -595,6 +599,9 @@ int AppropriateResolution(FloatType val) {
         val)
       return 6;
   }
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
   return full;
 }
 

From 7f409cb3c04694cdf867a04f11121eab35a67597 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Tue, 9 Jan 2024 09:38:37 -0800
Subject: [PATCH 290/336] Add a note about argv requiring NULL termination.

Fixes: #4434
PiperOrigin-RevId: 596960654
Change-Id: I1f70cc0801764fe0328030c46254f82eb9893a49
---
 docs/reference/testing.md | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/docs/reference/testing.md b/docs/reference/testing.md
index ead66b362..81640fd49 100644
--- a/docs/reference/testing.md
+++ b/docs/reference/testing.md
@@ -1317,7 +1317,9 @@ tests.
 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.
 

From 7c07a863693b0c831f80473f7c6905d7e458682c Mon Sep 17 00:00:00 2001
From: Derek Mauro 
Date: Tue, 9 Jan 2024 13:01:48 -0800
Subject: [PATCH 291/336] Update CI builds to use Bazel 7.0.0

--features=external_include_paths has been removed from Windows builds
since it appears cause build command errors currently
PiperOrigin-RevId: 597020418
Change-Id: Ie37be0d05f3a154ab0d3c3f7d39b4e2c0ed650a3
---
 ci/linux-presubmit.sh    | 7 +++----
 ci/macos-presubmit.sh    | 2 +-
 ci/windows-presubmit.bat | 3 +--
 3 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/ci/linux-presubmit.sh b/ci/linux-presubmit.sh
index a1caa2720..1e05998e4 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
@@ -80,7 +80,6 @@ time docker run \
       --copt="-Wuninitialized" \
       --copt="-Wundef" \
       --copt="-Wno-error=pragmas" \
-      --distdir="/bazel-distdir" \
       --features=external_include_paths \
       --keep_going \
       --show_timestamps \
@@ -102,7 +101,7 @@ for std in ${STD}; do
         --copt="-Wuninitialized" \
         --copt="-Wundef" \
         --define="absl=${absl}" \
-        --distdir="/bazel-distdir" \
+        --enable_bzlmod=false \
         --features=external_include_paths \
         --keep_going \
         --show_timestamps \
@@ -127,7 +126,7 @@ for std in ${STD}; do
         --copt="-Wuninitialized" \
         --copt="-Wundef" \
         --define="absl=${absl}" \
-        --distdir="/bazel-distdir" \
+        --enable_bzlmod=false \
         --features=external_include_paths \
         --keep_going \
         --linkopt="--gcc-toolchain=/usr/local" \
diff --git a/ci/macos-presubmit.sh b/ci/macos-presubmit.sh
index 681ebc2a9..1033282e7 100644
--- a/ci/macos-presubmit.sh
+++ b/ci/macos-presubmit.sh
@@ -53,7 +53,7 @@ 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-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}
diff --git a/ci/windows-presubmit.bat b/ci/windows-presubmit.bat
index 48962eb9e..38565fbf2 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,6 @@ SET BAZEL_VS=C:\Program Files\Microsoft Visual Studio\2022\Community
   --compilation_mode=dbg ^
   --copt=/std:c++14 ^
   --copt=/WX ^
-  --features=external_include_paths ^
   --keep_going ^
   --test_output=errors ^
   --test_tag_filters=-no_test_msvc2017

From f57505314bca32c5c5f186fd52c3cb720bf1853c Mon Sep 17 00:00:00 2001
From: Michael Leslie 
Date: Wed, 10 Jan 2024 11:34:22 -0800
Subject: [PATCH 292/336] only apply -lregex for qnx710 and newer

---
 googletest/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/googletest/CMakeLists.txt b/googletest/CMakeLists.txt
index 51a67c915..dce6a7c9e 100644
--- a/googletest/CMakeLists.txt
+++ b/googletest/CMakeLists.txt
@@ -147,7 +147,7 @@ target_include_directories(gtest SYSTEM INTERFACE
 target_include_directories(gtest_main SYSTEM INTERFACE
   "$"
   "$/${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)

From 778badf63a6459b15c237ffad798ef9a484e84fe Mon Sep 17 00:00:00 2001
From: kaswhy 
Date: Fri, 12 Jan 2024 01:06:00 +0900
Subject: [PATCH 293/336] Docs: add conditions for calling SetUp and TearDown()

---
 docs/advanced.md | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/docs/advanced.md b/docs/advanced.md
index 8e1df2a8b..ff50edab1 100644
--- a/docs/advanced.md
+++ b/docs/advanced.md
@@ -1004,14 +1004,18 @@ calling the `::testing::AddGlobalTestEnvironment()` function:
 Environment* AddGlobalTestEnvironment(Environment* env);
 ```
 
-Now, when `RUN_ALL_TESTS()` is called, it first calls the `SetUp()` method of
-each environment object, then runs the tests if none of the environments
-reported fatal failures and `GTEST_SKIP()` was not 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.
 
-RUN_ALL_TESTS() calls TearDown() for each environment object when they are recreated
-for each iteration. However, if the test environments are not recreated for each iteration,
-TearDown() is called only on the last iteration.
-Additionally, TearDown() is executed regardless of whether the tests were run or not.
+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 itself
+is not run due to exception handling (e.g., fatal failures or if GTEST_SKIP() is invoked).
+
+SetUp() and TearDown() are also 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 on the last iteration.
 
 It's OK to register multiple environment objects. In this suite, their `SetUp()`
 will be called in the order they are registered, and their `TearDown()` will be

From cfe5076a8b99ce7979b0b5d328ff8a9199e04eef Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Tue, 16 Jan 2024 11:18:39 -0800
Subject: [PATCH 294/336] Do not emit stack traces for messages generated by
 GTEST_SKIP()

Stack traces in assertion failures are an extremely useful tool for
developers tasked with investigating failing tests. It's difficult to
understate this. In contrast to ordinary test assertions (e.g.,
ASSERT_TRUE or EXPECT_FALSE), GTEST_SKIP is a developer-authored
directive to skip one or more tests. Stack traces emitted in skip
messages do not give the developer useful information, as the skip
message itself contains the code location where GTEST_SKIP was used. In
addition to being noise in the output, symbolization of stack traces is
not free. In some Chromium configurations, symbolization in a skipped
test can incur a cost in excess of 25 seconds for a test that otherwise
takes 0-1ms; see https://crbug.com/1517343#c9.

In this CL, we suppress generation and emission of stack traces for
kSkip messages to reduce the output noise and overhead of GTEST_SKIP().

PiperOrigin-RevId: 598899010
Change-Id: I46926fed452c8d7edcb3d636d8fed42cb6c0a9e9
---
 googletest/src/gtest.cc                           |  7 ++++++-
 .../test/googletest-output-test-golden-lin.txt    |  1 -
 googletest/test/gtest_xml_output_unittest.py      | 15 +++++++++------
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 479b2ee31..46212e742 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -459,7 +459,12 @@ void AssertHelper::operator=(const Message& message) const {
   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
 }
diff --git a/googletest/test/googletest-output-test-golden-lin.txt b/googletest/test/googletest-output-test-golden-lin.txt
index 6ddf822ff..e06856a2f 100644
--- a/googletest/test/googletest-output-test-golden-lin.txt
+++ b/googletest/test/googletest-output-test-golden-lin.txt
@@ -970,7 +970,6 @@ googletest-output-test_.cc:#: Skipped
 [----------] 1 test from TestSuiteThatSkipsInSetUp
 googletest-output-test_.cc:#: Skipped
 Skip entire test suite
-Stack trace: (omitted)
 
 [ RUN      ] TestSuiteThatSkipsInSetUp.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 422569e48..c3fea2c0a 100755
--- a/googletest/test/gtest_xml_output_unittest.py
+++ b/googletest/test/gtest_xml_output_unittest.py
@@ -112,20 +112,23 @@ Invalid characters in brackets []%(stack)s]]>
   
   
     
-      
+      
     
     
-      
+      
     
     
       
-      
+      
     
 
   

From f6f920d2ba09f3951af59045cd31c42e95bf127a Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Tue, 16 Jan 2024 12:55:45 -0800
Subject: [PATCH 295/336] Make posix::FileNo available under
 !GTEST_HAS_FILE_SYSTEM

This enables automatic color output without filesystem support, as that only requires testing to see if the output is a terminal.

Fixes: #4439
PiperOrigin-RevId: 598929397
Change-Id: Idca7490e6e090951a78cd1cdd710f41d756a68b4
---
 googletest/include/gtest/internal/gtest-port.h | 11 +++++++++--
 googletest/src/gtest.cc                        |  6 ++----
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index d061a49b9..f2b591dfd 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -2005,7 +2005,9 @@ inline std::string StripTrailingSpaces(std::string str) {
 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 +2018,32 @@ inline int FileNo(FILE* file) { return reinterpret_cast(_fileno(file)); }
 // 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 +2052,9 @@ inline int RmDir(const char*) { return 0; }
 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.
 
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 46212e742..8a19c50c6 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -3288,11 +3288,9 @@ static void ColoredPrintf(GTestColor color, const char* fmt, ...) {
   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);
 

From 96cd50c082d880a9aab6455dcc5817cfbf0ea45f Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Thu, 18 Jan 2024 14:23:34 -0800
Subject: [PATCH 296/336] If GTEST_NO_ABSL_FLAGS is #defined, then the Abseil
 flag library will not be used by googletest, even if GTEST_HAS_ABSL is
 #defined.

PiperOrigin-RevId: 599625032
Change-Id: Ieb994a15683dec89e88578120071eca8ac9fead1
---
 googletest/include/gtest/internal/gtest-port.h | 12 +++++++-----
 googletest/src/gtest.cc                        |  8 +++++++-
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index f2b591dfd..fa457b788 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
 
@@ -2252,7 +2253,7 @@ using TimeInMillis = int64_t;  // Represents time in milliseconds.
 #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) \
@@ -2277,7 +2278,8 @@ using TimeInMillis = int64_t;  // Represents time in milliseconds.
   (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)  \
@@ -2319,7 +2321,7 @@ using TimeInMillis = int64_t;  // Represents time in milliseconds.
 #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 8a19c50c6..7dc805943 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;
@@ -6688,7 +6692,7 @@ void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {
 // 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 positional_args;
@@ -6774,11 +6778,13 @@ void InitGoogleTestImpl(int* argc, CharType** argv) {
 #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);

From ffc477e705589a697b062c366480d80fe6124e9b Mon Sep 17 00:00:00 2001
From: Dino Radakovic 
Date: Mon, 22 Jan 2024 10:11:40 -0800
Subject: [PATCH 297/336] googletest: Fix incorrect comment about `value_param`
 of `internal::MakeAndRegisterTestInfo`

This was probably a copy-paste from the comment about `type_param`.

PiperOrigin-RevId: 600493462
Change-Id: I4a41c2673dd6560db0f68856aab3d32b103164b1
---
 googletest/include/gtest/internal/gtest-internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h
index 4f077fcfb..806b08624 100644
--- a/googletest/include/gtest/internal/gtest-internal.h
+++ b/googletest/include/gtest/internal/gtest-internal.h
@@ -555,7 +555,7 @@ struct SuiteApiResolver : T {
 //   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

From 1cab76c7b80756c42008fc36870146c8e38507de Mon Sep 17 00:00:00 2001
From: kaswhy 
Date: Tue, 23 Jan 2024 21:39:40 +0900
Subject: [PATCH 298/336] Docs: Add mention of
 `gtest_recreate_environments_when_repeating`

---
 docs/advanced.md | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/docs/advanced.md b/docs/advanced.md
index ff50edab1..715bd047a 100644
--- a/docs/advanced.md
+++ b/docs/advanced.md
@@ -1004,18 +1004,20 @@ calling the `::testing::AddGlobalTestEnvironment()` function:
 Environment* AddGlobalTestEnvironment(Environment* env);
 ```
 
-Now, when RUN_ALL_TESTS() is invoked, it first calls the SetUp() method. 
+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.
+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 itself
-is not run due to exception handling (e.g., fatal failures or if GTEST_SKIP() is invoked).
+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()`.
 
-SetUp() and TearDown() are also 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 on the last iteration.
+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 
+on the last iteration.
 
 It's OK to register multiple environment objects. In this suite, their `SetUp()`
 will be called in the order they are registered, and their `TearDown()` will be

From 563ebf1769af08d448765c31064260e1a16fcced Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Tue, 23 Jan 2024 07:02:01 -0800
Subject: [PATCH 299/336] Fix double-promotion warnings in
 AppropriateResolution()

When -Wdouble-promotion is enabled, the templatized function AppropriateResolution fails to compile since its float instantiation promotes floats to doubles when doing arithmetic and comparisons. Add static casts to resolve these errors.

PiperOrigin-RevId: 600776333
Change-Id: Ia530b4bbca6ddce27caf0a817196d87efef711cb
---
 googletest/include/gtest/gtest-printers.h | 49 +++++++++++++----------
 1 file changed, 28 insertions(+), 21 deletions(-)

diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h
index 0007a2a9d..b2822bcde 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   // NOLINT
-#endif  // GTEST_INTERNAL_HAS_STD_SPAN
+#endif           // GTEST_INTERNAL_HAS_STD_SPAN
 
 namespace testing {
 
@@ -241,8 +241,8 @@ struct StreamPrinter {
   // 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;
@@ -558,43 +558,50 @@ int AppropriateResolution(FloatType val) {
 #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(100000.0)) {  // 100,000 to 999,999
       mulfor6 = 1.0;
-    } else if (val >= 10000.0) {
+    } else if (val >= static_cast(10000.0)) {
       mulfor6 = 1e1;
-    } else if (val >= 1000.0) {
+    } else if (val >= static_cast(1000.0)) {
       mulfor6 = 1e2;
-    } else if (val >= 100.0) {
+    } else if (val >= static_cast(100.0)) {
       mulfor6 = 1e3;
-    } else if (val >= 10.0) {
+    } else if (val >= static_cast(10.0)) {
       mulfor6 = 1e4;
-    } else if (val >= 1.0) {
+    } else if (val >= static_cast(1.0)) {
       mulfor6 = 1e5;
-    } else if (val >= 0.1) {
+    } else if (val >= static_cast(0.1)) {
       mulfor6 = 1e6;
-    } else if (val >= 0.01) {
+    } else if (val >= static_cast(0.01)) {
       mulfor6 = 1e7;
-    } else if (val >= 0.001) {
+    } else if (val >= static_cast(0.001)) {
       mulfor6 = 1e8;
-    } else if (val >= 0.0001) {
+    } else if (val >= static_cast(0.0001)) {
       mulfor6 = 1e9;
     }
-    if (static_cast(static_cast(val * mulfor6 + 0.5)) /
+    if (static_cast(static_cast(
+            val * mulfor6 + (static_cast(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(1e10)) {
+    FloatType divfor6 = static_cast(1.0);
+    if (val >= static_cast(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(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(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(1e6)) {  // 1,000,000 to 9,999,999
       divfor6 = 10;
     }
-    if (static_cast(static_cast(val / divfor6 + 0.5)) *
+    if (static_cast(static_cast(
+            val / divfor6 + (static_cast(0.5)))) *
             divfor6 ==
         val)
       return 6;

From 6a5938233b6519ba99ddb7c7314d45d3fa877969 Mon Sep 17 00:00:00 2001
From: Derek Mauro 
Date: Thu, 25 Jan 2024 10:27:14 -0800
Subject: [PATCH 300/336] Add support for Bzlmod for the next release
 https://bazel.build/external/overview#bzlmod

Bzlmod will be the default in a future Bazel release.
By default it requires projects to be registered with the
Bazel Central Registry (https://registry.bazel.build/) and
thus uses regular releases by default.

Users that want to "live-at-head" can still do this through
with overrides (https://bazel.build/external/module#overrides).

This change updates GoogleTest dependencies to use released versions.
CI uses Bzlmod except in the case of linux_gcc-floor, which will
keep testing the old WORKSPACE-based dependency system.

PiperOrigin-RevId: 601489729
Change-Id: I6be52034eba0d0e5fe12110e5e82879305cf73ff
---
 .gitignore               |  1 +
 MODULE.bazel             | 57 ++++++++++++++++++++++++++++++++++++++++
 WORKSPACE                | 32 +++++++++++-----------
 WORKSPACE.bzlmod         | 35 ++++++++++++++++++++++++
 ci/linux-presubmit.sh    |  7 +++--
 ci/macos-presubmit.sh    |  1 +
 ci/windows-presubmit.bat |  1 +
 googletest_deps.bzl      | 16 +++++------
 8 files changed, 125 insertions(+), 25 deletions(-)
 create mode 100644 MODULE.bazel
 create mode 100644 WORKSPACE.bzlmod

diff --git a/.gitignore b/.gitignore
index fede02f65..f0df39db1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,7 @@ bazel-genfiles
 bazel-googletest
 bazel-out
 bazel-testlogs
+MODULE.bazel.lock
 # python
 *.pyc
 
diff --git a/MODULE.bazel b/MODULE.bazel
new file mode 100644
index 000000000..d4ad2b3ae
--- /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 f819ffe61..92cfd259a 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -6,22 +6,24 @@ googletest_deps()
 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 000000000..381432c5d
--- /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 1e05998e4..35e167072 100644
--- a/ci/linux-presubmit.sh
+++ b/ci/linux-presubmit.sh
@@ -67,6 +67,9 @@ for cc in /usr/local/bin/gcc /opt/llvm/clang/bin/clang; do
 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" \
@@ -101,7 +104,7 @@ for std in ${STD}; do
         --copt="-Wuninitialized" \
         --copt="-Wundef" \
         --define="absl=${absl}" \
-        --enable_bzlmod=false \
+        --enable_bzlmod=true \
         --features=external_include_paths \
         --keep_going \
         --show_timestamps \
@@ -126,7 +129,7 @@ for std in ${STD}; do
         --copt="-Wuninitialized" \
         --copt="-Wundef" \
         --define="absl=${absl}" \
-        --enable_bzlmod=false \
+        --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 1033282e7..70eaa74fb 100644
--- a/ci/macos-presubmit.sh
+++ b/ci/macos-presubmit.sh
@@ -69,6 +69,7 @@ for absl in 0 1; do
     --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 38565fbf2..9753f9c0c 100644
--- a/ci/windows-presubmit.bat
+++ b/ci/windows-presubmit.bat
@@ -51,6 +51,7 @@ SET BAZEL_VS=C:\Program Files\Microsoft Visual Studio\2022\Community
   --compilation_mode=dbg ^
   --copt=/std:c++14 ^
   --copt=/WX ^
+  --enable_bzlmod=true ^
   --keep_going ^
   --test_output=errors ^
   --test_tag_filters=-no_test_msvc2017
diff --git a/googletest_deps.bzl b/googletest_deps.bzl
index 8f19cbed7..8958890c7 100644
--- a/googletest_deps.bzl
+++ b/googletest_deps.bzl
@@ -7,16 +7,16 @@ def googletest_deps():
 
     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"],
         )

From 6fdb4c303f5e5fe42baf818ced2d82bee01e9b8c Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Tue, 30 Jan 2024 13:55:07 -0800
Subject: [PATCH 301/336] Do not emit stack traces for messages generated by
 SUCCEED()

Stack traces in assertion failures are an extremely useful tool for
developers tasked with investigating failing tests. It's difficult to
understate this. In contrast to ordinary test assertions (e.g.,
ASSERT_TRUE or EXPECT_FALSE), SUCCEED() is a developer-authored
directive that indicates a success codepath. In fact, the documentation
states that this directive doesn't generate any output. Generating stack
traces for uses of SUCCEED() is wasted work since they are never
printed. If this were to change one day in the future, they still would
not be useful since any emitted message would include the file and line
number where SUCCEED was used. In addition to being noise in the output
in this case, symbolization of stack traces is not free. In some
Chromium configurations, symbolization for use of SUCCEED() can incur a
cost in excess of 25 seconds for a test that otherwise takes 0-1ms; see
https://crbug.com/1517343.

In this CL, we suppress generation and emission of stack traces for
kSuccess messages to reduce the overhead of SUCCEED().

PiperOrigin-RevId: 602832162
Change-Id: I557dd6a1d3e6ed6562daf727d69fd01fe914827b
---
 googletest/src/gtest.cc                        | 18 ++++++++++++++----
 .../test/googletest-output-test-golden-lin.txt |  4 ----
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 7dc805943..6d6ff1bb0 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -451,6 +451,19 @@ static bool ShouldRunTestSuite(const TestSuite* test_suite) {
   return test_suite->should_run();
 }
 
+namespace {
+
+// Returns true if test part results of type `type` should include a stack
+// trace.
+bool ShouldEmitStackTraceForResultType(TestPartResult::Type type) {
+  // Suppress emission of the stack trace for SUCCEED() since it likely never
+  // requires investigation, and GTEST_SKIP() since skipping is an intentional
+  // act by the developer rather than a failure requiring investigation.
+  return type != TestPartResult::kSuccess && type != TestPartResult::kSkip;
+}
+
+}  // namespace
+
 // AssertHelper constructor.
 AssertHelper::AssertHelper(TestPartResult::Type type, const char* file,
                            int line, const char* message)
@@ -463,10 +476,7 @@ void AssertHelper::operator=(const Message& message) const {
   UnitTest::GetInstance()->AddTestPartResult(
       data_->type, data_->file, data_->line,
       AppendUserMessage(data_->message, message),
-      // 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
+      ShouldEmitStackTraceForResultType(data_->type)
           ? UnitTest::GetInstance()->impl()->CurrentOsStackTraceExceptTop(1)
           : ""
       // Skips the stack frame for this function itself.
diff --git a/googletest/test/googletest-output-test-golden-lin.txt b/googletest/test/googletest-output-test-golden-lin.txt
index e06856a2f..533eb8c6e 100644
--- a/googletest/test/googletest-output-test-golden-lin.txt
+++ b/googletest/test/googletest-output-test-golden-lin.txt
@@ -696,7 +696,6 @@ Expected: 1 fatal failure
   Actual:
 googletest-output-test_.cc:#: Success:
 Succeeded
-Stack trace: (omitted)
 
 
 Stack trace: (omitted)
@@ -733,7 +732,6 @@ Expected: 1 non-fatal failure
   Actual:
 googletest-output-test_.cc:#: Success:
 Succeeded
-Stack trace: (omitted)
 
 
 Stack trace: (omitted)
@@ -770,7 +768,6 @@ Expected: 1 fatal failure
   Actual:
 googletest-output-test_.cc:#: Success:
 Succeeded
-Stack trace: (omitted)
 
 
 Stack trace: (omitted)
@@ -807,7 +804,6 @@ Expected: 1 non-fatal failure
   Actual:
 googletest-output-test_.cc:#: Success:
 Succeeded
-Stack trace: (omitted)
 
 
 Stack trace: (omitted)

From 3cb7ce90b3d0e67c9f855bf9792a70e9777058d1 Mon Sep 17 00:00:00 2001
From: Soyeon Kim <112332952+kaswhy@users.noreply.github.com>
Date: Wed, 31 Jan 2024 21:11:21 +0900
Subject: [PATCH 302/336] Add myself to Contributors

---
 CONTRIBUTORS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 77397a5b5..ccea41ea8 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -55,6 +55,7 @@ Russ Cox 
 Russ Rufer 
 Sean Mcafee 
 Sigurður Ásgeirsson 
+Soyeon Kim 
 Sverre Sundsdal 
 Szymon Sobik 
 Takeshi Yoshino 

From 456574145cf71a5375777cab58453acfd92a920b Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Wed, 31 Jan 2024 06:50:36 -0800
Subject: [PATCH 303/336] Modifications to improve portability of googletest
 tests.

PiperOrigin-RevId: 603034597
Change-Id: I4d716ed67f80f41075bfa266d975460d2ac27eb6
---
 googletest/test/googletest-options-test.cc |  5 ++++-
 googletest/test/gtest_unittest.cc          | 12 ++++++++----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/googletest/test/googletest-options-test.cc b/googletest/test/googletest-options-test.cc
index b712c06fa..91d06a509 100644
--- a/googletest/test/googletest-options-test.cc
+++ b/googletest/test/googletest-options-test.cc
@@ -115,11 +115,14 @@ TEST(OutputFileHelpersTest, GetCurrentExecutableName) {
       strcasecmp("gtest_dll_test", exe_str.c_str()) == 0;
 #elif defined(GTEST_OS_FUCHSIA)
   const bool success = exe_str == "app";
+#elif defined(__EMSCRIPTEN__)
+  const bool success = exe_str == "patched_googletest-options-test.js";
 #else
   const bool success =
       exe_str == "googletest-options-test" || exe_str == "gtest_all_test" ||
       exe_str == "lt-gtest_all_test" || exe_str == "gtest_dll_test";
-#endif  // GTEST_OS_WINDOWS
+#endif  // platform ifdefs
+
   if (!success) FAIL() << "GetCurrentExecutableName() returns " << exe_str;
 }
 
diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc
index 67d776ed8..0b383ea7c 100644
--- a/googletest/test/gtest_unittest.cc
+++ b/googletest/test/gtest_unittest.cc
@@ -422,11 +422,14 @@ TEST(FormatTimeInMillisAsSecondsTest, FormatsNegativeNumber) {
   EXPECT_EQ("-1234567.89", FormatTimeInMillisAsSeconds(-1234567890));
 }
 
+// TODO: b/287046337 - In emscripten, local time zone modification is not
+// supported.
+#if !defined(__EMSCRIPTEN__)
 // Tests FormatEpochTimeInMillisAsIso8601().  The correctness of conversion
 // for particular dates below was verified in Python using
 // datetime.datetime.fromutctimestamp(/1000).
 
-// FormatEpochTimeInMillisAsIso8601 depends on the current timezone, so we
+// FormatEpochTimeInMillisAsIso8601 depends on the local timezone, so we
 // have to set up a particular timezone to obtain predictable results.
 class FormatEpochTimeInMillisAsIso8601Test : public Test {
  public:
@@ -445,9 +448,8 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test {
     }
     GTEST_DISABLE_MSC_DEPRECATED_POP_()
 
-    // Set up the time zone for FormatEpochTimeInMillisAsIso8601 to use.  We
-    // cannot use the local time zone because the function's output depends
-    // on the time zone.
+    // Set the local time zone for FormatEpochTimeInMillisAsIso8601 to be
+    // a fixed time zone for reproducibility purposes.
     SetTimeZone("UTC+00");
   }
 
@@ -514,6 +516,8 @@ TEST_F(FormatEpochTimeInMillisAsIso8601Test, PrintsEpochStart) {
   EXPECT_EQ("1970-01-01T00:00:00.000", FormatEpochTimeInMillisAsIso8601(0));
 }
 
+#endif  // __EMSCRIPTEN__
+
 #ifdef __BORLANDC__
 // Silences warnings: "Condition is always true", "Unreachable code"
 #pragma option push -w-ccc -w-rch

From 64be1c79fa2cea015d816687120878a110775351 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Tue, 6 Feb 2024 16:30:23 -0800
Subject: [PATCH 304/336] Destroy installed environments in normal code, not in
 static teardown.

Destruction in static teardown causes issues for Environments which own threads and try to join them in their destruction.

This may be a breaking change for users who call RUN_ALL_TESTS multiple times in the same main function if they also install environments, or those who access registered environments after RUN_ALL_TESTS.

The easiest fix is to only call RUN_ALL_TESTS once as the last line of the main function. Another potential fix is to re-register new instances of the Environment once before each call to RUN_ALL_TESTS.

PiperOrigin-RevId: 604800795
Change-Id: I37c44d4aca4a238052649f45a4b6b9cfb5355b71
---
 googletest/include/gtest/gtest.h          |   3 +-
 googletest/src/gtest.cc                   |  15 ++-
 googletest/test/gtest_environment_test.cc | 154 ++++++++++++----------
 googletest/test/gtest_repeat_test.cc      |   4 +-
 4 files changed, 96 insertions(+), 80 deletions(-)

diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h
index 45400fd0b..15d053916 100644
--- a/googletest/include/gtest/gtest.h
+++ b/googletest/include/gtest/gtest.h
@@ -2308,7 +2308,8 @@ TestInfo* RegisterTest(const char* test_suite_name, const char* test_name,
 // tests are successful, or 1 otherwise.
 //
 // RUN_ALL_TESTS() should be invoked after the command line has been
-// parsed by InitGoogleTest().
+// parsed by InitGoogleTest(). RUN_ALL_TESTS will tear down and delete any
+// installed environments and should only be called once per binary.
 //
 // This function was formerly a macro; thus, it is in the global
 // namespace and has an all-caps name.
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 6d6ff1bb0..d25f5c430 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -536,7 +536,8 @@ void InsertSyntheticTestCase(const std::string& name, CodeLocation location,
   if (ignored.find(name) != ignored.end()) return;
 
   const char kMissingInstantiation[] =  //
-      " is defined via TEST_P, but never instantiated. None of the test cases "
+      " is defined via TEST_P, but never instantiated. None of the test "
+      "cases "
       "will run. Either no INSTANTIATE_TEST_SUITE_P is provided or the only "
       "ones provided expand to nothing."
       "\n\n"
@@ -615,10 +616,12 @@ void TypeParameterizedTestSuiteRegistry::CheckForInstantiations() {
         "\n\n"
         "Ideally, TYPED_TEST_P definitions should only ever be included as "
         "part of binaries that intend to use them. (As opposed to, for "
-        "example, being placed in a library that may be linked in to get other "
+        "example, being placed in a library that may be linked in to get "
+        "other "
         "utilities.)"
         "\n\n"
-        "To suppress this error for this test suite, insert the following line "
+        "To suppress this error for this test suite, insert the following "
+        "line "
         "(in a non-header) in the namespace it is defined in:"
         "\n\n"
         "GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(" +
@@ -5991,6 +5994,12 @@ bool UnitTestImpl::RunAllTests() {
   }
 
   repeater->OnTestProgramEnd(*parent_);
+  // Destroy environments in normal code, not in static teardown.
+  bool delete_environment_on_teardown = true;
+  if (delete_environment_on_teardown) {
+    ForEach(environments_, internal::Delete);
+    environments_.clear();
+  }
 
   if (!gtest_is_initialized_before_run_all_tests) {
     ColoredPrintf(
diff --git a/googletest/test/gtest_environment_test.cc b/googletest/test/gtest_environment_test.cc
index 122eaf3ca..03657c7d8 100644
--- a/googletest/test/gtest_environment_test.cc
+++ b/googletest/test/gtest_environment_test.cc
@@ -40,16 +40,21 @@ namespace {
 
 enum FailureType { NO_FAILURE, NON_FATAL_FAILURE, FATAL_FAILURE };
 
+// Was SetUp run?
+bool set_up_was_run;
+// Was TearDown run?
+bool tear_down_was_run;
+// Was the TEST run?
+bool test_was_run;
+
 // For testing using global test environments.
 class MyEnvironment : public testing::Environment {
  public:
-  MyEnvironment() { Reset(); }
-
   // Depending on the value of failure_in_set_up_, SetUp() will
   // generate a non-fatal failure, generate a fatal failure, or
   // succeed.
   void SetUp() override {
-    set_up_was_run_ = true;
+    set_up_was_run = true;
 
     switch (failure_in_set_up_) {
       case NON_FATAL_FAILURE:
@@ -65,36 +70,18 @@ class MyEnvironment : public testing::Environment {
 
   // Generates a non-fatal failure.
   void TearDown() override {
-    tear_down_was_run_ = true;
+    tear_down_was_run = true;
     ADD_FAILURE() << "Expected non-fatal failure in global tear-down.";
   }
 
-  // Resets the state of the environment s.t. it can be reused.
-  void Reset() {
-    failure_in_set_up_ = NO_FAILURE;
-    set_up_was_run_ = false;
-    tear_down_was_run_ = false;
-  }
-
   // We call this function to set the type of failure SetUp() should
   // generate.
   void set_failure_in_set_up(FailureType type) { failure_in_set_up_ = type; }
 
-  // Was SetUp() run?
-  bool set_up_was_run() const { return set_up_was_run_; }
-
-  // Was TearDown() run?
-  bool tear_down_was_run() const { return tear_down_was_run_; }
-
  private:
   FailureType failure_in_set_up_;
-  bool set_up_was_run_;
-  bool tear_down_was_run_;
 };
 
-// Was the TEST run?
-bool test_was_run;
-
 // The sole purpose of this TEST is to enable us to check whether it
 // was run.
 TEST(FooTest, Bar) { test_was_run = true; }
@@ -112,67 +99,88 @@ void Check(bool condition, const char* msg) {
 // The 'failure' parameter specifies the type of failure that should
 // be generated by the global set-up.
 int RunAllTests(MyEnvironment* env, FailureType failure) {
-  env->Reset();
-  env->set_failure_in_set_up(failure);
+  set_up_was_run = false;
+  tear_down_was_run = false;
   test_was_run = false;
+  env->set_failure_in_set_up(failure);
   testing::internal::GetUnitTestImpl()->ClearAdHocTestResult();
   return RUN_ALL_TESTS();
 }
 
+// Registers a global test environment, and verifies that the
+// registration function returns its argument.
+MyEnvironment* RegisterTestEnv() {
+  MyEnvironment* const env = new MyEnvironment;
+  Check(testing::AddGlobalTestEnvironment(env) == env,
+        "AddGlobalTestEnvironment() should return its argument.");
+  return env;
+}
+
+// Verifies that RUN_ALL_TESTS() runs the tests when the global
+// set-up is successful.
+void TestGlobalSetUp() {
+  MyEnvironment* const env = RegisterTestEnv();
+  Check(RunAllTests(env, NO_FAILURE) != 0,
+        "RUN_ALL_TESTS() should return non-zero, as the global tear-down "
+        "should generate a failure.");
+  Check(test_was_run,
+        "The tests should run, as the global set-up should generate no "
+        "failure");
+  Check(tear_down_was_run,
+        "The global tear-down should run, as the global set-up was run.");
+}
+
+// Verifies that RUN_ALL_TESTS() runs the tests when the global
+// set-up generates no fatal failure.
+void TestTestsRun() {
+  MyEnvironment* const env = RegisterTestEnv();
+  Check(RunAllTests(env, NON_FATAL_FAILURE) != 0,
+        "RUN_ALL_TESTS() should return non-zero, as both the global set-up "
+        "and the global tear-down should generate a non-fatal failure.");
+  Check(test_was_run,
+        "The tests should run, as the global set-up should generate no "
+        "fatal failure.");
+  Check(tear_down_was_run,
+        "The global tear-down should run, as the global set-up was run.");
+}
+
+// Verifies that RUN_ALL_TESTS() runs no test when the global set-up
+// generates a fatal failure.
+void TestNoTestsRunSetUpFailure() {
+  MyEnvironment* const env = RegisterTestEnv();
+  Check(RunAllTests(env, FATAL_FAILURE) != 0,
+        "RUN_ALL_TESTS() should return non-zero, as the global set-up "
+        "should generate a fatal failure.");
+  Check(!test_was_run,
+        "The tests should not run, as the global set-up should generate "
+        "a fatal failure.");
+  Check(tear_down_was_run,
+        "The global tear-down should run, as the global set-up was run.");
+}
+
+// Verifies that RUN_ALL_TESTS() doesn't do global set-up or
+// tear-down when there is no test to run.
+void TestNoTestsSkipsSetUp() {
+  MyEnvironment* const env = RegisterTestEnv();
+  GTEST_FLAG_SET(filter, "-*");
+  Check(RunAllTests(env, NO_FAILURE) == 0,
+        "RUN_ALL_TESTS() should return zero, as there is no test to run.");
+  Check(!set_up_was_run,
+        "The global set-up should not run, as there is no test to run.");
+  Check(!tear_down_was_run,
+        "The global tear-down should not run, "
+        "as the global set-up was not run.");
+}
+
 }  // namespace
 
 int main(int argc, char** argv) {
   testing::InitGoogleTest(&argc, argv);
 
-  // Registers a global test environment, and verifies that the
-  // registration function returns its argument.
-  MyEnvironment* const env = new MyEnvironment;
-  Check(testing::AddGlobalTestEnvironment(env) == env,
-        "AddGlobalTestEnvironment() should return its argument.");
-
-  // Verifies that RUN_ALL_TESTS() runs the tests when the global
-  // set-up is successful.
-  Check(RunAllTests(env, NO_FAILURE) != 0,
-        "RUN_ALL_TESTS() should return non-zero, as the global tear-down "
-        "should generate a failure.");
-  Check(test_was_run,
-        "The tests should run, as the global set-up should generate no "
-        "failure");
-  Check(env->tear_down_was_run(),
-        "The global tear-down should run, as the global set-up was run.");
-
-  // Verifies that RUN_ALL_TESTS() runs the tests when the global
-  // set-up generates no fatal failure.
-  Check(RunAllTests(env, NON_FATAL_FAILURE) != 0,
-        "RUN_ALL_TESTS() should return non-zero, as both the global set-up "
-        "and the global tear-down should generate a non-fatal failure.");
-  Check(test_was_run,
-        "The tests should run, as the global set-up should generate no "
-        "fatal failure.");
-  Check(env->tear_down_was_run(),
-        "The global tear-down should run, as the global set-up was run.");
-
-  // Verifies that RUN_ALL_TESTS() runs no test when the global set-up
-  // generates a fatal failure.
-  Check(RunAllTests(env, FATAL_FAILURE) != 0,
-        "RUN_ALL_TESTS() should return non-zero, as the global set-up "
-        "should generate a fatal failure.");
-  Check(!test_was_run,
-        "The tests should not run, as the global set-up should generate "
-        "a fatal failure.");
-  Check(env->tear_down_was_run(),
-        "The global tear-down should run, as the global set-up was run.");
-
-  // Verifies that RUN_ALL_TESTS() doesn't do global set-up or
-  // tear-down when there is no test to run.
-  GTEST_FLAG_SET(filter, "-*");
-  Check(RunAllTests(env, NO_FAILURE) == 0,
-        "RUN_ALL_TESTS() should return zero, as there is no test to run.");
-  Check(!env->set_up_was_run(),
-        "The global set-up should not run, as there is no test to run.");
-  Check(!env->tear_down_was_run(),
-        "The global tear-down should not run, "
-        "as the global set-up was not run.");
+  TestGlobalSetUp();
+  TestTestsRun();
+  TestNoTestsRunSetUpFailure();
+  TestNoTestsSkipsSetUp();
 
   printf("PASS\n");
   return 0;
diff --git a/googletest/test/gtest_repeat_test.cc b/googletest/test/gtest_repeat_test.cc
index f67b7886e..55103d0e7 100644
--- a/googletest/test/gtest_repeat_test.cc
+++ b/googletest/test/gtest_repeat_test.cc
@@ -61,7 +61,6 @@ int g_environment_tear_down_count = 0;
 
 class MyEnvironment : public testing::Environment {
  public:
-  MyEnvironment() = default;
   void SetUp() override { g_environment_set_up_count++; }
   void TearDown() override { g_environment_tear_down_count++; }
 };
@@ -117,6 +116,7 @@ void ResetCounts() {
   g_should_pass_count = 0;
   g_death_test_count = 0;
   g_param_test_count = 0;
+  testing::AddGlobalTestEnvironment(new MyEnvironment);
 }
 
 // Checks that the count for each test is expected.
@@ -197,8 +197,6 @@ void TestRepeatWithFilterForFailedTests(int repeat) {
 int main(int argc, char **argv) {
   testing::InitGoogleTest(&argc, argv);
 
-  testing::AddGlobalTestEnvironment(new MyEnvironment);
-
   TestRepeatUnspecified();
   TestRepeat(0);
   TestRepeat(1);

From 96519a4019ff084112db9e532a621f92721cda4b Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Wed, 7 Feb 2024 09:00:30 -0800
Subject: [PATCH 305/336] Use _Exit instead of _exit in GoogleTest

_Exit is standardized since C99, whereas _exit is POSIX-only.

Fixes: #4447
PiperOrigin-RevId: 605000352
Change-Id: Ibfa84edaa043bd003a21383e8148bf45be7217f6
---
 googlemock/src/gmock-spec-builders.cc         |  2 +-
 .../internal/gtest-death-test-internal.h      |  2 +-
 googletest/src/gtest-death-test.cc            | 14 ++--
 googletest/test/googletest-death-test-test.cc | 76 ++++++++++---------
 4 files changed, 49 insertions(+), 45 deletions(-)

diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc
index fb67ab09d..ffdf03dd4 100644
--- a/googlemock/src/gmock-spec-builders.cc
+++ b/googlemock/src/gmock-spec-builders.cc
@@ -531,7 +531,7 @@ class MockObjectRegistry {
 #ifdef GTEST_OS_QURT
       qurt_exception_raise_fatal();
 #else
-      _exit(1);  // We cannot call exit() as it is not reentrant and
+      _Exit(1);  // We cannot call exit() as it is not reentrant and
                  // may already have been called.
 #endif
     }
diff --git a/googletest/include/gtest/internal/gtest-death-test-internal.h b/googletest/include/gtest/internal/gtest-death-test-internal.h
index 61536d657..3925e36ba 100644
--- a/googletest/include/gtest/internal/gtest-death-test-internal.h
+++ b/googletest/include/gtest/internal/gtest-death-test-internal.h
@@ -71,7 +71,7 @@ GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
 //
 // exit status:  The integer exit information in the format specified
 //               by wait(2)
-// exit code:    The integer code passed to exit(3), _exit(2), or
+// exit code:    The integer code passed to exit(3), _Exit(2), or
 //               returned from main()
 class GTEST_API_ DeathTest {
  public:
diff --git a/googletest/src/gtest-death-test.cc b/googletest/src/gtest-death-test.cc
index 8417a300f..f914db5b5 100644
--- a/googletest/src/gtest-death-test.cc
+++ b/googletest/src/gtest-death-test.cc
@@ -32,6 +32,8 @@
 
 #include "gtest/gtest-death-test.h"
 
+#include 
+
 #include 
 #include 
 #include 
@@ -115,7 +117,7 @@ GTEST_DEFINE_string_(
 GTEST_DEFINE_bool_(
     death_test_use_fork,
     testing::internal::BoolFromGTestEnv("death_test_use_fork", false),
-    "Instructs to use fork()/_exit() instead of clone() in death tests. "
+    "Instructs to use fork()/_Exit() instead of clone() in death tests. "
     "Ignored and always uses fork() on POSIX systems where clone() is not "
     "implemented. Useful when running under valgrind or similar tools if "
     "those do not support clone(). Valgrind 3.3.1 will just fail if "
@@ -299,7 +301,7 @@ enum DeathTestOutcome { IN_PROGRESS, DIED, LIVED, RETURNED, THREW };
     fputc(kDeathTestInternalError, parent);
     fprintf(parent, "%s", message.c_str());
     fflush(parent);
-    _exit(1);
+    _Exit(1);
   } else {
     fprintf(stderr, "%s", message.c_str());
     fflush(stderr);
@@ -511,7 +513,7 @@ std::string DeathTestImpl::GetErrorLogs() { return GetCapturedStderr(); }
 // Signals that the death test code which should have exited, didn't.
 // Should be called only in a death test child process.
 // Writes a status byte to the child's status file descriptor, then
-// calls _exit(1).
+// calls _Exit(1).
 void DeathTestImpl::Abort(AbortReason reason) {
   // The parent process considers the death test to be a failure if
   // it finds any data in our pipe.  So, here we write a single flag byte
@@ -523,13 +525,13 @@ void DeathTestImpl::Abort(AbortReason reason) {
   GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Write(write_fd(), &status_ch, 1));
   // We are leaking the descriptor here because on some platforms (i.e.,
   // when built as Windows DLL), destructors of global objects will still
-  // run after calling _exit(). On such systems, write_fd_ will be
+  // run after calling _Exit(). On such systems, write_fd_ will be
   // indirectly closed from the destructor of UnitTestImpl, causing double
   // close if it is also closed here. On debug configurations, double close
   // may assert. As there are no in-process buffers to flush here, we are
   // relying on the OS to close the descriptor after the process terminates
   // when the destructors are not run.
-  _exit(1);  // Exits w/o any normal exit hooks (we were supposed to crash)
+  _Exit(1);  // Exits w/o any normal exit hooks (we were supposed to crash)
 }
 
 // Returns an indented copy of stderr output for a death test.
@@ -1333,7 +1335,7 @@ static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) {
 #endif  // GTEST_HAS_CLONE
 
   if (use_fork && (child_pid = fork()) == 0) {
-    _exit(ExecDeathTestChildMain(&args));
+    _Exit(ExecDeathTestChildMain(&args));
   }
 #endif  // GTEST_OS_QNX
 #ifdef GTEST_OS_LINUX
diff --git a/googletest/test/googletest-death-test-test.cc b/googletest/test/googletest-death-test-test.cc
index 4cc81b723..75742c938 100644
--- a/googletest/test/googletest-death-test-test.cc
+++ b/googletest/test/googletest-death-test-test.cc
@@ -30,6 +30,8 @@
 //
 // Tests for death tests.
 
+#include 
+
 #include "gtest/gtest-death-test.h"
 #include "gtest/gtest.h"
 #include "gtest/internal/gtest-filepath.h"
@@ -111,15 +113,15 @@ void DieWithMessage(const ::std::string& message) {
   fprintf(stderr, "%s", message.c_str());
   fflush(stderr);  // Make sure the text is printed before the process exits.
 
-  // We call _exit() instead of exit(), as the former is a direct
+  // We call _Exit() instead of exit(), as the former is a direct
   // system call and thus safer in the presence of threads.  exit()
   // will invoke user-defined exit-hooks, which may do dangerous
   // things that conflict with death tests.
   //
-  // Some compilers can recognize that _exit() never returns and issue the
+  // Some compilers can recognize that _Exit() never returns and issue the
   // 'unreachable code' warning for code following this function, unless
   // fooled by a fake condition.
-  if (AlwaysTrue()) _exit(1);
+  if (AlwaysTrue()) _Exit(1);
 }
 
 void DieInside(const ::std::string& function) {
@@ -238,13 +240,13 @@ TEST(ExitStatusPredicateTest, ExitedWithCode) {
 
 #else
 
-// Returns the exit status of a process that calls _exit(2) with a
+// Returns the exit status of a process that calls _Exit(2) with a
 // given exit code.  This is a helper function for the
 // ExitStatusPredicateTest test suite.
 static int NormalExitStatus(int exit_code) {
   pid_t child_pid = fork();
   if (child_pid == 0) {
-    _exit(exit_code);
+    _Exit(exit_code);
   }
   int status;
   waitpid(child_pid, &status, 0);
@@ -260,7 +262,7 @@ static int KilledExitStatus(int signum) {
   pid_t child_pid = fork();
   if (child_pid == 0) {
     raise(signum);
-    _exit(1);
+    _Exit(1);
   }
   int status;
   waitpid(child_pid, &status, 0);
@@ -313,7 +315,7 @@ TEST_F(TestForDeathTest, SingleStatement) {
     ASSERT_DEATH(return, "");
 
   if (AlwaysTrue())
-    EXPECT_DEATH(_exit(1), "");
+    EXPECT_DEATH(_Exit(1), "");
   else
     // This empty "else" branch is meant to ensure that EXPECT_DEATH
     // doesn't expand into an "if" statement without an "else"
@@ -324,7 +326,7 @@ TEST_F(TestForDeathTest, SingleStatement) {
   if (AlwaysFalse())
     ;
   else
-    EXPECT_DEATH(_exit(1), "") << 1 << 2 << 3;
+    EXPECT_DEATH(_Exit(1), "") << 1 << 2 << 3;
 }
 #ifdef __GNUC__
 #pragma GCC diagnostic pop
@@ -339,11 +341,11 @@ TEST_F(TestForDeathTest, SwitchStatement) {
 
   switch (0)
   default:
-    ASSERT_DEATH(_exit(1), "") << "exit in default switch handler";
+    ASSERT_DEATH(_Exit(1), "") << "exit in default switch handler";
 
   switch (0)
   case 0:
-    EXPECT_DEATH(_exit(1), "") << "exit in switch case";
+    EXPECT_DEATH(_Exit(1), "") << "exit in switch case";
 
   GTEST_DISABLE_MSC_WARNINGS_POP_()
 }
@@ -371,10 +373,10 @@ TEST_F(TestForDeathTest, FastDeathTestInChangedDir) {
   GTEST_FLAG_SET(death_test_style, "fast");
 
   ChangeToRootDir();
-  EXPECT_EXIT(_exit(1), testing::ExitedWithCode(1), "");
+  EXPECT_EXIT(_Exit(1), testing::ExitedWithCode(1), "");
 
   ChangeToRootDir();
-  ASSERT_DEATH(_exit(1), "");
+  ASSERT_DEATH(_Exit(1), "");
 }
 
 #ifdef GTEST_OS_LINUX
@@ -416,7 +418,7 @@ void DisableSigprofActionAndTimer(struct sigaction* old_signal_action) {
 TEST_F(TestForDeathTest, FastSigprofActionSet) {
   GTEST_FLAG_SET(death_test_style, "fast");
   SetSigprofActionAndTimer();
-  EXPECT_DEATH(_exit(1), "");
+  EXPECT_DEATH(_Exit(1), "");
   struct sigaction old_signal_action;
   DisableSigprofActionAndTimer(&old_signal_action);
   EXPECT_TRUE(old_signal_action.sa_sigaction == SigprofAction);
@@ -425,7 +427,7 @@ TEST_F(TestForDeathTest, FastSigprofActionSet) {
 TEST_F(TestForDeathTest, ThreadSafeSigprofActionSet) {
   GTEST_FLAG_SET(death_test_style, "threadsafe");
   SetSigprofActionAndTimer();
-  EXPECT_DEATH(_exit(1), "");
+  EXPECT_DEATH(_Exit(1), "");
   struct sigaction old_signal_action;
   DisableSigprofActionAndTimer(&old_signal_action);
   EXPECT_TRUE(old_signal_action.sa_sigaction == SigprofAction);
@@ -449,24 +451,24 @@ TEST_F(TestForDeathTest, ThreadsafeDeathTestInLoop) {
   GTEST_FLAG_SET(death_test_style, "threadsafe");
 
   for (int i = 0; i < 3; ++i)
-    EXPECT_EXIT(_exit(i), testing::ExitedWithCode(i), "") << ": i = " << i;
+    EXPECT_EXIT(_Exit(i), testing::ExitedWithCode(i), "") << ": i = " << i;
 }
 
 TEST_F(TestForDeathTest, ThreadsafeDeathTestInChangedDir) {
   GTEST_FLAG_SET(death_test_style, "threadsafe");
 
   ChangeToRootDir();
-  EXPECT_EXIT(_exit(1), testing::ExitedWithCode(1), "");
+  EXPECT_EXIT(_Exit(1), testing::ExitedWithCode(1), "");
 
   ChangeToRootDir();
-  ASSERT_DEATH(_exit(1), "");
+  ASSERT_DEATH(_Exit(1), "");
 }
 
 TEST_F(TestForDeathTest, MixedStyles) {
   GTEST_FLAG_SET(death_test_style, "threadsafe");
-  EXPECT_DEATH(_exit(1), "");
+  EXPECT_DEATH(_Exit(1), "");
   GTEST_FLAG_SET(death_test_style, "fast");
-  EXPECT_DEATH(_exit(1), "");
+  EXPECT_DEATH(_Exit(1), "");
 }
 
 #if GTEST_HAS_CLONE && GTEST_HAS_PTHREAD
@@ -480,7 +482,7 @@ TEST_F(TestForDeathTest, DoesNotExecuteAtforkHooks) {
     GTEST_FLAG_SET(death_test_style, "threadsafe");
     pthread_flag = false;
     ASSERT_EQ(0, pthread_atfork(&SetPthreadFlag, nullptr, nullptr));
-    ASSERT_DEATH(_exit(1), "");
+    ASSERT_DEATH(_Exit(1), "");
     ASSERT_FALSE(pthread_flag);
   }
 }
@@ -805,8 +807,8 @@ TEST_F(TestForDeathTest, AssertDebugDeathAborts10) {
 
 // Tests the *_EXIT family of macros, using a variety of predicates.
 static void TestExitMacros() {
-  EXPECT_EXIT(_exit(1), testing::ExitedWithCode(1), "");
-  ASSERT_EXIT(_exit(42), testing::ExitedWithCode(42), "");
+  EXPECT_EXIT(_Exit(1), testing::ExitedWithCode(1), "");
+  ASSERT_EXIT(_Exit(42), testing::ExitedWithCode(42), "");
 
 #ifdef GTEST_OS_WINDOWS
 
@@ -823,7 +825,7 @@ static void TestExitMacros() {
 
   EXPECT_FATAL_FAILURE(
       {  // NOLINT
-        ASSERT_EXIT(_exit(0), testing::KilledBySignal(SIGSEGV), "")
+        ASSERT_EXIT(_Exit(0), testing::KilledBySignal(SIGSEGV), "")
             << "This failure is expected, too.";
       },
       "This failure is expected, too.");
@@ -849,7 +851,7 @@ TEST_F(TestForDeathTest, InvalidStyle) {
   GTEST_FLAG_SET(death_test_style, "rococo");
   EXPECT_NONFATAL_FAILURE(
       {  // NOLINT
-        EXPECT_DEATH(_exit(0), "") << "This failure is expected.";
+        EXPECT_DEATH(_Exit(0), "") << "This failure is expected.";
       },
       "This failure is expected.");
 }
@@ -1140,7 +1142,7 @@ TEST_F(MacroLogicDeathTest, ChildDoesNotDie) {
   // This time there are two calls to Abort: one since the test didn't
   // die, and another from the ReturnSentinel when it's destroyed.  The
   // sentinel normally isn't destroyed if a test doesn't die, since
-  // _exit(2) is called in that case by ForkingDeathTest, but not by
+  // _Exit(2) is called in that case by ForkingDeathTest, but not by
   // our MockDeathTest.
   ASSERT_EQ(2U, factory_->AbortCalls());
   EXPECT_EQ(DeathTest::TEST_DID_NOT_DIE, factory_->AbortArgument(0));
@@ -1152,21 +1154,21 @@ TEST_F(MacroLogicDeathTest, ChildDoesNotDie) {
 // Tests that a successful death test does not register a successful
 // test part.
 TEST(SuccessRegistrationDeathTest, NoSuccessPart) {
-  EXPECT_DEATH(_exit(1), "");
+  EXPECT_DEATH(_Exit(1), "");
   EXPECT_EQ(0, GetUnitTestImpl()->current_test_result()->total_part_count());
 }
 
 TEST(StreamingAssertionsDeathTest, DeathTest) {
-  EXPECT_DEATH(_exit(1), "") << "unexpected failure";
-  ASSERT_DEATH(_exit(1), "") << "unexpected failure";
+  EXPECT_DEATH(_Exit(1), "") << "unexpected failure";
+  ASSERT_DEATH(_Exit(1), "") << "unexpected failure";
   EXPECT_NONFATAL_FAILURE(
       {  // NOLINT
-        EXPECT_DEATH(_exit(0), "") << "expected failure";
+        EXPECT_DEATH(_Exit(0), "") << "expected failure";
       },
       "expected failure");
   EXPECT_FATAL_FAILURE(
       {  // NOLINT
-        ASSERT_DEATH(_exit(0), "") << "expected failure";
+        ASSERT_DEATH(_Exit(0), "") << "expected failure";
       },
       "expected failure");
 }
@@ -1330,7 +1332,7 @@ TEST(InDeathTestChildDeathTest, ReportsDeathTestCorrectlyInFastStyle) {
       {
         fprintf(stderr, InDeathTestChild() ? "Inside" : "Outside");
         fflush(stderr);
-        _exit(1);
+        _Exit(1);
       },
       "Inside");
 }
@@ -1342,7 +1344,7 @@ TEST(InDeathTestChildDeathTest, ReportsDeathTestCorrectlyInThreadSafeStyle) {
       {
         fprintf(stderr, InDeathTestChild() ? "Inside" : "Outside");
         fflush(stderr);
-        _exit(1);
+        _Exit(1);
       },
       "Inside");
 }
@@ -1350,7 +1352,7 @@ TEST(InDeathTestChildDeathTest, ReportsDeathTestCorrectlyInThreadSafeStyle) {
 void DieWithMessage(const char* message) {
   fputs(message, stderr);
   fflush(stderr);  // Make sure the text is printed before the process exits.
-  _exit(1);
+  _Exit(1);
 }
 
 TEST(MatcherDeathTest, DoesNotBreakBareRegexMatching) {
@@ -1466,7 +1468,7 @@ TEST(ConditionalDeathMacrosSyntaxDeathTest, SingleStatement) {
     ASSERT_DEATH_IF_SUPPORTED(return, "");
 
   if (AlwaysTrue())
-    EXPECT_DEATH_IF_SUPPORTED(_exit(1), "");
+    EXPECT_DEATH_IF_SUPPORTED(_Exit(1), "");
   else
     // This empty "else" branch is meant to ensure that EXPECT_DEATH
     // doesn't expand into an "if" statement without an "else"
@@ -1477,7 +1479,7 @@ TEST(ConditionalDeathMacrosSyntaxDeathTest, SingleStatement) {
   if (AlwaysFalse())
     ;  // NOLINT
   else
-    EXPECT_DEATH_IF_SUPPORTED(_exit(1), "") << 1 << 2 << 3;
+    EXPECT_DEATH_IF_SUPPORTED(_Exit(1), "") << 1 << 2 << 3;
 }
 #ifdef __GNUC__
 #pragma GCC diagnostic pop
@@ -1492,11 +1494,11 @@ TEST(ConditionalDeathMacrosSyntaxDeathTest, SwitchStatement) {
 
   switch (0)
   default:
-    ASSERT_DEATH_IF_SUPPORTED(_exit(1), "") << "exit in default switch handler";
+    ASSERT_DEATH_IF_SUPPORTED(_Exit(1), "") << "exit in default switch handler";
 
   switch (0)
   case 0:
-    EXPECT_DEATH_IF_SUPPORTED(_exit(1), "") << "exit in switch case";
+    EXPECT_DEATH_IF_SUPPORTED(_Exit(1), "") << "exit in switch case";
 
   GTEST_DISABLE_MSC_WARNINGS_POP_()
 }

From b75ecf1bed2fcd416b66c86cb6fe79122abf132e Mon Sep 17 00:00:00 2001
From: Matt Kulukundis 
Date: Wed, 7 Feb 2024 15:05:25 -0800
Subject: [PATCH 306/336] Switch rank structs to be consistent with written
 guidance in go/ranked-overloads

PiperOrigin-RevId: 605110251
Change-Id: I304f3863333cb9ef0b85c5bab5277e757ef9950a
---
 googlemock/include/gmock/gmock-matchers.h | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h
index 8052c74a1..c4149f2ef 100644
--- a/googlemock/include/gmock/gmock-matchers.h
+++ b/googlemock/include/gmock/gmock-matchers.h
@@ -2920,26 +2920,27 @@ class EachMatcher {
   const M inner_matcher_;
 };
 
-struct Rank1 {};
-struct Rank0 : Rank1 {};
+// Use go/ranked-overloads for dispatching.
+struct Rank0 {};
+struct Rank1 : Rank0 {};
 
 namespace pair_getters {
 using std::get;
 template 
-auto First(T& x, Rank1) -> decltype(get<0>(x)) {  // NOLINT
+auto First(T& x, Rank0) -> decltype(get<0>(x)) {  // NOLINT
   return get<0>(x);
 }
 template 
-auto First(T& x, Rank0) -> decltype((x.first)) {  // NOLINT
+auto First(T& x, Rank1) -> decltype((x.first)) {  // NOLINT
   return x.first;
 }
 
 template 
-auto Second(T& x, Rank1) -> decltype(get<1>(x)) {  // NOLINT
+auto Second(T& x, Rank0) -> decltype(get<1>(x)) {  // NOLINT
   return get<1>(x);
 }
 template 
-auto Second(T& x, Rank0) -> decltype((x.second)) {  // NOLINT
+auto Second(T& x, Rank1) -> decltype((x.second)) {  // NOLINT
   return x.second;
 }
 }  // namespace pair_getters
@@ -2965,7 +2966,7 @@ class KeyMatcherImpl : public MatcherInterface {
                        MatchResultListener* listener) const override {
     StringMatchResultListener inner_listener;
     const bool match = inner_matcher_.MatchAndExplain(
-        pair_getters::First(key_value, Rank0()), &inner_listener);
+        pair_getters::First(key_value, Rank1()), &inner_listener);
     const std::string explanation = inner_listener.str();
     if (!explanation.empty()) {
       *listener << "whose first field is a value " << explanation;
@@ -3087,18 +3088,18 @@ class PairMatcherImpl : public MatcherInterface {
     if (!listener->IsInterested()) {
       // If the listener is not interested, we don't need to construct the
       // explanation.
-      return first_matcher_.Matches(pair_getters::First(a_pair, Rank0())) &&
-             second_matcher_.Matches(pair_getters::Second(a_pair, Rank0()));
+      return first_matcher_.Matches(pair_getters::First(a_pair, Rank1())) &&
+             second_matcher_.Matches(pair_getters::Second(a_pair, Rank1()));
     }
     StringMatchResultListener first_inner_listener;
-    if (!first_matcher_.MatchAndExplain(pair_getters::First(a_pair, Rank0()),
+    if (!first_matcher_.MatchAndExplain(pair_getters::First(a_pair, Rank1()),
                                         &first_inner_listener)) {
       *listener << "whose first field does not match";
       PrintIfNotEmpty(first_inner_listener.str(), listener->stream());
       return false;
     }
     StringMatchResultListener second_inner_listener;
-    if (!second_matcher_.MatchAndExplain(pair_getters::Second(a_pair, Rank0()),
+    if (!second_matcher_.MatchAndExplain(pair_getters::Second(a_pair, Rank1()),
                                          &second_inner_listener)) {
       *listener << "whose second field does not match";
       PrintIfNotEmpty(second_inner_listener.str(), listener->stream());

From f5448b3d712b0f291999420c6f89a207afe90a06 Mon Sep 17 00:00:00 2001
From: danfabo <155268264+danfabo@users.noreply.github.com>
Date: Sun, 11 Feb 2024 02:36:02 +0100
Subject: [PATCH 307/336] Get include dirs from target rather than global
 variables.

The global variable gtest_SOURCE_DIR is replaced by CMake when fetch-content is used with the name "GTest" and points to the root directory. The include directories from the gtest target are always valid.
---
 googlemock/CMakeLists.txt | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/googlemock/CMakeLists.txt b/googlemock/CMakeLists.txt
index 428bd9f8e..99b2411f3 100644
--- a/googlemock/CMakeLists.txt
+++ b/googlemock/CMakeLists.txt
@@ -65,12 +65,13 @@ endif()
 config_compiler_and_linker() # from ${gtest_dir}/cmake/internal_utils.cmake
 
 # Adds Google Mock's and Google Test's header directories to the search path.
+# Get Google Test's include dirs from the target, gtest_SOURCE_DIR is broken
+# when using fetch-content with the name "GTest".
+get_target_property(gtest_include_dirs gtest INCLUDE_DIRECTORIES)
 set(gmock_build_include_dirs
   "${gmock_SOURCE_DIR}/include"
   "${gmock_SOURCE_DIR}"
-  "${gtest_SOURCE_DIR}/include"
-  # This directory is needed to build directly from Google Test sources.
-  "${gtest_SOURCE_DIR}")
+  "${gtest_include_dirs}")
 include_directories(${gmock_build_include_dirs})
 
 ########################################################################

From 6eb225cb8823c254d3a64549f2e1efad05c01757 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Tue, 13 Feb 2024 13:54:14 -0800
Subject: [PATCH 308/336] Add anchor for expectation ordering note

PiperOrigin-RevId: 606736565
Change-Id: Ifad0b34e1deeec1374377d733375c6210896d0d3
---
 docs/gmock_for_dummies.md | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/docs/gmock_for_dummies.md b/docs/gmock_for_dummies.md
index 9f24dcae5..ed2297c2f 100644
--- a/docs/gmock_for_dummies.md
+++ b/docs/gmock_for_dummies.md
@@ -261,6 +261,8 @@ happen. Therefore it's a good idea to turn on the heap checker in your tests
 when you allocate mocks on the heap. You get that automatically if you use the
 `gtest_main` library already.
 
+###### Expectation Ordering
+
 **Important note:** gMock requires expectations to be set **before** the mock
 functions are called, otherwise the behavior is **undefined**. Do not alternate
 between calls to `EXPECT_CALL()` and calls to the mock functions, and do not set

From 9756ee7cbaef1b6652065616ab832810a6032bbf Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Tue, 13 Feb 2024 20:56:05 -0800
Subject: [PATCH 309/336] Support Fuchsia target builds.

The Fuchsia team has been using either fork branches
(https://fuchsia.googlesource.com/third_
party/github.com/google/googletest/+/refs/heads/sandbox/fuchsia_bazel_sdk)
or patch files
(https://cs.opensource.google/fuchsia/fuchsia/+/main:build/bazel/patches/googletest/fuchsia-support.bundle)
to support googletest-based tests that run against a Fuchsia target device.

As our SDK is maturing and @platforms//os:fuchsia constraint has been added
for a while now, upstream Fuchsia gtest support to reduce technical debt and
overhead.

This change is noop for non-fuchsia platform builds.

PiperOrigin-RevId: 606843739
Change-Id: I61e0eb9c641f288d7ae57354fc0b484fce013223
---
 BUILD.bazel | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/BUILD.bazel b/BUILD.bazel
index b1e3b7fba..e407ae29f 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -56,6 +56,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 = {
@@ -147,6 +153,17 @@ cc_library(
             "@com_googlesource_code_re2//: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/syslog",
+            "@fuchsia_sdk//pkg/zx",
+        ],
+        "//conditions:default": [],
     }),
 )
 

From 5df0241ea4880e5a846775d3efc8b873f7b36c31 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Wed, 14 Feb 2024 16:10:41 -0800
Subject: [PATCH 310/336] gtest.h: add IWYU export pragmas

PiperOrigin-RevId: 607136416
Change-Id: Ia29dd3156d4d455194745e58501eaee9d77045a1
---
 googletest/include/gtest/gtest.h | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h
index 15d053916..de8eceaf6 100644
--- a/googletest/include/gtest/gtest.h
+++ b/googletest/include/gtest/gtest.h
@@ -60,16 +60,16 @@
 #include 
 #include 
 
-#include "gtest/gtest-assertion-result.h"
-#include "gtest/gtest-death-test.h"
-#include "gtest/gtest-matchers.h"
-#include "gtest/gtest-message.h"
-#include "gtest/gtest-param-test.h"
-#include "gtest/gtest-printers.h"
-#include "gtest/gtest-test-part.h"
-#include "gtest/gtest-typed-test.h"
-#include "gtest/gtest_pred_impl.h"
-#include "gtest/gtest_prod.h"
+#include "gtest/gtest-assertion-result.h"  // IWYU pragma: export
+#include "gtest/gtest-death-test.h"  // IWYU pragma: export
+#include "gtest/gtest-matchers.h"  // IWYU pragma: export
+#include "gtest/gtest-message.h"  // IWYU pragma: export
+#include "gtest/gtest-param-test.h"  // IWYU pragma: export
+#include "gtest/gtest-printers.h"  // IWYU pragma: export
+#include "gtest/gtest-test-part.h"  // IWYU pragma: export
+#include "gtest/gtest-typed-test.h"  // IWYU pragma: export
+#include "gtest/gtest_pred_impl.h"  // IWYU pragma: export
+#include "gtest/gtest_prod.h"  // IWYU pragma: export
 #include "gtest/internal/gtest-internal.h"
 #include "gtest/internal/gtest-string.h"
 

From db38b59fa0194e4b701793ee50d28a9ee319d20c Mon Sep 17 00:00:00 2001
From: Derek Mauro 
Date: Wed, 21 Feb 2024 11:05:22 -0800
Subject: [PATCH 311/336] Rollback
 https://github.com/google/googletest/commit/9756ee7cbaef1b6652065616ab832810a6032bbf

The commit breaks some bazel commands without @fuchsia_sdk being listed as a dependency.

Fixes #4472

PiperOrigin-RevId: 609057667
Change-Id: I32ea8237862d7c10add55304ecc4547a7304ce36
---
 BUILD.bazel | 17 -----------------
 1 file changed, 17 deletions(-)

diff --git a/BUILD.bazel b/BUILD.bazel
index e407ae29f..b1e3b7fba 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -56,12 +56,6 @@ 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 = {
@@ -153,17 +147,6 @@ cc_library(
             "@com_googlesource_code_re2//: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/syslog",
-            "@fuchsia_sdk//pkg/zx",
-        ],
-        "//conditions:default": [],
     }),
 )
 

From 9d43b27f7a873596496a2ea70721b3f9eb82df01 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Thu, 22 Feb 2024 08:47:35 -0800
Subject: [PATCH 312/336] Revert incorrect update.

PiperOrigin-RevId: 609387046
Change-Id: I03e42c39011fc7e9715f896591a44ebede1933b2
---
 docs/reference/mocking.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/docs/reference/mocking.md b/docs/reference/mocking.md
index 3ad49527c..ab37ebf36 100644
--- a/docs/reference/mocking.md
+++ b/docs/reference/mocking.md
@@ -81,8 +81,8 @@ EXPECT_CALL(mock_object, method_name(matchers...))
     .Times(cardinality)            // Can be used at most once
     .InSequence(sequences...)      // Can be used any number of times
     .After(expectations...)        // Can be used any number of times
-    .WillRepeatedly(action)        // Can be used any number of times
-    .WillOnce(action)              // Can be used at most once
+    .WillOnce(action)              // Can be used any number of times
+    .WillRepeatedly(action)        // Can be used at most once
     .RetiresOnSaturation();        // Can be used at most once
 ```
 

From 4c676b94b8ec284f20337862829412aab7e7927f Mon Sep 17 00:00:00 2001
From: Tiago Freire 
Date: Fri, 23 Feb 2024 13:23:25 +0100
Subject: [PATCH 313/336] Fixed gcc linker error 58

---
 googletest/src/gtest-death-test.cc | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/googletest/src/gtest-death-test.cc b/googletest/src/gtest-death-test.cc
index f914db5b5..c319ba893 100644
--- a/googletest/src/gtest-death-test.cc
+++ b/googletest/src/gtest-death-test.cc
@@ -630,13 +630,23 @@ bool DeathTestImpl::Passed(bool status_ok) {
 #ifndef GTEST_OS_WINDOWS
 // Note: The return value points into args, so the return value's lifetime is
 // bound to that of args.
-static std::unique_ptr CreateArgvFromArgs(
-    std::vector& args) {
-  auto result = std::make_unique(args.size() + 1);
-  for (size_t i = 0; i < args.size(); ++i) {
-    result[i] = &args[i][0];
+static std::vector CreateArgvFromArgs(
+    std::vector& args){
+  std::vector result;
+
+  size_t arg_size = args.size();
+  //if(arg_size >= std::numeric_limits::max()){
+  //  result.resize(1);
+  //  result[0] = nullptr;
+  //  return result;
+  //}
+
+  result.resize(arg_size + 1);
+  for (size_t i = 0; i < arg_size; ++i) {
+	  result[i] = args[i].data();
   }
-  result[args.size()] = nullptr;  // extra null terminator
+
+  result[arg_size] = nullptr;  // extra null terminator
   return result;
 }
 #endif
@@ -1036,8 +1046,8 @@ DeathTest::TestRole FuchsiaDeathTest::AssumeRole() {
   // "Fuchsia Test Component" which contains a "Fuchsia Component Manifest")
   // Launching processes is a privileged operation in Fuchsia, and the
   // declaration indicates that the ability is required for the component.
-  std::unique_ptr argv = CreateArgvFromArgs(args);
-  status = fdio_spawn_etc(child_job, FDIO_SPAWN_CLONE_ALL, argv[0], argv.get(),
+  std::vector argv = CreateArgvFromArgs(args);
+  status = fdio_spawn_etc(child_job, FDIO_SPAWN_CLONE_ALL, argv[0], argv.data(),
                           nullptr, 2, spawn_actions,
                           child_process_.reset_and_get_address(), nullptr);
   GTEST_DEATH_TEST_CHECK_(status == ZX_OK);
@@ -1388,8 +1398,8 @@ DeathTest::TestRole ExecDeathTest::AssumeRole() {
   // is necessary.
   FlushInfoLog();
 
-  std::unique_ptr argv = CreateArgvFromArgs(args);
-  const pid_t child_pid = ExecDeathTestSpawnChild(argv.get(), pipe_fd[0]);
+  std::vector argv = CreateArgvFromArgs(args);
+  const pid_t child_pid = ExecDeathTestSpawnChild(argv.data(), pipe_fd[0]);
   GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1]));
   set_child_pid(child_pid);
   set_read_fd(pipe_fd[0]);

From 814ba36338ae48b6066cd797a4fde84aaeacc4db Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Tue, 27 Feb 2024 11:03:43 -0800
Subject: [PATCH 314/336] Make sure that current_test_suite and
 current_test_info are mutex-protected while writing for thread-safety.

PiperOrigin-RevId: 610810340
Change-Id: I37f33510373dff04b8e9c9e8a9f32d30fcce46ff
---
 googletest/include/gtest/gtest.h    | 16 ++++++++++
 googletest/src/gtest-internal-inl.h | 24 +++++++-------
 googletest/src/gtest.cc             | 49 ++++++++++++++++++-----------
 3 files changed, 59 insertions(+), 30 deletions(-)

diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h
index de8eceaf6..2b70e49c4 100644
--- a/googletest/include/gtest/gtest.h
+++ b/googletest/include/gtest/gtest.h
@@ -1262,6 +1262,20 @@ class GTEST_API_ UnitTest {
   // total_test_suite_count() - 1. If i is not in that range, returns NULL.
   TestSuite* GetMutableTestSuite(int i);
 
+  // Invokes OsStackTrackGetterInterface::UponLeavingGTest. UponLeavingGTest()
+  // should be called immediately before Google Test calls user code. It saves
+  // some information about the current stack that CurrentStackTrace() will use
+  // to find and hide Google Test stack frames.
+  void UponLeavingGTest();
+
+  // Sets the TestSuite object for the test that's currently running.
+  void set_current_test_suite(TestSuite* a_current_test_suite)
+      GTEST_LOCK_EXCLUDED_(mutex_);
+
+  // Sets the TestInfo object for the test that's currently running.
+  void set_current_test_info(TestInfo* a_current_test_info)
+      GTEST_LOCK_EXCLUDED_(mutex_);
+
   // Accessors for the implementation object.
   internal::UnitTestImpl* impl() { return impl_; }
   const internal::UnitTestImpl* impl() const { return impl_; }
@@ -1270,6 +1284,8 @@ class GTEST_API_ UnitTest {
   // members of UnitTest.
   friend class ScopedTrace;
   friend class Test;
+  friend class TestInfo;
+  friend class TestSuite;
   friend class internal::AssertHelper;
   friend class internal::StreamingListenerTest;
   friend class internal::UnitTestRecordPropertyTestHelper;
diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h
index 4799a1e7b..6dea34f8f 100644
--- a/googletest/src/gtest-internal-inl.h
+++ b/googletest/src/gtest-internal-inl.h
@@ -709,18 +709,6 @@ class GTEST_API_ UnitTestImpl {
     return type_parameterized_test_registry_;
   }
 
-  // Sets the TestSuite object for the test that's currently running.
-  void set_current_test_suite(TestSuite* a_current_test_suite) {
-    current_test_suite_ = a_current_test_suite;
-  }
-
-  // Sets the TestInfo object for the test that's currently running.  If
-  // current_test_info is NULL, the assertion results will be stored in
-  // ad_hoc_test_result_.
-  void set_current_test_info(TestInfo* a_current_test_info) {
-    current_test_info_ = a_current_test_info;
-  }
-
   // Registers all parameterized tests defined using TEST_P and
   // INSTANTIATE_TEST_SUITE_P, creating regular tests for each test/parameter
   // combination. This method can be called more then once; it has guards
@@ -841,6 +829,18 @@ class GTEST_API_ UnitTestImpl {
   // GTEST_FLAG(catch_exceptions) at the moment it starts.
   void set_catch_exceptions(bool value) { catch_exceptions_ = value; }
 
+  // Sets the TestSuite object for the test that's currently running.
+  void set_current_test_suite(TestSuite* a_current_test_suite) {
+    current_test_suite_ = a_current_test_suite;
+  }
+
+  // Sets the TestInfo object for the test that's currently running.  If
+  // current_test_info is NULL, the assertion results will be stored in
+  // ad_hoc_test_result_.
+  void set_current_test_info(TestInfo* a_current_test_info) {
+    current_test_info_ = a_current_test_info;
+  }
+
   // The UnitTest object that owns this implementation object.
   UnitTest* const parent_;
 
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index d25f5c430..c5f22bb7f 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -2836,14 +2836,13 @@ void TestInfo::Run() {
   }
 
   // Tells UnitTest where to store test result.
-  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
-  impl->set_current_test_info(this);
+  UnitTest::GetInstance()->set_current_test_info(this);
 
   // Notifies the unit test event listeners that a test is about to start.
   repeater->OnTestStart(*this);
   result_.set_start_timestamp(internal::GetTimeInMillis());
   internal::Timer timer;
-  impl->os_stack_trace_getter()->UponLeavingGTest();
+  UnitTest::GetInstance()->UponLeavingGTest();
 
   // Creates the test object.
   Test* const test = internal::HandleExceptionsInMethodIfSupported(
@@ -2861,7 +2860,7 @@ void TestInfo::Run() {
 
   if (test != nullptr) {
     // Deletes the test object.
-    impl->os_stack_trace_getter()->UponLeavingGTest();
+    UnitTest::GetInstance()->UponLeavingGTest();
     internal::HandleExceptionsInMethodIfSupported(
         test, &Test::DeleteSelf_, "the test fixture's destructor");
   }
@@ -2873,15 +2872,14 @@ void TestInfo::Run() {
 
   // Tells UnitTest to stop associating assertion results to this
   // test.
-  impl->set_current_test_info(nullptr);
+  UnitTest::GetInstance()->set_current_test_info(nullptr);
 }
 
 // Skip and records a skipped test result for this object.
 void TestInfo::Skip() {
   if (!should_run_) return;
 
-  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
-  impl->set_current_test_info(this);
+  UnitTest::GetInstance()->set_current_test_info(this);
 
   TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();
 
@@ -2890,12 +2888,13 @@ void TestInfo::Skip() {
 
   const TestPartResult test_part_result =
       TestPartResult(TestPartResult::kSkip, this->file(), this->line(), "");
-  impl->GetTestPartResultReporterForCurrentThread()->ReportTestPartResult(
-      test_part_result);
+  internal::GetUnitTestImpl()
+      ->GetTestPartResultReporterForCurrentThread()
+      ->ReportTestPartResult(test_part_result);
 
   // Notifies the unit test event listener that a test has just finished.
   repeater->OnTestEnd(*this);
-  impl->set_current_test_info(nullptr);
+  UnitTest::GetInstance()->set_current_test_info(nullptr);
 }
 
 // class TestSuite
@@ -2991,8 +2990,7 @@ void TestSuite::AddTestInfo(TestInfo* test_info) {
 void TestSuite::Run() {
   if (!should_run_) return;
 
-  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
-  impl->set_current_test_suite(this);
+  UnitTest::GetInstance()->set_current_test_suite(this);
 
   TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();
 
@@ -3022,7 +3020,7 @@ void TestSuite::Run() {
   repeater->OnTestCaseStart(*this);
 #endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_
 
-  impl->os_stack_trace_getter()->UponLeavingGTest();
+  UnitTest::GetInstance()->UponLeavingGTest();
   internal::HandleExceptionsInMethodIfSupported(
       this, &TestSuite::RunSetUpTestSuite, "SetUpTestSuite()");
 
@@ -3047,7 +3045,7 @@ void TestSuite::Run() {
   }
   elapsed_time_ = timer.Elapsed();
 
-  impl->os_stack_trace_getter()->UponLeavingGTest();
+  UnitTest::GetInstance()->UponLeavingGTest();
   internal::HandleExceptionsInMethodIfSupported(
       this, &TestSuite::RunTearDownTestSuite, "TearDownTestSuite()");
 
@@ -3058,15 +3056,14 @@ void TestSuite::Run() {
   repeater->OnTestCaseEnd(*this);
 #endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_
 
-  impl->set_current_test_suite(nullptr);
+  UnitTest::GetInstance()->set_current_test_suite(nullptr);
 }
 
 // Skips all tests under this TestSuite.
 void TestSuite::Skip() {
   if (!should_run_) return;
 
-  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
-  impl->set_current_test_suite(this);
+  UnitTest::GetInstance()->set_current_test_suite(this);
 
   TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();
 
@@ -3088,7 +3085,7 @@ void TestSuite::Skip() {
   repeater->OnTestCaseEnd(*this);
 #endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_
 
-  impl->set_current_test_suite(nullptr);
+  UnitTest::GetInstance()->set_current_test_suite(nullptr);
 }
 
 // Clears the results of all tests in this test suite.
@@ -5304,6 +5301,22 @@ TestSuite* UnitTest::GetMutableTestSuite(int i) {
   return impl()->GetMutableSuiteCase(i);
 }
 
+void UnitTest::UponLeavingGTest() {
+  impl()->os_stack_trace_getter()->UponLeavingGTest();
+}
+
+// Sets the TestSuite object for the test that's currently running.
+void UnitTest::set_current_test_suite(TestSuite* a_current_test_suite) {
+  internal::MutexLock lock(&mutex_);
+  impl_->set_current_test_suite(a_current_test_suite);
+}
+
+// Sets the TestInfo object for the test that's currently running.
+void UnitTest::set_current_test_info(TestInfo* a_current_test_info) {
+  internal::MutexLock lock(&mutex_);
+  impl_->set_current_test_info(a_current_test_info);
+}
+
 // Returns the list of event listeners that can be used to track events
 // inside Google Test.
 TestEventListeners& UnitTest::listeners() { return *impl()->listeners(); }

From 3b6d48e8d5c1d9b3f9f10ac030a94008bfaf032b Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Tue, 27 Feb 2024 11:53:48 -0800
Subject: [PATCH 315/336] Reland
 https://github.com/google/googletest/commit/9756ee7cbaef1b6652065616ab832810a6032bbf

Since Fuchsia engineers rarely work within this repo, initialize a lightweight fake @fuchsia_sdk repo rather than distributing the Fuchsia SDK here.

Tested locally via `bazel query --[no]enable_bzlmod "deps(set(//googletest/test:gtest_all_test))"` (#4472)

PiperOrigin-RevId: 610826859
Change-Id: I7d41b1dbe9e7f133fe535d7337dc5bff5bf97d3a
---
 BUILD.bazel          | 17 +++++++++++++++++
 MODULE.bazel         |  4 ++++
 fake_fuchsia_sdk.bzl | 33 +++++++++++++++++++++++++++++++++
 googletest_deps.bzl  |  6 ++++++
 4 files changed, 60 insertions(+)
 create mode 100644 fake_fuchsia_sdk.bzl

diff --git a/BUILD.bazel b/BUILD.bazel
index b1e3b7fba..e407ae29f 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -56,6 +56,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 = {
@@ -147,6 +153,17 @@ cc_library(
             "@com_googlesource_code_re2//: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/syslog",
+            "@fuchsia_sdk//pkg/zx",
+        ],
+        "//conditions:default": [],
     }),
 )
 
diff --git a/MODULE.bazel b/MODULE.bazel
index d4ad2b3ae..b81ebf043 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -53,5 +53,9 @@ bazel_dep(name = "re2",
 bazel_dep(name = "rules_python",
           version = "0.29.0")
 
+
+fake_fuchsia_sdk = use_repo_rule("//:fake_fuchsia_sdk.bzl", "fake_fuchsia_sdk")
+fake_fuchsia_sdk(name = "fuchsia_sdk")
+
 # 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/fake_fuchsia_sdk.bzl b/fake_fuchsia_sdk.bzl
new file mode 100644
index 000000000..2024dc6c4
--- /dev/null
+++ b/fake_fuchsia_sdk.bzl
@@ -0,0 +1,33 @@
+"""Provides a fake @fuchsia_sdk implementation that's used when the real one isn't available.
+
+This is needed since bazel queries on targets that depend on //:gtest (eg:
+`bazel query "deps(set(//googletest/test:gtest_all_test))"`) will fail if @fuchsia_sdk is not
+defined when bazel is evaluating the transitive closure of the query target.
+
+See https://github.com/google/googletest/issues/4472.
+"""
+
+def _fake_fuchsia_sdk_impl(repo_ctx):
+    for stub_target in repo_ctx.attr._stub_build_targets:
+        stub_package = stub_target
+        stub_target_name = stub_target.split("/")[-1]
+        repo_ctx.file("%s/BUILD.bazel" % stub_package, """
+filegroup(
+    name = "%s",
+)
+""" % stub_target_name)
+
+fake_fuchsia_sdk = repository_rule(
+    doc = "Used to create a fake @fuchsia_sdk repository with stub build targets.",
+    implementation = _fake_fuchsia_sdk_impl,
+    attrs = {
+        "_stub_build_targets": attr.string_list(
+            doc = "The stub build targets to initialize.",
+            default = [
+                "pkg/fdio",
+                "pkg/syslog",
+                "pkg/zx",
+            ],
+        ),
+    },
+)
diff --git a/googletest_deps.bzl b/googletest_deps.bzl
index 8958890c7..1b7d2c8b8 100644
--- a/googletest_deps.bzl
+++ b/googletest_deps.bzl
@@ -1,6 +1,7 @@
 """Load dependencies needed to use the googletest library as a 3rd-party consumer."""
 
 load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+load("//:fake_fuchsia_sdk.bzl", "fake_fuchsia_sdk")
 
 def googletest_deps():
     """Loads common dependencies needed to use the googletest library."""
@@ -20,3 +21,8 @@ def googletest_deps():
             strip_prefix = "abseil-cpp-20240116.0",
             urls = ["https://github.com/abseil/abseil-cpp/releases/download/20240116.0/abseil-cpp-20240116.0.tar.gz"],
         )
+
+    if not native.existing_rule("fuchsia_sdk"):
+        fake_fuchsia_sdk(
+            name = "fuchsia_sdk",
+        )

From e4fdb87e76b9fc4b01c54ad81aea19d6e994b994 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Thu, 29 Feb 2024 07:41:40 -0800
Subject: [PATCH 316/336] Accept one-shot callables in InvokeArgument.

PiperOrigin-RevId: 611467660
Change-Id: Ic89ffc986141bee61f835cb60088aee92eb8bad9
---
 googlemock/include/gmock/gmock-more-actions.h |  5 +++--
 googlemock/test/gmock-more-actions_test.cc    | 10 ++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/googlemock/include/gmock/gmock-more-actions.h b/googlemock/include/gmock/gmock-more-actions.h
index dd90e31fa..e341d47fc 100644
--- a/googlemock/include/gmock/gmock-more-actions.h
+++ b/googlemock/include/gmock/gmock-more-actions.h
@@ -592,8 +592,9 @@ namespace internal {
 // Overloads for other custom-callables are provided in the
 // internal/custom/gmock-generated-actions.h header.
 template 
-auto InvokeArgument(F f, Args... args) -> decltype(f(args...)) {
-  return f(args...);
+auto InvokeArgument(F &&f,
+                    Args... args) -> decltype(std::forward(f)(args...)) {
+  return std::forward(f)(args...);
 }
 
 template 
diff --git a/googlemock/test/gmock-more-actions_test.cc b/googlemock/test/gmock-more-actions_test.cc
index 16af68928..7ed89a988 100644
--- a/googlemock/test/gmock-more-actions_test.cc
+++ b/googlemock/test/gmock-more-actions_test.cc
@@ -91,6 +91,10 @@ struct UnaryMoveOnlyFunctor : UnaryFunctor {
   UnaryMoveOnlyFunctor(UnaryMoveOnlyFunctor&&) = default;
 };
 
+struct OneShotUnaryFunctor {
+  int operator()(bool x) && { return x ? 1 : -1; }
+};
+
 const char* Binary(const char* input, short n) { return input + n; }  // NOLINT
 
 int Ternary(int x, char y, short z) { return x + y + z; }  // NOLINT
@@ -716,6 +720,12 @@ TEST(InvokeArgumentTest, Functor1MoveOnly) {
   EXPECT_EQ(1, a.Perform(std::make_tuple(UnaryMoveOnlyFunctor())));
 }
 
+// Tests using InvokeArgument with a one-shot unary functor.
+TEST(InvokeArgumentTest, OneShotFunctor1) {
+  Action a = InvokeArgument<0>(true);  // NOLINT
+  EXPECT_EQ(1, a.Perform(std::make_tuple(OneShotUnaryFunctor())));
+}
+
 // Tests using InvokeArgument with a 5-ary function.
 TEST(InvokeArgumentTest, Function5) {
   Action a =  // NOLINT

From b9059aaa4cb93b3fb177670cbfd9c6d0690af37e Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Tue, 5 Mar 2024 02:36:18 -0800
Subject: [PATCH 317/336] Optimize Google Test process startup

Google Test performs hidden test registration during process
startup. For test binaries that contain a large number of tests, this
registration can be costly. In this CL, we reduce the overhead of
registration via several tactics:

- Treat CodeLocation and FilePath as value types, using std::move to
  pass them around.
- Reduce string copies in various places by either passing std::string
  values via std::move, or passing const-refs to std::string instances.
- Use std::to_string to stringify an int in DefaultParamName rather than
  a std::stringstream.
- Pull some std::string instances out of nested loops in
  ParameterizedTestSuiteInfo::RegisterTests so as to reuse some
  allocations, and replace stringstream with ordinary string appends.
- Use std::unordered_map in UnitTestImpl::GetTestSuite and
  ParameterizedTestSuiteRegistry::GetTestSuitePatternHolder to spend a
  little memory to turn O(N) lookups into constant time lookpus.
- Use range-based for loops in various places.
- Use emplace-ish methods to add to containers where appropriate.

All together, these changes reduce the overall runtime of a series of 50
death tests in a single Chromium test executable by ~38% due to the
fact that the registration costs are paid in every death test's child
process.

PiperOrigin-RevId: 612763676
Change-Id: I1f46e012ccb9004c009e1027e4f7c38780ffb9e2
---
 googletest/include/gtest/gtest.h              |   6 +-
 .../include/gtest/internal/gtest-filepath.h   |   8 +-
 .../include/gtest/internal/gtest-internal.h   |  29 ++--
 .../include/gtest/internal/gtest-param-util.h | 140 +++++++++---------
 googletest/src/gtest-internal-inl.h           |  20 ++-
 googletest/src/gtest.cc                       | 117 +++++++--------
 6 files changed, 159 insertions(+), 161 deletions(-)

diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h
index 2b70e49c4..c89966952 100644
--- a/googletest/include/gtest/gtest.h
+++ b/googletest/include/gtest/gtest.h
@@ -607,7 +607,7 @@ class GTEST_API_ TestInfo {
   friend class internal::UnitTestImpl;
   friend class internal::StreamingListenerTest;
   friend TestInfo* internal::MakeAndRegisterTestInfo(
-      const char* test_suite_name, const char* name, const char* type_param,
+      std::string test_suite_name, const char* name, const char* type_param,
       const char* value_param, internal::CodeLocation code_location,
       internal::TypeId fixture_class_id, internal::SetUpTestSuiteFunc set_up_tc,
       internal::TearDownTestSuiteFunc tear_down_tc,
@@ -615,7 +615,7 @@ class GTEST_API_ TestInfo {
 
   // Constructs a TestInfo object. The newly constructed instance assumes
   // ownership of the factory object.
-  TestInfo(const std::string& test_suite_name, const std::string& name,
+  TestInfo(std::string test_suite_name, std::string name,
            const char* a_type_param,   // NULL if not a type-parameterized test
            const char* a_value_param,  // NULL if not a value-parameterized test
            internal::CodeLocation a_code_location,
@@ -683,7 +683,7 @@ class GTEST_API_ TestSuite {
   //                 this is not a type-parameterized test.
   //   set_up_tc:    pointer to the function that sets up the test suite
   //   tear_down_tc: pointer to the function that tears down the test suite
-  TestSuite(const char* name, const char* a_type_param,
+  TestSuite(const std::string& name, const char* a_type_param,
             internal::SetUpTestSuiteFunc set_up_tc,
             internal::TearDownTestSuiteFunc tear_down_tc);
 
diff --git a/googletest/include/gtest/internal/gtest-filepath.h b/googletest/include/gtest/internal/gtest-filepath.h
index 5189c81da..7ffb49238 100644
--- a/googletest/include/gtest/internal/gtest-filepath.h
+++ b/googletest/include/gtest/internal/gtest-filepath.h
@@ -43,6 +43,7 @@
 #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
 
 #include 
+#include 
 
 #include "gtest/internal/gtest-port.h"
 #include "gtest/internal/gtest-string.h"
@@ -70,8 +71,9 @@ class GTEST_API_ FilePath {
  public:
   FilePath() : pathname_("") {}
   FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) {}
+  FilePath(FilePath&& rhs) : pathname_(std::move(rhs.pathname_)) {}
 
-  explicit FilePath(const std::string& pathname) : pathname_(pathname) {
+  explicit FilePath(std::string pathname) : pathname_(std::move(pathname)) {
     Normalize();
   }
 
@@ -79,6 +81,10 @@ class GTEST_API_ FilePath {
     Set(rhs);
     return *this;
   }
+  FilePath& operator=(FilePath&& rhs) {
+    pathname_ = std::move(rhs.pathname_);
+    return *this;
+  }
 
   void Set(const FilePath& rhs) { pathname_ = rhs.pathname_; }
 
diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h
index 806b08624..4661248f7 100644
--- a/googletest/include/gtest/internal/gtest-internal.h
+++ b/googletest/include/gtest/internal/gtest-internal.h
@@ -474,8 +474,8 @@ using SetUpTestSuiteFunc = void (*)();
 using TearDownTestSuiteFunc = void (*)();
 
 struct CodeLocation {
-  CodeLocation(const std::string& a_file, int a_line)
-      : file(a_file), line(a_line) {}
+  CodeLocation(std::string a_file, int a_line)
+      : file(std::move(a_file)), line(a_line) {}
 
   std::string file;
   int line;
@@ -564,7 +564,7 @@ struct SuiteApiResolver : T {
 //                     The newly created TestInfo instance will assume
 //                     ownership of the factory object.
 GTEST_API_ TestInfo* MakeAndRegisterTestInfo(
-    const char* test_suite_name, const char* name, const char* type_param,
+    std::string test_suite_name, const char* name, const char* type_param,
     const char* value_param, CodeLocation code_location,
     TypeId fixture_class_id, SetUpTestSuiteFunc set_up_tc,
     TearDownTestSuiteFunc tear_down_tc, TestFactoryBase* factory);
@@ -595,8 +595,7 @@ class GTEST_API_ TypedTestSuitePState {
       fflush(stderr);
       posix::Abort();
     }
-    registered_tests_.insert(
-        ::std::make_pair(test_name, CodeLocation(file, line)));
+    registered_tests_.emplace(test_name, CodeLocation(file, line));
     return true;
   }
 
@@ -700,7 +699,7 @@ class TypeParameterizedTest {
   // specified in INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, TestSuite,
   // Types).  Valid values for 'index' are [0, N - 1] where N is the
   // length of Types.
-  static bool Register(const char* prefix, const CodeLocation& code_location,
+  static bool Register(const char* prefix, CodeLocation code_location,
                        const char* case_name, const char* test_names, int index,
                        const std::vector& type_names =
                            GenerateNames()) {
@@ -712,8 +711,7 @@ class TypeParameterizedTest {
     // list.
     MakeAndRegisterTestInfo(
         (std::string(prefix) + (prefix[0] == '\0' ? "" : "/") + case_name +
-         "/" + type_names[static_cast(index)])
-            .c_str(),
+         "/" + type_names[static_cast(index)]),
         StripTrailingSpaces(GetPrefixUntilComma(test_names)).c_str(),
         GetTypeName().c_str(),
         nullptr,  // No value parameter.
@@ -725,13 +723,9 @@ class TypeParameterizedTest {
         new TestFactoryImpl);
 
     // Next, recurses (at compile time) with the tail of the type list.
-    return TypeParameterizedTest::Register(prefix,
-                                                                 code_location,
-                                                                 case_name,
-                                                                 test_names,
-                                                                 index + 1,
-                                                                 type_names);
+    return TypeParameterizedTest::
+        Register(prefix, std::move(code_location), case_name, test_names,
+                 index + 1, type_names);
   }
 };
 
@@ -739,7 +733,7 @@ class TypeParameterizedTest {
 template 
 class TypeParameterizedTest {
  public:
-  static bool Register(const char* /*prefix*/, const CodeLocation&,
+  static bool Register(const char* /*prefix*/, CodeLocation,
                        const char* /*case_name*/, const char* /*test_names*/,
                        int /*index*/,
                        const std::vector& =
@@ -786,7 +780,8 @@ class TypeParameterizedTestSuite {
 
     // Next, recurses (at compile time) with the tail of the test list.
     return TypeParameterizedTestSuite::Register(prefix, code_location,
+                                      Types>::Register(prefix,
+                                                       std::move(code_location),
                                                        state, case_name,
                                                        SkipComma(test_names),
                                                        type_names);
diff --git a/googletest/include/gtest/internal/gtest-param-util.h b/googletest/include/gtest/internal/gtest-param-util.h
index b04f70206..1fc500f97 100644
--- a/googletest/include/gtest/internal/gtest-param-util.h
+++ b/googletest/include/gtest/internal/gtest-param-util.h
@@ -47,6 +47,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -85,7 +86,7 @@ namespace internal {
 // TEST_P macro is used to define two tests with the same name
 // but in different namespaces.
 GTEST_API_ void ReportInvalidTestSuiteType(const char* test_suite_name,
-                                           CodeLocation code_location);
+                                           const CodeLocation& code_location);
 
 template 
 class ParamGeneratorInterface;
@@ -379,9 +380,7 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface {
 // integer test parameter index.
 template 
 std::string DefaultParamName(const TestParamInfo& info) {
-  Message name_stream;
-  name_stream << info.index;
-  return name_stream.GetString();
+  return std::to_string(info.index);
 }
 
 template 
@@ -513,9 +512,10 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
   typedef ParamGenerator(GeneratorCreationFunc)();
   using ParamNameGeneratorFunc = std::string(const TestParamInfo&);
 
-  explicit ParameterizedTestSuiteInfo(const char* name,
+  explicit ParameterizedTestSuiteInfo(std::string name,
                                       CodeLocation code_location)
-      : test_suite_name_(name), code_location_(code_location) {}
+      : test_suite_name_(std::move(name)),
+        code_location_(std::move(code_location)) {}
 
   // Test suite base name for display purposes.
   const std::string& GetTestSuiteName() const override {
@@ -529,20 +529,21 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
   // prefix). test_base_name is the name of an individual test without
   // parameter index. For the test SequenceA/FooTest.DoBar/1 FooTest is
   // test suite base name and DoBar is test base name.
-  void AddTestPattern(const char* test_suite_name, const char* test_base_name,
+  void AddTestPattern(const char*,
+                      const char* test_base_name,
                       TestMetaFactoryBase* meta_factory,
                       CodeLocation code_location) {
-    tests_.push_back(std::shared_ptr(new TestInfo(
-        test_suite_name, test_base_name, meta_factory, code_location)));
+    tests_.emplace_back(
+        new TestInfo(test_base_name, meta_factory, std::move(code_location)));
   }
   // INSTANTIATE_TEST_SUITE_P macro uses AddGenerator() to record information
   // about a generator.
-  int AddTestSuiteInstantiation(const std::string& instantiation_name,
+  int AddTestSuiteInstantiation(std::string instantiation_name,
                                 GeneratorCreationFunc* func,
                                 ParamNameGeneratorFunc* name_func,
                                 const char* file, int line) {
-    instantiations_.push_back(
-        InstantiationInfo(instantiation_name, func, name_func, file, line));
+    instantiations_.emplace_back(std::move(instantiation_name), func, name_func,
+                                 file, line);
     return 0;  // Return value used only to run this method in namespace scope.
   }
   // UnitTest class invokes this method to register tests in this test suite
@@ -553,34 +554,31 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
   void RegisterTests() override {
     bool generated_instantiations = false;
 
-    for (typename TestInfoContainer::iterator test_it = tests_.begin();
-         test_it != tests_.end(); ++test_it) {
-      std::shared_ptr test_info = *test_it;
-      for (typename InstantiationContainer::iterator gen_it =
-               instantiations_.begin();
-           gen_it != instantiations_.end(); ++gen_it) {
-        const std::string& instantiation_name = gen_it->name;
-        ParamGenerator generator((*gen_it->generator)());
-        ParamNameGeneratorFunc* name_func = gen_it->name_func;
-        const char* file = gen_it->file;
-        int line = gen_it->line;
+    std::string test_suite_name;
+    std::string test_name;
+    for (const std::shared_ptr& test_info : tests_) {
+      for (const InstantiationInfo& instantiation : instantiations_) {
+        const std::string& instantiation_name = instantiation.name;
+        ParamGenerator generator((*instantiation.generator)());
+        ParamNameGeneratorFunc* name_func = instantiation.name_func;
+        const char* file = instantiation.file;
+        int line = instantiation.line;
 
-        std::string test_suite_name;
         if (!instantiation_name.empty())
           test_suite_name = instantiation_name + "/";
-        test_suite_name += test_info->test_suite_base_name;
+        else
+          test_suite_name.clear();
+        test_suite_name += test_suite_name_;
 
         size_t i = 0;
         std::set test_param_names;
-        for (typename ParamGenerator::iterator param_it =
-                 generator.begin();
-             param_it != generator.end(); ++param_it, ++i) {
+        for (const auto& param : generator) {
           generated_instantiations = true;
 
-          Message test_name_stream;
+          test_name.clear();
 
           std::string param_name =
-              name_func(TestParamInfo(*param_it, i));
+              name_func(TestParamInfo(param, i));
 
           GTEST_CHECK_(IsValidParamName(param_name))
               << "Parameterized test name '" << param_name
@@ -592,23 +590,25 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
               << "Duplicate parameterized test name '" << param_name << "', in "
               << file << " line " << line << std::endl;
 
-          test_param_names.insert(param_name);
-
           if (!test_info->test_base_name.empty()) {
-            test_name_stream << test_info->test_base_name << "/";
+            test_name.append(test_info->test_base_name).append("/");
           }
-          test_name_stream << param_name;
+          test_name += param_name;
+
+          test_param_names.insert(std::move(param_name));
+
           MakeAndRegisterTestInfo(
-              test_suite_name.c_str(), test_name_stream.GetString().c_str(),
+              test_suite_name, test_name.c_str(),
               nullptr,  // No type parameter.
-              PrintToString(*param_it).c_str(), test_info->code_location,
+              PrintToString(param).c_str(), test_info->code_location,
               GetTestSuiteTypeId(),
               SuiteApiResolver::GetSetUpCaseOrSuite(file, line),
               SuiteApiResolver::GetTearDownCaseOrSuite(file, line),
-              test_info->test_meta_factory->CreateTestFactory(*param_it));
-        }  // for param_it
-      }    // for gen_it
-    }      // for test_it
+              test_info->test_meta_factory->CreateTestFactory(param));
+          ++i;
+        }  // for param
+      }  // for instantiation
+    }  // for test_info
 
     if (!generated_instantiations) {
       // There are no generaotrs, or they all generate nothing ...
@@ -621,15 +621,13 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
   // LocalTestInfo structure keeps information about a single test registered
   // with TEST_P macro.
   struct TestInfo {
-    TestInfo(const char* a_test_suite_base_name, const char* a_test_base_name,
+    TestInfo(const char* a_test_base_name,
              TestMetaFactoryBase* a_test_meta_factory,
              CodeLocation a_code_location)
-        : test_suite_base_name(a_test_suite_base_name),
-          test_base_name(a_test_base_name),
+        : test_base_name(a_test_base_name),
           test_meta_factory(a_test_meta_factory),
-          code_location(a_code_location) {}
+          code_location(std::move(a_code_location)) {}
 
-    const std::string test_suite_base_name;
     const std::string test_base_name;
     const std::unique_ptr> test_meta_factory;
     const CodeLocation code_location;
@@ -639,11 +637,10 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
   //  
   struct InstantiationInfo {
-    InstantiationInfo(const std::string& name_in,
-                      GeneratorCreationFunc* generator_in,
+    InstantiationInfo(std::string name_in, GeneratorCreationFunc* generator_in,
                       ParamNameGeneratorFunc* name_func_in, const char* file_in,
                       int line_in)
-        : name(name_in),
+        : name(std::move(name_in)),
           generator(generator_in),
           name_func(name_func_in),
           file(file_in),
@@ -704,29 +701,32 @@ class ParameterizedTestSuiteRegistry {
   // tests and instantiations of a particular test suite.
   template 
   ParameterizedTestSuiteInfo* GetTestSuitePatternHolder(
-      const char* test_suite_name, CodeLocation code_location) {
+      std::string test_suite_name, CodeLocation code_location) {
     ParameterizedTestSuiteInfo* typed_test_info = nullptr;
-    for (auto& test_suite_info : test_suite_infos_) {
-      if (test_suite_info->GetTestSuiteName() == test_suite_name) {
-        if (test_suite_info->GetTestSuiteTypeId() != GetTypeId()) {
-          // Complain about incorrect usage of Google Test facilities
-          // and terminate the program since we cannot guaranty correct
-          // test suite setup and tear-down in this case.
-          ReportInvalidTestSuiteType(test_suite_name, code_location);
-          posix::Abort();
-        } else {
-          // At this point we are sure that the object we found is of the same
-          // type we are looking for, so we downcast it to that type
-          // without further checks.
-          typed_test_info = CheckedDowncastToActualType<
-              ParameterizedTestSuiteInfo>(test_suite_info);
-        }
-        break;
+
+    auto item_it = suite_name_to_info_index_.find(test_suite_name);
+    if (item_it != suite_name_to_info_index_.end()) {
+      auto* test_suite_info = test_suite_infos_[item_it->second];
+      if (test_suite_info->GetTestSuiteTypeId() != GetTypeId()) {
+        // Complain about incorrect usage of Google Test facilities
+        // and terminate the program since we cannot guaranty correct
+        // test suite setup and tear-down in this case.
+        ReportInvalidTestSuiteType(test_suite_name.c_str(), code_location);
+        posix::Abort();
+      } else {
+        // At this point we are sure that the object we found is of the same
+        // type we are looking for, so we downcast it to that type
+        // without further checks.
+        typed_test_info =
+            CheckedDowncastToActualType>(
+                test_suite_info);
       }
     }
     if (typed_test_info == nullptr) {
       typed_test_info = new ParameterizedTestSuiteInfo(
-          test_suite_name, code_location);
+          test_suite_name, std::move(code_location));
+      suite_name_to_info_index_.emplace(std::move(test_suite_name),
+                                        test_suite_infos_.size());
       test_suite_infos_.push_back(typed_test_info);
     }
     return typed_test_info;
@@ -740,8 +740,9 @@ class ParameterizedTestSuiteRegistry {
 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
   template 
   ParameterizedTestCaseInfo* GetTestCasePatternHolder(
-      const char* test_case_name, CodeLocation code_location) {
-    return GetTestSuitePatternHolder(test_case_name, code_location);
+      std::string test_case_name, CodeLocation code_location) {
+    return GetTestSuitePatternHolder(std::move(test_case_name),
+                                               std::move(code_location));
   }
 
 #endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_
@@ -750,6 +751,7 @@ class ParameterizedTestSuiteRegistry {
   using TestSuiteInfoContainer = ::std::vector;
 
   TestSuiteInfoContainer test_suite_infos_;
+  ::std::unordered_map suite_name_to_info_index_;
 
   ParameterizedTestSuiteRegistry(const ParameterizedTestSuiteRegistry&) =
       delete;
@@ -776,7 +778,7 @@ class TypeParameterizedTestSuiteRegistry {
  private:
   struct TypeParameterizedTestSuiteInfo {
     explicit TypeParameterizedTestSuiteInfo(CodeLocation c)
-        : code_location(c), instantiated(false) {}
+        : code_location(std::move(c)), instantiated(false) {}
 
     CodeLocation code_location;
     bool instantiated;
diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h
index 6dea34f8f..6a7f4dd93 100644
--- a/googletest/src/gtest-internal-inl.h
+++ b/googletest/src/gtest-internal-inl.h
@@ -46,6 +46,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "gtest/internal/gtest-port.h"
@@ -649,13 +650,15 @@ class GTEST_API_ UnitTestImpl {
   //                    this is not a typed or a type-parameterized test.
   //   set_up_tc:       pointer to the function that sets up the test suite
   //   tear_down_tc:    pointer to the function that tears down the test suite
-  TestSuite* GetTestSuite(const char* test_suite_name, const char* type_param,
+  TestSuite* GetTestSuite(const std::string& test_suite_name,
+                          const char* type_param,
                           internal::SetUpTestSuiteFunc set_up_tc,
                           internal::TearDownTestSuiteFunc tear_down_tc);
 
 //  Legacy API is deprecated but still available
 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
-  TestCase* GetTestCase(const char* test_case_name, const char* type_param,
+  TestCase* GetTestCase(const std::string& test_case_name,
+                        const char* type_param,
                         internal::SetUpTestSuiteFunc set_up_tc,
                         internal::TearDownTestSuiteFunc tear_down_tc) {
     return GetTestSuite(test_case_name, type_param, set_up_tc, tear_down_tc);
@@ -681,13 +684,13 @@ class GTEST_API_ UnitTestImpl {
     // AddTestInfo(), which is called to register a TEST or TEST_F
     // before main() is reached.
     if (original_working_dir_.IsEmpty()) {
-      original_working_dir_.Set(FilePath::GetCurrentDir());
+      original_working_dir_ = FilePath::GetCurrentDir();
       GTEST_CHECK_(!original_working_dir_.IsEmpty())
           << "Failed to get the current working directory.";
     }
 #endif  // GTEST_HAS_FILE_SYSTEM
 
-    GetTestSuite(test_info->test_suite_name(), test_info->type_param(),
+    GetTestSuite(test_info->test_suite_name_, test_info->type_param(),
                  set_up_tc, tear_down_tc)
         ->AddTestInfo(test_info);
   }
@@ -823,6 +826,12 @@ class GTEST_API_ UnitTestImpl {
   bool catch_exceptions() const { return catch_exceptions_; }
 
  private:
+  struct CompareTestSuitesByPointer {
+    bool operator()(const TestSuite* lhs, const TestSuite* rhs) const {
+      return lhs->name_ < rhs->name_;
+    };
+  };
+
   friend class ::testing::UnitTest;
 
   // Used by UnitTest::Run() to capture the state of
@@ -873,6 +882,9 @@ class GTEST_API_ UnitTestImpl {
   // elements in the vector.
   std::vector test_suites_;
 
+  // The set of TestSuites by name.
+  std::unordered_map test_suites_by_name_;
+
   // Provides a level of indirection for the test suite list to allow
   // easy shuffling and restoring the test suite order.  The i-th
   // element of this vector is the index of the i-th test suite in the
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index c5f22bb7f..ca9f524e4 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -578,7 +578,7 @@ void InsertSyntheticTestCase(const std::string& name, CodeLocation location,
 void RegisterTypeParameterizedTestSuite(const char* test_suite_name,
                                         CodeLocation code_location) {
   GetUnitTestImpl()->type_parameterized_test_registry().RegisterTestSuite(
-      test_suite_name, code_location);
+      test_suite_name, std::move(code_location));
 }
 
 void RegisterTypeParameterizedTestSuiteInstantiation(const char* case_name) {
@@ -589,7 +589,7 @@ void RegisterTypeParameterizedTestSuiteInstantiation(const char* case_name) {
 void TypeParameterizedTestSuiteRegistry::RegisterTestSuite(
     const char* test_suite_name, CodeLocation code_location) {
   suites_.emplace(std::string(test_suite_name),
-                  TypeParameterizedTestSuiteInfo(code_location));
+                  TypeParameterizedTestSuiteInfo(std::move(code_location)));
 }
 
 void TypeParameterizedTestSuiteRegistry::RegisterInstantiation(
@@ -801,7 +801,7 @@ class UnitTestFilter {
   // Returns true if and only if name matches at least one of the patterns in
   // the filter.
   bool MatchesName(const std::string& name) const {
-    return exact_match_patterns_.count(name) > 0 ||
+    return exact_match_patterns_.find(name) != exact_match_patterns_.end() ||
            std::any_of(glob_patterns_.begin(), glob_patterns_.end(),
                        [&name](const std::string& pattern) {
                          return PatternMatchesString(
@@ -2740,18 +2740,16 @@ bool Test::IsSkipped() {
 
 // Constructs a TestInfo object. It assumes ownership of the test factory
 // object.
-TestInfo::TestInfo(const std::string& a_test_suite_name,
-                   const std::string& a_name, const char* a_type_param,
-                   const char* a_value_param,
+TestInfo::TestInfo(std::string a_test_suite_name, std::string a_name,
+                   const char* a_type_param, const char* a_value_param,
                    internal::CodeLocation a_code_location,
                    internal::TypeId fixture_class_id,
                    internal::TestFactoryBase* factory)
-    : test_suite_name_(a_test_suite_name),
-      // begin()/end() is MSVC 17.3.3 ASAN crash workaround (GitHub issue #3997)
-      name_(a_name.begin(), a_name.end()),
+    : test_suite_name_(std::move(a_test_suite_name)),
+      name_(std::move(a_name)),
       type_param_(a_type_param ? new std::string(a_type_param) : nullptr),
       value_param_(a_value_param ? new std::string(a_value_param) : nullptr),
-      location_(a_code_location),
+      location_(std::move(a_code_location)),
       fixture_class_id_(fixture_class_id),
       should_run_(false),
       is_disabled_(false),
@@ -2784,19 +2782,19 @@ namespace internal {
 //                     The newly created TestInfo instance will assume
 //                     ownership of the factory object.
 TestInfo* MakeAndRegisterTestInfo(
-    const char* test_suite_name, const char* name, const char* type_param,
+    std::string test_suite_name, const char* name, const char* type_param,
     const char* value_param, CodeLocation code_location,
     TypeId fixture_class_id, SetUpTestSuiteFunc set_up_tc,
     TearDownTestSuiteFunc tear_down_tc, TestFactoryBase* factory) {
   TestInfo* const test_info =
-      new TestInfo(test_suite_name, name, type_param, value_param,
-                   code_location, fixture_class_id, factory);
+      new TestInfo(std::move(test_suite_name), name, type_param, value_param,
+                   std::move(code_location), fixture_class_id, factory);
   GetUnitTestImpl()->AddTestInfo(set_up_tc, tear_down_tc, test_info);
   return test_info;
 }
 
 void ReportInvalidTestSuiteType(const char* test_suite_name,
-                                CodeLocation code_location) {
+                                const CodeLocation& code_location) {
   Message errors;
   errors
       << "Attempted redefinition of test suite " << test_suite_name << ".\n"
@@ -2948,7 +2946,7 @@ int TestSuite::total_test_count() const {
 //                 this is not a typed or a type-parameterized test suite.
 //   set_up_tc:    pointer to the function that sets up the test suite
 //   tear_down_tc: pointer to the function that tears down the test suite
-TestSuite::TestSuite(const char* a_name, const char* a_type_param,
+TestSuite::TestSuite(const std::string& a_name, const char* a_type_param,
                      internal::SetUpTestSuiteFunc set_up_tc,
                      internal::TearDownTestSuiteFunc tear_down_tc)
     : name_(a_name),
@@ -3836,11 +3834,10 @@ void TestEventRepeater::Append(TestEventListener* listener) {
 }
 
 TestEventListener* TestEventRepeater::Release(TestEventListener* listener) {
-  for (size_t i = 0; i < listeners_.size(); ++i) {
-    if (listeners_[i] == listener) {
-      listeners_.erase(listeners_.begin() + static_cast(i));
-      return listener;
-    }
+  auto iter = std::find(listeners_.begin(), listeners_.end(), listener);
+  if (iter != listeners_.end()) {
+    listeners_.erase(iter);
+    return listener;
   }
 
   return nullptr;
@@ -3851,20 +3848,21 @@ TestEventListener* TestEventRepeater::Release(TestEventListener* listener) {
 #define GTEST_REPEATER_METHOD_(Name, Type)              \
   void TestEventRepeater::Name(const Type& parameter) { \
     if (forwarding_enabled_) {                          \
-      for (size_t i = 0; i < listeners_.size(); i++) {  \
-        listeners_[i]->Name(parameter);                 \
+      for (auto* listener : listeners_) {               \
+        listener->Name(parameter);                      \
       }                                                 \
     }                                                   \
   }
 // This defines a member that forwards the call to all listeners in reverse
 // order.
-#define GTEST_REVERSE_REPEATER_METHOD_(Name, Type)      \
-  void TestEventRepeater::Name(const Type& parameter) { \
-    if (forwarding_enabled_) {                          \
-      for (size_t i = listeners_.size(); i != 0; i--) { \
-        listeners_[i - 1]->Name(parameter);             \
-      }                                                 \
-    }                                                   \
+#define GTEST_REVERSE_REPEATER_METHOD_(Name, Type)                 \
+  void TestEventRepeater::Name(const Type& parameter) {            \
+    if (forwarding_enabled_) {                                     \
+      const auto end = listeners_.rend();                          \
+      for (auto scan = listeners_.rbegin(); scan != end; ++scan) { \
+        (*scan)->Name(parameter);                                  \
+      }                                                            \
+    }                                                              \
   }
 
 GTEST_REPEATER_METHOD_(OnTestProgramStart, UnitTest)
@@ -3894,8 +3892,8 @@ GTEST_REVERSE_REPEATER_METHOD_(OnTestProgramEnd, UnitTest)
 void TestEventRepeater::OnTestIterationStart(const UnitTest& unit_test,
                                              int iteration) {
   if (forwarding_enabled_) {
-    for (size_t i = 0; i < listeners_.size(); i++) {
-      listeners_[i]->OnTestIterationStart(unit_test, iteration);
+    for (auto* listener : listeners_) {
+      listener->OnTestIterationStart(unit_test, iteration);
     }
   }
 }
@@ -3903,8 +3901,9 @@ void TestEventRepeater::OnTestIterationStart(const UnitTest& unit_test,
 void TestEventRepeater::OnTestIterationEnd(const UnitTest& unit_test,
                                            int iteration) {
   if (forwarding_enabled_) {
-    for (size_t i = listeners_.size(); i > 0; i--) {
-      listeners_[i - 1]->OnTestIterationEnd(unit_test, iteration);
+    const auto end = listeners_.rend();
+    for (auto scan = listeners_.rbegin(); scan != end; ++scan) {
+      (*scan)->OnTestIterationEnd(unit_test, iteration);
     }
   }
 }
@@ -5746,29 +5745,6 @@ void UnitTestImpl::PostFlagParsingInit() {
   }
 }
 
-// A predicate that checks the name of a TestSuite against a known
-// value.
-//
-// This is used for implementation of the UnitTest class only.  We put
-// it in the anonymous namespace to prevent polluting the outer
-// namespace.
-//
-// TestSuiteNameIs is copyable.
-class TestSuiteNameIs {
- public:
-  // Constructor.
-  explicit TestSuiteNameIs(const std::string& name) : name_(name) {}
-
-  // Returns true if and only if the name of test_suite matches name_.
-  bool operator()(const TestSuite* test_suite) const {
-    return test_suite != nullptr &&
-           strcmp(test_suite->name(), name_.c_str()) == 0;
-  }
-
- private:
-  std::string name_;
-};
-
 // Finds and returns a TestSuite with the given name.  If one doesn't
 // exist, creates one and returns it.  It's the CALLER'S
 // RESPONSIBILITY to ensure that this function is only called WHEN THE
@@ -5782,19 +5758,27 @@ class TestSuiteNameIs {
 //   set_up_tc:       pointer to the function that sets up the test suite
 //   tear_down_tc:    pointer to the function that tears down the test suite
 TestSuite* UnitTestImpl::GetTestSuite(
-    const char* test_suite_name, const char* type_param,
+    const std::string& test_suite_name, const char* type_param,
     internal::SetUpTestSuiteFunc set_up_tc,
     internal::TearDownTestSuiteFunc tear_down_tc) {
-  // Can we find a TestSuite with the given name?
-  const auto test_suite =
-      std::find_if(test_suites_.rbegin(), test_suites_.rend(),
-                   TestSuiteNameIs(test_suite_name));
+  // During initialization, all TestInfos for a given suite are added in
+  // sequence. To optimize this case, see if the most recently added suite is
+  // the one being requested now.
+  if (!test_suites_.empty() &&
+      (*test_suites_.rbegin())->name_ == test_suite_name) {
+    return *test_suites_.rbegin();
+  }
 
-  if (test_suite != test_suites_.rend()) return *test_suite;
+  // Fall back to searching the collection.
+  auto item_it = test_suites_by_name_.find(test_suite_name);
+  if (item_it != test_suites_by_name_.end()) {
+    return item_it->second;
+  }
 
-  // No.  Let's create one.
+  // Not found. Create a new instance.
   auto* const new_test_suite =
       new TestSuite(test_suite_name, type_param, set_up_tc, tear_down_tc);
+  test_suites_by_name_.emplace(test_suite_name, new_test_suite);
 
   const UnitTestFilter death_test_suite_filter(kDeathTestSuiteFilter);
   // Is this a death test suite?
@@ -6146,12 +6130,11 @@ int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) {
   int num_runnable_tests = 0;
   int num_selected_tests = 0;
   for (auto* test_suite : test_suites_) {
-    const std::string& test_suite_name = test_suite->name();
+    const std::string& test_suite_name = test_suite->name_;
     test_suite->set_should_run(false);
 
-    for (size_t j = 0; j < test_suite->test_info_list().size(); j++) {
-      TestInfo* const test_info = test_suite->test_info_list()[j];
-      const std::string test_name(test_info->name());
+    for (TestInfo* test_info : test_suite->test_info_list()) {
+      const std::string& test_name = test_info->name_;
       // A test is disabled if test suite name or test name matches
       // kDisableTestFilter.
       const bool is_disabled =

From 31993dfa6b47e11c7a6ef67cfa8af90892b9bd1c Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Tue, 5 Mar 2024 09:58:22 -0800
Subject: [PATCH 318/336] Revert Optimize Google Test process startup

PiperOrigin-RevId: 612878184
Change-Id: Ia8e23da1ad09c2e0ce635a855f0c250f368f6878
---
 googletest/include/gtest/gtest.h              |   6 +-
 .../include/gtest/internal/gtest-filepath.h   |   8 +-
 .../include/gtest/internal/gtest-internal.h   |  29 ++--
 .../include/gtest/internal/gtest-param-util.h | 140 +++++++++---------
 googletest/src/gtest-internal-inl.h           |  20 +--
 googletest/src/gtest.cc                       | 117 ++++++++-------
 6 files changed, 161 insertions(+), 159 deletions(-)

diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h
index c89966952..2b70e49c4 100644
--- a/googletest/include/gtest/gtest.h
+++ b/googletest/include/gtest/gtest.h
@@ -607,7 +607,7 @@ class GTEST_API_ TestInfo {
   friend class internal::UnitTestImpl;
   friend class internal::StreamingListenerTest;
   friend TestInfo* internal::MakeAndRegisterTestInfo(
-      std::string test_suite_name, const char* name, const char* type_param,
+      const char* test_suite_name, const char* name, const char* type_param,
       const char* value_param, internal::CodeLocation code_location,
       internal::TypeId fixture_class_id, internal::SetUpTestSuiteFunc set_up_tc,
       internal::TearDownTestSuiteFunc tear_down_tc,
@@ -615,7 +615,7 @@ class GTEST_API_ TestInfo {
 
   // Constructs a TestInfo object. The newly constructed instance assumes
   // ownership of the factory object.
-  TestInfo(std::string test_suite_name, std::string name,
+  TestInfo(const std::string& test_suite_name, const std::string& name,
            const char* a_type_param,   // NULL if not a type-parameterized test
            const char* a_value_param,  // NULL if not a value-parameterized test
            internal::CodeLocation a_code_location,
@@ -683,7 +683,7 @@ class GTEST_API_ TestSuite {
   //                 this is not a type-parameterized test.
   //   set_up_tc:    pointer to the function that sets up the test suite
   //   tear_down_tc: pointer to the function that tears down the test suite
-  TestSuite(const std::string& name, const char* a_type_param,
+  TestSuite(const char* name, const char* a_type_param,
             internal::SetUpTestSuiteFunc set_up_tc,
             internal::TearDownTestSuiteFunc tear_down_tc);
 
diff --git a/googletest/include/gtest/internal/gtest-filepath.h b/googletest/include/gtest/internal/gtest-filepath.h
index 7ffb49238..5189c81da 100644
--- a/googletest/include/gtest/internal/gtest-filepath.h
+++ b/googletest/include/gtest/internal/gtest-filepath.h
@@ -43,7 +43,6 @@
 #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
 
 #include 
-#include 
 
 #include "gtest/internal/gtest-port.h"
 #include "gtest/internal/gtest-string.h"
@@ -71,9 +70,8 @@ class GTEST_API_ FilePath {
  public:
   FilePath() : pathname_("") {}
   FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) {}
-  FilePath(FilePath&& rhs) : pathname_(std::move(rhs.pathname_)) {}
 
-  explicit FilePath(std::string pathname) : pathname_(std::move(pathname)) {
+  explicit FilePath(const std::string& pathname) : pathname_(pathname) {
     Normalize();
   }
 
@@ -81,10 +79,6 @@ class GTEST_API_ FilePath {
     Set(rhs);
     return *this;
   }
-  FilePath& operator=(FilePath&& rhs) {
-    pathname_ = std::move(rhs.pathname_);
-    return *this;
-  }
 
   void Set(const FilePath& rhs) { pathname_ = rhs.pathname_; }
 
diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h
index 4661248f7..806b08624 100644
--- a/googletest/include/gtest/internal/gtest-internal.h
+++ b/googletest/include/gtest/internal/gtest-internal.h
@@ -474,8 +474,8 @@ using SetUpTestSuiteFunc = void (*)();
 using TearDownTestSuiteFunc = void (*)();
 
 struct CodeLocation {
-  CodeLocation(std::string a_file, int a_line)
-      : file(std::move(a_file)), line(a_line) {}
+  CodeLocation(const std::string& a_file, int a_line)
+      : file(a_file), line(a_line) {}
 
   std::string file;
   int line;
@@ -564,7 +564,7 @@ struct SuiteApiResolver : T {
 //                     The newly created TestInfo instance will assume
 //                     ownership of the factory object.
 GTEST_API_ TestInfo* MakeAndRegisterTestInfo(
-    std::string test_suite_name, const char* name, const char* type_param,
+    const char* test_suite_name, const char* name, const char* type_param,
     const char* value_param, CodeLocation code_location,
     TypeId fixture_class_id, SetUpTestSuiteFunc set_up_tc,
     TearDownTestSuiteFunc tear_down_tc, TestFactoryBase* factory);
@@ -595,7 +595,8 @@ class GTEST_API_ TypedTestSuitePState {
       fflush(stderr);
       posix::Abort();
     }
-    registered_tests_.emplace(test_name, CodeLocation(file, line));
+    registered_tests_.insert(
+        ::std::make_pair(test_name, CodeLocation(file, line)));
     return true;
   }
 
@@ -699,7 +700,7 @@ class TypeParameterizedTest {
   // specified in INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, TestSuite,
   // Types).  Valid values for 'index' are [0, N - 1] where N is the
   // length of Types.
-  static bool Register(const char* prefix, CodeLocation code_location,
+  static bool Register(const char* prefix, const CodeLocation& code_location,
                        const char* case_name, const char* test_names, int index,
                        const std::vector& type_names =
                            GenerateNames()) {
@@ -711,7 +712,8 @@ class TypeParameterizedTest {
     // list.
     MakeAndRegisterTestInfo(
         (std::string(prefix) + (prefix[0] == '\0' ? "" : "/") + case_name +
-         "/" + type_names[static_cast(index)]),
+         "/" + type_names[static_cast(index)])
+            .c_str(),
         StripTrailingSpaces(GetPrefixUntilComma(test_names)).c_str(),
         GetTypeName().c_str(),
         nullptr,  // No value parameter.
@@ -723,9 +725,13 @@ class TypeParameterizedTest {
         new TestFactoryImpl);
 
     // Next, recurses (at compile time) with the tail of the type list.
-    return TypeParameterizedTest::
-        Register(prefix, std::move(code_location), case_name, test_names,
-                 index + 1, type_names);
+    return TypeParameterizedTest::Register(prefix,
+                                                                 code_location,
+                                                                 case_name,
+                                                                 test_names,
+                                                                 index + 1,
+                                                                 type_names);
   }
 };
 
@@ -733,7 +739,7 @@ class TypeParameterizedTest {
 template 
 class TypeParameterizedTest {
  public:
-  static bool Register(const char* /*prefix*/, CodeLocation,
+  static bool Register(const char* /*prefix*/, const CodeLocation&,
                        const char* /*case_name*/, const char* /*test_names*/,
                        int /*index*/,
                        const std::vector& =
@@ -780,8 +786,7 @@ class TypeParameterizedTestSuite {
 
     // Next, recurses (at compile time) with the tail of the test list.
     return TypeParameterizedTestSuite::Register(prefix,
-                                                       std::move(code_location),
+                                      Types>::Register(prefix, code_location,
                                                        state, case_name,
                                                        SkipComma(test_names),
                                                        type_names);
diff --git a/googletest/include/gtest/internal/gtest-param-util.h b/googletest/include/gtest/internal/gtest-param-util.h
index 1fc500f97..b04f70206 100644
--- a/googletest/include/gtest/internal/gtest-param-util.h
+++ b/googletest/include/gtest/internal/gtest-param-util.h
@@ -47,7 +47,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
@@ -86,7 +85,7 @@ namespace internal {
 // TEST_P macro is used to define two tests with the same name
 // but in different namespaces.
 GTEST_API_ void ReportInvalidTestSuiteType(const char* test_suite_name,
-                                           const CodeLocation& code_location);
+                                           CodeLocation code_location);
 
 template 
 class ParamGeneratorInterface;
@@ -380,7 +379,9 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface {
 // integer test parameter index.
 template 
 std::string DefaultParamName(const TestParamInfo& info) {
-  return std::to_string(info.index);
+  Message name_stream;
+  name_stream << info.index;
+  return name_stream.GetString();
 }
 
 template 
@@ -512,10 +513,9 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
   typedef ParamGenerator(GeneratorCreationFunc)();
   using ParamNameGeneratorFunc = std::string(const TestParamInfo&);
 
-  explicit ParameterizedTestSuiteInfo(std::string name,
+  explicit ParameterizedTestSuiteInfo(const char* name,
                                       CodeLocation code_location)
-      : test_suite_name_(std::move(name)),
-        code_location_(std::move(code_location)) {}
+      : test_suite_name_(name), code_location_(code_location) {}
 
   // Test suite base name for display purposes.
   const std::string& GetTestSuiteName() const override {
@@ -529,21 +529,20 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
   // prefix). test_base_name is the name of an individual test without
   // parameter index. For the test SequenceA/FooTest.DoBar/1 FooTest is
   // test suite base name and DoBar is test base name.
-  void AddTestPattern(const char*,
-                      const char* test_base_name,
+  void AddTestPattern(const char* test_suite_name, const char* test_base_name,
                       TestMetaFactoryBase* meta_factory,
                       CodeLocation code_location) {
-    tests_.emplace_back(
-        new TestInfo(test_base_name, meta_factory, std::move(code_location)));
+    tests_.push_back(std::shared_ptr(new TestInfo(
+        test_suite_name, test_base_name, meta_factory, code_location)));
   }
   // INSTANTIATE_TEST_SUITE_P macro uses AddGenerator() to record information
   // about a generator.
-  int AddTestSuiteInstantiation(std::string instantiation_name,
+  int AddTestSuiteInstantiation(const std::string& instantiation_name,
                                 GeneratorCreationFunc* func,
                                 ParamNameGeneratorFunc* name_func,
                                 const char* file, int line) {
-    instantiations_.emplace_back(std::move(instantiation_name), func, name_func,
-                                 file, line);
+    instantiations_.push_back(
+        InstantiationInfo(instantiation_name, func, name_func, file, line));
     return 0;  // Return value used only to run this method in namespace scope.
   }
   // UnitTest class invokes this method to register tests in this test suite
@@ -554,31 +553,34 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
   void RegisterTests() override {
     bool generated_instantiations = false;
 
-    std::string test_suite_name;
-    std::string test_name;
-    for (const std::shared_ptr& test_info : tests_) {
-      for (const InstantiationInfo& instantiation : instantiations_) {
-        const std::string& instantiation_name = instantiation.name;
-        ParamGenerator generator((*instantiation.generator)());
-        ParamNameGeneratorFunc* name_func = instantiation.name_func;
-        const char* file = instantiation.file;
-        int line = instantiation.line;
+    for (typename TestInfoContainer::iterator test_it = tests_.begin();
+         test_it != tests_.end(); ++test_it) {
+      std::shared_ptr test_info = *test_it;
+      for (typename InstantiationContainer::iterator gen_it =
+               instantiations_.begin();
+           gen_it != instantiations_.end(); ++gen_it) {
+        const std::string& instantiation_name = gen_it->name;
+        ParamGenerator generator((*gen_it->generator)());
+        ParamNameGeneratorFunc* name_func = gen_it->name_func;
+        const char* file = gen_it->file;
+        int line = gen_it->line;
 
+        std::string test_suite_name;
         if (!instantiation_name.empty())
           test_suite_name = instantiation_name + "/";
-        else
-          test_suite_name.clear();
-        test_suite_name += test_suite_name_;
+        test_suite_name += test_info->test_suite_base_name;
 
         size_t i = 0;
         std::set test_param_names;
-        for (const auto& param : generator) {
+        for (typename ParamGenerator::iterator param_it =
+                 generator.begin();
+             param_it != generator.end(); ++param_it, ++i) {
           generated_instantiations = true;
 
-          test_name.clear();
+          Message test_name_stream;
 
           std::string param_name =
-              name_func(TestParamInfo(param, i));
+              name_func(TestParamInfo(*param_it, i));
 
           GTEST_CHECK_(IsValidParamName(param_name))
               << "Parameterized test name '" << param_name
@@ -590,25 +592,23 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
               << "Duplicate parameterized test name '" << param_name << "', in "
               << file << " line " << line << std::endl;
 
+          test_param_names.insert(param_name);
+
           if (!test_info->test_base_name.empty()) {
-            test_name.append(test_info->test_base_name).append("/");
+            test_name_stream << test_info->test_base_name << "/";
           }
-          test_name += param_name;
-
-          test_param_names.insert(std::move(param_name));
-
+          test_name_stream << param_name;
           MakeAndRegisterTestInfo(
-              test_suite_name, test_name.c_str(),
+              test_suite_name.c_str(), test_name_stream.GetString().c_str(),
               nullptr,  // No type parameter.
-              PrintToString(param).c_str(), test_info->code_location,
+              PrintToString(*param_it).c_str(), test_info->code_location,
               GetTestSuiteTypeId(),
               SuiteApiResolver::GetSetUpCaseOrSuite(file, line),
               SuiteApiResolver::GetTearDownCaseOrSuite(file, line),
-              test_info->test_meta_factory->CreateTestFactory(param));
-          ++i;
-        }  // for param
-      }  // for instantiation
-    }  // for test_info
+              test_info->test_meta_factory->CreateTestFactory(*param_it));
+        }  // for param_it
+      }    // for gen_it
+    }      // for test_it
 
     if (!generated_instantiations) {
       // There are no generaotrs, or they all generate nothing ...
@@ -621,13 +621,15 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
   // LocalTestInfo structure keeps information about a single test registered
   // with TEST_P macro.
   struct TestInfo {
-    TestInfo(const char* a_test_base_name,
+    TestInfo(const char* a_test_suite_base_name, const char* a_test_base_name,
              TestMetaFactoryBase* a_test_meta_factory,
              CodeLocation a_code_location)
-        : test_base_name(a_test_base_name),
+        : test_suite_base_name(a_test_suite_base_name),
+          test_base_name(a_test_base_name),
           test_meta_factory(a_test_meta_factory),
-          code_location(std::move(a_code_location)) {}
+          code_location(a_code_location) {}
 
+    const std::string test_suite_base_name;
     const std::string test_base_name;
     const std::unique_ptr> test_meta_factory;
     const CodeLocation code_location;
@@ -637,10 +639,11 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
   //  
   struct InstantiationInfo {
-    InstantiationInfo(std::string name_in, GeneratorCreationFunc* generator_in,
+    InstantiationInfo(const std::string& name_in,
+                      GeneratorCreationFunc* generator_in,
                       ParamNameGeneratorFunc* name_func_in, const char* file_in,
                       int line_in)
-        : name(std::move(name_in)),
+        : name(name_in),
           generator(generator_in),
           name_func(name_func_in),
           file(file_in),
@@ -701,32 +704,29 @@ class ParameterizedTestSuiteRegistry {
   // tests and instantiations of a particular test suite.
   template 
   ParameterizedTestSuiteInfo* GetTestSuitePatternHolder(
-      std::string test_suite_name, CodeLocation code_location) {
+      const char* test_suite_name, CodeLocation code_location) {
     ParameterizedTestSuiteInfo* typed_test_info = nullptr;
-
-    auto item_it = suite_name_to_info_index_.find(test_suite_name);
-    if (item_it != suite_name_to_info_index_.end()) {
-      auto* test_suite_info = test_suite_infos_[item_it->second];
-      if (test_suite_info->GetTestSuiteTypeId() != GetTypeId()) {
-        // Complain about incorrect usage of Google Test facilities
-        // and terminate the program since we cannot guaranty correct
-        // test suite setup and tear-down in this case.
-        ReportInvalidTestSuiteType(test_suite_name.c_str(), code_location);
-        posix::Abort();
-      } else {
-        // At this point we are sure that the object we found is of the same
-        // type we are looking for, so we downcast it to that type
-        // without further checks.
-        typed_test_info =
-            CheckedDowncastToActualType>(
-                test_suite_info);
+    for (auto& test_suite_info : test_suite_infos_) {
+      if (test_suite_info->GetTestSuiteName() == test_suite_name) {
+        if (test_suite_info->GetTestSuiteTypeId() != GetTypeId()) {
+          // Complain about incorrect usage of Google Test facilities
+          // and terminate the program since we cannot guaranty correct
+          // test suite setup and tear-down in this case.
+          ReportInvalidTestSuiteType(test_suite_name, code_location);
+          posix::Abort();
+        } else {
+          // At this point we are sure that the object we found is of the same
+          // type we are looking for, so we downcast it to that type
+          // without further checks.
+          typed_test_info = CheckedDowncastToActualType<
+              ParameterizedTestSuiteInfo>(test_suite_info);
+        }
+        break;
       }
     }
     if (typed_test_info == nullptr) {
       typed_test_info = new ParameterizedTestSuiteInfo(
-          test_suite_name, std::move(code_location));
-      suite_name_to_info_index_.emplace(std::move(test_suite_name),
-                                        test_suite_infos_.size());
+          test_suite_name, code_location);
       test_suite_infos_.push_back(typed_test_info);
     }
     return typed_test_info;
@@ -740,9 +740,8 @@ class ParameterizedTestSuiteRegistry {
 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
   template 
   ParameterizedTestCaseInfo* GetTestCasePatternHolder(
-      std::string test_case_name, CodeLocation code_location) {
-    return GetTestSuitePatternHolder(std::move(test_case_name),
-                                               std::move(code_location));
+      const char* test_case_name, CodeLocation code_location) {
+    return GetTestSuitePatternHolder(test_case_name, code_location);
   }
 
 #endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_
@@ -751,7 +750,6 @@ class ParameterizedTestSuiteRegistry {
   using TestSuiteInfoContainer = ::std::vector;
 
   TestSuiteInfoContainer test_suite_infos_;
-  ::std::unordered_map suite_name_to_info_index_;
 
   ParameterizedTestSuiteRegistry(const ParameterizedTestSuiteRegistry&) =
       delete;
@@ -778,7 +776,7 @@ class TypeParameterizedTestSuiteRegistry {
  private:
   struct TypeParameterizedTestSuiteInfo {
     explicit TypeParameterizedTestSuiteInfo(CodeLocation c)
-        : code_location(std::move(c)), instantiated(false) {}
+        : code_location(c), instantiated(false) {}
 
     CodeLocation code_location;
     bool instantiated;
diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h
index 6a7f4dd93..6dea34f8f 100644
--- a/googletest/src/gtest-internal-inl.h
+++ b/googletest/src/gtest-internal-inl.h
@@ -46,7 +46,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include "gtest/internal/gtest-port.h"
@@ -650,15 +649,13 @@ class GTEST_API_ UnitTestImpl {
   //                    this is not a typed or a type-parameterized test.
   //   set_up_tc:       pointer to the function that sets up the test suite
   //   tear_down_tc:    pointer to the function that tears down the test suite
-  TestSuite* GetTestSuite(const std::string& test_suite_name,
-                          const char* type_param,
+  TestSuite* GetTestSuite(const char* test_suite_name, const char* type_param,
                           internal::SetUpTestSuiteFunc set_up_tc,
                           internal::TearDownTestSuiteFunc tear_down_tc);
 
 //  Legacy API is deprecated but still available
 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
-  TestCase* GetTestCase(const std::string& test_case_name,
-                        const char* type_param,
+  TestCase* GetTestCase(const char* test_case_name, const char* type_param,
                         internal::SetUpTestSuiteFunc set_up_tc,
                         internal::TearDownTestSuiteFunc tear_down_tc) {
     return GetTestSuite(test_case_name, type_param, set_up_tc, tear_down_tc);
@@ -684,13 +681,13 @@ class GTEST_API_ UnitTestImpl {
     // AddTestInfo(), which is called to register a TEST or TEST_F
     // before main() is reached.
     if (original_working_dir_.IsEmpty()) {
-      original_working_dir_ = FilePath::GetCurrentDir();
+      original_working_dir_.Set(FilePath::GetCurrentDir());
       GTEST_CHECK_(!original_working_dir_.IsEmpty())
           << "Failed to get the current working directory.";
     }
 #endif  // GTEST_HAS_FILE_SYSTEM
 
-    GetTestSuite(test_info->test_suite_name_, test_info->type_param(),
+    GetTestSuite(test_info->test_suite_name(), test_info->type_param(),
                  set_up_tc, tear_down_tc)
         ->AddTestInfo(test_info);
   }
@@ -826,12 +823,6 @@ class GTEST_API_ UnitTestImpl {
   bool catch_exceptions() const { return catch_exceptions_; }
 
  private:
-  struct CompareTestSuitesByPointer {
-    bool operator()(const TestSuite* lhs, const TestSuite* rhs) const {
-      return lhs->name_ < rhs->name_;
-    };
-  };
-
   friend class ::testing::UnitTest;
 
   // Used by UnitTest::Run() to capture the state of
@@ -882,9 +873,6 @@ class GTEST_API_ UnitTestImpl {
   // elements in the vector.
   std::vector test_suites_;
 
-  // The set of TestSuites by name.
-  std::unordered_map test_suites_by_name_;
-
   // Provides a level of indirection for the test suite list to allow
   // easy shuffling and restoring the test suite order.  The i-th
   // element of this vector is the index of the i-th test suite in the
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index ca9f524e4..c5f22bb7f 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -578,7 +578,7 @@ void InsertSyntheticTestCase(const std::string& name, CodeLocation location,
 void RegisterTypeParameterizedTestSuite(const char* test_suite_name,
                                         CodeLocation code_location) {
   GetUnitTestImpl()->type_parameterized_test_registry().RegisterTestSuite(
-      test_suite_name, std::move(code_location));
+      test_suite_name, code_location);
 }
 
 void RegisterTypeParameterizedTestSuiteInstantiation(const char* case_name) {
@@ -589,7 +589,7 @@ void RegisterTypeParameterizedTestSuiteInstantiation(const char* case_name) {
 void TypeParameterizedTestSuiteRegistry::RegisterTestSuite(
     const char* test_suite_name, CodeLocation code_location) {
   suites_.emplace(std::string(test_suite_name),
-                  TypeParameterizedTestSuiteInfo(std::move(code_location)));
+                  TypeParameterizedTestSuiteInfo(code_location));
 }
 
 void TypeParameterizedTestSuiteRegistry::RegisterInstantiation(
@@ -801,7 +801,7 @@ class UnitTestFilter {
   // Returns true if and only if name matches at least one of the patterns in
   // the filter.
   bool MatchesName(const std::string& name) const {
-    return exact_match_patterns_.find(name) != exact_match_patterns_.end() ||
+    return exact_match_patterns_.count(name) > 0 ||
            std::any_of(glob_patterns_.begin(), glob_patterns_.end(),
                        [&name](const std::string& pattern) {
                          return PatternMatchesString(
@@ -2740,16 +2740,18 @@ bool Test::IsSkipped() {
 
 // Constructs a TestInfo object. It assumes ownership of the test factory
 // object.
-TestInfo::TestInfo(std::string a_test_suite_name, std::string a_name,
-                   const char* a_type_param, const char* a_value_param,
+TestInfo::TestInfo(const std::string& a_test_suite_name,
+                   const std::string& a_name, const char* a_type_param,
+                   const char* a_value_param,
                    internal::CodeLocation a_code_location,
                    internal::TypeId fixture_class_id,
                    internal::TestFactoryBase* factory)
-    : test_suite_name_(std::move(a_test_suite_name)),
-      name_(std::move(a_name)),
+    : test_suite_name_(a_test_suite_name),
+      // begin()/end() is MSVC 17.3.3 ASAN crash workaround (GitHub issue #3997)
+      name_(a_name.begin(), a_name.end()),
       type_param_(a_type_param ? new std::string(a_type_param) : nullptr),
       value_param_(a_value_param ? new std::string(a_value_param) : nullptr),
-      location_(std::move(a_code_location)),
+      location_(a_code_location),
       fixture_class_id_(fixture_class_id),
       should_run_(false),
       is_disabled_(false),
@@ -2782,19 +2784,19 @@ namespace internal {
 //                     The newly created TestInfo instance will assume
 //                     ownership of the factory object.
 TestInfo* MakeAndRegisterTestInfo(
-    std::string test_suite_name, const char* name, const char* type_param,
+    const char* test_suite_name, const char* name, const char* type_param,
     const char* value_param, CodeLocation code_location,
     TypeId fixture_class_id, SetUpTestSuiteFunc set_up_tc,
     TearDownTestSuiteFunc tear_down_tc, TestFactoryBase* factory) {
   TestInfo* const test_info =
-      new TestInfo(std::move(test_suite_name), name, type_param, value_param,
-                   std::move(code_location), fixture_class_id, factory);
+      new TestInfo(test_suite_name, name, type_param, value_param,
+                   code_location, fixture_class_id, factory);
   GetUnitTestImpl()->AddTestInfo(set_up_tc, tear_down_tc, test_info);
   return test_info;
 }
 
 void ReportInvalidTestSuiteType(const char* test_suite_name,
-                                const CodeLocation& code_location) {
+                                CodeLocation code_location) {
   Message errors;
   errors
       << "Attempted redefinition of test suite " << test_suite_name << ".\n"
@@ -2946,7 +2948,7 @@ int TestSuite::total_test_count() const {
 //                 this is not a typed or a type-parameterized test suite.
 //   set_up_tc:    pointer to the function that sets up the test suite
 //   tear_down_tc: pointer to the function that tears down the test suite
-TestSuite::TestSuite(const std::string& a_name, const char* a_type_param,
+TestSuite::TestSuite(const char* a_name, const char* a_type_param,
                      internal::SetUpTestSuiteFunc set_up_tc,
                      internal::TearDownTestSuiteFunc tear_down_tc)
     : name_(a_name),
@@ -3834,10 +3836,11 @@ void TestEventRepeater::Append(TestEventListener* listener) {
 }
 
 TestEventListener* TestEventRepeater::Release(TestEventListener* listener) {
-  auto iter = std::find(listeners_.begin(), listeners_.end(), listener);
-  if (iter != listeners_.end()) {
-    listeners_.erase(iter);
-    return listener;
+  for (size_t i = 0; i < listeners_.size(); ++i) {
+    if (listeners_[i] == listener) {
+      listeners_.erase(listeners_.begin() + static_cast(i));
+      return listener;
+    }
   }
 
   return nullptr;
@@ -3848,21 +3851,20 @@ TestEventListener* TestEventRepeater::Release(TestEventListener* listener) {
 #define GTEST_REPEATER_METHOD_(Name, Type)              \
   void TestEventRepeater::Name(const Type& parameter) { \
     if (forwarding_enabled_) {                          \
-      for (auto* listener : listeners_) {               \
-        listener->Name(parameter);                      \
+      for (size_t i = 0; i < listeners_.size(); i++) {  \
+        listeners_[i]->Name(parameter);                 \
       }                                                 \
     }                                                   \
   }
 // This defines a member that forwards the call to all listeners in reverse
 // order.
-#define GTEST_REVERSE_REPEATER_METHOD_(Name, Type)                 \
-  void TestEventRepeater::Name(const Type& parameter) {            \
-    if (forwarding_enabled_) {                                     \
-      const auto end = listeners_.rend();                          \
-      for (auto scan = listeners_.rbegin(); scan != end; ++scan) { \
-        (*scan)->Name(parameter);                                  \
-      }                                                            \
-    }                                                              \
+#define GTEST_REVERSE_REPEATER_METHOD_(Name, Type)      \
+  void TestEventRepeater::Name(const Type& parameter) { \
+    if (forwarding_enabled_) {                          \
+      for (size_t i = listeners_.size(); i != 0; i--) { \
+        listeners_[i - 1]->Name(parameter);             \
+      }                                                 \
+    }                                                   \
   }
 
 GTEST_REPEATER_METHOD_(OnTestProgramStart, UnitTest)
@@ -3892,8 +3894,8 @@ GTEST_REVERSE_REPEATER_METHOD_(OnTestProgramEnd, UnitTest)
 void TestEventRepeater::OnTestIterationStart(const UnitTest& unit_test,
                                              int iteration) {
   if (forwarding_enabled_) {
-    for (auto* listener : listeners_) {
-      listener->OnTestIterationStart(unit_test, iteration);
+    for (size_t i = 0; i < listeners_.size(); i++) {
+      listeners_[i]->OnTestIterationStart(unit_test, iteration);
     }
   }
 }
@@ -3901,9 +3903,8 @@ void TestEventRepeater::OnTestIterationStart(const UnitTest& unit_test,
 void TestEventRepeater::OnTestIterationEnd(const UnitTest& unit_test,
                                            int iteration) {
   if (forwarding_enabled_) {
-    const auto end = listeners_.rend();
-    for (auto scan = listeners_.rbegin(); scan != end; ++scan) {
-      (*scan)->OnTestIterationEnd(unit_test, iteration);
+    for (size_t i = listeners_.size(); i > 0; i--) {
+      listeners_[i - 1]->OnTestIterationEnd(unit_test, iteration);
     }
   }
 }
@@ -5745,6 +5746,29 @@ void UnitTestImpl::PostFlagParsingInit() {
   }
 }
 
+// A predicate that checks the name of a TestSuite against a known
+// value.
+//
+// This is used for implementation of the UnitTest class only.  We put
+// it in the anonymous namespace to prevent polluting the outer
+// namespace.
+//
+// TestSuiteNameIs is copyable.
+class TestSuiteNameIs {
+ public:
+  // Constructor.
+  explicit TestSuiteNameIs(const std::string& name) : name_(name) {}
+
+  // Returns true if and only if the name of test_suite matches name_.
+  bool operator()(const TestSuite* test_suite) const {
+    return test_suite != nullptr &&
+           strcmp(test_suite->name(), name_.c_str()) == 0;
+  }
+
+ private:
+  std::string name_;
+};
+
 // Finds and returns a TestSuite with the given name.  If one doesn't
 // exist, creates one and returns it.  It's the CALLER'S
 // RESPONSIBILITY to ensure that this function is only called WHEN THE
@@ -5758,27 +5782,19 @@ void UnitTestImpl::PostFlagParsingInit() {
 //   set_up_tc:       pointer to the function that sets up the test suite
 //   tear_down_tc:    pointer to the function that tears down the test suite
 TestSuite* UnitTestImpl::GetTestSuite(
-    const std::string& test_suite_name, const char* type_param,
+    const char* test_suite_name, const char* type_param,
     internal::SetUpTestSuiteFunc set_up_tc,
     internal::TearDownTestSuiteFunc tear_down_tc) {
-  // During initialization, all TestInfos for a given suite are added in
-  // sequence. To optimize this case, see if the most recently added suite is
-  // the one being requested now.
-  if (!test_suites_.empty() &&
-      (*test_suites_.rbegin())->name_ == test_suite_name) {
-    return *test_suites_.rbegin();
-  }
+  // Can we find a TestSuite with the given name?
+  const auto test_suite =
+      std::find_if(test_suites_.rbegin(), test_suites_.rend(),
+                   TestSuiteNameIs(test_suite_name));
 
-  // Fall back to searching the collection.
-  auto item_it = test_suites_by_name_.find(test_suite_name);
-  if (item_it != test_suites_by_name_.end()) {
-    return item_it->second;
-  }
+  if (test_suite != test_suites_.rend()) return *test_suite;
 
-  // Not found. Create a new instance.
+  // No.  Let's create one.
   auto* const new_test_suite =
       new TestSuite(test_suite_name, type_param, set_up_tc, tear_down_tc);
-  test_suites_by_name_.emplace(test_suite_name, new_test_suite);
 
   const UnitTestFilter death_test_suite_filter(kDeathTestSuiteFilter);
   // Is this a death test suite?
@@ -6130,11 +6146,12 @@ int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) {
   int num_runnable_tests = 0;
   int num_selected_tests = 0;
   for (auto* test_suite : test_suites_) {
-    const std::string& test_suite_name = test_suite->name_;
+    const std::string& test_suite_name = test_suite->name();
     test_suite->set_should_run(false);
 
-    for (TestInfo* test_info : test_suite->test_info_list()) {
-      const std::string& test_name = test_info->name_;
+    for (size_t j = 0; j < test_suite->test_info_list().size(); j++) {
+      TestInfo* const test_info = test_suite->test_info_list()[j];
+      const std::string test_name(test_info->name());
       // A test is disabled if test suite name or test name matches
       // kDisableTestFilter.
       const bool is_disabled =

From e1a38bc3707741d249fa22d2064552a08e37555b Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Thu, 7 Mar 2024 23:53:04 -0800
Subject: [PATCH 319/336] Reland: Optimize Google Test process startup

Google Test performs hidden test registration during process
startup. For test binaries that contain a large number of tests, this
registration can be costly. In this CL, we reduce the overhead of
registration via several tactics:

- Treat CodeLocation and FilePath as value types, using std::move to
  pass them around.
- Reduce string copies in various places by either passing std::string
  values via std::move, or passing const-refs to std::string instances.
- Use std::to_string to stringify an int in DefaultParamName rather than
  a std::stringstream.
- Pull some std::string instances out of nested loops in
  ParameterizedTestSuiteInfo::RegisterTests so as to reuse some
  allocations, and replace stringstream with ordinary string appends.
- Use std::unordered_map in UnitTestImpl::GetTestSuite and
  ParameterizedTestSuiteRegistry::GetTestSuitePatternHolder to spend a
  little memory to turn O(N) lookups into constant time lookpus.
- Use range-based for loops in a few places.
- Use emplace-ish methods to add to containers where appropriate.

All together, these changes reduce the overall runtime of a series of 50
death tests in a single Chromium test executable by ~38% due to the
fact that the registration costs are paid in every death test's child
process.

PiperOrigin-RevId: 613833210
Change-Id: I51a262a770edff98ffa1e3b60c4d78a8308f9a9f
---
 googletest/include/gtest/gtest.h              |   6 +-
 .../include/gtest/internal/gtest-filepath.h   |   8 +-
 .../include/gtest/internal/gtest-internal.h   |  29 ++--
 .../include/gtest/internal/gtest-param-util.h | 140 +++++++++---------
 googletest/src/gtest-internal-inl.h           |  20 ++-
 googletest/src/gtest.cc                       |  80 ++++------
 6 files changed, 140 insertions(+), 143 deletions(-)

diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h
index 2b70e49c4..c89966952 100644
--- a/googletest/include/gtest/gtest.h
+++ b/googletest/include/gtest/gtest.h
@@ -607,7 +607,7 @@ class GTEST_API_ TestInfo {
   friend class internal::UnitTestImpl;
   friend class internal::StreamingListenerTest;
   friend TestInfo* internal::MakeAndRegisterTestInfo(
-      const char* test_suite_name, const char* name, const char* type_param,
+      std::string test_suite_name, const char* name, const char* type_param,
       const char* value_param, internal::CodeLocation code_location,
       internal::TypeId fixture_class_id, internal::SetUpTestSuiteFunc set_up_tc,
       internal::TearDownTestSuiteFunc tear_down_tc,
@@ -615,7 +615,7 @@ class GTEST_API_ TestInfo {
 
   // Constructs a TestInfo object. The newly constructed instance assumes
   // ownership of the factory object.
-  TestInfo(const std::string& test_suite_name, const std::string& name,
+  TestInfo(std::string test_suite_name, std::string name,
            const char* a_type_param,   // NULL if not a type-parameterized test
            const char* a_value_param,  // NULL if not a value-parameterized test
            internal::CodeLocation a_code_location,
@@ -683,7 +683,7 @@ class GTEST_API_ TestSuite {
   //                 this is not a type-parameterized test.
   //   set_up_tc:    pointer to the function that sets up the test suite
   //   tear_down_tc: pointer to the function that tears down the test suite
-  TestSuite(const char* name, const char* a_type_param,
+  TestSuite(const std::string& name, const char* a_type_param,
             internal::SetUpTestSuiteFunc set_up_tc,
             internal::TearDownTestSuiteFunc tear_down_tc);
 
diff --git a/googletest/include/gtest/internal/gtest-filepath.h b/googletest/include/gtest/internal/gtest-filepath.h
index 5189c81da..7ffb49238 100644
--- a/googletest/include/gtest/internal/gtest-filepath.h
+++ b/googletest/include/gtest/internal/gtest-filepath.h
@@ -43,6 +43,7 @@
 #define GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
 
 #include 
+#include 
 
 #include "gtest/internal/gtest-port.h"
 #include "gtest/internal/gtest-string.h"
@@ -70,8 +71,9 @@ class GTEST_API_ FilePath {
  public:
   FilePath() : pathname_("") {}
   FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) {}
+  FilePath(FilePath&& rhs) : pathname_(std::move(rhs.pathname_)) {}
 
-  explicit FilePath(const std::string& pathname) : pathname_(pathname) {
+  explicit FilePath(std::string pathname) : pathname_(std::move(pathname)) {
     Normalize();
   }
 
@@ -79,6 +81,10 @@ class GTEST_API_ FilePath {
     Set(rhs);
     return *this;
   }
+  FilePath& operator=(FilePath&& rhs) {
+    pathname_ = std::move(rhs.pathname_);
+    return *this;
+  }
 
   void Set(const FilePath& rhs) { pathname_ = rhs.pathname_; }
 
diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h
index 806b08624..4661248f7 100644
--- a/googletest/include/gtest/internal/gtest-internal.h
+++ b/googletest/include/gtest/internal/gtest-internal.h
@@ -474,8 +474,8 @@ using SetUpTestSuiteFunc = void (*)();
 using TearDownTestSuiteFunc = void (*)();
 
 struct CodeLocation {
-  CodeLocation(const std::string& a_file, int a_line)
-      : file(a_file), line(a_line) {}
+  CodeLocation(std::string a_file, int a_line)
+      : file(std::move(a_file)), line(a_line) {}
 
   std::string file;
   int line;
@@ -564,7 +564,7 @@ struct SuiteApiResolver : T {
 //                     The newly created TestInfo instance will assume
 //                     ownership of the factory object.
 GTEST_API_ TestInfo* MakeAndRegisterTestInfo(
-    const char* test_suite_name, const char* name, const char* type_param,
+    std::string test_suite_name, const char* name, const char* type_param,
     const char* value_param, CodeLocation code_location,
     TypeId fixture_class_id, SetUpTestSuiteFunc set_up_tc,
     TearDownTestSuiteFunc tear_down_tc, TestFactoryBase* factory);
@@ -595,8 +595,7 @@ class GTEST_API_ TypedTestSuitePState {
       fflush(stderr);
       posix::Abort();
     }
-    registered_tests_.insert(
-        ::std::make_pair(test_name, CodeLocation(file, line)));
+    registered_tests_.emplace(test_name, CodeLocation(file, line));
     return true;
   }
 
@@ -700,7 +699,7 @@ class TypeParameterizedTest {
   // specified in INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, TestSuite,
   // Types).  Valid values for 'index' are [0, N - 1] where N is the
   // length of Types.
-  static bool Register(const char* prefix, const CodeLocation& code_location,
+  static bool Register(const char* prefix, CodeLocation code_location,
                        const char* case_name, const char* test_names, int index,
                        const std::vector& type_names =
                            GenerateNames()) {
@@ -712,8 +711,7 @@ class TypeParameterizedTest {
     // list.
     MakeAndRegisterTestInfo(
         (std::string(prefix) + (prefix[0] == '\0' ? "" : "/") + case_name +
-         "/" + type_names[static_cast(index)])
-            .c_str(),
+         "/" + type_names[static_cast(index)]),
         StripTrailingSpaces(GetPrefixUntilComma(test_names)).c_str(),
         GetTypeName().c_str(),
         nullptr,  // No value parameter.
@@ -725,13 +723,9 @@ class TypeParameterizedTest {
         new TestFactoryImpl);
 
     // Next, recurses (at compile time) with the tail of the type list.
-    return TypeParameterizedTest::Register(prefix,
-                                                                 code_location,
-                                                                 case_name,
-                                                                 test_names,
-                                                                 index + 1,
-                                                                 type_names);
+    return TypeParameterizedTest::
+        Register(prefix, std::move(code_location), case_name, test_names,
+                 index + 1, type_names);
   }
 };
 
@@ -739,7 +733,7 @@ class TypeParameterizedTest {
 template 
 class TypeParameterizedTest {
  public:
-  static bool Register(const char* /*prefix*/, const CodeLocation&,
+  static bool Register(const char* /*prefix*/, CodeLocation,
                        const char* /*case_name*/, const char* /*test_names*/,
                        int /*index*/,
                        const std::vector& =
@@ -786,7 +780,8 @@ class TypeParameterizedTestSuite {
 
     // Next, recurses (at compile time) with the tail of the test list.
     return TypeParameterizedTestSuite::Register(prefix, code_location,
+                                      Types>::Register(prefix,
+                                                       std::move(code_location),
                                                        state, case_name,
                                                        SkipComma(test_names),
                                                        type_names);
diff --git a/googletest/include/gtest/internal/gtest-param-util.h b/googletest/include/gtest/internal/gtest-param-util.h
index b04f70206..1fc500f97 100644
--- a/googletest/include/gtest/internal/gtest-param-util.h
+++ b/googletest/include/gtest/internal/gtest-param-util.h
@@ -47,6 +47,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -85,7 +86,7 @@ namespace internal {
 // TEST_P macro is used to define two tests with the same name
 // but in different namespaces.
 GTEST_API_ void ReportInvalidTestSuiteType(const char* test_suite_name,
-                                           CodeLocation code_location);
+                                           const CodeLocation& code_location);
 
 template 
 class ParamGeneratorInterface;
@@ -379,9 +380,7 @@ class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface {
 // integer test parameter index.
 template 
 std::string DefaultParamName(const TestParamInfo& info) {
-  Message name_stream;
-  name_stream << info.index;
-  return name_stream.GetString();
+  return std::to_string(info.index);
 }
 
 template 
@@ -513,9 +512,10 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
   typedef ParamGenerator(GeneratorCreationFunc)();
   using ParamNameGeneratorFunc = std::string(const TestParamInfo&);
 
-  explicit ParameterizedTestSuiteInfo(const char* name,
+  explicit ParameterizedTestSuiteInfo(std::string name,
                                       CodeLocation code_location)
-      : test_suite_name_(name), code_location_(code_location) {}
+      : test_suite_name_(std::move(name)),
+        code_location_(std::move(code_location)) {}
 
   // Test suite base name for display purposes.
   const std::string& GetTestSuiteName() const override {
@@ -529,20 +529,21 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
   // prefix). test_base_name is the name of an individual test without
   // parameter index. For the test SequenceA/FooTest.DoBar/1 FooTest is
   // test suite base name and DoBar is test base name.
-  void AddTestPattern(const char* test_suite_name, const char* test_base_name,
+  void AddTestPattern(const char*,
+                      const char* test_base_name,
                       TestMetaFactoryBase* meta_factory,
                       CodeLocation code_location) {
-    tests_.push_back(std::shared_ptr(new TestInfo(
-        test_suite_name, test_base_name, meta_factory, code_location)));
+    tests_.emplace_back(
+        new TestInfo(test_base_name, meta_factory, std::move(code_location)));
   }
   // INSTANTIATE_TEST_SUITE_P macro uses AddGenerator() to record information
   // about a generator.
-  int AddTestSuiteInstantiation(const std::string& instantiation_name,
+  int AddTestSuiteInstantiation(std::string instantiation_name,
                                 GeneratorCreationFunc* func,
                                 ParamNameGeneratorFunc* name_func,
                                 const char* file, int line) {
-    instantiations_.push_back(
-        InstantiationInfo(instantiation_name, func, name_func, file, line));
+    instantiations_.emplace_back(std::move(instantiation_name), func, name_func,
+                                 file, line);
     return 0;  // Return value used only to run this method in namespace scope.
   }
   // UnitTest class invokes this method to register tests in this test suite
@@ -553,34 +554,31 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
   void RegisterTests() override {
     bool generated_instantiations = false;
 
-    for (typename TestInfoContainer::iterator test_it = tests_.begin();
-         test_it != tests_.end(); ++test_it) {
-      std::shared_ptr test_info = *test_it;
-      for (typename InstantiationContainer::iterator gen_it =
-               instantiations_.begin();
-           gen_it != instantiations_.end(); ++gen_it) {
-        const std::string& instantiation_name = gen_it->name;
-        ParamGenerator generator((*gen_it->generator)());
-        ParamNameGeneratorFunc* name_func = gen_it->name_func;
-        const char* file = gen_it->file;
-        int line = gen_it->line;
+    std::string test_suite_name;
+    std::string test_name;
+    for (const std::shared_ptr& test_info : tests_) {
+      for (const InstantiationInfo& instantiation : instantiations_) {
+        const std::string& instantiation_name = instantiation.name;
+        ParamGenerator generator((*instantiation.generator)());
+        ParamNameGeneratorFunc* name_func = instantiation.name_func;
+        const char* file = instantiation.file;
+        int line = instantiation.line;
 
-        std::string test_suite_name;
         if (!instantiation_name.empty())
           test_suite_name = instantiation_name + "/";
-        test_suite_name += test_info->test_suite_base_name;
+        else
+          test_suite_name.clear();
+        test_suite_name += test_suite_name_;
 
         size_t i = 0;
         std::set test_param_names;
-        for (typename ParamGenerator::iterator param_it =
-                 generator.begin();
-             param_it != generator.end(); ++param_it, ++i) {
+        for (const auto& param : generator) {
           generated_instantiations = true;
 
-          Message test_name_stream;
+          test_name.clear();
 
           std::string param_name =
-              name_func(TestParamInfo(*param_it, i));
+              name_func(TestParamInfo(param, i));
 
           GTEST_CHECK_(IsValidParamName(param_name))
               << "Parameterized test name '" << param_name
@@ -592,23 +590,25 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
               << "Duplicate parameterized test name '" << param_name << "', in "
               << file << " line " << line << std::endl;
 
-          test_param_names.insert(param_name);
-
           if (!test_info->test_base_name.empty()) {
-            test_name_stream << test_info->test_base_name << "/";
+            test_name.append(test_info->test_base_name).append("/");
           }
-          test_name_stream << param_name;
+          test_name += param_name;
+
+          test_param_names.insert(std::move(param_name));
+
           MakeAndRegisterTestInfo(
-              test_suite_name.c_str(), test_name_stream.GetString().c_str(),
+              test_suite_name, test_name.c_str(),
               nullptr,  // No type parameter.
-              PrintToString(*param_it).c_str(), test_info->code_location,
+              PrintToString(param).c_str(), test_info->code_location,
               GetTestSuiteTypeId(),
               SuiteApiResolver::GetSetUpCaseOrSuite(file, line),
               SuiteApiResolver::GetTearDownCaseOrSuite(file, line),
-              test_info->test_meta_factory->CreateTestFactory(*param_it));
-        }  // for param_it
-      }    // for gen_it
-    }      // for test_it
+              test_info->test_meta_factory->CreateTestFactory(param));
+          ++i;
+        }  // for param
+      }  // for instantiation
+    }  // for test_info
 
     if (!generated_instantiations) {
       // There are no generaotrs, or they all generate nothing ...
@@ -621,15 +621,13 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
   // LocalTestInfo structure keeps information about a single test registered
   // with TEST_P macro.
   struct TestInfo {
-    TestInfo(const char* a_test_suite_base_name, const char* a_test_base_name,
+    TestInfo(const char* a_test_base_name,
              TestMetaFactoryBase* a_test_meta_factory,
              CodeLocation a_code_location)
-        : test_suite_base_name(a_test_suite_base_name),
-          test_base_name(a_test_base_name),
+        : test_base_name(a_test_base_name),
           test_meta_factory(a_test_meta_factory),
-          code_location(a_code_location) {}
+          code_location(std::move(a_code_location)) {}
 
-    const std::string test_suite_base_name;
     const std::string test_base_name;
     const std::unique_ptr> test_meta_factory;
     const CodeLocation code_location;
@@ -639,11 +637,10 @@ class ParameterizedTestSuiteInfo : public ParameterizedTestSuiteInfoBase {
   //  
   struct InstantiationInfo {
-    InstantiationInfo(const std::string& name_in,
-                      GeneratorCreationFunc* generator_in,
+    InstantiationInfo(std::string name_in, GeneratorCreationFunc* generator_in,
                       ParamNameGeneratorFunc* name_func_in, const char* file_in,
                       int line_in)
-        : name(name_in),
+        : name(std::move(name_in)),
           generator(generator_in),
           name_func(name_func_in),
           file(file_in),
@@ -704,29 +701,32 @@ class ParameterizedTestSuiteRegistry {
   // tests and instantiations of a particular test suite.
   template 
   ParameterizedTestSuiteInfo* GetTestSuitePatternHolder(
-      const char* test_suite_name, CodeLocation code_location) {
+      std::string test_suite_name, CodeLocation code_location) {
     ParameterizedTestSuiteInfo* typed_test_info = nullptr;
-    for (auto& test_suite_info : test_suite_infos_) {
-      if (test_suite_info->GetTestSuiteName() == test_suite_name) {
-        if (test_suite_info->GetTestSuiteTypeId() != GetTypeId()) {
-          // Complain about incorrect usage of Google Test facilities
-          // and terminate the program since we cannot guaranty correct
-          // test suite setup and tear-down in this case.
-          ReportInvalidTestSuiteType(test_suite_name, code_location);
-          posix::Abort();
-        } else {
-          // At this point we are sure that the object we found is of the same
-          // type we are looking for, so we downcast it to that type
-          // without further checks.
-          typed_test_info = CheckedDowncastToActualType<
-              ParameterizedTestSuiteInfo>(test_suite_info);
-        }
-        break;
+
+    auto item_it = suite_name_to_info_index_.find(test_suite_name);
+    if (item_it != suite_name_to_info_index_.end()) {
+      auto* test_suite_info = test_suite_infos_[item_it->second];
+      if (test_suite_info->GetTestSuiteTypeId() != GetTypeId()) {
+        // Complain about incorrect usage of Google Test facilities
+        // and terminate the program since we cannot guaranty correct
+        // test suite setup and tear-down in this case.
+        ReportInvalidTestSuiteType(test_suite_name.c_str(), code_location);
+        posix::Abort();
+      } else {
+        // At this point we are sure that the object we found is of the same
+        // type we are looking for, so we downcast it to that type
+        // without further checks.
+        typed_test_info =
+            CheckedDowncastToActualType>(
+                test_suite_info);
       }
     }
     if (typed_test_info == nullptr) {
       typed_test_info = new ParameterizedTestSuiteInfo(
-          test_suite_name, code_location);
+          test_suite_name, std::move(code_location));
+      suite_name_to_info_index_.emplace(std::move(test_suite_name),
+                                        test_suite_infos_.size());
       test_suite_infos_.push_back(typed_test_info);
     }
     return typed_test_info;
@@ -740,8 +740,9 @@ class ParameterizedTestSuiteRegistry {
 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
   template 
   ParameterizedTestCaseInfo* GetTestCasePatternHolder(
-      const char* test_case_name, CodeLocation code_location) {
-    return GetTestSuitePatternHolder(test_case_name, code_location);
+      std::string test_case_name, CodeLocation code_location) {
+    return GetTestSuitePatternHolder(std::move(test_case_name),
+                                               std::move(code_location));
   }
 
 #endif  //  GTEST_REMOVE_LEGACY_TEST_CASEAPI_
@@ -750,6 +751,7 @@ class ParameterizedTestSuiteRegistry {
   using TestSuiteInfoContainer = ::std::vector;
 
   TestSuiteInfoContainer test_suite_infos_;
+  ::std::unordered_map suite_name_to_info_index_;
 
   ParameterizedTestSuiteRegistry(const ParameterizedTestSuiteRegistry&) =
       delete;
@@ -776,7 +778,7 @@ class TypeParameterizedTestSuiteRegistry {
  private:
   struct TypeParameterizedTestSuiteInfo {
     explicit TypeParameterizedTestSuiteInfo(CodeLocation c)
-        : code_location(c), instantiated(false) {}
+        : code_location(std::move(c)), instantiated(false) {}
 
     CodeLocation code_location;
     bool instantiated;
diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h
index 6dea34f8f..cc6f00488 100644
--- a/googletest/src/gtest-internal-inl.h
+++ b/googletest/src/gtest-internal-inl.h
@@ -46,6 +46,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "gtest/internal/gtest-port.h"
@@ -649,13 +650,15 @@ class GTEST_API_ UnitTestImpl {
   //                    this is not a typed or a type-parameterized test.
   //   set_up_tc:       pointer to the function that sets up the test suite
   //   tear_down_tc:    pointer to the function that tears down the test suite
-  TestSuite* GetTestSuite(const char* test_suite_name, const char* type_param,
+  TestSuite* GetTestSuite(const std::string& test_suite_name,
+                          const char* type_param,
                           internal::SetUpTestSuiteFunc set_up_tc,
                           internal::TearDownTestSuiteFunc tear_down_tc);
 
 //  Legacy API is deprecated but still available
 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
-  TestCase* GetTestCase(const char* test_case_name, const char* type_param,
+  TestCase* GetTestCase(const std::string& test_case_name,
+                        const char* type_param,
                         internal::SetUpTestSuiteFunc set_up_tc,
                         internal::TearDownTestSuiteFunc tear_down_tc) {
     return GetTestSuite(test_case_name, type_param, set_up_tc, tear_down_tc);
@@ -681,13 +684,13 @@ class GTEST_API_ UnitTestImpl {
     // AddTestInfo(), which is called to register a TEST or TEST_F
     // before main() is reached.
     if (original_working_dir_.IsEmpty()) {
-      original_working_dir_.Set(FilePath::GetCurrentDir());
+      original_working_dir_ = FilePath::GetCurrentDir();
       GTEST_CHECK_(!original_working_dir_.IsEmpty())
           << "Failed to get the current working directory.";
     }
 #endif  // GTEST_HAS_FILE_SYSTEM
 
-    GetTestSuite(test_info->test_suite_name(), test_info->type_param(),
+    GetTestSuite(test_info->test_suite_name_, test_info->type_param(),
                  set_up_tc, tear_down_tc)
         ->AddTestInfo(test_info);
   }
@@ -823,6 +826,12 @@ class GTEST_API_ UnitTestImpl {
   bool catch_exceptions() const { return catch_exceptions_; }
 
  private:
+  struct CompareTestSuitesByPointer {
+    bool operator()(const TestSuite* lhs, const TestSuite* rhs) const {
+      return lhs->name_ < rhs->name_;
+    }
+  };
+
   friend class ::testing::UnitTest;
 
   // Used by UnitTest::Run() to capture the state of
@@ -873,6 +882,9 @@ class GTEST_API_ UnitTestImpl {
   // elements in the vector.
   std::vector test_suites_;
 
+  // The set of TestSuites by name.
+  std::unordered_map test_suites_by_name_;
+
   // Provides a level of indirection for the test suite list to allow
   // easy shuffling and restoring the test suite order.  The i-th
   // element of this vector is the index of the i-th test suite in the
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index c5f22bb7f..d4292ae06 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -578,7 +578,7 @@ void InsertSyntheticTestCase(const std::string& name, CodeLocation location,
 void RegisterTypeParameterizedTestSuite(const char* test_suite_name,
                                         CodeLocation code_location) {
   GetUnitTestImpl()->type_parameterized_test_registry().RegisterTestSuite(
-      test_suite_name, code_location);
+      test_suite_name, std::move(code_location));
 }
 
 void RegisterTypeParameterizedTestSuiteInstantiation(const char* case_name) {
@@ -589,7 +589,7 @@ void RegisterTypeParameterizedTestSuiteInstantiation(const char* case_name) {
 void TypeParameterizedTestSuiteRegistry::RegisterTestSuite(
     const char* test_suite_name, CodeLocation code_location) {
   suites_.emplace(std::string(test_suite_name),
-                  TypeParameterizedTestSuiteInfo(code_location));
+                  TypeParameterizedTestSuiteInfo(std::move(code_location)));
 }
 
 void TypeParameterizedTestSuiteRegistry::RegisterInstantiation(
@@ -801,7 +801,7 @@ class UnitTestFilter {
   // Returns true if and only if name matches at least one of the patterns in
   // the filter.
   bool MatchesName(const std::string& name) const {
-    return exact_match_patterns_.count(name) > 0 ||
+    return exact_match_patterns_.find(name) != exact_match_patterns_.end() ||
            std::any_of(glob_patterns_.begin(), glob_patterns_.end(),
                        [&name](const std::string& pattern) {
                          return PatternMatchesString(
@@ -2740,18 +2740,16 @@ bool Test::IsSkipped() {
 
 // Constructs a TestInfo object. It assumes ownership of the test factory
 // object.
-TestInfo::TestInfo(const std::string& a_test_suite_name,
-                   const std::string& a_name, const char* a_type_param,
-                   const char* a_value_param,
+TestInfo::TestInfo(std::string a_test_suite_name, std::string a_name,
+                   const char* a_type_param, const char* a_value_param,
                    internal::CodeLocation a_code_location,
                    internal::TypeId fixture_class_id,
                    internal::TestFactoryBase* factory)
-    : test_suite_name_(a_test_suite_name),
-      // begin()/end() is MSVC 17.3.3 ASAN crash workaround (GitHub issue #3997)
-      name_(a_name.begin(), a_name.end()),
+    : test_suite_name_(std::move(a_test_suite_name)),
+      name_(std::move(a_name)),
       type_param_(a_type_param ? new std::string(a_type_param) : nullptr),
       value_param_(a_value_param ? new std::string(a_value_param) : nullptr),
-      location_(a_code_location),
+      location_(std::move(a_code_location)),
       fixture_class_id_(fixture_class_id),
       should_run_(false),
       is_disabled_(false),
@@ -2784,19 +2782,19 @@ namespace internal {
 //                     The newly created TestInfo instance will assume
 //                     ownership of the factory object.
 TestInfo* MakeAndRegisterTestInfo(
-    const char* test_suite_name, const char* name, const char* type_param,
+    std::string test_suite_name, const char* name, const char* type_param,
     const char* value_param, CodeLocation code_location,
     TypeId fixture_class_id, SetUpTestSuiteFunc set_up_tc,
     TearDownTestSuiteFunc tear_down_tc, TestFactoryBase* factory) {
   TestInfo* const test_info =
-      new TestInfo(test_suite_name, name, type_param, value_param,
-                   code_location, fixture_class_id, factory);
+      new TestInfo(std::move(test_suite_name), name, type_param, value_param,
+                   std::move(code_location), fixture_class_id, factory);
   GetUnitTestImpl()->AddTestInfo(set_up_tc, tear_down_tc, test_info);
   return test_info;
 }
 
 void ReportInvalidTestSuiteType(const char* test_suite_name,
-                                CodeLocation code_location) {
+                                const CodeLocation& code_location) {
   Message errors;
   errors
       << "Attempted redefinition of test suite " << test_suite_name << ".\n"
@@ -2948,7 +2946,7 @@ int TestSuite::total_test_count() const {
 //                 this is not a typed or a type-parameterized test suite.
 //   set_up_tc:    pointer to the function that sets up the test suite
 //   tear_down_tc: pointer to the function that tears down the test suite
-TestSuite::TestSuite(const char* a_name, const char* a_type_param,
+TestSuite::TestSuite(const std::string& a_name, const char* a_type_param,
                      internal::SetUpTestSuiteFunc set_up_tc,
                      internal::TearDownTestSuiteFunc tear_down_tc)
     : name_(a_name),
@@ -5746,29 +5744,6 @@ void UnitTestImpl::PostFlagParsingInit() {
   }
 }
 
-// A predicate that checks the name of a TestSuite against a known
-// value.
-//
-// This is used for implementation of the UnitTest class only.  We put
-// it in the anonymous namespace to prevent polluting the outer
-// namespace.
-//
-// TestSuiteNameIs is copyable.
-class TestSuiteNameIs {
- public:
-  // Constructor.
-  explicit TestSuiteNameIs(const std::string& name) : name_(name) {}
-
-  // Returns true if and only if the name of test_suite matches name_.
-  bool operator()(const TestSuite* test_suite) const {
-    return test_suite != nullptr &&
-           strcmp(test_suite->name(), name_.c_str()) == 0;
-  }
-
- private:
-  std::string name_;
-};
-
 // Finds and returns a TestSuite with the given name.  If one doesn't
 // exist, creates one and returns it.  It's the CALLER'S
 // RESPONSIBILITY to ensure that this function is only called WHEN THE
@@ -5782,19 +5757,27 @@ class TestSuiteNameIs {
 //   set_up_tc:       pointer to the function that sets up the test suite
 //   tear_down_tc:    pointer to the function that tears down the test suite
 TestSuite* UnitTestImpl::GetTestSuite(
-    const char* test_suite_name, const char* type_param,
+    const std::string& test_suite_name, const char* type_param,
     internal::SetUpTestSuiteFunc set_up_tc,
     internal::TearDownTestSuiteFunc tear_down_tc) {
-  // Can we find a TestSuite with the given name?
-  const auto test_suite =
-      std::find_if(test_suites_.rbegin(), test_suites_.rend(),
-                   TestSuiteNameIs(test_suite_name));
+  // During initialization, all TestInfos for a given suite are added in
+  // sequence. To optimize this case, see if the most recently added suite is
+  // the one being requested now.
+  if (!test_suites_.empty() &&
+      (*test_suites_.rbegin())->name_ == test_suite_name) {
+    return *test_suites_.rbegin();
+  }
 
-  if (test_suite != test_suites_.rend()) return *test_suite;
+  // Fall back to searching the collection.
+  auto item_it = test_suites_by_name_.find(test_suite_name);
+  if (item_it != test_suites_by_name_.end()) {
+    return item_it->second;
+  }
 
-  // No.  Let's create one.
+  // Not found. Create a new instance.
   auto* const new_test_suite =
       new TestSuite(test_suite_name, type_param, set_up_tc, tear_down_tc);
+  test_suites_by_name_.emplace(test_suite_name, new_test_suite);
 
   const UnitTestFilter death_test_suite_filter(kDeathTestSuiteFilter);
   // Is this a death test suite?
@@ -6146,12 +6129,11 @@ int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) {
   int num_runnable_tests = 0;
   int num_selected_tests = 0;
   for (auto* test_suite : test_suites_) {
-    const std::string& test_suite_name = test_suite->name();
+    const std::string& test_suite_name = test_suite->name_;
     test_suite->set_should_run(false);
 
-    for (size_t j = 0; j < test_suite->test_info_list().size(); j++) {
-      TestInfo* const test_info = test_suite->test_info_list()[j];
-      const std::string test_name(test_info->name());
+    for (TestInfo* test_info : test_suite->test_info_list()) {
+      const std::string& test_name = test_info->name_;
       // A test is disabled if test suite name or test name matches
       // kDisableTestFilter.
       const bool is_disabled =

From b479e7a3c161d7087113a05f8cb034b870313a55 Mon Sep 17 00:00:00 2001
From: Daniel Cheng 
Date: Mon, 11 Mar 2024 10:31:09 -0700
Subject: [PATCH 320/336] Guard Abseil flags usage in googlemock with
 GTEST_NO_ABSL_FLAGS.

googletest avoids using the Abseil flag library, so googlemock should
do the same for consistency.

PiperOrigin-RevId: 614713968
Change-Id: I0925804b8644ddc6fd3ad07a320d94829b11bb8e
---
 googlemock/include/gmock/internal/gmock-port.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/googlemock/include/gmock/internal/gmock-port.h b/googlemock/include/gmock/internal/gmock-port.h
index 55ddfb6c6..e9d9e32a7 100644
--- a/googlemock/include/gmock/internal/gmock-port.h
+++ b/googlemock/include/gmock/internal/gmock-port.h
@@ -56,7 +56,7 @@
 #include "gmock/internal/custom/gmock-port.h"
 #include "gtest/internal/gtest-port.h"
 
-#ifdef GTEST_HAS_ABSL
+#if defined(GTEST_HAS_ABSL) && !defined(GTEST_NO_ABSL_FLAGS)
 #include "absl/flags/declare.h"
 #include "absl/flags/flag.h"
 #endif
@@ -73,7 +73,7 @@
 #define GMOCK_FLAG(name) FLAGS_gmock_##name
 
 // Pick a command line flags implementation.
-#ifdef GTEST_HAS_ABSL
+#if defined(GTEST_HAS_ABSL) && !defined(GTEST_NO_ABSL_FLAGS)
 
 // Macros for defining flags.
 #define GMOCK_DEFINE_bool_(name, default_val, doc) \
@@ -95,7 +95,7 @@
 #define GMOCK_FLAG_SET(name, value) \
   (void)(::absl::SetFlag(&GMOCK_FLAG(name), value))
 
-#else  // GTEST_HAS_ABSL
+#else  // defined(GTEST_HAS_ABSL) && !defined(GTEST_NO_ABSL_FLAGS)
 
 // Macros for defining flags.
 #define GMOCK_DEFINE_bool_(name, default_val, doc)  \
@@ -134,6 +134,6 @@
 #define GMOCK_FLAG_GET(name) ::testing::GMOCK_FLAG(name)
 #define GMOCK_FLAG_SET(name, value) (void)(::testing::GMOCK_FLAG(name) = value)
 
-#endif  // GTEST_HAS_ABSL
+#endif  // defined(GTEST_HAS_ABSL) && !defined(GTEST_NO_ABSL_FLAGS)
 
 #endif  // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_

From c231e6f5b152029dbd5fa4a9e0c04095035aec3f Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Thu, 14 Mar 2024 23:59:31 -0700
Subject: [PATCH 321/336] Add test for move-only type in `Action` signature

PiperOrigin-RevId: 616031018
Change-Id: Ie724f9562174387eab866a824d28106f344c558d
---
 googlemock/test/gmock-more-actions_test.cc | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/googlemock/test/gmock-more-actions_test.cc b/googlemock/test/gmock-more-actions_test.cc
index 7ed89a988..354a79b19 100644
--- a/googlemock/test/gmock-more-actions_test.cc
+++ b/googlemock/test/gmock-more-actions_test.cc
@@ -828,6 +828,22 @@ TEST(InvokeArgumentTest, ByExplicitConstReferenceFunction) {
   EXPECT_FALSE(a.Perform(std::make_tuple(&ReferencesGlobalDouble)));
 }
 
+TEST(InvokeArgumentTest, MoveOnlyType) {
+  struct Marker {};
+  struct {
+    // Method takes a unique_ptr (to a type we don't care about), and an
+    // invocable type.
+    MOCK_METHOD(bool, MockMethod,
+                (std::unique_ptr, std::function), ());
+  } mock;
+
+  ON_CALL(mock, MockMethod(_, _)).WillByDefault(InvokeArgument<1>());
+
+  // This compiles, but is a little opaque as a workaround:
+  ON_CALL(mock, MockMethod(_, _))
+      .WillByDefault(WithArg<1>(InvokeArgument<0>()));
+}
+
 // Tests DoAll(a1, a2).
 TEST(DoAllTest, TwoActions) {
   int n = 0;

From a1a608348ee09747d27a1501debf9c975142d06a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mustafa=20Berkay=20D=C3=BCzenli?= 
Date: Sat, 16 Mar 2024 00:28:30 +0300
Subject: [PATCH 322/336] Add colored output support for Alacritty

---
 googletest/src/gtest.cc                  | 1 +
 googletest/test/googletest-color-test.py | 1 +
 googletest/test/gtest_unittest.cc        | 3 +++
 3 files changed, 5 insertions(+)

diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index d4292ae06..63ee78c40 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -3270,6 +3270,7 @@ bool ShouldUseColor(bool stdout_is_tty) {
         term != nullptr && (String::CStringEquals(term, "xterm") ||
                             String::CStringEquals(term, "xterm-color") ||
                             String::CStringEquals(term, "xterm-kitty") ||
+                            String::CStringEquals(term, "alacritty") ||
                             String::CStringEquals(term, "screen") ||
                             String::CStringEquals(term, "tmux") ||
                             String::CStringEquals(term, "rxvt-unicode") ||
diff --git a/googletest/test/googletest-color-test.py b/googletest/test/googletest-color-test.py
index 8926a4815..8968cf1f6 100755
--- a/googletest/test/googletest-color-test.py
+++ b/googletest/test/googletest-color-test.py
@@ -80,6 +80,7 @@ class GTestColorTest(gtest_test_utils.TestCase):
     self.assertTrue(UsesColor('xterm', None, None))
     self.assertTrue(UsesColor('xterm-color', None, None))
     self.assertTrue(UsesColor('xterm-kitty', None, None))
+    self.assertTrue(UsesColor('alacritty', None, None))
     self.assertTrue(UsesColor('xterm-256color', None, None))
 
   def testFlagOnly(self):
diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc
index 0b383ea7c..b699f27d9 100644
--- a/googletest/test/gtest_unittest.cc
+++ b/googletest/test/gtest_unittest.cc
@@ -6671,6 +6671,9 @@ TEST(ColoredOutputTest, UsesColorsWhenTermSupportsColors) {
   SetEnv("TERM", "xterm-kitty");      // TERM supports colors.
   EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.
 
+  SetEnv("TERM", "alacritty");        // TERM supports colors.
+  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.
+
   SetEnv("TERM", "xterm-256color");   // TERM supports colors.
   EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.
 

From f1269cc220734a5be8d68b370bf27efe6962bdb2 Mon Sep 17 00:00:00 2001
From: Troels Gram <28827711+to01z@users.noreply.github.com>
Date: Sat, 23 Mar 2024 22:53:35 -0700
Subject: [PATCH 323/336] Add support for compiling GoogleTest for Xbox

Support for Xbox platforms, requires the code to support compilation with the
WINAPI_FAMILY_GAMES subset of the Win32 API.

- Add support for WINAPI_FAMILY_GAMES to enable GTEST_OS_WINDOWS_GAMES platform.
- Disable stream redirection (GTEST_HAS_STREAM_REDIRECTION = 0) and colored TTY
  printing for GTEST_OS_WINDOWS_GAMES platform. Both features currently require
  Win32 functions that don't exist in the WINAPI_FAMILY_GAMES subset.

Misc fixes:
- gtest-port.cc: Move GTEST_DISABLE_MSC_DEPRECATED_PUSH_ into
  GTEST_HAS_STREAM_REDIRECTION conditional section where the corresponding
  GTEST_DISABLE_MSC_DEPRECATED_POP_ is located.
- googletest-port-test.cc: Switch stream redirection tests to be conditional on
  GTEST_HAS_STREAM_REDIRECTION instead of !defined(GTEST_OS_WINDOWS_MOBILE).
---
 googletest/include/gtest/internal/gtest-port-arch.h |  2 ++
 googletest/include/gtest/internal/gtest-port.h      | 10 ++++++----
 googletest/src/gtest-port.cc                        |  4 ++--
 googletest/src/gtest.cc                             | 12 +++++++-----
 googletest/test/googletest-port-test.cc             |  4 ++--
 5 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/googletest/include/gtest/internal/gtest-port-arch.h b/googletest/include/gtest/internal/gtest-port-arch.h
index 3162f2b1c..7ec968f31 100644
--- a/googletest/include/gtest/internal/gtest-port-arch.h
+++ b/googletest/include/gtest/internal/gtest-port-arch.h
@@ -56,6 +56,8 @@
 #elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_TV_TITLE)
 #define GTEST_OS_WINDOWS_PHONE 1
 #define GTEST_OS_WINDOWS_TV_TITLE 1
+#elif WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_GAMES)
+#define GTEST_OS_WINDOWS_GAMES 1
 #else
 // WINAPI_FAMILY defined but no known partition matched.
 // Default to desktop.
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index fa457b788..35bcf9bfe 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -658,9 +658,10 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
 // By default, we assume that stream redirection is supported on all
 // platforms except known mobile / embedded ones. Also, if the port doesn't have
 // a file system, stream redirection is not supported.
-#if defined(GTEST_OS_WINDOWS_MOBILE) || defined(GTEST_OS_WINDOWS_PHONE) || \
-    defined(GTEST_OS_WINDOWS_RT) || defined(GTEST_OS_ESP8266) ||           \
-    defined(GTEST_OS_XTENSA) || defined(GTEST_OS_QURT) ||                  \
+#if defined(GTEST_OS_WINDOWS_MOBILE) || defined(GTEST_OS_WINDOWS_PHONE) ||  \
+    defined(GTEST_OS_WINDOWS_RT) || defined(GTEST_OS_WINDOWS_GAMES) ||      \
+    defined(GTEST_OS_ESP8266) ||                                            \
+    defined(GTEST_OS_XTENSA) || defined(GTEST_OS_QURT) ||                   \
     !GTEST_HAS_FILE_SYSTEM
 #define GTEST_HAS_STREAM_REDIRECTION 0
 #else
@@ -2108,7 +2109,8 @@ GTEST_DISABLE_MSC_DEPRECATED_PUSH_()
 // defined there.
 #if GTEST_HAS_FILE_SYSTEM
 #if !defined(GTEST_OS_WINDOWS_MOBILE) && !defined(GTEST_OS_WINDOWS_PHONE) && \
-    !defined(GTEST_OS_WINDOWS_RT) && !defined(GTEST_OS_ESP8266) &&           \
+    !defined(GTEST_OS_WINDOWS_RT) && !defined(GTEST_OS_WINDOWS_GAMES) && \
+    !defined(GTEST_OS_ESP8266) && \
     !defined(GTEST_OS_XTENSA) && !defined(GTEST_OS_QURT)
 inline int ChDir(const char* dir) { return chdir(dir); }
 #endif
diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc
index 3bb7dd450..d4238146e 100644
--- a/googletest/src/gtest-port.cc
+++ b/googletest/src/gtest-port.cc
@@ -1033,12 +1033,12 @@ GTestLog::~GTestLog() {
   }
 }
 
+#if GTEST_HAS_STREAM_REDIRECTION
+
 // Disable Microsoft deprecation warnings for POSIX functions called from
 // this class (creat, dup, dup2, and close)
 GTEST_DISABLE_MSC_DEPRECATED_PUSH_()
 
-#if GTEST_HAS_STREAM_REDIRECTION
-
 namespace {
 
 #if defined(GTEST_OS_LINUX_ANDROID) || defined(GTEST_OS_IOS)
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 36f4a2da1..898904f5f 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -3184,8 +3184,9 @@ static void PrintTestPartResult(const TestPartResult& test_part_result) {
 }
 
 // class PrettyUnitTestResultPrinter
-#if defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_MOBILE) &&    \
-    !defined(GTEST_OS_WINDOWS_PHONE) && !defined(GTEST_OS_WINDOWS_RT) && \
+#if defined(GTEST_OS_WINDOWS) &&                                             \
+    !defined(GTEST_OS_WINDOWS_MOBILE) && !defined(GTEST_OS_WINDOWS_GAMES) && \
+    !defined(GTEST_OS_WINDOWS_PHONE) && !defined(GTEST_OS_WINDOWS_RT) &&     \
     !defined(GTEST_OS_WINDOWS_MINGW)
 
 // Returns the character attribute for the given color.
@@ -3313,8 +3314,9 @@ static void ColoredPrintf(GTestColor color, const char* fmt, ...) {
     return;
   }
 
-#if defined(GTEST_OS_WINDOWS) && !defined(GTEST_OS_WINDOWS_MOBILE) &&    \
-    !defined(GTEST_OS_WINDOWS_PHONE) && !defined(GTEST_OS_WINDOWS_RT) && \
+#if defined(GTEST_OS_WINDOWS) &&                                             \
+    !defined(GTEST_OS_WINDOWS_MOBILE) && !defined(GTEST_OS_WINDOWS_GAMES) && \
+    !defined(GTEST_OS_WINDOWS_PHONE) && !defined(GTEST_OS_WINDOWS_RT) &&     \
     !defined(GTEST_OS_WINDOWS_MINGW)
   const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);
 
@@ -5473,7 +5475,7 @@ int UnitTest::Run() {
   // about crashes - they are expected.
   if (impl()->catch_exceptions() || in_death_test_child_process) {
 #if !defined(GTEST_OS_WINDOWS_MOBILE) && !defined(GTEST_OS_WINDOWS_PHONE) && \
-    !defined(GTEST_OS_WINDOWS_RT)
+    !defined(GTEST_OS_WINDOWS_RT) && !defined(GTEST_OS_WINDOWS_GAMES)
     // SetErrorMode doesn't exist on CE.
     SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT |
                  SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
diff --git a/googletest/test/googletest-port-test.cc b/googletest/test/googletest-port-test.cc
index 9f05a0199..69d637bde 100644
--- a/googletest/test/googletest-port-test.cc
+++ b/googletest/test/googletest-port-test.cc
@@ -918,7 +918,7 @@ TEST(RETest, PartialMatchWorks) {
 
 #endif  // GTEST_USES_POSIX_RE
 
-#ifndef GTEST_OS_WINDOWS_MOBILE
+#if GTEST_HAS_STREAM_REDIRECTION
 
 TEST(CaptureTest, CapturesStdout) {
   CaptureStdout();
@@ -960,7 +960,7 @@ TEST(CaptureDeathTest, CannotReenterStdoutCapture) {
   // themselves.
 }
 
-#endif  // !GTEST_OS_WINDOWS_MOBILE
+#endif  // GTEST_HAS_STREAM_REDIRECTION
 
 TEST(ThreadLocalTest, DefaultConstructorInitializesToDefaultValues) {
   ThreadLocal t1;

From 53ee0fc0b2239ef0bd0db23583a91102472e0cbe Mon Sep 17 00:00:00 2001
From: David Matson 
Date: Thu, 28 Mar 2024 16:59:37 -0700
Subject: [PATCH 324/336] Fix help text for stream_result_to flag.

Support for Mac was previously added, in addition to Linux. Fix the help
text to match the code.
---
 googletest/src/gtest.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 36f4a2da1..9c2301152 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -379,7 +379,7 @@ GTEST_DEFINE_string_(
     testing::internal::StringFromGTestEnv("stream_result_to", ""),
     "This flag specifies the host name and the port number on which to stream "
     "test results. Example: \"localhost:555\". The flag is effective only on "
-    "Linux.");
+    "Linux and Mac.");
 
 GTEST_DEFINE_bool_(
     throw_on_failure,

From f7a6bba24c7252aa7060ab1a2124d72f96d0da78 Mon Sep 17 00:00:00 2001
From: David Matson 
Date: Thu, 28 Mar 2024 17:34:21 -0700
Subject: [PATCH 325/336] Fix typo in comment.

---
 googletest/src/gtest.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 36f4a2da1..449321c65 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -2340,7 +2340,7 @@ static const char* const kReservedTestCaseAttributes[] = {
     "type_param", "value_param", "file",   "line"};
 
 // Use a slightly different set for allowed output to ensure existing tests can
-// still RecordProperty("result") or "RecordProperty(timestamp")
+// still RecordProperty("result") or RecordProperty("timestamp")
 static const char* const kReservedOutputTestCaseAttributes[] = {
     "classname",   "name", "status", "time",   "type_param",
     "value_param", "file", "line",   "result", "timestamp"};

From a7678dd0db369dcb0110d83cfa5c9f9ba02f2423 Mon Sep 17 00:00:00 2001
From: Troels Gram <28827711+to01z@users.noreply.github.com>
Date: Thu, 28 Mar 2024 22:05:08 -0700
Subject: [PATCH 326/336] Revert changes to googletest-port-test.cc

GoogleTest's tests do not currently compile when WINAPI_FAMILY is set to
anything else than WINAPI_FAMILY_DESKTOP_APP on Windows (if WINAPI_FAMILY is not
set explicitly, it will default to WINAPI_FAMILY_DESKTOP_APP).
---
 googletest/test/googletest-port-test.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/googletest/test/googletest-port-test.cc b/googletest/test/googletest-port-test.cc
index 69d637bde..9f05a0199 100644
--- a/googletest/test/googletest-port-test.cc
+++ b/googletest/test/googletest-port-test.cc
@@ -918,7 +918,7 @@ TEST(RETest, PartialMatchWorks) {
 
 #endif  // GTEST_USES_POSIX_RE
 
-#if GTEST_HAS_STREAM_REDIRECTION
+#ifndef GTEST_OS_WINDOWS_MOBILE
 
 TEST(CaptureTest, CapturesStdout) {
   CaptureStdout();
@@ -960,7 +960,7 @@ TEST(CaptureDeathTest, CannotReenterStdoutCapture) {
   // themselves.
 }
 
-#endif  // GTEST_HAS_STREAM_REDIRECTION
+#endif  // !GTEST_OS_WINDOWS_MOBILE
 
 TEST(ThreadLocalTest, DefaultConstructorInitializesToDefaultValues) {
   ThreadLocal t1;

From 77afe8e0149c207edd9561c28de6d2226673b51f Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Sat, 30 Mar 2024 01:53:46 -0700
Subject: [PATCH 327/336] Automated Code Change

PiperOrigin-RevId: 620448229
Change-Id: I487a0d8a8f89ebe82c9ec66fbb60cbe2203188c9
---
 googletest/include/gtest/internal/gtest-filepath.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/googletest/include/gtest/internal/gtest-filepath.h b/googletest/include/gtest/internal/gtest-filepath.h
index 7ffb49238..6dc47be54 100644
--- a/googletest/include/gtest/internal/gtest-filepath.h
+++ b/googletest/include/gtest/internal/gtest-filepath.h
@@ -71,7 +71,7 @@ class GTEST_API_ FilePath {
  public:
   FilePath() : pathname_("") {}
   FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) {}
-  FilePath(FilePath&& rhs) : pathname_(std::move(rhs.pathname_)) {}
+  FilePath(FilePath&& rhs) noexcept : pathname_(std::move(rhs.pathname_)) {}
 
   explicit FilePath(std::string pathname) : pathname_(std::move(pathname)) {
     Normalize();
@@ -81,7 +81,7 @@ class GTEST_API_ FilePath {
     Set(rhs);
     return *this;
   }
-  FilePath& operator=(FilePath&& rhs) {
+  FilePath& operator=(FilePath&& rhs) noexcept {
     pathname_ = std::move(rhs.pathname_);
     return *this;
   }

From ec7b38672c04c8af3cfb078214edf6751b841014 Mon Sep 17 00:00:00 2001
From: Derek Mauro 
Date: Wed, 3 Apr 2024 07:05:10 -0700
Subject: [PATCH 328/336] Delete the unofficial GitHub actions tests. We do not
 look at these.

Close #4509

PiperOrigin-RevId: 621511191
Change-Id: Icbd3fe0a18444e0888bbec61345c6a957d8899d6
---
 .github/workflows/gtest-ci.yml | 43 ----------------------------------
 1 file changed, 43 deletions(-)
 delete mode 100644 .github/workflows/gtest-ci.yml

diff --git a/.github/workflows/gtest-ci.yml b/.github/workflows/gtest-ci.yml
deleted file mode 100644
index 03a8cc5e2..000000000
--- a/.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 ...

From f16770d63dcb69019c0547b26a4a433d2cc62bd7 Mon Sep 17 00:00:00 2001
From: David Matson 
Date: Thu, 28 Mar 2024 20:09:35 -0700
Subject: [PATCH 329/336] Add skipped messages to JSON output (fixes #4507).

Fix the gap between JSON and XML output.
---
 googletest/src/gtest.cc                       | 57 +++++++++++++------
 .../test/googletest-json-output-unittest.py   | 18 ++++++
 googletest/test/gtest_json_test_utils.py      |  3 +
 3 files changed, 62 insertions(+), 16 deletions(-)

diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index 2653dbb23..2aac95919 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -4743,26 +4743,51 @@ void JsonUnitTestResultPrinter::OutputJsonTestResult(::std::ostream* stream,
                                                      const TestResult& result) {
   const std::string kIndent = Indent(10);
 
-  int failures = 0;
-  for (int i = 0; i < result.total_part_count(); ++i) {
-    const TestPartResult& part = result.GetTestPartResult(i);
-    if (part.failed()) {
-      *stream << ",\n";
-      if (++failures == 1) {
-        *stream << kIndent << "\"" << "failures" << "\": [\n";
+  {
+    int failures = 0;
+    for (int i = 0; i < result.total_part_count(); ++i) {
+      const TestPartResult& part = result.GetTestPartResult(i);
+      if (part.failed()) {
+        *stream << ",\n";
+        if (++failures == 1) {
+          *stream << kIndent << "\"" << "failures" << "\": [\n";
+        }
+        const std::string location =
+            internal::FormatCompilerIndependentFileLocation(part.file_name(),
+                                                            part.line_number());
+        const std::string message = EscapeJson(location + "\n" + part.message());
+        *stream << kIndent << "  {\n"
+                << kIndent << "    \"failure\": \"" << message << "\",\n"
+                << kIndent << "    \"type\": \"\"\n"
+                << kIndent << "  }";
       }
-      const std::string location =
-          internal::FormatCompilerIndependentFileLocation(part.file_name(),
-                                                          part.line_number());
-      const std::string message = EscapeJson(location + "\n" + part.message());
-      *stream << kIndent << "  {\n"
-              << kIndent << "    \"failure\": \"" << message << "\",\n"
-              << kIndent << "    \"type\": \"\"\n"
-              << kIndent << "  }";
     }
+
+    if (failures > 0) *stream << "\n" << kIndent << "]";
+  }
+
+  {
+    int skipped = 0;
+    for (int i = 0; i < result.total_part_count(); ++i) {
+      const TestPartResult& part = result.GetTestPartResult(i);
+      if (part.skipped()) {
+        *stream << ",\n";
+        if (++skipped == 1) {
+          *stream << kIndent << "\"" << "skipped" << "\": [\n";
+        }
+        const std::string location =
+            internal::FormatCompilerIndependentFileLocation(part.file_name(),
+                                                            part.line_number());
+        const std::string message = EscapeJson(location + "\n" + part.message());
+        *stream << kIndent << "  {\n"
+                << kIndent << "    \"message\": \"" << message << "\"\n"
+                << kIndent << "  }";
+      }
+    }
+
+    if (skipped > 0) *stream << "\n" << kIndent << "]";
   }
 
-  if (failures > 0) *stream << "\n" << kIndent << "]";
   *stream << "\n" << Indent(8) << "}";
 }
 
diff --git a/googletest/test/googletest-json-output-unittest.py b/googletest/test/googletest-json-output-unittest.py
index cb9769452..323f4b3e0 100644
--- a/googletest/test/googletest-json-output-unittest.py
+++ b/googletest/test/googletest-json-output-unittest.py
@@ -150,6 +150,12 @@ EXPECTED_NON_EMPTY = {
                     'time': '*',
                     'timestamp': '*',
                     'classname': 'SkippedTest',
+                    'skipped': [{
+                        'message': (
+                            'gtest_xml_output_unittest_.cc:*\n'
+                            '\n'
+                        )
+                    }],
                 },
                 {
                     'name': 'SkippedWithMessage',
@@ -160,6 +166,12 @@ EXPECTED_NON_EMPTY = {
                     'time': '*',
                     'timestamp': '*',
                     'classname': 'SkippedTest',
+                    'skipped': [{
+                        'message': (
+                            'gtest_xml_output_unittest_.cc:*\n'
+                            'It is good practice to tell why you skip a test.\n'
+                        )
+                    }],
                 },
                 {
                     'name': 'SkippedAfterFailure',
@@ -179,6 +191,12 @@ EXPECTED_NON_EMPTY = {
                         ),
                         'type': '',
                     }],
+                    'skipped': [{
+                        'message': (
+                            'gtest_xml_output_unittest_.cc:*\n'
+                            'It is good practice to tell why you skip a test.\n'
+                        )
+                    }],
                 },
             ],
         },
diff --git a/googletest/test/gtest_json_test_utils.py b/googletest/test/gtest_json_test_utils.py
index 86a5925b0..694a7a60d 100644
--- a/googletest/test/gtest_json_test_utils.py
+++ b/googletest/test/gtest_json_test_utils.py
@@ -51,6 +51,9 @@ def normalize(obj):
     elif key == 'failure':
       value = re.sub(r'^.*[/\\](.*:)\d+\n', '\\1*\n', value)
       return re.sub(r'Stack trace:\n(.|\n)*', 'Stack trace:\n*', value)
+    elif key == 'message':
+      value = re.sub(r'^.*[/\\](.*:)\d+\n', '\\1*\n', value)
+      return re.sub(r'Stack trace:\n(.|\n)*', 'Stack trace:\n*', value)
     elif key == 'file':
       return re.sub(r'^.*[/\\](.*)', '\\1', value)
     else:

From d3a29ff624e0984a40a60dbc1f03ac74b8d03658 Mon Sep 17 00:00:00 2001
From: Derek Mauro 
Date: Wed, 3 Apr 2024 13:21:06 -0700
Subject: [PATCH 330/336] Fix a race condition between the Watcher thread and
 the main thread during program exit

A race condition exist between the Watcher thread and main(). A case
was found where the Watcher thread does not get execution time before
the main function returns and calls atexit(). At that point the
Watcher thread started runing tls_init() code while the main thread
was shutting down. This resulted in rare crashes and deadlocks.

Fixes #4493
Closes #4494

PiperOrigin-RevId: 621619768
Change-Id: I66f00d8f0f3c37f9937c6d13890f7fa10038256d
---
 googletest/src/gtest-port.cc | 35 +++++++++++++++++++++++++----------
 1 file changed, 25 insertions(+), 10 deletions(-)

diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc
index 3bb7dd450..aa3372596 100644
--- a/googletest/src/gtest-port.cc
+++ b/googletest/src/gtest-port.cc
@@ -587,9 +587,11 @@ class ThreadLocalRegistryImpl {
   // thread's ID.
   typedef std::map ThreadIdToThreadLocals;
 
-  // Holds the thread id and thread handle that we pass from
-  // StartWatcherThreadFor to WatcherThreadFunc.
-  typedef std::pair ThreadIdAndHandle;
+  struct WatcherThreadParams {
+    DWORD thread_id;
+    HANDLE handle;
+    Notification has_initialized;
+  };
 
   static void StartWatcherThreadFor(DWORD thread_id) {
     // The returned handle will be kept in thread_map and closed by
@@ -597,6 +599,11 @@ class ThreadLocalRegistryImpl {
     HANDLE thread =
         ::OpenThread(SYNCHRONIZE | THREAD_QUERY_INFORMATION, FALSE, thread_id);
     GTEST_CHECK_(thread != nullptr);
+
+    WatcherThreadParams* watcher_thread_params = new WatcherThreadParams;
+    watcher_thread_params->thread_id = thread_id;
+    watcher_thread_params->handle = thread;
+
     // We need to pass a valid thread ID pointer into CreateThread for it
     // to work correctly under Win98.
     DWORD watcher_thread_id;
@@ -604,7 +611,7 @@ class ThreadLocalRegistryImpl {
         nullptr,  // Default security.
         0,        // Default stack size
         &ThreadLocalRegistryImpl::WatcherThreadFunc,
-        reinterpret_cast(new ThreadIdAndHandle(thread_id, thread)),
+        reinterpret_cast(watcher_thread_params),
         CREATE_SUSPENDED, &watcher_thread_id);
     GTEST_CHECK_(watcher_thread != nullptr)
         << "CreateThread failed with error " << ::GetLastError() << ".";
@@ -614,17 +621,25 @@ class ThreadLocalRegistryImpl {
                         ::GetThreadPriority(::GetCurrentThread()));
     ::ResumeThread(watcher_thread);
     ::CloseHandle(watcher_thread);
+
+    // Wait for the watcher thread to start to avoid race conditions.
+    // One specific race condition that can happen is that we have returned
+    // from main and have started to tear down, the newly spawned watcher
+    // thread may access already-freed variables, like global shared_ptrs.
+    watcher_thread_params->has_initialized.WaitForNotification();
   }
 
   // Monitors exit from a given thread and notifies those
   // ThreadIdToThreadLocals about thread termination.
   static DWORD WINAPI WatcherThreadFunc(LPVOID param) {
-    const ThreadIdAndHandle* tah =
-        reinterpret_cast(param);
-    GTEST_CHECK_(::WaitForSingleObject(tah->second, INFINITE) == WAIT_OBJECT_0);
-    OnThreadExit(tah->first);
-    ::CloseHandle(tah->second);
-    delete tah;
+    WatcherThreadParams* watcher_thread_params =
+        reinterpret_cast(param);
+    watcher_thread_params->has_initialized.Notify();
+    GTEST_CHECK_(::WaitForSingleObject(watcher_thread_params->handle,
+                                       INFINITE) == WAIT_OBJECT_0);
+    OnThreadExit(watcher_thread_params->thread_id);
+    ::CloseHandle(watcher_thread_params->handle);
+    delete watcher_thread_params;
     return 0;
   }
 

From 0af976647f49ff0944c5971ae0a45d6fcdf1ecca Mon Sep 17 00:00:00 2001
From: Lawrence Wolf-Sonkin 
Date: Thu, 4 Apr 2024 12:37:50 -0700
Subject: [PATCH 331/336] [gtest] Use `std::index_sequence` and friends instead
 of rolling our own

* Applies for `std::index_sequence`, `std::make_index_sequence`, and `std::index_sequence_for` replacing `IndexSequence`, `MakeIndexSequence` and IndexSequenceFor`
* Also deleted implementation helper `DoubleSequence`
* The standard interfaces [have been in the standard library since C++14](https://en.cppreference.com/w/cpp/utility/integer_sequence), which [is the minimum supported C++ version by Google Test](https://github.com/google/oss-policies-info/blob/main/foundational-cxx-support-matrix.md)

PiperOrigin-RevId: 621939977
Change-Id: Id264266f08da66c0fa2a6e6fbb8f86fd3cb3a421
---
 googlemock/include/gmock/gmock-actions.h      |  6 +-
 googlemock/include/gmock/gmock-matchers.h     | 56 +++++++++----------
 .../gmock/internal/gmock-internal-utils.h     | 14 +++--
 googlemock/src/gmock-internal-utils.cc        |  5 +-
 .../include/gtest/internal/gtest-internal.h   | 54 ++++--------------
 .../include/gtest/internal/gtest-param-util.h |  8 +--
 googletest/test/gtest_unittest.cc             | 16 ------
 7 files changed, 56 insertions(+), 103 deletions(-)

diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h
index fab999338..7e17b305e 100644
--- a/googlemock/include/gmock/gmock-actions.h
+++ b/googlemock/include/gmock/gmock-actions.h
@@ -2135,13 +2135,13 @@ struct ActionImpl : ImplBase::type {
   R operator()(Args&&... arg) const {
     static constexpr size_t kMaxArgs =
         sizeof...(Args) <= 10 ? sizeof...(Args) : 10;
-    return Apply(MakeIndexSequence{},
-                 MakeIndexSequence<10 - kMaxArgs>{},
+    return Apply(std::make_index_sequence{},
+                 std::make_index_sequence<10 - kMaxArgs>{},
                  args_type{std::forward(arg)...});
   }
 
   template 
-  R Apply(IndexSequence, IndexSequence,
+  R Apply(std::index_sequence, std::index_sequence,
           const args_type& args) const {
     // Impl need not be specific to the signature of action being implemented;
     // only the implementing function body needs to have all of the specific
diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h
index c4149f2ef..6b6b4371b 100644
--- a/googlemock/include/gmock/gmock-matchers.h
+++ b/googlemock/include/gmock/gmock-matchers.h
@@ -490,12 +490,12 @@ class MatcherBaseImpl> {
 
   template 
   operator ::testing::Matcher() const {  // NOLINT(runtime/explicit)
-    return Apply(MakeIndexSequence{});
+    return Apply(std::make_index_sequence{});
   }
 
  private:
   template 
-  ::testing::Matcher Apply(IndexSequence) const {
+  ::testing::Matcher Apply(std::index_sequence) const {
     return ::testing::Matcher(
         new typename Derived::template gmock_Impl(
             std::get(params_)...));
@@ -3152,8 +3152,8 @@ class PairMatcher {
 };
 
 template 
-auto UnpackStructImpl(const T& t, IndexSequence, int)
-    -> decltype(std::tie(get(t)...)) {
+auto UnpackStructImpl(const T& t, std::index_sequence,
+                      int) -> decltype(std::tie(get(t)...)) {
   static_assert(std::tuple_size::value == sizeof...(I),
                 "Number of arguments doesn't match the number of fields.");
   return std::tie(get(t)...);
@@ -3161,97 +3161,97 @@ auto UnpackStructImpl(const T& t, IndexSequence, int)
 
 #if defined(__cpp_structured_bindings) && __cpp_structured_bindings >= 201606
 template 
-auto UnpackStructImpl(const T& t, MakeIndexSequence<1>, char) {
+auto UnpackStructImpl(const T& t, std::make_index_sequence<1>, char) {
   const auto& [a] = t;
   return std::tie(a);
 }
 template 
-auto UnpackStructImpl(const T& t, MakeIndexSequence<2>, char) {
+auto UnpackStructImpl(const T& t, std::make_index_sequence<2>, char) {
   const auto& [a, b] = t;
   return std::tie(a, b);
 }
 template 
-auto UnpackStructImpl(const T& t, MakeIndexSequence<3>, char) {
+auto UnpackStructImpl(const T& t, std::make_index_sequence<3>, char) {
   const auto& [a, b, c] = t;
   return std::tie(a, b, c);
 }
 template 
-auto UnpackStructImpl(const T& t, MakeIndexSequence<4>, char) {
+auto UnpackStructImpl(const T& t, std::make_index_sequence<4>, char) {
   const auto& [a, b, c, d] = t;
   return std::tie(a, b, c, d);
 }
 template 
-auto UnpackStructImpl(const T& t, MakeIndexSequence<5>, char) {
+auto UnpackStructImpl(const T& t, std::make_index_sequence<5>, char) {
   const auto& [a, b, c, d, e] = t;
   return std::tie(a, b, c, d, e);
 }
 template 
-auto UnpackStructImpl(const T& t, MakeIndexSequence<6>, char) {
+auto UnpackStructImpl(const T& t, std::make_index_sequence<6>, char) {
   const auto& [a, b, c, d, e, f] = t;
   return std::tie(a, b, c, d, e, f);
 }
 template 
-auto UnpackStructImpl(const T& t, MakeIndexSequence<7>, char) {
+auto UnpackStructImpl(const T& t, std::make_index_sequence<7>, char) {
   const auto& [a, b, c, d, e, f, g] = t;
   return std::tie(a, b, c, d, e, f, g);
 }
 template 
-auto UnpackStructImpl(const T& t, MakeIndexSequence<8>, char) {
+auto UnpackStructImpl(const T& t, std::make_index_sequence<8>, char) {
   const auto& [a, b, c, d, e, f, g, h] = t;
   return std::tie(a, b, c, d, e, f, g, h);
 }
 template 
-auto UnpackStructImpl(const T& t, MakeIndexSequence<9>, char) {
+auto UnpackStructImpl(const T& t, std::make_index_sequence<9>, char) {
   const auto& [a, b, c, d, e, f, g, h, i] = t;
   return std::tie(a, b, c, d, e, f, g, h, i);
 }
 template 
-auto UnpackStructImpl(const T& t, MakeIndexSequence<10>, char) {
+auto UnpackStructImpl(const T& t, std::make_index_sequence<10>, char) {
   const auto& [a, b, c, d, e, f, g, h, i, j] = t;
   return std::tie(a, b, c, d, e, f, g, h, i, j);
 }
 template 
-auto UnpackStructImpl(const T& t, MakeIndexSequence<11>, char) {
+auto UnpackStructImpl(const T& t, std::make_index_sequence<11>, char) {
   const auto& [a, b, c, d, e, f, g, h, i, j, k] = t;
   return std::tie(a, b, c, d, e, f, g, h, i, j, k);
 }
 template 
-auto UnpackStructImpl(const T& t, MakeIndexSequence<12>, char) {
+auto UnpackStructImpl(const T& t, std::make_index_sequence<12>, char) {
   const auto& [a, b, c, d, e, f, g, h, i, j, k, l] = t;
   return std::tie(a, b, c, d, e, f, g, h, i, j, k, l);
 }
 template 
-auto UnpackStructImpl(const T& t, MakeIndexSequence<13>, char) {
+auto UnpackStructImpl(const T& t, std::make_index_sequence<13>, char) {
   const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m] = t;
   return std::tie(a, b, c, d, e, f, g, h, i, j, k, l, m);
 }
 template 
-auto UnpackStructImpl(const T& t, MakeIndexSequence<14>, char) {
+auto UnpackStructImpl(const T& t, std::make_index_sequence<14>, char) {
   const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m, n] = t;
   return std::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n);
 }
 template 
-auto UnpackStructImpl(const T& t, MakeIndexSequence<15>, char) {
+auto UnpackStructImpl(const T& t, std::make_index_sequence<15>, char) {
   const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o] = t;
   return std::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o);
 }
 template 
-auto UnpackStructImpl(const T& t, MakeIndexSequence<16>, char) {
+auto UnpackStructImpl(const T& t, std::make_index_sequence<16>, char) {
   const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p] = t;
   return std::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p);
 }
 template 
-auto UnpackStructImpl(const T& t, MakeIndexSequence<17>, char) {
+auto UnpackStructImpl(const T& t, std::make_index_sequence<17>, char) {
   const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q] = t;
   return std::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q);
 }
 template 
-auto UnpackStructImpl(const T& t, MakeIndexSequence<18>, char) {
+auto UnpackStructImpl(const T& t, std::make_index_sequence<18>, char) {
   const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r] = t;
   return std::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r);
 }
 template 
-auto UnpackStructImpl(const T& t, MakeIndexSequence<19>, char) {
+auto UnpackStructImpl(const T& t, std::make_index_sequence<19>, char) {
   const auto& [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s] = t;
   return std::tie(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s);
 }
@@ -3259,8 +3259,8 @@ auto UnpackStructImpl(const T& t, MakeIndexSequence<19>, char) {
 
 template 
 auto UnpackStruct(const T& t)
-    -> decltype((UnpackStructImpl)(t, MakeIndexSequence{}, 0)) {
-  return (UnpackStructImpl)(t, MakeIndexSequence{}, 0);
+    -> decltype((UnpackStructImpl)(t, std::make_index_sequence{}, 0)) {
+  return (UnpackStructImpl)(t, std::make_index_sequence{}, 0);
 }
 
 // Helper function to do comma folding in C++11.
@@ -3273,7 +3273,7 @@ template 
 class FieldsAreMatcherImpl;
 
 template 
-class FieldsAreMatcherImpl>
+class FieldsAreMatcherImpl>
     : public MatcherInterface {
   using UnpackedType =
       decltype(UnpackStruct(std::declval()));
@@ -3355,8 +3355,8 @@ class FieldsAreMatcher {
   template 
   operator Matcher() const {  // NOLINT
     return Matcher(
-        new FieldsAreMatcherImpl>(
-            matchers_));
+        new FieldsAreMatcherImpl>(matchers_));
   }
 
  private:
diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h
index ead6d7c80..b7685f573 100644
--- a/googlemock/include/gmock/internal/gmock-internal-utils.h
+++ b/googlemock/include/gmock/internal/gmock-internal-utils.h
@@ -44,6 +44,7 @@
 #include   // NOLINT
 #include 
 #include 
+#include 
 #include 
 
 #include "gmock/internal/gmock-port.h"
@@ -420,7 +421,7 @@ struct RemoveConstFromKey > {
 GTEST_API_ void IllegalDoDefault(const char* file, int line);
 
 template 
-auto ApplyImpl(F&& f, Tuple&& args, IndexSequence)
+auto ApplyImpl(F&& f, Tuple&& args, std::index_sequence)
     -> decltype(std::forward(f)(
         std::get(std::forward(args))...)) {
   return std::forward(f)(std::get(std::forward(args))...);
@@ -428,12 +429,13 @@ auto ApplyImpl(F&& f, Tuple&& args, IndexSequence)
 
 // Apply the function to a tuple of arguments.
 template 
-auto Apply(F&& f, Tuple&& args) -> decltype(ApplyImpl(
-    std::forward(f), std::forward(args),
-    MakeIndexSequence::type>::value>())) {
+auto Apply(F&& f, Tuple&& args)
+    -> decltype(ApplyImpl(
+        std::forward(f), std::forward(args),
+        std::make_index_sequence::type>::value>())) {
   return ApplyImpl(std::forward(f), std::forward(args),
-                   MakeIndexSequence::type>::value>());
 }
 
diff --git a/googlemock/src/gmock-internal-utils.cc b/googlemock/src/gmock-internal-utils.cc
index 5c2ce0d57..96c7e306e 100644
--- a/googlemock/src/gmock-internal-utils.cc
+++ b/googlemock/src/gmock-internal-utils.cc
@@ -44,6 +44,7 @@
 #include 
 #include   // NOLINT
 #include 
+#include 
 #include 
 
 #include "gmock/gmock.h"
@@ -211,14 +212,14 @@ constexpr char UnBase64Impl(char c, const char* const base64, char carry) {
 }
 
 template 
-constexpr std::array UnBase64Impl(IndexSequence,
+constexpr std::array UnBase64Impl(std::index_sequence,
                                              const char* const base64) {
   return {
       {UnBase64Impl(UndoWebSafeEncoding(static_cast(I)), base64, 0)...}};
 }
 
 constexpr std::array UnBase64(const char* const base64) {
-  return UnBase64Impl(MakeIndexSequence<256>{}, base64);
+  return UnBase64Impl(std::make_index_sequence<256>{}, base64);
 }
 
 static constexpr char kBase64[] =
diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h
index 4661248f7..cffb8e114 100644
--- a/googletest/include/gtest/internal/gtest-internal.h
+++ b/googletest/include/gtest/internal/gtest-internal.h
@@ -1137,40 +1137,6 @@ class NativeArray {
   void (NativeArray::*clone_)(const Element*, size_t);
 };
 
-// Backport of std::index_sequence.
-template 
-struct IndexSequence {
-  using type = IndexSequence;
-};
-
-// Double the IndexSequence, and one if plus_one is true.
-template 
-struct DoubleSequence;
-template 
-struct DoubleSequence, sizeofT> {
-  using type = IndexSequence;
-};
-template 
-struct DoubleSequence, sizeofT> {
-  using type = IndexSequence;
-};
-
-// Backport of std::make_index_sequence.
-// It uses O(ln(N)) instantiation depth.
-template 
-struct MakeIndexSequenceImpl
-    : DoubleSequence::type,
-                     N / 2>::type {};
-
-template <>
-struct MakeIndexSequenceImpl<0> : IndexSequence<> {};
-
-template 
-using MakeIndexSequence = typename MakeIndexSequenceImpl::type;
-
-template 
-using IndexSequenceFor = typename MakeIndexSequence::type;
-
 template 
 struct Ignore {
   Ignore(...);  // NOLINT
@@ -1179,7 +1145,7 @@ struct Ignore {
 template 
 struct ElemFromListImpl;
 template 
-struct ElemFromListImpl> {
+struct ElemFromListImpl> {
   // We make Ignore a template to solve a problem with MSVC.
   // A non-template Ignore would work fine with `decltype(Ignore(I))...`, but
   // MSVC doesn't understand how to deal with that pack expansion.
@@ -1190,9 +1156,8 @@ struct ElemFromListImpl> {
 
 template 
 struct ElemFromList {
-  using type =
-      decltype(ElemFromListImpl::type>::Apply(
-          static_cast(nullptr)...));
+  using type = decltype(ElemFromListImpl>::Apply(
+      static_cast(nullptr)...));
 };
 
 struct FlatTupleConstructTag {};
@@ -1217,9 +1182,9 @@ template 
 struct FlatTupleBase;
 
 template 
-struct FlatTupleBase, IndexSequence>
+struct FlatTupleBase, std::index_sequence>
     : FlatTupleElemBase, Idx>... {
-  using Indices = IndexSequence;
+  using Indices = std::index_sequence;
   FlatTupleBase() = default;
   template 
   explicit FlatTupleBase(FlatTupleConstructTag, Args&&... args)
@@ -1254,14 +1219,15 @@ struct FlatTupleBase, IndexSequence>
 // implementations.
 // FlatTuple and ElemFromList are not recursive and have a fixed depth
 // regardless of T...
-// MakeIndexSequence, on the other hand, it is recursive but with an
+// std::make_index_sequence, on the other hand, it is recursive but with an
 // instantiation depth of O(ln(N)).
 template 
 class FlatTuple
     : private FlatTupleBase,
-                            typename MakeIndexSequence::type> {
-  using Indices = typename FlatTupleBase<
-      FlatTuple, typename MakeIndexSequence::type>::Indices;
+                            std::make_index_sequence> {
+  using Indices =
+      typename FlatTupleBase,
+                             std::make_index_sequence>::Indices;
 
  public:
   FlatTuple() = default;
diff --git a/googletest/include/gtest/internal/gtest-param-util.h b/googletest/include/gtest/internal/gtest-param-util.h
index 1fc500f97..cc7ea5317 100644
--- a/googletest/include/gtest/internal/gtest-param-util.h
+++ b/googletest/include/gtest/internal/gtest-param-util.h
@@ -807,12 +807,12 @@ class ValueArray {
 
   template 
   operator ParamGenerator() const {  // NOLINT
-    return ValuesIn(MakeVector(MakeIndexSequence()));
+    return ValuesIn(MakeVector(std::make_index_sequence()));
   }
 
  private:
   template 
-  std::vector MakeVector(IndexSequence) const {
+  std::vector MakeVector(std::index_sequence) const {
     return std::vector{static_cast(v_.template Get())...};
   }
 
@@ -842,7 +842,7 @@ class CartesianProductGenerator
   template 
   class IteratorImpl;
   template 
-  class IteratorImpl>
+  class IteratorImpl>
       : public ParamIteratorInterface {
    public:
     IteratorImpl(const ParamGeneratorInterface* base,
@@ -933,7 +933,7 @@ class CartesianProductGenerator
     std::shared_ptr current_value_;
   };
 
-  using Iterator = IteratorImpl::type>;
+  using Iterator = IteratorImpl>;
 
   std::tuple...> generators_;
 };
diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc
index 5d7cfb092..edbe2ea26 100644
--- a/googletest/test/gtest_unittest.cc
+++ b/googletest/test/gtest_unittest.cc
@@ -7482,22 +7482,6 @@ TEST(NativeArrayTest, WorksForTwoDimensionalArray) {
   EXPECT_EQ(a, na.begin());
 }
 
-// IndexSequence
-TEST(IndexSequence, MakeIndexSequence) {
-  using testing::internal::IndexSequence;
-  using testing::internal::MakeIndexSequence;
-  EXPECT_TRUE(
-      (std::is_same, MakeIndexSequence<0>::type>::value));
-  EXPECT_TRUE(
-      (std::is_same, MakeIndexSequence<1>::type>::value));
-  EXPECT_TRUE(
-      (std::is_same, MakeIndexSequence<2>::type>::value));
-  EXPECT_TRUE((
-      std::is_same, MakeIndexSequence<3>::type>::value));
-  EXPECT_TRUE(
-      (std::is_base_of, MakeIndexSequence<3>>::value));
-}
-
 // ElemFromList
 TEST(ElemFromList, Basic) {
   using testing::internal::ElemFromList;

From f10e11fb27301fba21caa71030bb5024e67aa135 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Fri, 5 Apr 2024 09:39:12 -0700
Subject: [PATCH 332/336] No external change

PiperOrigin-RevId: 622203227
Change-Id: Ic3c24edf917dbda7b02c6ab8ce695398a436dc4c
---
 googletest/include/gtest/gtest-assertion-result.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/googletest/include/gtest/gtest-assertion-result.h b/googletest/include/gtest/gtest-assertion-result.h
index 56fe128f2..74eb2b1f3 100644
--- a/googletest/include/gtest/gtest-assertion-result.h
+++ b/googletest/include/gtest/gtest-assertion-result.h
@@ -129,7 +129,7 @@ namespace testing {
 //
 //   Expected: Foo() is even
 //     Actual: it's 5
-//
+
 class GTEST_API_ AssertionResult {
  public:
   // Copy constructor.

From b1a777f31913f8a047f43b2a5f823e736e7f5082 Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Wed, 10 Apr 2024 01:02:58 -0700
Subject: [PATCH 333/336] Fix https://github.com/google/googletest/issues/4423

PiperOrigin-RevId: 623407029
Change-Id: I3559f11e1c18a4f151d521c6ac115c358a11b40c
---
 docs/reference/testing.md | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/docs/reference/testing.md b/docs/reference/testing.md
index 81640fd49..c93556e66 100644
--- a/docs/reference/testing.md
+++ b/docs/reference/testing.md
@@ -94,7 +94,8 @@ Instantiates the value-parameterized test suite *`TestSuiteName`* (defined with
 The argument *`InstantiationName`* is a unique name for the instantiation of the
 test suite, to distinguish between multiple instantiations. In test output, the
 instantiation name is added as a prefix to the test suite name
-*`TestSuiteName`*.
+*`TestSuiteName`*. If *`InstantiationName`* is empty
+(`INSTANTIATE_TEST_SUITE_P(, ...)`), no prefix is added.
 
 The argument *`param_generator`* is one of the following GoogleTest-provided
 functions that generate the test parameters, all defined in the `::testing`
@@ -277,7 +278,8 @@ must be registered with
 The argument *`InstantiationName`* is a unique name for the instantiation of the
 test suite, to distinguish between multiple instantiations. In test output, the
 instantiation name is added as a prefix to the test suite name
-*`TestSuiteName`*.
+*`TestSuiteName`*. If *`InstantiationName`* is empty
+(`INSTANTIATE_TYPED_TEST_SUITE_P(, ...)`), no prefix is added.
 
 The argument *`Types`* is a [`Types`](#Types) object representing the list of
 types to run the tests on, for example:

From 5197b1a8e6a1ef9f214f4aa537b0be17cbf91946 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Krzysztof=20Kosi=C5=84ski?= 
Date: Fri, 12 Apr 2024 13:18:22 -0700
Subject: [PATCH 334/336] Modify example in the primer to match Testing FAQ.

The CtorVsSetUp section of the FAQ says that constructors and destructors should be preferred over SetUp() and TearDown(), because they will automatically chain up to the fixture's base class, whereas for methods the user must remember to add the chaining manually.

PiperOrigin-RevId: 624273474
Change-Id: Ida41aae193d417eaf996587c7ae1a0099a8cab32
---
 docs/primer.md | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/docs/primer.md b/docs/primer.md
index 0f90c0399..61806be6e 100644
--- a/docs/primer.md
+++ b/docs/primer.md
@@ -273,14 +273,14 @@ First, define a fixture class. By convention, you should give it the name
 ```c++
 class QueueTest : public testing::Test {
  protected:
-  void SetUp() override {
+  QueueTest() {
      // q0_ remains empty
      q1_.Enqueue(1);
      q2_.Enqueue(2);
      q2_.Enqueue(3);
   }
 
-  // void TearDown() override {}
+  // ~QueueTest() override = default;
 
   Queue q0_;
   Queue q1_;
@@ -288,8 +288,9 @@ class QueueTest : public testing::Test {
 };
 ```
 
-In this case, `TearDown()` is not needed since we don't have to clean up after
-each test, other than what's already done by the destructor.
+In this case, we don't need to define a destructor or a `TearDown()` method,
+because the implicit destructor generated by the compiler will perform all of
+the necessary cleanup.
 
 Now we'll write tests using `TEST_F()` and this fixture.
 
@@ -326,11 +327,9 @@ would lead to a segfault when `n` is `NULL`.
 When these tests run, the following happens:
 
 1.  GoogleTest constructs a `QueueTest` object (let's call it `t1`).
-2.  `t1.SetUp()` initializes `t1`.
-3.  The first test (`IsEmptyInitially`) runs on `t1`.
-4.  `t1.TearDown()` cleans up after the test finishes.
-5.  `t1` is destructed.
-6.  The above steps are repeated on another `QueueTest` object, this time
+2.  The first test (`IsEmptyInitially`) runs on `t1`.
+3.  `t1` is destructed.
+4.  The above steps are repeated on another `QueueTest` object, this time
     running the `DequeueWorks` test.
 
 **Availability**: Linux, Windows, Mac.

From 5a37b517ad4ab6738556f0284c256cae1466c5b4 Mon Sep 17 00:00:00 2001
From: Derek Mauro 
Date: Tue, 16 Apr 2024 13:15:51 -0700
Subject: [PATCH 335/336] Use `[[maybe_unused]]` when it is available to avoid
 -Wused-but-marked-unused warnings

PiperOrigin-RevId: 625430612
Change-Id: Ia9d2e47984e1e6f91966afae8a6750119ae69446
---
 googlemock/include/gmock/gmock-actions.h      |   6 +-
 googlemock/include/gmock/gmock-matchers.h     |  92 ++++++-------
 googletest/include/gtest/gtest-param-test.h   |   6 +-
 googletest/include/gtest/gtest-typed-test.h   | 126 +++++++++---------
 .../include/gtest/internal/gtest-internal.h   |   3 +-
 .../include/gtest/internal/gtest-port.h       |  34 ++++-
 googletest/test/gtest_unittest.cc             |   7 +-
 7 files changed, 150 insertions(+), 124 deletions(-)

diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h
index 7e17b305e..cd1299695 100644
--- a/googlemock/include/gmock/gmock-actions.h
+++ b/googlemock/include/gmock/gmock-actions.h
@@ -2174,9 +2174,9 @@ template 
 }
 
 #define GMOCK_INTERNAL_ARG_UNUSED(i, data, el) \
-  , const arg##i##_type& arg##i GTEST_ATTRIBUTE_UNUSED_
-#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_                 \
-  const args_type& args GTEST_ATTRIBUTE_UNUSED_ GMOCK_PP_REPEAT( \
+  , GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED const arg##i##_type& arg##i
+#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_                               \
+  GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED const args_type& args GMOCK_PP_REPEAT( \
       GMOCK_INTERNAL_ARG_UNUSED, , 10)
 
 #define GMOCK_INTERNAL_ARG(i, data, el) , const arg##i##_type& arg##i
diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h
index 6b6b4371b..33a67165a 100644
--- a/googlemock/include/gmock/gmock-matchers.h
+++ b/googlemock/include/gmock/gmock-matchers.h
@@ -5445,47 +5445,47 @@ PolymorphicMatcher> ThrowsMessage(
       ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)
 
 // MATCHER* macros itself are listed below.
-#define MATCHER(name, description)                                             \
-  class name##Matcher                                                          \
-      : public ::testing::internal::MatcherBaseImpl {           \
-   public:                                                                     \
-    template                                                \
-    class gmock_Impl : public ::testing::MatcherInterface {   \
-     public:                                                                   \
-      gmock_Impl() {}                                                          \
-      bool MatchAndExplain(                                                    \
-          const arg_type& arg,                                                 \
-          ::testing::MatchResultListener* result_listener) const override;     \
-      void DescribeTo(::std::ostream* gmock_os) const override {               \
-        *gmock_os << FormatDescription(false);                                 \
-      }                                                                        \
-      void DescribeNegationTo(::std::ostream* gmock_os) const override {       \
-        *gmock_os << FormatDescription(true);                                  \
-      }                                                                        \
-                                                                               \
-     private:                                                                  \
-      ::std::string FormatDescription(bool negation) const {                   \
-        /* NOLINTNEXTLINE readability-redundant-string-init */                 \
-        ::std::string gmock_description = (description);                       \
-        if (!gmock_description.empty()) {                                      \
-          return gmock_description;                                            \
-        }                                                                      \
-        return ::testing::internal::FormatMatcherDescription(negation, #name,  \
-                                                             {}, {});          \
-      }                                                                        \
-    };                                                                         \
-  };                                                                           \
-  inline name##Matcher GMOCK_INTERNAL_WARNING_PUSH()                           \
-      GMOCK_INTERNAL_WARNING_CLANG(ignored, "-Wunused-function")               \
-          GMOCK_INTERNAL_WARNING_CLANG(ignored, "-Wunused-member-function")    \
-              name GMOCK_INTERNAL_WARNING_POP()() {                            \
-    return {};                                                                 \
-  }                                                                            \
-  template                                                  \
-  bool name##Matcher::gmock_Impl::MatchAndExplain(                   \
-      const arg_type& arg,                                                     \
-      ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_) \
-      const
+#define MATCHER(name, description)                                            \
+  class name##Matcher                                                         \
+      : public ::testing::internal::MatcherBaseImpl {          \
+   public:                                                                    \
+    template                                               \
+    class gmock_Impl : public ::testing::MatcherInterface {  \
+     public:                                                                  \
+      gmock_Impl() {}                                                         \
+      bool MatchAndExplain(                                                   \
+          const arg_type& arg,                                                \
+          ::testing::MatchResultListener* result_listener) const override;    \
+      void DescribeTo(::std::ostream* gmock_os) const override {              \
+        *gmock_os << FormatDescription(false);                                \
+      }                                                                       \
+      void DescribeNegationTo(::std::ostream* gmock_os) const override {      \
+        *gmock_os << FormatDescription(true);                                 \
+      }                                                                       \
+                                                                              \
+     private:                                                                 \
+      ::std::string FormatDescription(bool negation) const {                  \
+        /* NOLINTNEXTLINE readability-redundant-string-init */                \
+        ::std::string gmock_description = (description);                      \
+        if (!gmock_description.empty()) {                                     \
+          return gmock_description;                                           \
+        }                                                                     \
+        return ::testing::internal::FormatMatcherDescription(negation, #name, \
+                                                             {}, {});         \
+      }                                                                       \
+    };                                                                        \
+  };                                                                          \
+  inline name##Matcher GMOCK_INTERNAL_WARNING_PUSH()                          \
+      GMOCK_INTERNAL_WARNING_CLANG(ignored, "-Wunused-function")              \
+          GMOCK_INTERNAL_WARNING_CLANG(ignored, "-Wunused-member-function")   \
+              name GMOCK_INTERNAL_WARNING_POP()() {                           \
+    return {};                                                                \
+  }                                                                           \
+  template                                                 \
+  bool name##Matcher::gmock_Impl::MatchAndExplain(                  \
+      const arg_type& arg,                                                    \
+      GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED ::testing::MatchResultListener*   \
+          result_listener) const
 
 #define MATCHER_P(name, p0, description) \
   GMOCK_INTERNAL_MATCHER(name, name##MatcherP, description, (#p0), (p0))
@@ -5567,11 +5567,11 @@ PolymorphicMatcher> ThrowsMessage(
   }                                                                            \
   template                       \
   template                                                  \
-  bool full_name::gmock_Impl<        \
-      arg_type>::MatchAndExplain(const arg_type& arg,                          \
-                                 ::testing::MatchResultListener*               \
-                                     result_listener GTEST_ATTRIBUTE_UNUSED_)  \
-      const
+  bool full_name::                   \
+      gmock_Impl::MatchAndExplain(                                   \
+          const arg_type& arg,                                                 \
+          GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED ::testing::                    \
+              MatchResultListener* result_listener) const
 
 #define GMOCK_INTERNAL_MATCHER_TEMPLATE_PARAMS(args) \
   GMOCK_PP_TAIL(                                     \
diff --git a/googletest/include/gtest/gtest-param-test.h b/googletest/include/gtest/gtest-param-test.h
index 49a47ead0..6847b6461 100644
--- a/googletest/include/gtest/gtest-param-test.h
+++ b/googletest/include/gtest/gtest-param-test.h
@@ -469,7 +469,7 @@ internal::ParamConverterGenerator ConvertGenerator(
               ::testing::internal::CodeLocation(__FILE__, __LINE__));          \
       return 0;                                                                \
     }                                                                          \
-    static int gtest_registering_dummy_ GTEST_ATTRIBUTE_UNUSED_;               \
+    GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED static int gtest_registering_dummy_; \
   };                                                                           \
   int GTEST_TEST_CLASS_NAME_(test_suite_name,                                  \
                              test_name)::gtest_registering_dummy_ =            \
@@ -514,8 +514,8 @@ internal::ParamConverterGenerator ConvertGenerator(
         ::testing::internal::DefaultParamName,   \
         DUMMY_PARAM_))))(info);                                              \
   }                                                                          \
-  static int gtest_##prefix##test_suite_name##_dummy_                        \
-      GTEST_ATTRIBUTE_UNUSED_ =                                              \
+  GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED static int                           \
+      gtest_##prefix##test_suite_name##_dummy_ =                             \
           ::testing::UnitTest::GetInstance()                                 \
               ->parameterized_test_registry()                                \
               .GetTestSuitePatternHolder(                   \
diff --git a/googletest/include/gtest/gtest-typed-test.h b/googletest/include/gtest/gtest-typed-test.h
index 72de536bc..305b0b50d 100644
--- a/googletest/include/gtest/gtest-typed-test.h
+++ b/googletest/include/gtest/gtest-typed-test.h
@@ -194,33 +194,34 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);
   typedef ::testing::internal::NameGeneratorSelector<__VA_ARGS__>::type \
   GTEST_NAME_GENERATOR_(CaseName)
 
-#define TYPED_TEST(CaseName, TestName)                                        \
-  static_assert(sizeof(GTEST_STRINGIFY_(TestName)) > 1,                       \
-                "test-name must not be empty");                               \
-  template                                         \
-  class GTEST_TEST_CLASS_NAME_(CaseName, TestName)                            \
-      : public CaseName {                                   \
-   private:                                                                   \
-    typedef CaseName TestFixture;                           \
-    typedef gtest_TypeParam_ TypeParam;                                       \
-    void TestBody() override;                                                 \
-  };                                                                          \
-  static bool gtest_##CaseName##_##TestName##_registered_                     \
-      GTEST_ATTRIBUTE_UNUSED_ = ::testing::internal::TypeParameterizedTest<   \
-          CaseName,                                                           \
-          ::testing::internal::TemplateSel, \
-          GTEST_TYPE_PARAMS_(                                                 \
-              CaseName)>::Register("",                                        \
-                                   ::testing::internal::CodeLocation(         \
-                                       __FILE__, __LINE__),                   \
-                                   GTEST_STRINGIFY_(CaseName),                \
-                                   GTEST_STRINGIFY_(TestName), 0,             \
-                                   ::testing::internal::GenerateNames<        \
-                                       GTEST_NAME_GENERATOR_(CaseName),       \
-                                       GTEST_TYPE_PARAMS_(CaseName)>());      \
-  template                                         \
-  void GTEST_TEST_CLASS_NAME_(CaseName,                                       \
+#define TYPED_TEST(CaseName, TestName)                                       \
+  static_assert(sizeof(GTEST_STRINGIFY_(TestName)) > 1,                      \
+                "test-name must not be empty");                              \
+  template                                        \
+  class GTEST_TEST_CLASS_NAME_(CaseName, TestName)                           \
+      : public CaseName {                                  \
+   private:                                                                  \
+    typedef CaseName TestFixture;                          \
+    typedef gtest_TypeParam_ TypeParam;                                      \
+    void TestBody() override;                                                \
+  };                                                                         \
+  GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED static bool                          \
+      gtest_##CaseName##_##TestName##_registered_ =                          \
+          ::testing::internal::TypeParameterizedTest<                        \
+              CaseName,                                                      \
+              ::testing::internal::TemplateSel,                                      \
+              GTEST_TYPE_PARAMS_(                                            \
+                  CaseName)>::Register("",                                   \
+                                       ::testing::internal::CodeLocation(    \
+                                           __FILE__, __LINE__),              \
+                                       GTEST_STRINGIFY_(CaseName),           \
+                                       GTEST_STRINGIFY_(TestName), 0,        \
+                                       ::testing::internal::GenerateNames<   \
+                                           GTEST_NAME_GENERATOR_(CaseName),  \
+                                           GTEST_TYPE_PARAMS_(CaseName)>()); \
+  template                                        \
+  void GTEST_TEST_CLASS_NAME_(CaseName,                                      \
                               TestName)::TestBody()
 
 // Legacy API is deprecated but still available
@@ -267,22 +268,23 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);
   TYPED_TEST_SUITE_P
 #endif  // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
 
-#define TYPED_TEST_P(SuiteName, TestName)                           \
-  namespace GTEST_SUITE_NAMESPACE_(SuiteName) {                     \
-  template                               \
-  class TestName : public SuiteName {             \
-   private:                                                         \
-    typedef SuiteName TestFixture;                \
-    typedef gtest_TypeParam_ TypeParam;                             \
-    void TestBody() override;                                       \
-  };                                                                \
-  static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \
-      GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).AddTestName(       \
-          __FILE__, __LINE__, GTEST_STRINGIFY_(SuiteName),          \
-          GTEST_STRINGIFY_(TestName));                              \
-  }                                                                 \
-  template                               \
-  void GTEST_SUITE_NAMESPACE_(                                      \
+#define TYPED_TEST_P(SuiteName, TestName)                         \
+  namespace GTEST_SUITE_NAMESPACE_(SuiteName) {                   \
+  template                             \
+  class TestName : public SuiteName {           \
+   private:                                                       \
+    typedef SuiteName TestFixture;              \
+    typedef gtest_TypeParam_ TypeParam;                           \
+    void TestBody() override;                                     \
+  };                                                              \
+  GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED static bool               \
+      gtest_##TestName##_defined_ =                               \
+          GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).AddTestName( \
+              __FILE__, __LINE__, GTEST_STRINGIFY_(SuiteName),    \
+              GTEST_STRINGIFY_(TestName));                        \
+  }                                                               \
+  template                             \
+  void GTEST_SUITE_NAMESPACE_(                                    \
       SuiteName)::TestName::TestBody()
 
 // Note: this won't work correctly if the trailing arguments are macros.
@@ -290,8 +292,8 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);
   namespace GTEST_SUITE_NAMESPACE_(SuiteName) {                             \
   typedef ::testing::internal::Templates<__VA_ARGS__> gtest_AllTests_;      \
   }                                                                         \
-  static const char* const GTEST_REGISTERED_TEST_NAMES_(                    \
-      SuiteName) GTEST_ATTRIBUTE_UNUSED_ =                                  \
+  GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED static const char* const            \
+  GTEST_REGISTERED_TEST_NAMES_(SuiteName) =                                 \
       GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).VerifyRegisteredTestNames( \
           GTEST_STRINGIFY_(SuiteName), __FILE__, __LINE__, #__VA_ARGS__)
 
@@ -303,22 +305,24 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);
   REGISTER_TYPED_TEST_SUITE_P
 #endif  // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
 
-#define INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, SuiteName, Types, ...)     \
-  static_assert(sizeof(GTEST_STRINGIFY_(Prefix)) > 1,                     \
-                "test-suit-prefix must not be empty");                    \
-  static bool gtest_##Prefix##_##SuiteName GTEST_ATTRIBUTE_UNUSED_ =      \
-      ::testing::internal::TypeParameterizedTestSuite<                    \
-          SuiteName, GTEST_SUITE_NAMESPACE_(SuiteName)::gtest_AllTests_,  \
-          ::testing::internal::GenerateTypeList::type>::           \
-          Register(GTEST_STRINGIFY_(Prefix),                              \
-                   ::testing::internal::CodeLocation(__FILE__, __LINE__), \
-                   >EST_TYPED_TEST_SUITE_P_STATE_(SuiteName),           \
-                   GTEST_STRINGIFY_(SuiteName),                           \
-                   GTEST_REGISTERED_TEST_NAMES_(SuiteName),               \
-                   ::testing::internal::GenerateNames<                    \
-                       ::testing::internal::NameGeneratorSelector<        \
-                           __VA_ARGS__>::type,                            \
-                       ::testing::internal::GenerateTypeList::type>())
+#define INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, SuiteName, Types, ...)        \
+  static_assert(sizeof(GTEST_STRINGIFY_(Prefix)) > 1,                        \
+                "test-suit-prefix must not be empty");                       \
+  GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED static bool                          \
+      gtest_##Prefix##_##SuiteName =                                         \
+          ::testing::internal::TypeParameterizedTestSuite<                   \
+              SuiteName, GTEST_SUITE_NAMESPACE_(SuiteName)::gtest_AllTests_, \
+              ::testing::internal::GenerateTypeList::type>::          \
+              Register(                                                      \
+                  GTEST_STRINGIFY_(Prefix),                                  \
+                  ::testing::internal::CodeLocation(__FILE__, __LINE__),     \
+                  >EST_TYPED_TEST_SUITE_P_STATE_(SuiteName),               \
+                  GTEST_STRINGIFY_(SuiteName),                               \
+                  GTEST_REGISTERED_TEST_NAMES_(SuiteName),                   \
+                  ::testing::internal::GenerateNames<                        \
+                      ::testing::internal::NameGeneratorSelector<            \
+                          __VA_ARGS__>::type,                                \
+                      ::testing::internal::GenerateTypeList::type>())
 
 // Legacy API is deprecated but still available
 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h
index cffb8e114..7e55dc605 100644
--- a/googletest/include/gtest/internal/gtest-internal.h
+++ b/googletest/include/gtest/internal/gtest-internal.h
@@ -1501,7 +1501,8 @@ class NeverThrown {
                                                                                \
    private:                                                                    \
     void TestBody() override;                                                  \
-    static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_;      \
+    GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED static ::testing::TestInfo* const    \
+        test_info_;                                                            \
   };                                                                           \
                                                                                \
   ::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_suite_name,           \
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index 6c469e9be..4f0d89d04 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -194,8 +194,6 @@
 //
 // Macros for basic C++ coding:
 //   GTEST_AMBIGUOUS_ELSE_BLOCKER_ - for disabling a gcc warning.
-//   GTEST_ATTRIBUTE_UNUSED_  - declares that a class' instances or a
-//                              variable don't have to be used.
 //   GTEST_MUST_USE_RESULT_   - declares that a function's result must be used.
 //   GTEST_INTENTIONAL_CONST_COND_PUSH_ - start code section where MSVC C4127 is
 //                                        suppressed (constant conditional).
@@ -749,6 +747,20 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
 #define GTEST_HAVE_ATTRIBUTE_(x) 0
 #endif
 
+// GTEST_INTERNAL_HAVE_CPP_ATTRIBUTE
+//
+// A function-like feature checking macro that accepts C++11 style attributes.
+// It's a wrapper around `__has_cpp_attribute`, defined by ISO C++ SD-6
+// (https://en.cppreference.com/w/cpp/experimental/feature_test). If we don't
+// find `__has_cpp_attribute`, will evaluate to 0.
+#if defined(__has_cpp_attribute)
+// NOTE: requiring __cplusplus above should not be necessary, but
+// works around https://bugs.llvm.org/show_bug.cgi?id=23435.
+#define GTEST_INTERNAL_HAVE_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
+#else
+#define GTEST_INTERNAL_HAVE_CPP_ATTRIBUTE(x) 0
+#endif
+
 // GTEST_HAVE_FEATURE_
 //
 // A function-like feature checking macro that is a wrapper around
@@ -760,14 +772,22 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
 #endif
 
 // Use this annotation after a variable or parameter declaration to tell the
-// compiler the variable/parameter does not have to be used.
+// compiler the variable/parameter may be used.
 // Example:
 //
-//   GTEST_ATTRIBUTE_UNUSED_ int foo = bar();
-#if GTEST_HAVE_ATTRIBUTE_(unused)
-#define GTEST_ATTRIBUTE_UNUSED_ __attribute__((unused))
+//   GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED int foo = bar();
+//
+// This can be removed once we only support only C++17 or newer and
+// [[maybe_unused]] is available on all supported platforms.
+#if GTEST_INTERNAL_HAVE_CPP_ATTRIBUTE(maybe_unused)
+#define GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED [[maybe_unused]]
+#elif GTEST_HAVE_ATTRIBUTE_(unused)
+// This is inferior to [[maybe_unused]] as it can produce a
+// -Wused-but-marked-unused warning on optionally used symbols, but it is all we
+// have.
+#define GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED __attribute__((__unused__))
 #else
-#define GTEST_ATTRIBUTE_UNUSED_
+#define GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED
 #endif
 
 // Use this annotation before a function that takes a printf format string.
diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc
index edbe2ea26..5ded86507 100644
--- a/googletest/test/gtest_unittest.cc
+++ b/googletest/test/gtest_unittest.cc
@@ -2163,7 +2163,7 @@ class UnitTestRecordPropertyTestEnvironment : public Environment {
 };
 
 // This will test property recording outside of any test or test case.
-static Environment* record_property_env GTEST_ATTRIBUTE_UNUSED_ =
+GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED static Environment* record_property_env =
     AddGlobalTestEnvironment(new UnitTestRecordPropertyTestEnvironment);
 
 // This group of tests is for predicate assertions (ASSERT_PRED*, etc)
@@ -6705,8 +6705,9 @@ TEST(ColoredOutputTest, UsesColorsWhenTermSupportsColors) {
 
 // Verifies that StaticAssertTypeEq works in a namespace scope.
 
-static bool dummy1 GTEST_ATTRIBUTE_UNUSED_ = StaticAssertTypeEq();
-static bool dummy2 GTEST_ATTRIBUTE_UNUSED_ =
+GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED static bool dummy1 =
+    StaticAssertTypeEq();
+GTEST_INTERNAL_ATTRIBUTE_MAYBE_UNUSED static bool dummy2 =
     StaticAssertTypeEq();
 
 // Verifies that StaticAssertTypeEq works in a class.

From d83fee138a9ae6cb7c03688a2d08d4043a39815d Mon Sep 17 00:00:00 2001
From: Abseil Team 
Date: Thu, 25 Apr 2024 09:49:37 -0700
Subject: [PATCH 336/336] Adds "IWYU pragma: export" to gtest-param-util.h

PiperOrigin-RevId: 628105419
Change-Id: I364e8089b62050c44059e208b610e324eb5a656d
---
 googletest/include/gtest/gtest-param-test.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/googletest/include/gtest/gtest-param-test.h b/googletest/include/gtest/gtest-param-test.h
index 6847b6461..55ee088b9 100644
--- a/googletest/include/gtest/gtest-param-test.h
+++ b/googletest/include/gtest/gtest-param-test.h
@@ -178,7 +178,7 @@ TEST_P(DerivedTest, DoesBlah) {
 #include 
 
 #include "gtest/internal/gtest-internal.h"
-#include "gtest/internal/gtest-param-util.h"
+#include "gtest/internal/gtest-param-util.h"  // IWYU pragma: export
 #include "gtest/internal/gtest-port.h"
 
 namespace testing {