From 067aa4c28bb1064f16312766f1b9688942d70a15 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Tue, 4 Dec 2018 14:47:24 +0100 Subject: [PATCH 01/15] Do not define GTEST_IS_THREADSAFE within GTEST_HAS_SEH --- googletest/include/gtest/internal/gtest-port.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 4cd74fb6..8d1b6191 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -785,13 +785,17 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; # define GTEST_HAS_SEH 0 # endif -#define GTEST_IS_THREADSAFE \ - (GTEST_HAS_MUTEX_AND_THREAD_LOCAL_ \ - || (GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT) \ - || GTEST_HAS_PTHREAD) - #endif // GTEST_HAS_SEH +#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) + +#endif // GTEST_IS_THREADSAFE + // GTEST_API_ qualifies all symbols that must be exported. The definitions below // are guarded by #ifndef to give embedders a chance to define GTEST_API_ in // gtest/internal/custom/gtest-port.h From 2c8ab3f18b2ed9fdc1742ec60b6e34248d04efe3 Mon Sep 17 00:00:00 2001 From: Chris Johnson Date: Tue, 4 Dec 2018 21:44:39 -0600 Subject: [PATCH 02/15] feat: Add initial support for PlatformIO and Arduino --- .travis.yml | 9 +++++++++ ci/build-platformio.sh | 2 ++ ci/install-platformio.sh | 5 +++++ googlemock/src/gmock_main.cc | 16 ++++++++++++++++ googletest/src/gtest_main.cc | 14 ++++++++++++++ platformio.ini | 31 +++++++++++++++++++++++++++++++ 6 files changed, 77 insertions(+) create mode 100644 ci/build-platformio.sh create mode 100644 ci/install-platformio.sh create mode 100644 platformio.ini diff --git a/.travis.yml b/.travis.yml index 2b0ac21a..74e1b8f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,12 @@ language: cpp # It is more tedious, but grants us far more flexibility. matrix: include: + - os: linux + dist: trusty + sudo: required + group: deprecated-2017Q3 + install: ./ci/install-platformio.sh + script: ./ci/build-platformio.sh - os: linux compiler: gcc sudo : true @@ -44,6 +50,9 @@ matrix: env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 if: type != pull_request +before_install: + - chmod -R +x ./ci/*.sh + # These are the install and build (script) phases for the most common entries in the matrix. They could be included # in each entry in the matrix, but that is just repetitive. install: diff --git a/ci/build-platformio.sh b/ci/build-platformio.sh new file mode 100644 index 00000000..1d7658d8 --- /dev/null +++ b/ci/build-platformio.sh @@ -0,0 +1,2 @@ +# run PlatformIO builds +platformio run diff --git a/ci/install-platformio.sh b/ci/install-platformio.sh new file mode 100644 index 00000000..4d7860a5 --- /dev/null +++ b/ci/install-platformio.sh @@ -0,0 +1,5 @@ +# install PlatformIO +sudo pip install -U platformio + +# update PlatformIO +platformio update diff --git a/googlemock/src/gmock_main.cc b/googlemock/src/gmock_main.cc index a3a271e6..50d0b426 100644 --- a/googlemock/src/gmock_main.cc +++ b/googlemock/src/gmock_main.cc @@ -32,6 +32,20 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" +#ifdef ARDUINO +void setup() { + int argc = 0; + char** argv = nullptr; + // Since Google Mock depends on Google Test, InitGoogleMock() is + // also responsible for initializing Google Test. Therefore there's + // no need for calling testing::InitGoogleTest() separately. + testing::InitGoogleMock(&argc, argv); +} +void loop() { + RUN_ALL_TESTS(); +} +#else + // MS C++ compiler/linker has a bug on Windows (not on Windows CE), which // causes a link error when _tmain is defined in a static library and UNICODE // is enabled. For this reason instead of _tmain, main function is used on @@ -52,3 +66,5 @@ GTEST_API_ int main(int argc, char** argv) { testing::InitGoogleMock(&argc, argv); return RUN_ALL_TESTS(); } +#endif + diff --git a/googletest/src/gtest_main.cc b/googletest/src/gtest_main.cc index 2113f621..0d343ba9 100644 --- a/googletest/src/gtest_main.cc +++ b/googletest/src/gtest_main.cc @@ -30,8 +30,22 @@ #include #include "gtest/gtest.h" +#ifdef ARDUINO +void setup() { + int argc = 0; + char** argv = nullptr; + testing::InitGoogleTest(&argc, argv); +} + +void loop() { + RUN_ALL_TESTS(); +} + +#else + GTEST_API_ int main(int argc, char **argv) { printf("Running main() from %s\n", __FILE__); testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } +#endif diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 00000000..3910026b --- /dev/null +++ b/platformio.ini @@ -0,0 +1,31 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; http://docs.platformio.org/page/projectconf.html + + +[platformio] +#src_dir = ./googlemock +#src_dir = ./googletest +src_dir = . + +[env:googletest_esp32] +platform = espressif32 +board = esp32dev +framework = arduino +build_flags = -I./googletest/include -I./googletest +src_filter = +<*> -<.git/> - - - - - - + + +upload_speed = 921600 + +[env:googlemock_esp32] +platform = espressif32 +board = esp32dev +framework = arduino +build_flags = -I./googlemock/include -I./googletest/include -I./googletest -I./googlemock +src_filter = +<*> -<.git/> - - - + + + +upload_speed = 921600 From 39c09043b83ea6a46407468c4733271334cdf1b4 Mon Sep 17 00:00:00 2001 From: Chris Johnson Date: Thu, 6 Dec 2018 12:35:06 -0600 Subject: [PATCH 03/15] chore: Add initial library.json config Added initial library.json config for PlatformIO Version will be synced to proper googletest version once the PIO library has been registered and proven out round trip. --- library.json | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 library.json diff --git a/library.json b/library.json new file mode 100644 index 00000000..0e35a61f --- /dev/null +++ b/library.json @@ -0,0 +1,51 @@ +{ + "name": "googletest", + "keywords": "unittest, unit, test, gtest, gmock", + "description": "googletest is a testing framework developed by the Testing Technology team with Google's specific requirements and constraints in mind. No matter whether you work on 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.", + "license": "BSD-3-Clause", + "homepage": "https://github.com/abseil/googletest/blob/master/README.md", + "repository": { + "type": "git", + "url": "https://github.com/abseil/googletest.git" + }, + "version": "0.0.1", + "exclude": [ + "ci", + "googlemock/build-aux", + "googlemock/cmake", + "googlemock/make", + "googlemock/msvc", + "googlemock/scripts", + "googlemock/test", + "googlemock/CMakeLists.txt", + "googlemock/Makefile.am", + "googlemock/configure.ac", + "googletest/cmake", + "googletest/codegear", + "googletest/m4", + "googletest/make", + "googletest/msvc", + "googletest/scripts", + "googletest/test", + "googletest/xcode", + "googletest/CMakeLists.txt", + "googletest/Makefile.am", + "googletest/configure.ac", + ], + "frameworks": "arduino", + "platforms": [ + "espressif32" + ], + "export": { + "include": [ + "googlemock/include/*", + "googletest/include/*" + ] + }, + "build": { + "flags": [ + "-I googlemock/include", + "-I googletest/include" + ] + } +} From d9251df84951768fa74cc0e01c3a76dbc1b2b0b1 Mon Sep 17 00:00:00 2001 From: Chris Johnson Date: Thu, 6 Dec 2018 15:26:28 -0600 Subject: [PATCH 04/15] fix: Remove global chmod from Travis Removed global chmod +x for Travis scripts in favor of just applying it to PlatformIO builds. --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 74e1b8f1..fd8f7c65 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ matrix: dist: trusty sudo: required group: deprecated-2017Q3 + before_install: chmod -R +x ./ci/*platformio.sh install: ./ci/install-platformio.sh script: ./ci/build-platformio.sh - os: linux @@ -50,9 +51,6 @@ matrix: env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 if: type != pull_request -before_install: - - chmod -R +x ./ci/*.sh - # These are the install and build (script) phases for the most common entries in the matrix. They could be included # in each entry in the matrix, but that is just repetitive. install: From 31eb5e9b873af4b509be2f77616113007fa0de9d Mon Sep 17 00:00:00 2001 From: Chris Johnson Date: Fri, 7 Dec 2018 12:24:01 -0600 Subject: [PATCH 05/15] chore: Update version to latest release --- library.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.json b/library.json index 0e35a61f..3104ec1e 100644 --- a/library.json +++ b/library.json @@ -8,7 +8,7 @@ "type": "git", "url": "https://github.com/abseil/googletest.git" }, - "version": "0.0.1", + "version": "1.8.1", "exclude": [ "ci", "googlemock/build-aux", From b5c08cb9f4f1673bd943cbaea87b827c228d08e6 Mon Sep 17 00:00:00 2001 From: Dominic Jodoin Date: Mon, 10 Dec 2018 12:58:45 -0500 Subject: [PATCH 06/15] Cache gcc and clang APT packages --- .travis.yml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2b0ac21a..2bcf752f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,6 +44,17 @@ matrix: env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 if: type != pull_request +before_install: + - | + if [ ! -f ${TRAVIS_BUILD_DIR}/apt-cache/pkgcache.bin ]; then + mkdir -p ${TRAVIS_BUILD_DIR}/apt-cache/archives/partial + mkdir -p ${TRAVIS_BUILD_DIR}/apt-cache/partial + mkdir -p ${TRAVIS_BUILD_DIR}/apt-cache/lists + sudo apt-get -y -o Dir::cache=${TRAVIS_BUILD_DIR}/apt-cache -o Dir::State::Lists=${TRAVIS_BUILD_DIR}/apt-cache/lists update + sudo apt-get install --download-only -o Dir::cache=${TRAVIS_BUILD_DIR}/apt-cache -o Dir::State::Lists=${TRAVIS_BUILD_DIR}/apt-cache/lists g++-4.9 clang-3.9 + fi + - sudo apt-get install --no-download -o Dir::cache=${TRAVIS_BUILD_DIR}/apt-cache -o Dir::State::Lists=${TRAVIS_BUILD_DIR}/apt-cache/lists g++-4.9 clang-3.9 + # These are the install and build (script) phases for the most common entries in the matrix. They could be included # in each entry in the matrix, but that is just repetitive. install: @@ -63,9 +74,13 @@ addons: sources: - ubuntu-toolchain-r-test - llvm-toolchain-precise-3.9 - packages: - - g++-4.9 - - clang-3.9 + +before_cache: + - sudo chown -R $USER ${TRAVIS_BUILD_DIR}/apt-cache + +cache: + directories: + - apt-cache notifications: email: false From 06bb8d4d6dcfd1a6111794467676500d955cb144 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Mon, 10 Dec 2018 22:46:47 -0500 Subject: [PATCH 07/15] Googletest export The gmock matchers have a concept of MatchAndExpain; where the details of the matching are written to a "result listener". A matcher can avoid creating expensive debug info by checking result_listener->IsInterested(); but, unfortunately, the default matcher code (called from EXPECT_THAT) is always "interested". This change implements EXPECT_THAT matching to first run the matcher in a "not interested" mode; and then run it a second time ("interested") only if the match fails. PiperOrigin-RevId: 224929783 --- googlemock/include/gmock/gmock-matchers.h | 14 +++- googlemock/test/gmock-matchers_test.cc | 89 +++++++++++++++++++++-- 2 files changed, 96 insertions(+), 7 deletions(-) diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index b859f1aa..68278bea 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -1296,14 +1296,24 @@ class PredicateFormatterFromMatcher { // We don't write MatcherCast either, as that allows // potentially unsafe downcasting of the matcher argument. const Matcher matcher = SafeMatcherCast(matcher_); - StringMatchResultListener listener; - if (MatchPrintAndExplain(x, matcher, &listener)) + + // The expected path here is that the matcher should match (i.e. that most + // tests pass) so optimize for this case. + if (matcher.Matches(x)) { return AssertionSuccess(); + } ::std::stringstream ss; ss << "Value of: " << value_text << "\n" << "Expected: "; matcher.DescribeTo(&ss); + + // Rerun the matcher to "PrintAndExain" the failure. + StringMatchResultListener listener; + if (MatchPrintAndExplain(x, matcher, &listener)) { + ss << "\n The matcher failed on the initial attempt; but passed when " + "rerun to generate the explanation."; + } ss << "\n Actual: " << listener.str(); return AssertionFailure() << ss.str(); } diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc index dd4931be..81819464 100644 --- a/googlemock/test/gmock-matchers_test.cc +++ b/googlemock/test/gmock-matchers_test.cc @@ -85,6 +85,7 @@ using std::pair; using std::set; using std::stringstream; using std::vector; +using testing::_; using testing::A; using testing::AllArgs; using testing::AllOf; @@ -110,12 +111,12 @@ using testing::Le; using testing::Lt; using testing::MakeMatcher; using testing::MakePolymorphicMatcher; -using testing::MatchResultListener; using testing::Matcher; using testing::MatcherCast; using testing::MatcherInterface; using testing::Matches; using testing::MatchesRegex; +using testing::MatchResultListener; using testing::NanSensitiveDoubleEq; using testing::NanSensitiveDoubleNear; using testing::NanSensitiveFloatEq; @@ -135,15 +136,14 @@ using testing::StartsWith; using testing::StrCaseEq; using testing::StrCaseNe; using testing::StrEq; -using testing::StrNe; using testing::StringMatchResultListener; +using testing::StrNe; using testing::Truly; using testing::TypedEq; using testing::UnorderedPointwise; using testing::Value; using testing::WhenSorted; using testing::WhenSortedBy; -using testing::_; using testing::internal::DummyMatchResultListener; using testing::internal::ElementMatcherPair; using testing::internal::ElementMatcherPairs; @@ -152,10 +152,11 @@ using testing::internal::FloatingEqMatcher; using testing::internal::FormatMatcherDescription; using testing::internal::IsReadableTypeName; using testing::internal::MatchMatrix; +using testing::internal::PredicateFormatterFromMatcher; using testing::internal::RE; using testing::internal::StreamMatchResultListener; -using testing::internal::Strings; using testing::internal::string; +using testing::internal::Strings; // For testing ExplainMatchResultTo(). class GreaterThanMatcher : public MatcherInterface { @@ -4932,7 +4933,7 @@ TYPED_TEST(ContainerEqTest, DuplicateDifference) { } #endif // GTEST_HAS_TYPED_TEST -// Tests that mutliple missing values are reported. +// Tests that multiple missing values are reported. // Using just vector here, so order is predictable. TEST(ContainerEqExtraTest, MultipleValuesMissing) { static const int vals[] = {1, 1, 2, 3, 5, 8}; @@ -6910,6 +6911,84 @@ TEST(ArgsTest, ExplainsMatchResultWithInnerExplanation) { Explain(m, std::make_tuple('\0', 42, 43))); } +class PredicateFormatterFromMatcherTest : public ::testing::Test { + protected: + enum Behavior { kInitialSuccess, kAlwaysFail, kFlaky }; + + // A matcher that can return different results when used multiple times on the + // same input. No real matcher should do this; but this lets us test that we + // detect such behavior and fail appropriately. + class MockMatcher : public MatcherInterface { + public: + bool MatchAndExplain(Behavior behavior, + MatchResultListener* listener) const override { + *listener << "[MatchAndExplain]"; + switch (behavior) { + case kInitialSuccess: + // The first call to MatchAndExplain should use a "not interested" + // listener; so this is expected to return |true|. There should be no + // subsequent calls. + return !listener->IsInterested(); + + case kAlwaysFail: + return false; + + case kFlaky: + // The first call to MatchAndExplain should use a "not interested" + // listener; so this will return |false|. Subsequent calls should have + // an "interested" listener; so this will return |true|, thus + // simulating a flaky matcher. + return listener->IsInterested(); + } + } + + void DescribeTo(ostream* os) const override { *os << "[DescribeTo]"; } + + void DescribeNegationTo(ostream* os) const override { + *os << "[DescribeNegationTo]"; + } + }; + + AssertionResult RunPredicateFormatter(Behavior behavior) { + auto matcher = MakeMatcher(new MockMatcher); + PredicateFormatterFromMatcher> predicate_formatter( + matcher); + return predicate_formatter("dummy-name", behavior); + } + + const std::string kMatcherType = + "testing::gmock_matchers_test::PredicateFormatterFromMatcherTest::" + "Behavior"; +}; + +TEST_F(PredicateFormatterFromMatcherTest, ShortCircuitOnSuccess) { + AssertionResult result = RunPredicateFormatter(kInitialSuccess); + EXPECT_TRUE(result); // Implicit cast to bool. + EXPECT_EQ("", result.message()); +} + +TEST_F(PredicateFormatterFromMatcherTest, NoShortCircuitOnFailure) { + AssertionResult result = RunPredicateFormatter(kAlwaysFail); + EXPECT_FALSE(result); // Implicit cast to bool. + std::string expect = + "Value of: dummy-name\nExpected: [DescribeTo]\n" + " Actual: 1" + + OfType(kMatcherType) + ", [MatchAndExplain]"; + EXPECT_EQ(expect, result.message()); +} + +TEST_F(PredicateFormatterFromMatcherTest, DetectsFlakyShortCircuit) { + AssertionResult result = RunPredicateFormatter(kFlaky); + EXPECT_FALSE(result); // Implicit cast to bool. + std::string expect = + "Value of: dummy-name\nExpected: [DescribeTo]\n" + " The matcher failed on the initial attempt; but passed when rerun to " + "generate the explanation.\n" + " Actual: 2" + + OfType(kMatcherType) + ", [MatchAndExplain]"; + EXPECT_EQ(expect, result.message()); +} + } // namespace gmock_matchers_test } // namespace testing From 6cbd3753dc195595689a0fbb99e7297128a2ed26 Mon Sep 17 00:00:00 2001 From: misterg Date: Tue, 11 Dec 2018 11:35:25 -0500 Subject: [PATCH 08/15] Googletest export rollback of 224929783 PiperOrigin-RevId: 225008559 --- googlemock/include/gmock/gmock-matchers.h | 14 +--- googlemock/test/gmock-matchers_test.cc | 89 ++--------------------- 2 files changed, 7 insertions(+), 96 deletions(-) diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index 68278bea..b859f1aa 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -1296,24 +1296,14 @@ class PredicateFormatterFromMatcher { // We don't write MatcherCast either, as that allows // potentially unsafe downcasting of the matcher argument. const Matcher matcher = SafeMatcherCast(matcher_); - - // The expected path here is that the matcher should match (i.e. that most - // tests pass) so optimize for this case. - if (matcher.Matches(x)) { + StringMatchResultListener listener; + if (MatchPrintAndExplain(x, matcher, &listener)) return AssertionSuccess(); - } ::std::stringstream ss; ss << "Value of: " << value_text << "\n" << "Expected: "; matcher.DescribeTo(&ss); - - // Rerun the matcher to "PrintAndExain" the failure. - StringMatchResultListener listener; - if (MatchPrintAndExplain(x, matcher, &listener)) { - ss << "\n The matcher failed on the initial attempt; but passed when " - "rerun to generate the explanation."; - } ss << "\n Actual: " << listener.str(); return AssertionFailure() << ss.str(); } diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc index 81819464..dd4931be 100644 --- a/googlemock/test/gmock-matchers_test.cc +++ b/googlemock/test/gmock-matchers_test.cc @@ -85,7 +85,6 @@ using std::pair; using std::set; using std::stringstream; using std::vector; -using testing::_; using testing::A; using testing::AllArgs; using testing::AllOf; @@ -111,12 +110,12 @@ using testing::Le; using testing::Lt; using testing::MakeMatcher; using testing::MakePolymorphicMatcher; +using testing::MatchResultListener; using testing::Matcher; using testing::MatcherCast; using testing::MatcherInterface; using testing::Matches; using testing::MatchesRegex; -using testing::MatchResultListener; using testing::NanSensitiveDoubleEq; using testing::NanSensitiveDoubleNear; using testing::NanSensitiveFloatEq; @@ -136,14 +135,15 @@ using testing::StartsWith; using testing::StrCaseEq; using testing::StrCaseNe; using testing::StrEq; -using testing::StringMatchResultListener; using testing::StrNe; +using testing::StringMatchResultListener; using testing::Truly; using testing::TypedEq; using testing::UnorderedPointwise; using testing::Value; using testing::WhenSorted; using testing::WhenSortedBy; +using testing::_; using testing::internal::DummyMatchResultListener; using testing::internal::ElementMatcherPair; using testing::internal::ElementMatcherPairs; @@ -152,11 +152,10 @@ using testing::internal::FloatingEqMatcher; using testing::internal::FormatMatcherDescription; using testing::internal::IsReadableTypeName; using testing::internal::MatchMatrix; -using testing::internal::PredicateFormatterFromMatcher; using testing::internal::RE; using testing::internal::StreamMatchResultListener; -using testing::internal::string; using testing::internal::Strings; +using testing::internal::string; // For testing ExplainMatchResultTo(). class GreaterThanMatcher : public MatcherInterface { @@ -4933,7 +4932,7 @@ TYPED_TEST(ContainerEqTest, DuplicateDifference) { } #endif // GTEST_HAS_TYPED_TEST -// Tests that multiple missing values are reported. +// Tests that mutliple missing values are reported. // Using just vector here, so order is predictable. TEST(ContainerEqExtraTest, MultipleValuesMissing) { static const int vals[] = {1, 1, 2, 3, 5, 8}; @@ -6911,84 +6910,6 @@ TEST(ArgsTest, ExplainsMatchResultWithInnerExplanation) { Explain(m, std::make_tuple('\0', 42, 43))); } -class PredicateFormatterFromMatcherTest : public ::testing::Test { - protected: - enum Behavior { kInitialSuccess, kAlwaysFail, kFlaky }; - - // A matcher that can return different results when used multiple times on the - // same input. No real matcher should do this; but this lets us test that we - // detect such behavior and fail appropriately. - class MockMatcher : public MatcherInterface { - public: - bool MatchAndExplain(Behavior behavior, - MatchResultListener* listener) const override { - *listener << "[MatchAndExplain]"; - switch (behavior) { - case kInitialSuccess: - // The first call to MatchAndExplain should use a "not interested" - // listener; so this is expected to return |true|. There should be no - // subsequent calls. - return !listener->IsInterested(); - - case kAlwaysFail: - return false; - - case kFlaky: - // The first call to MatchAndExplain should use a "not interested" - // listener; so this will return |false|. Subsequent calls should have - // an "interested" listener; so this will return |true|, thus - // simulating a flaky matcher. - return listener->IsInterested(); - } - } - - void DescribeTo(ostream* os) const override { *os << "[DescribeTo]"; } - - void DescribeNegationTo(ostream* os) const override { - *os << "[DescribeNegationTo]"; - } - }; - - AssertionResult RunPredicateFormatter(Behavior behavior) { - auto matcher = MakeMatcher(new MockMatcher); - PredicateFormatterFromMatcher> predicate_formatter( - matcher); - return predicate_formatter("dummy-name", behavior); - } - - const std::string kMatcherType = - "testing::gmock_matchers_test::PredicateFormatterFromMatcherTest::" - "Behavior"; -}; - -TEST_F(PredicateFormatterFromMatcherTest, ShortCircuitOnSuccess) { - AssertionResult result = RunPredicateFormatter(kInitialSuccess); - EXPECT_TRUE(result); // Implicit cast to bool. - EXPECT_EQ("", result.message()); -} - -TEST_F(PredicateFormatterFromMatcherTest, NoShortCircuitOnFailure) { - AssertionResult result = RunPredicateFormatter(kAlwaysFail); - EXPECT_FALSE(result); // Implicit cast to bool. - std::string expect = - "Value of: dummy-name\nExpected: [DescribeTo]\n" - " Actual: 1" + - OfType(kMatcherType) + ", [MatchAndExplain]"; - EXPECT_EQ(expect, result.message()); -} - -TEST_F(PredicateFormatterFromMatcherTest, DetectsFlakyShortCircuit) { - AssertionResult result = RunPredicateFormatter(kFlaky); - EXPECT_FALSE(result); // Implicit cast to bool. - std::string expect = - "Value of: dummy-name\nExpected: [DescribeTo]\n" - " The matcher failed on the initial attempt; but passed when rerun to " - "generate the explanation.\n" - " Actual: 2" + - OfType(kMatcherType) + ", [MatchAndExplain]"; - EXPECT_EQ(expect, result.message()); -} - } // namespace gmock_matchers_test } // namespace testing From ea5e941d84707918eadde0d6bc407978e5a6a2aa Mon Sep 17 00:00:00 2001 From: Dominic Jodoin Date: Tue, 11 Dec 2018 22:50:17 -0500 Subject: [PATCH 09/15] Change directory ownership earlier --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2bcf752f..e8a062ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -54,6 +54,7 @@ before_install: sudo apt-get install --download-only -o Dir::cache=${TRAVIS_BUILD_DIR}/apt-cache -o Dir::State::Lists=${TRAVIS_BUILD_DIR}/apt-cache/lists g++-4.9 clang-3.9 fi - sudo apt-get install --no-download -o Dir::cache=${TRAVIS_BUILD_DIR}/apt-cache -o Dir::State::Lists=${TRAVIS_BUILD_DIR}/apt-cache/lists g++-4.9 clang-3.9 + - sudo chown -R $USER ${TRAVIS_BUILD_DIR}/apt-cache # These are the install and build (script) phases for the most common entries in the matrix. They could be included # in each entry in the matrix, but that is just repetitive. @@ -75,9 +76,6 @@ addons: - ubuntu-toolchain-r-test - llvm-toolchain-precise-3.9 -before_cache: - - sudo chown -R $USER ${TRAVIS_BUILD_DIR}/apt-cache - cache: directories: - apt-cache From fc0f92676865ed3347ce3d7cecd64f51fa2bfe50 Mon Sep 17 00:00:00 2001 From: Dominic Jodoin Date: Tue, 11 Dec 2018 23:58:13 -0500 Subject: [PATCH 10/15] Don't cache APT packages on OS X/macOS --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index e8a062ed..13b861ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,15 +46,15 @@ matrix: before_install: - | - if [ ! -f ${TRAVIS_BUILD_DIR}/apt-cache/pkgcache.bin ]; then + if [ "$TRAVIS_OS_NAME" != "osx" ] && [ ! -f ${TRAVIS_BUILD_DIR}/apt-cache/pkgcache.bin ]; then mkdir -p ${TRAVIS_BUILD_DIR}/apt-cache/archives/partial mkdir -p ${TRAVIS_BUILD_DIR}/apt-cache/partial mkdir -p ${TRAVIS_BUILD_DIR}/apt-cache/lists sudo apt-get -y -o Dir::cache=${TRAVIS_BUILD_DIR}/apt-cache -o Dir::State::Lists=${TRAVIS_BUILD_DIR}/apt-cache/lists update sudo apt-get install --download-only -o Dir::cache=${TRAVIS_BUILD_DIR}/apt-cache -o Dir::State::Lists=${TRAVIS_BUILD_DIR}/apt-cache/lists g++-4.9 clang-3.9 fi - - sudo apt-get install --no-download -o Dir::cache=${TRAVIS_BUILD_DIR}/apt-cache -o Dir::State::Lists=${TRAVIS_BUILD_DIR}/apt-cache/lists g++-4.9 clang-3.9 - - sudo chown -R $USER ${TRAVIS_BUILD_DIR}/apt-cache + - [ "$TRAVIS_OS_NAME" != "osx" ] && sudo apt-get install --no-download -o Dir::cache=${TRAVIS_BUILD_DIR}/apt-cache -o Dir::State::Lists=${TRAVIS_BUILD_DIR}/apt-cache/lists g++-4.9 clang-3.9 + - [ "$TRAVIS_OS_NAME" != "osx" ] && sudo chown -R $USER ${TRAVIS_BUILD_DIR}/apt-cache # These are the install and build (script) phases for the most common entries in the matrix. They could be included # in each entry in the matrix, but that is just repetitive. From 3b1f43c2e7a5ce49792f240488a9fcb7fe92d36c Mon Sep 17 00:00:00 2001 From: Dominic Jodoin Date: Wed, 12 Dec 2018 00:01:07 -0500 Subject: [PATCH 11/15] Use if statements --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 13b861ef..8ea55db5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,8 +53,8 @@ before_install: sudo apt-get -y -o Dir::cache=${TRAVIS_BUILD_DIR}/apt-cache -o Dir::State::Lists=${TRAVIS_BUILD_DIR}/apt-cache/lists update sudo apt-get install --download-only -o Dir::cache=${TRAVIS_BUILD_DIR}/apt-cache -o Dir::State::Lists=${TRAVIS_BUILD_DIR}/apt-cache/lists g++-4.9 clang-3.9 fi - - [ "$TRAVIS_OS_NAME" != "osx" ] && sudo apt-get install --no-download -o Dir::cache=${TRAVIS_BUILD_DIR}/apt-cache -o Dir::State::Lists=${TRAVIS_BUILD_DIR}/apt-cache/lists g++-4.9 clang-3.9 - - [ "$TRAVIS_OS_NAME" != "osx" ] && sudo chown -R $USER ${TRAVIS_BUILD_DIR}/apt-cache + - if [ "$TRAVIS_OS_NAME" != "osx" ]; then sudo apt-get install --no-download -o Dir::cache=${TRAVIS_BUILD_DIR}/apt-cache -o Dir::State::Lists=${TRAVIS_BUILD_DIR}/apt-cache/lists g++-4.9 clang-3.9; fi + - if [ "$TRAVIS_OS_NAME" != "osx" ]; then sudo chown -R $USER ${TRAVIS_BUILD_DIR}/apt-cache; fi # These are the install and build (script) phases for the most common entries in the matrix. They could be included # in each entry in the matrix, but that is just repetitive. From 6ef59138137280ffb3c01f41f527abc2bd3249d0 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Tue, 11 Dec 2018 14:10:54 -0500 Subject: [PATCH 12/15] Googletest export The gmock matchers have a concept of MatchAndExpain; where the details of the matching are written to a "result listener". A matcher can avoid creating expensive debug info by checking result_listener->IsInterested(); but, unfortunately, the default matcher code (called from EXPECT_THAT) is always "interested". This change implements EXPECT_THAT matching to first run the matcher in a "not interested" mode; and then run it a second time ("interested") only if the match fails. PiperOrigin-RevId: 225036073 --- googlemock/include/gmock/gmock-matchers.h | 14 +++- googlemock/test/gmock-matchers_test.cc | 93 +++++++++++++++++++++-- 2 files changed, 100 insertions(+), 7 deletions(-) diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index b859f1aa..68278bea 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -1296,14 +1296,24 @@ class PredicateFormatterFromMatcher { // We don't write MatcherCast either, as that allows // potentially unsafe downcasting of the matcher argument. const Matcher matcher = SafeMatcherCast(matcher_); - StringMatchResultListener listener; - if (MatchPrintAndExplain(x, matcher, &listener)) + + // The expected path here is that the matcher should match (i.e. that most + // tests pass) so optimize for this case. + if (matcher.Matches(x)) { return AssertionSuccess(); + } ::std::stringstream ss; ss << "Value of: " << value_text << "\n" << "Expected: "; matcher.DescribeTo(&ss); + + // Rerun the matcher to "PrintAndExain" the failure. + StringMatchResultListener listener; + if (MatchPrintAndExplain(x, matcher, &listener)) { + ss << "\n The matcher failed on the initial attempt; but passed when " + "rerun to generate the explanation."; + } ss << "\n Actual: " << listener.str(); return AssertionFailure() << ss.str(); } diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc index dd4931be..c1589a40 100644 --- a/googlemock/test/gmock-matchers_test.cc +++ b/googlemock/test/gmock-matchers_test.cc @@ -85,6 +85,7 @@ using std::pair; using std::set; using std::stringstream; using std::vector; +using testing::_; using testing::A; using testing::AllArgs; using testing::AllOf; @@ -110,12 +111,12 @@ using testing::Le; using testing::Lt; using testing::MakeMatcher; using testing::MakePolymorphicMatcher; -using testing::MatchResultListener; using testing::Matcher; using testing::MatcherCast; using testing::MatcherInterface; using testing::Matches; using testing::MatchesRegex; +using testing::MatchResultListener; using testing::NanSensitiveDoubleEq; using testing::NanSensitiveDoubleNear; using testing::NanSensitiveFloatEq; @@ -135,15 +136,14 @@ using testing::StartsWith; using testing::StrCaseEq; using testing::StrCaseNe; using testing::StrEq; -using testing::StrNe; using testing::StringMatchResultListener; +using testing::StrNe; using testing::Truly; using testing::TypedEq; using testing::UnorderedPointwise; using testing::Value; using testing::WhenSorted; using testing::WhenSortedBy; -using testing::_; using testing::internal::DummyMatchResultListener; using testing::internal::ElementMatcherPair; using testing::internal::ElementMatcherPairs; @@ -152,10 +152,11 @@ using testing::internal::FloatingEqMatcher; using testing::internal::FormatMatcherDescription; using testing::internal::IsReadableTypeName; using testing::internal::MatchMatrix; +using testing::internal::PredicateFormatterFromMatcher; using testing::internal::RE; using testing::internal::StreamMatchResultListener; -using testing::internal::Strings; using testing::internal::string; +using testing::internal::Strings; // For testing ExplainMatchResultTo(). class GreaterThanMatcher : public MatcherInterface { @@ -4932,7 +4933,7 @@ TYPED_TEST(ContainerEqTest, DuplicateDifference) { } #endif // GTEST_HAS_TYPED_TEST -// Tests that mutliple missing values are reported. +// Tests that multiple missing values are reported. // Using just vector here, so order is predictable. TEST(ContainerEqExtraTest, MultipleValuesMissing) { static const int vals[] = {1, 1, 2, 3, 5, 8}; @@ -6910,6 +6911,88 @@ TEST(ArgsTest, ExplainsMatchResultWithInnerExplanation) { Explain(m, std::make_tuple('\0', 42, 43))); } +class PredicateFormatterFromMatcherTest : public ::testing::Test { + protected: + enum Behavior { kInitialSuccess, kAlwaysFail, kFlaky }; + + // A matcher that can return different results when used multiple times on the + // same input. No real matcher should do this; but this lets us test that we + // detect such behavior and fail appropriately. + class MockMatcher : public MatcherInterface { + public: + bool MatchAndExplain(Behavior behavior, + MatchResultListener* listener) const override { + *listener << "[MatchAndExplain]"; + switch (behavior) { + case kInitialSuccess: + // The first call to MatchAndExplain should use a "not interested" + // listener; so this is expected to return |true|. There should be no + // subsequent calls. + return !listener->IsInterested(); + + case kAlwaysFail: + return false; + + case kFlaky: + // The first call to MatchAndExplain should use a "not interested" + // listener; so this will return |false|. Subsequent calls should have + // an "interested" listener; so this will return |true|, thus + // simulating a flaky matcher. + return listener->IsInterested(); + } + + GTEST_LOG_(FATAL) << "This should never be reached"; + return false; + } + + void DescribeTo(ostream* os) const override { *os << "[DescribeTo]"; } + + void DescribeNegationTo(ostream* os) const override { + *os << "[DescribeNegationTo]"; + } + }; + + AssertionResult RunPredicateFormatter(Behavior behavior) { + auto matcher = MakeMatcher(new MockMatcher); + PredicateFormatterFromMatcher> predicate_formatter( + matcher); + return predicate_formatter("dummy-name", behavior); + } + + const std::string kMatcherType = + "testing::gmock_matchers_test::PredicateFormatterFromMatcherTest::" + "Behavior"; +}; + +TEST_F(PredicateFormatterFromMatcherTest, ShortCircuitOnSuccess) { + AssertionResult result = RunPredicateFormatter(kInitialSuccess); + EXPECT_TRUE(result); // Implicit cast to bool. + std::string expect; + EXPECT_EQ(expect, result.message()); +} + +TEST_F(PredicateFormatterFromMatcherTest, NoShortCircuitOnFailure) { + AssertionResult result = RunPredicateFormatter(kAlwaysFail); + EXPECT_FALSE(result); // Implicit cast to bool. + std::string expect = + "Value of: dummy-name\nExpected: [DescribeTo]\n" + " Actual: 1" + + OfType(kMatcherType) + ", [MatchAndExplain]"; + EXPECT_EQ(expect, result.message()); +} + +TEST_F(PredicateFormatterFromMatcherTest, DetectsFlakyShortCircuit) { + AssertionResult result = RunPredicateFormatter(kFlaky); + EXPECT_FALSE(result); // Implicit cast to bool. + std::string expect = + "Value of: dummy-name\nExpected: [DescribeTo]\n" + " The matcher failed on the initial attempt; but passed when rerun to " + "generate the explanation.\n" + " Actual: 2" + + OfType(kMatcherType) + ", [MatchAndExplain]"; + EXPECT_EQ(expect, result.message()); +} + } // namespace gmock_matchers_test } // namespace testing From 3949c403c0ed7c73ae0f67aae266cf1a2216e7ed Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Thu, 13 Dec 2018 14:04:11 -0500 Subject: [PATCH 13/15] Update README.md point build badge back to proper repo path --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c9b00d25..ac1a85db 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Google Test # -[![Build Status](https://api.travis-ci.org/abseil/googletest.svg?branch=master)](https://travis-ci.org/abseil/googletest) +[![Build Status](https://api.travis-ci.org/google/googletest.svg?branch=master)](https://travis-ci.org/google/googletest) [![Build status](https://ci.appveyor.com/api/projects/status/4o38plt0xbo1ubc8/branch/master?svg=true)](https://ci.appveyor.com/project/GoogleTestAppVeyor/googletest/branch/master) **Future Plans**: From 81f00260668d1124df94eb1266163043882db0ca Mon Sep 17 00:00:00 2001 From: misterg Date: Wed, 12 Dec 2018 15:24:04 -0500 Subject: [PATCH 14/15] Googletest export Internal Change PiperOrigin-RevId: 225231727 --- CONTRIBUTING.md | 4 ++-- googlemock/cmake/gmock.pc.in | 2 +- googlemock/cmake/gmock_main.pc.in | 2 +- googlemock/include/gmock/gmock-generated-actions.h | 2 +- googlemock/include/gmock/gmock-generated-actions.h.pump | 2 +- googlemock/include/gmock/gmock-generated-matchers.h | 2 +- googlemock/include/gmock/gmock-generated-matchers.h.pump | 2 +- googlemock/src/gmock-spec-builders.cc | 2 +- googlemock/test/gmock-spec-builders_test.cc | 2 +- googlemock/test/gmock_output_test_golden.txt | 8 ++++---- googletest/cmake/gtest.pc.in | 2 +- googletest/cmake/gtest_main.pc.in | 2 +- googletest/include/gtest/internal/gtest-port.h | 2 +- googletest/src/gtest-death-test.cc | 2 +- googletest/src/gtest.cc | 2 +- 15 files changed, 19 insertions(+), 19 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index db354eef..b52f8ee5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,7 +26,7 @@ If you are a Googler, you can either create an internal change or work on GitHub ## Contributing A Patch 1. Submit an issue describing your proposed change to the - [issue tracker](https://github.com/abseil/googletest). + [issue tracker](https://github.com/google/googletest). 1. Please don't mix more than one logical change per submittal, because it makes the history hard to follow. If you want to make a change that doesn't have a corresponding issue in the issue @@ -79,7 +79,7 @@ itself is a valuable contribution. To keep the source consistent, readable, diffable and easy to merge, we use a fairly rigid coding style, as defined by the [google-styleguide](https://github.com/google/styleguide) project. All patches will be expected to conform to the style outlined [here](https://google.github.io/styleguide/cppguide.html). -Use [.clang-format](https://github.com/abseil/googletest/blob/master/.clang-format) to check your formatting +Use [.clang-format](https://github.com/google/googletest/blob/master/.clang-format) to check your formatting ## Requirements for Contributors ### diff --git a/googlemock/cmake/gmock.pc.in b/googlemock/cmake/gmock.pc.in index fea0ea34..08e04547 100644 --- a/googlemock/cmake/gmock.pc.in +++ b/googlemock/cmake/gmock.pc.in @@ -5,7 +5,7 @@ includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ Name: gmock Description: GoogleMock (without main() function) Version: @PROJECT_VERSION@ -URL: https://github.com/abseil/googletest +URL: https://github.com/google/googletest Requires: gtest Libs: -L${libdir} -lgmock @CMAKE_THREAD_LIBS_INIT@ Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ @CMAKE_THREAD_LIBS_INIT@ diff --git a/googlemock/cmake/gmock_main.pc.in b/googlemock/cmake/gmock_main.pc.in index 3b24dc40..b22fe614 100644 --- a/googlemock/cmake/gmock_main.pc.in +++ b/googlemock/cmake/gmock_main.pc.in @@ -5,7 +5,7 @@ includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ Name: gmock_main Description: GoogleMock (with main() function) Version: @PROJECT_VERSION@ -URL: https://github.com/abseil/googletest +URL: https://github.com/google/googletest Requires: gmock Libs: -L${libdir} -lgmock_main @CMAKE_THREAD_LIBS_INIT@ Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ @CMAKE_THREAD_LIBS_INIT@ diff --git a/googlemock/include/gmock/gmock-generated-actions.h b/googlemock/include/gmock/gmock-generated-actions.h index 1e06213e..fac491b7 100644 --- a/googlemock/include/gmock/gmock-generated-actions.h +++ b/googlemock/include/gmock/gmock-generated-actions.h @@ -661,7 +661,7 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6, // MORE INFORMATION: // // To learn more about using these macros, please search for 'ACTION' on -// https://github.com/abseil/googletest/blob/master/googlemock/docs/CookBook.md +// https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md // An internal macro needed for implementing ACTION*(). #define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_\ diff --git a/googlemock/include/gmock/gmock-generated-actions.h.pump b/googlemock/include/gmock/gmock-generated-actions.h.pump index 4381d6b2..d38b1f92 100644 --- a/googlemock/include/gmock/gmock-generated-actions.h.pump +++ b/googlemock/include/gmock/gmock-generated-actions.h.pump @@ -289,7 +289,7 @@ $range j2 2..i // MORE INFORMATION: // // To learn more about using these macros, please search for 'ACTION' on -// https://github.com/abseil/googletest/blob/master/googlemock/docs/CookBook.md +// https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md $range i 0..n $range k 0..n-1 diff --git a/googlemock/include/gmock/gmock-generated-matchers.h b/googlemock/include/gmock/gmock-generated-matchers.h index b77b3f19..f9c927c1 100644 --- a/googlemock/include/gmock/gmock-generated-matchers.h +++ b/googlemock/include/gmock/gmock-generated-matchers.h @@ -261,7 +261,7 @@ // // To learn more about using these macros, please search for 'MATCHER' // on -// https://github.com/abseil/googletest/blob/master/googlemock/docs/CookBook.md +// https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md #define MATCHER(name, description)\ class name##Matcher {\ diff --git a/googlemock/include/gmock/gmock-generated-matchers.h.pump b/googlemock/include/gmock/gmock-generated-matchers.h.pump index 8be4869b..43a0c5fa 100644 --- a/googlemock/include/gmock/gmock-generated-matchers.h.pump +++ b/googlemock/include/gmock/gmock-generated-matchers.h.pump @@ -263,7 +263,7 @@ $$ }} This line fixes auto-indentation of the following code in Emacs. // // To learn more about using these macros, please search for 'MATCHER' // on -// https://github.com/abseil/googletest/blob/master/googlemock/docs/CookBook.md +// https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md $range i 0..n $for i diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index e832966f..5db774ed 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -291,7 +291,7 @@ void ReportUninterestingCall(CallReaction reaction, const std::string& msg) { "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/abseil/googletest/blob/master/googlemock/" + "https://github.com/google/googletest/blob/master/googlemock/" "docs/CookBook.md#" "knowing-when-to-expect for details.\n", stack_frames_to_skip); diff --git a/googlemock/test/gmock-spec-builders_test.cc b/googlemock/test/gmock-spec-builders_test.cc index 8427bf16..557abaea 100644 --- a/googlemock/test/gmock-spec-builders_test.cc +++ b/googlemock/test/gmock-spec-builders_test.cc @@ -2176,7 +2176,7 @@ class GMockVerboseFlagTest : public VerboseFlagPreservingFixture { "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/abseil/googletest/blob/master/googlemock/docs/" + "https://github.com/google/googletest/blob/master/googlemock/docs/" "CookBook.md#" "knowing-when-to-expect for details."; diff --git a/googlemock/test/gmock_output_test_golden.txt b/googlemock/test/gmock_output_test_golden.txt index de4afd2e..dbcb2118 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/abseil/googletest/blob/master/googlemock/docs/CookBook.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/master/googlemock/docs/CookBook.md#knowing-when-to-expect 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/abseil/googletest/blob/master/googlemock/docs/CookBook.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/master/googlemock/docs/CookBook.md#knowing-when-to-expect 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/abseil/googletest/blob/master/googlemock/docs/CookBook.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/master/googlemock/docs/CookBook.md#knowing-when-to-expect 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/abseil/googletest/blob/master/googlemock/docs/CookBook.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/master/googlemock/docs/CookBook.md#knowing-when-to-expect for details. [ OK ] GMockOutputTest.UninterestingCallWithDefaultAction [ RUN ] GMockOutputTest.ExplicitActionsRunOutWithDefaultAction diff --git a/googletest/cmake/gtest.pc.in b/googletest/cmake/gtest.pc.in index ad241882..9aae29e2 100644 --- a/googletest/cmake/gtest.pc.in +++ b/googletest/cmake/gtest.pc.in @@ -5,6 +5,6 @@ includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ Name: gtest Description: GoogleTest (without main() function) Version: @PROJECT_VERSION@ -URL: https://github.com/abseil/googletest +URL: https://github.com/google/googletest Libs: -L${libdir} -lgtest @CMAKE_THREAD_LIBS_INIT@ Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ @CMAKE_THREAD_LIBS_INIT@ diff --git a/googletest/cmake/gtest_main.pc.in b/googletest/cmake/gtest_main.pc.in index 9e41b583..915f2973 100644 --- a/googletest/cmake/gtest_main.pc.in +++ b/googletest/cmake/gtest_main.pc.in @@ -5,7 +5,7 @@ includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ Name: gtest_main Description: GoogleTest (with main() function) Version: @PROJECT_VERSION@ -URL: https://github.com/abseil/googletest +URL: https://github.com/google/googletest Requires: gtest Libs: -L${libdir} -lgtest_main @CMAKE_THREAD_LIBS_INIT@ Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ @CMAKE_THREAD_LIBS_INIT@ diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 42ff5c73..0637a23a 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -285,7 +285,7 @@ # define GTEST_FLAG_PREFIX_DASH_ "gtest-" # define GTEST_FLAG_PREFIX_UPPER_ "GTEST_" # define GTEST_NAME_ "Google Test" -# define GTEST_PROJECT_URL_ "https://github.com/abseil/googletest/" +# define GTEST_PROJECT_URL_ "https://github.com/google/googletest/" #endif // !defined(GTEST_DEV_EMAIL_) #if !defined(GTEST_INIT_GOOGLE_TEST_NAME_) diff --git a/googletest/src/gtest-death-test.cc b/googletest/src/gtest-death-test.cc index fb885e23..44247e81 100644 --- a/googletest/src/gtest-death-test.cc +++ b/googletest/src/gtest-death-test.cc @@ -246,7 +246,7 @@ static std::string DeathTestThreadWarning(size_t thread_count) { msg << "detected " << thread_count << " threads."; } msg << " See " - "https://github.com/abseil/googletest/blob/master/googletest/docs/" + "https://github.com/google/googletest/blob/master/googletest/docs/" "advanced.md#death-tests-and-threads" << " for more explanation and suggested solutions, especially if" << " this is the last message you see before your test times out."; diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index a5581f72..db90fe65 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -5363,7 +5363,7 @@ bool ShouldRunTestOnShard(int total_shards, int shard_index, int test_id) { // each TestCase and TestInfo object. // If shard_tests == true, further filters tests based on sharding // variables in the environment - see -// https://github.com/abseil/googletest/blob/master/googletest/docs/advanced.md +// https://github.com/google/googletest/blob/master/googletest/docs/advanced.md // . Returns the number of tests that should run. int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) { const Int32 total_shards = shard_tests == HONOR_SHARDING_PROTOCOL ? From c6cb7e033591528a5fe2c63157a0d8ce927740dc Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Thu, 13 Dec 2018 12:47:22 -0500 Subject: [PATCH 15/15] Googletest export Support skipped in XML and JSON output PiperOrigin-RevId: 225386540 --- googletest/src/gtest.cc | 4 +++- .../test/googletest-json-output-unittest.py | 18 +++++++++++++++++- googletest/test/gtest_xml_output_unittest.py | 19 +++++++++++-------- googletest/test/gtest_xml_output_unittest_.cc | 7 +++++++ 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index db90fe65..34641af3 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -3761,7 +3761,8 @@ void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream, } OutputXmlAttribute(stream, kTestcase, "status", - test_info.should_run() ? "run" : "notrun"); + result.Skipped() ? "skipped" : + test_info.should_run() ? "run" : "notrun"); OutputXmlAttribute(stream, kTestcase, "time", FormatTimeInMillisAsSeconds(result.elapsed_time())); OutputXmlAttribute(stream, kTestcase, "classname", test_case_name); @@ -4126,6 +4127,7 @@ void JsonUnitTestResultPrinter::OutputJsonTestInfo(::std::ostream* stream, } OutputJsonKey(stream, kTestcase, "status", + result.Skipped() ? "SKIPPED" : test_info.should_run() ? "RUN" : "NOTRUN", kIndent); OutputJsonKey(stream, kTestcase, "time", FormatTimeInMillisAsDuration(result.elapsed_time()), kIndent); diff --git a/googletest/test/googletest-json-output-unittest.py b/googletest/test/googletest-json-output-unittest.py index 57dcd5fa..b09b590e 100644 --- a/googletest/test/googletest-json-output-unittest.py +++ b/googletest/test/googletest-json-output-unittest.py @@ -57,7 +57,7 @@ else: STACK_TRACE_TEMPLATE = '' EXPECTED_NON_EMPTY = { - u'tests': 23, + u'tests': 24, u'failures': 4, u'disabled': 2, u'errors': 0, @@ -123,6 +123,22 @@ EXPECTED_NON_EMPTY = { } ] }, + { + u'name': u'SkippedTest', + u'tests': 1, + u'failures': 0, + u'disabled': 0, + u'errors': 0, + u'time': u'*', + u'testsuite': [ + { + u'name': u'Skipped', + u'status': u'SKIPPED', + u'time': u'*', + u'classname': u'SkippedTest' + } + ] + }, { u'name': u'MixedResultTest', u'tests': 3, diff --git a/googletest/test/gtest_xml_output_unittest.py b/googletest/test/gtest_xml_output_unittest.py index 8669f19e..ab733d1d 100755 --- a/googletest/test/gtest_xml_output_unittest.py +++ b/googletest/test/gtest_xml_output_unittest.py @@ -65,7 +65,7 @@ else: sys.argv.remove(NO_STACKTRACE_SUPPORT_FLAG) EXPECTED_NON_EMPTY_XML = """ - + @@ -108,6 +108,9 @@ Invalid characters in brackets []%(stack)s]]> + + + @@ -183,15 +186,15 @@ EXPECTED_SHARDED_TEST_XML = """ - - - - - - + + + + + + - + """ diff --git a/googletest/test/gtest_xml_output_unittest_.cc b/googletest/test/gtest_xml_output_unittest_.cc index 2ee88380..39d9b4ef 100644 --- a/googletest/test/gtest_xml_output_unittest_.cc +++ b/googletest/test/gtest_xml_output_unittest_.cc @@ -67,6 +67,13 @@ TEST_F(DisabledTest, DISABLED_test_not_run) { FAIL() << "Unexpected failure: Disabled test should not be run"; } +class SkippedTest : public Test { +}; + +TEST_F(SkippedTest, Skipped) { + GTEST_SKIP(); +} + TEST(MixedResultTest, Succeeds) { EXPECT_EQ(1, 1); ASSERT_EQ(1, 1);