From 72901486ba39f8f4df9d0386b0521b711ef374a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Travert?= Date: Sun, 26 Jun 2022 18:59:46 +0200 Subject: [PATCH 1/9] Avoid implicit conversion from int to char --- googlemock/src/gmock-internal-utils.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googlemock/src/gmock-internal-utils.cc b/googlemock/src/gmock-internal-utils.cc index 0a74841f..2d7c5c4e 100644 --- a/googlemock/src/gmock-internal-utils.cc +++ b/googlemock/src/gmock-internal-utils.cc @@ -201,7 +201,7 @@ GTEST_API_ void IllegalDoDefault(const char* file, int line) { constexpr char UnBase64Impl(char c, const char* const base64, char carry) { return *base64 == 0 ? static_cast(65) : *base64 == c ? carry - : UnBase64Impl(c, base64 + 1, carry + 1); + : UnBase64Impl(c, base64 + 1, static_cast(carry + 1)); } template From 5eaa1139038076ed9bc029ab6518844a1b03ea7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Travert?= Date: Sun, 26 Jun 2022 19:01:00 +0200 Subject: [PATCH 2/9] Avoid implicit conversion from int to char --- googletest/src/gtest-printers.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/src/gtest-printers.cc b/googletest/src/gtest-printers.cc index f3976d23..d475ad36 100644 --- a/googletest/src/gtest-printers.cc +++ b/googletest/src/gtest-printers.cc @@ -315,7 +315,7 @@ void PrintTo(__uint128_t v, ::std::ostream* os) { low = low / 10 + high_mod * 1844674407370955161 + carry / 10; char digit = static_cast(carry % 10); - *--p = '0' + digit; + *--p = static_cast('0' + digit); } *os << p; } From 91c3669f21cf569f13bd15569b5411e6ca9a8961 Mon Sep 17 00:00:00 2001 From: Keith Smiley Date: Fri, 19 Aug 2022 11:10:56 -0700 Subject: [PATCH 3/9] 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 00000000..f93facf0 --- /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 b2dcab49..e61880f9 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 4eb5bbe4..f6eb9b7d 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 8f35df58..a5d6635a 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 afd902e992b720d1b3e106bc5e425a5768872265 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Fri, 26 Aug 2022 06:34:54 -0700 Subject: [PATCH 4/9] Consider all TERM values ending in "-256color" to be color supporting. In particular this handles TERM=hterm-256color correctly. PiperOrigin-RevId: 470232889 Change-Id: Iea594a3fde2b8b0a10e527956d70ba0bb3452e08 --- googletest/src/gtest.cc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 513a8878..81409a33 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -3245,18 +3245,15 @@ bool ShouldUseColor(bool stdout_is_tty) { #else // On non-Windows platforms, we rely on the TERM variable. const char* const term = posix::GetEnv("TERM"); - const bool term_supports_color = + const bool term_supports_color = term != nullptr && ( String::CStringEquals(term, "xterm") || String::CStringEquals(term, "xterm-color") || - String::CStringEquals(term, "xterm-256color") || String::CStringEquals(term, "screen") || - String::CStringEquals(term, "screen-256color") || String::CStringEquals(term, "tmux") || - String::CStringEquals(term, "tmux-256color") || String::CStringEquals(term, "rxvt-unicode") || - String::CStringEquals(term, "rxvt-unicode-256color") || String::CStringEquals(term, "linux") || - String::CStringEquals(term, "cygwin"); + String::CStringEquals(term, "cygwin") || + String::EndsWithCaseInsensitive(term, "-256color")); return stdout_is_tty && term_supports_color; #endif // GTEST_OS_WINDOWS } From 0e0d9feefab1b51aaab9dfd70132e93c0b6964e5 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Thu, 1 Sep 2022 07:24:20 -0700 Subject: [PATCH 5/9] 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 f565d980..b568aefe 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 6/9] 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 b1343fdc..92d8eb9d 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 7/9] 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 8a11d864..5be298d3 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 8/9] 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 f93facf0..00000000 --- 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 e61880f9..b2dcab49 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 f6eb9b7d..4eb5bbe4 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 a5d6635a..8f35df58 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 9/9] 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 b2dcab49..bcef926b 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 ...