From 08d76be4cc597863f6e6b43accbf299d0055ac54 Mon Sep 17 00:00:00 2001 From: Tobias Markus Date: Sun, 22 May 2016 18:35:47 +0200 Subject: [PATCH 01/33] Performance fixes reported by cppcheck --- googletest/test/gtest-param-test_test.cc | 8 ++++---- googletest/test/gtest_unittest.cc | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/googletest/test/gtest-param-test_test.cc b/googletest/test/gtest-param-test_test.cc index 8b278bb9..857f6c5e 100644 --- a/googletest/test/gtest-param-test_test.cc +++ b/googletest/test/gtest-param-test_test.cc @@ -141,7 +141,7 @@ void VerifyGenerator(const ParamGenerator& generator, << ", expected_values[i] is " << PrintValue(expected_values[i]) << ", *it is " << PrintValue(*it) << ", and 'it' is an iterator created with the copy constructor.\n"; - it++; + ++it; } EXPECT_TRUE(it == generator.end()) << "At the presumed end of sequence when accessing via an iterator " @@ -161,7 +161,7 @@ void VerifyGenerator(const ParamGenerator& generator, << ", expected_values[i] is " << PrintValue(expected_values[i]) << ", *it is " << PrintValue(*it) << ", and 'it' is an iterator created with the copy constructor.\n"; - it++; + ++it; } EXPECT_TRUE(it == generator.end()) << "At the presumed end of sequence when accessing via an iterator " @@ -196,7 +196,7 @@ TEST(IteratorTest, ParamIteratorConformsToForwardIteratorConcept) { << "element same as its source points to"; // Verifies that iterator assignment works as expected. - it++; + ++it; EXPECT_FALSE(*it == *it2); it2 = it; EXPECT_TRUE(*it == *it2) << "Assigned iterators must point to the " @@ -215,7 +215,7 @@ TEST(IteratorTest, ParamIteratorConformsToForwardIteratorConcept) { // Verifies that prefix and postfix operator++() advance an iterator // all the same. it2 = it; - it++; + ++it; ++it2; EXPECT_TRUE(*it == *it2); } diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index 88e94134..78257fb9 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -7655,7 +7655,7 @@ TEST(NativeArrayTest, MethodsWork) { EXPECT_EQ(0, *it); ++it; EXPECT_EQ(1, *it); - it++; + ++it; EXPECT_EQ(2, *it); ++it; EXPECT_EQ(na.end(), it); @@ -7703,4 +7703,3 @@ TEST(SkipPrefixTest, DoesNotSkipWhenPrefixDoesNotMatch) { EXPECT_FALSE(SkipPrefix("world!", &p)); EXPECT_EQ(str, p); } - From 68f19facc26aba2e1d3e73978b7daf9b0bfa3970 Mon Sep 17 00:00:00 2001 From: Claus Stovgaard Date: Tue, 30 Aug 2016 16:15:46 +0200 Subject: [PATCH 02/33] Moved the ignoring of *.pyc files to top level for also covering googlemock python scripts. --- .gitignore | 2 ++ googletest/.gitignore | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 googletest/.gitignore diff --git a/.gitignore b/.gitignore index ce310bc3..1da12d1c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ # Ignore CI build directory build/ +# python +*.pyc diff --git a/googletest/.gitignore b/googletest/.gitignore deleted file mode 100644 index 4b7be4b9..00000000 --- a/googletest/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# python -*.pyc From 194e3c810299d0f122111c33c403f85c882dfafd Mon Sep 17 00:00:00 2001 From: Gallaecio Date: Sat, 8 Oct 2016 22:17:31 +0200 Subject: [PATCH 03/33] Fix WhenSorted() documentation example --- googlemock/docs/CheatSheet.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googlemock/docs/CheatSheet.md b/googlemock/docs/CheatSheet.md index ef4451b8..c94c2dac 100644 --- a/googlemock/docs/CheatSheet.md +++ b/googlemock/docs/CheatSheet.md @@ -249,7 +249,7 @@ match them more flexibly, or get more informative messages, you can use: | `SizeIs(m)` | `argument` is a container whose size matches `m`. E.g. `SizeIs(2)` or `SizeIs(Lt(2))`. | | `UnorderedElementsAre(e0, e1, ..., en)` | `argument` has `n + 1` elements, and under some permutation each element matches an `ei` (for a different `i`), which can be a value or a matcher. 0 to 10 arguments are allowed. | | `UnorderedElementsAreArray({ e0, e1, ..., en })`, `UnorderedElementsAreArray(array)`, or `UnorderedElementsAreArray(array, count)` | The same as `UnorderedElementsAre()` except that the expected element values/matchers come from an initializer list, STL-style container, or C-style array. | -| `WhenSorted(m)` | When `argument` is sorted using the `<` operator, it matches container matcher `m`. E.g. `WhenSorted(UnorderedElementsAre(1, 2, 3))` verifies that `argument` contains elements `1`, `2`, and `3`, ignoring order. | +| `WhenSorted(m)` | When `argument` is sorted using the `<` operator, it matches container matcher `m`. E.g. `WhenSorted(ElementsAre(1, 2, 3))` verifies that `argument` contains elements `1`, `2`, and `3`, ignoring order. | | `WhenSortedBy(comparator, m)` | The same as `WhenSorted(m)`, except that the given comparator instead of `<` is used to sort `argument`. E.g. `WhenSortedBy(std::greater(), ElementsAre(3, 2, 1))`. | Notes: From fa892afcb9532fe559a067b49f31952c7a80c3c7 Mon Sep 17 00:00:00 2001 From: Olivier Clavel Date: Mon, 13 Feb 2017 14:59:00 +0100 Subject: [PATCH 04/33] Wrong version reported (1.7.0 should be 1.8.0) `gtest-config --version` reports wrong version. Made against master branch but please note that this affects tag release-1.8.0 and the distribution tarballs. --- googletest/configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/configure.ac b/googletest/configure.ac index cc592e15..254c8c4b 100644 --- a/googletest/configure.ac +++ b/googletest/configure.ac @@ -5,7 +5,7 @@ m4_include(m4/acx_pthread.m4) # "[1.0.1]"). It also asumes that there won't be any closing parenthesis # between "AC_INIT(" and the closing ")" including comments and strings. AC_INIT([Google C++ Testing Framework], - [1.7.0], + [1.8.0], [googletestframework@googlegroups.com], [gtest]) From b74070cfd90c57b3ef2f80c8a50ca5f505a9e3aa Mon Sep 17 00:00:00 2001 From: Olivier Clavel Date: Mon, 13 Feb 2017 22:15:22 +0100 Subject: [PATCH 05/33] googlemock version must be changed as well keep googletest and googlemock versions in sync --- googlemock/configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/googlemock/configure.ac b/googlemock/configure.ac index 3b740f20..1ed0767e 100644 --- a/googlemock/configure.ac +++ b/googlemock/configure.ac @@ -1,7 +1,7 @@ m4_include(../googletest/m4/acx_pthread.m4) AC_INIT([Google C++ Mocking Framework], - [1.7.0], + [1.8.0], [googlemock@googlegroups.com], [gmock]) @@ -101,7 +101,7 @@ AC_ARG_VAR([GTEST_VERSION], [The version of Google Test available.]) HAVE_BUILT_GTEST="no" -GTEST_MIN_VERSION="1.7.0" +GTEST_MIN_VERSION="1.8.0" AS_IF([test "x${enable_external_gtest}" = "xyes"], [# Begin filling in variables as we are able. From 6e1970e2376c14bf658eb88f655a054030353f9f Mon Sep 17 00:00:00 2001 From: Alyssa Wilk Date: Thu, 10 Aug 2017 09:41:09 -0400 Subject: [PATCH 06/33] Adding a flag option to change the default mock type --- .../include/gmock/gmock-spec-builders.h | 1 - googlemock/include/gmock/gmock.h | 1 + googlemock/src/gmock-spec-builders.cc | 3 +- googlemock/src/gmock.cc | 24 ++++++++++- googlemock/test/gmock-spec-builders_test.cc | 35 ++++++++++++++++ googlemock/test/gmock_test.cc | 41 +++++++++++++++++++ 6 files changed, 102 insertions(+), 3 deletions(-) diff --git a/googlemock/include/gmock/gmock-spec-builders.h b/googlemock/include/gmock/gmock-spec-builders.h index 39f72129..96802444 100644 --- a/googlemock/include/gmock/gmock-spec-builders.h +++ b/googlemock/include/gmock/gmock-spec-builders.h @@ -363,7 +363,6 @@ enum CallReaction { kAllow, kWarn, kFail, - kDefault = kWarn // By default, warn about uninteresting calls. }; } // namespace internal diff --git a/googlemock/include/gmock/gmock.h b/googlemock/include/gmock/gmock.h index 6735c71b..5764bc85 100644 --- a/googlemock/include/gmock/gmock.h +++ b/googlemock/include/gmock/gmock.h @@ -71,6 +71,7 @@ namespace testing { // Declares Google Mock flags that we want a user to use programmatically. GMOCK_DECLARE_bool_(catch_leaked_mocks); GMOCK_DECLARE_string_(verbose); +GMOCK_DECLARE_int32_(default_mock_behavior); // Initializes Google Mock. This must be called before running the // tests. In particular, it parses the command line for the flags diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index 2fa1ee4b..1fc8d988 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -648,7 +648,8 @@ internal::CallReaction Mock::GetReactionOnUninterestingCalls( GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) { internal::MutexLock l(&internal::g_gmock_mutex); return (g_uninteresting_call_reaction.count(mock_obj) == 0) ? - internal::kDefault : g_uninteresting_call_reaction[mock_obj]; + static_cast(GMOCK_FLAG(default_mock_behavior)) : + g_uninteresting_call_reaction[mock_obj]; } // Tells Google Mock to ignore mock_obj when checking for leaked mock diff --git a/googlemock/src/gmock.cc b/googlemock/src/gmock.cc index eac3d842..3c370510 100644 --- a/googlemock/src/gmock.cc +++ b/googlemock/src/gmock.cc @@ -48,6 +48,13 @@ GMOCK_DEFINE_string_(verbose, internal::kWarningVerbosity, " warning - prints warnings and errors.\n" " error - prints errors only."); +GMOCK_DEFINE_int32_(default_mock_behavior, 1, + "Controls the default behavior of mocks." + " Valid values:\n" + " 0 - by default, mocks act as NiceMocks.\n" + " 1 - by default, mocks act as NaggyMocks.\n" + " 2 - by default, mocks act as StrictMocks."); + namespace internal { // Parses a string as a command line flag. The string should have the @@ -120,6 +127,19 @@ static bool ParseGoogleMockStringFlag(const char* str, const char* flag, return true; } +static bool ParseGoogleMockIntFlag(const char* str, const char* flag, + int* value) { + // Gets the value of the flag as a string. + const char* const value_str = ParseGoogleMockFlagValue(str, flag, true); + + // Aborts if the parsing failed. + if (value_str == NULL) return false; + + // Sets *value to the value of the flag. + *value = atoi(value_str); + return true; +} + // The internal implementation of InitGoogleMock(). // // The type parameter CharType can be instantiated to either char or @@ -138,7 +158,9 @@ void InitGoogleMockImpl(int* argc, CharType** argv) { // Do we see a Google Mock flag? if (ParseGoogleMockBoolFlag(arg, "catch_leaked_mocks", &GMOCK_FLAG(catch_leaked_mocks)) || - ParseGoogleMockStringFlag(arg, "verbose", &GMOCK_FLAG(verbose))) { + ParseGoogleMockStringFlag(arg, "verbose", &GMOCK_FLAG(verbose)) || + ParseGoogleMockIntFlag(arg, "default_mock_behavior", + &GMOCK_FLAG(default_mock_behavior))) { // Yes. Shift the remainder of the argv list left by one. Note // that argv has (*argc + 1) elements, the last one always being // NULL. The following loop moves the trailing NULL element as diff --git a/googlemock/test/gmock-spec-builders_test.cc b/googlemock/test/gmock-spec-builders_test.cc index 389e0709..00cb1198 100644 --- a/googlemock/test/gmock-spec-builders_test.cc +++ b/googlemock/test/gmock-spec-builders_test.cc @@ -93,8 +93,11 @@ using testing::Sequence; using testing::SetArgPointee; using testing::internal::ExpectationTester; using testing::internal::FormatFileLocation; +using testing::internal::kAllow; using testing::internal::kErrorVerbosity; +using testing::internal::kFail; using testing::internal::kInfoVerbosity; +using testing::internal::kWarn; using testing::internal::kWarningVerbosity; using testing::internal::linked_ptr; @@ -691,6 +694,38 @@ TEST(ExpectCallSyntaxTest, WarnsOnTooFewActions) { b.DoB(); } +TEST(ExpectCallSyntaxTest, WarningIsErrorWithFlag) { + int original_behavior = testing::GMOCK_FLAG(default_mock_behavior); + + testing::GMOCK_FLAG(default_mock_behavior) = kAllow; + CaptureStdout(); + { + MockA a; + a.DoA(0); + } + std::string output = GetCapturedStdout(); + EXPECT_TRUE(output.empty()) << output; + + testing::GMOCK_FLAG(default_mock_behavior) = kWarn; + CaptureStdout(); + { + MockA a; + a.DoA(0); + } + std::string warning_output = GetCapturedStdout(); + EXPECT_PRED_FORMAT2(IsSubstring, "GMOCK WARNING", warning_output); + EXPECT_PRED_FORMAT2(IsSubstring, "Uninteresting mock function call", warning_output); + + testing::GMOCK_FLAG(default_mock_behavior) = kFail; + EXPECT_NONFATAL_FAILURE({ + MockA a; + a.DoA(0); + },"Uninteresting mock function call"); + + testing::GMOCK_FLAG(default_mock_behavior) = original_behavior; +} + + #endif // GTEST_HAS_STREAM_REDIRECTION // Tests the semantics of ON_CALL(). diff --git a/googlemock/test/gmock_test.cc b/googlemock/test/gmock_test.cc index d8d0c57b..28995345 100644 --- a/googlemock/test/gmock_test.cc +++ b/googlemock/test/gmock_test.cc @@ -40,6 +40,7 @@ #if !defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_) +using testing::GMOCK_FLAG(default_mock_behavior); using testing::GMOCK_FLAG(verbose); using testing::InitGoogleMock; @@ -103,6 +104,26 @@ TEST(InitGoogleMockTest, ParsesSingleFlag) { TestInitGoogleMock(argv, new_argv, "info"); } +TEST(InitGoogleMockTest, ParsesMultipleFlags) { + int old_default_behavior = GMOCK_FLAG(default_mock_behavior); + const wchar_t* argv[] = { + L"foo.exe", + L"--gmock_verbose=info", + L"--gmock_default_mock_behavior=2", + NULL + }; + + const wchar_t* new_argv[] = { + L"foo.exe", + NULL + }; + + TestInitGoogleMock(argv, new_argv, "info"); + EXPECT_EQ(2, GMOCK_FLAG(default_mock_behavior)); + EXPECT_NE(2, old_default_behavior); + GMOCK_FLAG(default_mock_behavior) = old_default_behavior; +} + TEST(InitGoogleMockTest, ParsesUnrecognizedFlag) { const char* argv[] = { "foo.exe", @@ -177,6 +198,26 @@ TEST(WideInitGoogleMockTest, ParsesSingleFlag) { TestInitGoogleMock(argv, new_argv, "info"); } +TEST(WideInitGoogleMockTest, ParsesMultipleFlags) { + int old_default_behavior = GMOCK_FLAG(default_mock_behavior); + const wchar_t* argv[] = { + L"foo.exe", + L"--gmock_verbose=info", + L"--gmock_default_mock_behavior=2", + NULL + }; + + const wchar_t* new_argv[] = { + L"foo.exe", + NULL + }; + + TestInitGoogleMock(argv, new_argv, "info"); + EXPECT_EQ(2, GMOCK_FLAG(default_mock_behavior)); + EXPECT_NE(2, old_default_behavior); + GMOCK_FLAG(default_mock_behavior) = old_default_behavior; +} + TEST(WideInitGoogleMockTest, ParsesUnrecognizedFlag) { const wchar_t* argv[] = { L"foo.exe", From a2803bc37dafdaad05b335e64a83aff03096a4ba Mon Sep 17 00:00:00 2001 From: Alyssa Wilk Date: Wed, 16 Aug 2017 12:43:26 -0400 Subject: [PATCH 07/33] Handling invalid flag values --- googlemock/src/gmock-spec-builders.cc | 9 ++++++++- googlemock/test/gmock-spec-builders_test.cc | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index 1fc8d988..a725d185 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -508,6 +508,13 @@ bool UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked() return expectations_met; } +CallReaction intToCallReaction(int mock_behavior) { + if (mock_behavior >= kAllow && mock_behavior <= kFail) { + return static_cast(mock_behavior); + } + return kWarn; +} + } // namespace internal // Class Mock. @@ -648,7 +655,7 @@ internal::CallReaction Mock::GetReactionOnUninterestingCalls( GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) { internal::MutexLock l(&internal::g_gmock_mutex); return (g_uninteresting_call_reaction.count(mock_obj) == 0) ? - static_cast(GMOCK_FLAG(default_mock_behavior)) : + internal::intToCallReaction(GMOCK_FLAG(default_mock_behavior)) : g_uninteresting_call_reaction[mock_obj]; } diff --git a/googlemock/test/gmock-spec-builders_test.cc b/googlemock/test/gmock-spec-builders_test.cc index 00cb1198..34088de1 100644 --- a/googlemock/test/gmock-spec-builders_test.cc +++ b/googlemock/test/gmock-spec-builders_test.cc @@ -722,6 +722,26 @@ TEST(ExpectCallSyntaxTest, WarningIsErrorWithFlag) { a.DoA(0); },"Uninteresting mock function call"); + // Out of bounds values are converted to kWarn + testing::GMOCK_FLAG(default_mock_behavior) = -1; + CaptureStdout(); + { + MockA a; + a.DoA(0); + } + warning_output = GetCapturedStdout(); + EXPECT_PRED_FORMAT2(IsSubstring, "GMOCK WARNING", warning_output); + EXPECT_PRED_FORMAT2(IsSubstring, "Uninteresting mock function call", warning_output); + testing::GMOCK_FLAG(default_mock_behavior) = 3; + CaptureStdout(); + { + MockA a; + a.DoA(0); + } + warning_output = GetCapturedStdout(); + EXPECT_PRED_FORMAT2(IsSubstring, "GMOCK WARNING", warning_output); + EXPECT_PRED_FORMAT2(IsSubstring, "Uninteresting mock function call", warning_output); + testing::GMOCK_FLAG(default_mock_behavior) = original_behavior; } From cb8ebf5c9a04e90e338483878e0cdb8f3fbaf6e1 Mon Sep 17 00:00:00 2001 From: Arkady Shapkin Date: Tue, 22 Aug 2017 00:13:23 +0300 Subject: [PATCH 08/33] Support x64 configuration for old VS2015 projects --- googlemock/msvc/2015/gmock.sln | 14 +++++ googlemock/msvc/2015/gmock.vcxproj | 65 +++++++++++++++++++- googlemock/msvc/2015/gmock_main.vcxproj | 65 +++++++++++++++++++- googlemock/msvc/2015/gmock_test.vcxproj | 79 ++++++++++++++++++++++++- 4 files changed, 216 insertions(+), 7 deletions(-) diff --git a/googlemock/msvc/2015/gmock.sln b/googlemock/msvc/2015/gmock.sln index c59e07fc..d4203a84 100644 --- a/googlemock/msvc/2015/gmock.sln +++ b/googlemock/msvc/2015/gmock.sln @@ -10,21 +10,35 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Debug|Win32.ActiveCfg = Debug|Win32 {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Debug|Win32.Build.0 = Debug|Win32 + {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Debug|x64.ActiveCfg = Debug|x64 + {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Debug|x64.Build.0 = Debug|x64 {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Release|Win32.ActiveCfg = Release|Win32 {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Release|Win32.Build.0 = Release|Win32 + {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Release|x64.ActiveCfg = Release|x64 + {34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Release|x64.Build.0 = Release|x64 {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Debug|Win32.ActiveCfg = Debug|Win32 {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Debug|Win32.Build.0 = Debug|Win32 + {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Debug|x64.ActiveCfg = Debug|x64 + {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Debug|x64.Build.0 = Debug|x64 {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Release|Win32.ActiveCfg = Release|Win32 {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Release|Win32.Build.0 = Release|Win32 + {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Release|x64.ActiveCfg = Release|x64 + {F10D22F8-AC7B-4213-8720-608E7D878CD2}.Release|x64.Build.0 = Release|x64 {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Debug|Win32.ActiveCfg = Debug|Win32 {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Debug|Win32.Build.0 = Debug|Win32 + {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Debug|x64.ActiveCfg = Debug|x64 + {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Debug|x64.Build.0 = Debug|x64 {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Release|Win32.ActiveCfg = Release|Win32 {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Release|Win32.Build.0 = Release|Win32 + {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Release|x64.ActiveCfg = Release|x64 + {E4EF614B-30DF-4954-8C53-580A0BF6B589}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/googlemock/msvc/2015/gmock.vcxproj b/googlemock/msvc/2015/gmock.vcxproj index d5ddd091..c6b56e61 100644 --- a/googlemock/msvc/2015/gmock.vcxproj +++ b/googlemock/msvc/2015/gmock.vcxproj @@ -5,10 +5,18 @@ Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + {34681F0D-CE45-415D-B5F2-5C662DFE3BD5} @@ -22,11 +30,22 @@ true v140 + + StaticLibrary + Unicode + true + v140 + StaticLibrary Unicode v140 + + StaticLibrary + Unicode + v140 + @@ -34,18 +53,34 @@ + + + + + + + + <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Platform)-$(Configuration)\ $(OutDir)$(ProjectName)\ - $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Platform)-$(Configuration)\ $(OutDir)$(ProjectName)\ + + $(SolutionDir)$(Platform)-$(Configuration)\ + $(OutDir)$(ProjectName)\ + + + $(SolutionDir)$(Platform)-$(Configuration)\ + $(OutDir)$(ProjectName)\ + Disabled @@ -60,6 +95,19 @@ ProgramDatabase + + + Disabled + ..\..\include;..\..;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + ProgramDatabase + + ..\..\include;..\..;%(AdditionalIncludeDirectories) @@ -71,11 +119,24 @@ ProgramDatabase + + + ..\..\include;..\..;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + MultiThreaded + + + Level3 + ProgramDatabase + + $(GTestDir);%(AdditionalIncludeDirectories) + $(GTestDir);%(AdditionalIncludeDirectories) $(GTestDir);%(AdditionalIncludeDirectories) + $(GTestDir);%(AdditionalIncludeDirectories) diff --git a/googlemock/msvc/2015/gmock_main.vcxproj b/googlemock/msvc/2015/gmock_main.vcxproj index 76cc68b9..42381dfa 100644 --- a/googlemock/msvc/2015/gmock_main.vcxproj +++ b/googlemock/msvc/2015/gmock_main.vcxproj @@ -5,10 +5,18 @@ Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + {E4EF614B-30DF-4954-8C53-580A0BF6B589} @@ -22,11 +30,22 @@ true v140 + + StaticLibrary + Unicode + true + v140 + StaticLibrary Unicode v140 + + StaticLibrary + Unicode + v140 + @@ -34,18 +53,34 @@ + + + + + + + + <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Platform)-$(Configuration)\ $(OutDir)$(ProjectName)\ - $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Platform)-$(Configuration)\ $(OutDir)$(ProjectName)\ + + $(SolutionDir)$(Platform)-$(Configuration)\ + $(OutDir)$(ProjectName)\ + + + $(SolutionDir)$(Platform)-$(Configuration)\ + $(OutDir)$(ProjectName)\ + Disabled @@ -60,6 +95,19 @@ ProgramDatabase + + + Disabled + ../../include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + ProgramDatabase + + ../../include;%(AdditionalIncludeDirectories) @@ -71,6 +119,17 @@ ProgramDatabase + + + ../../include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + MultiThreaded + + + Level3 + ProgramDatabase + + {34681f0d-ce45-415d-b5f2-5c662dfe3bd5} @@ -81,7 +140,9 @@ ../../include;%(AdditionalIncludeDirectories) + ../../include;%(AdditionalIncludeDirectories) ../../include;%(AdditionalIncludeDirectories) + ../../include;%(AdditionalIncludeDirectories) diff --git a/googlemock/msvc/2015/gmock_test.vcxproj b/googlemock/msvc/2015/gmock_test.vcxproj index 76ea5534..01d1f201 100644 --- a/googlemock/msvc/2015/gmock_test.vcxproj +++ b/googlemock/msvc/2015/gmock_test.vcxproj @@ -5,10 +5,18 @@ Debug Win32 + + Debug + x64 + Release Win32 + + Release + x64 + {F10D22F8-AC7B-4213-8720-608E7D878CD2} @@ -22,11 +30,22 @@ true v140 + + Application + Unicode + true + v140 + Application Unicode v140 + + Application + Unicode + v140 + @@ -34,19 +53,37 @@ + + + + + + + + <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Platform)-$(Configuration)\ $(OutDir)$(ProjectName)\ true - $(SolutionDir)$(Configuration)\ + true + $(SolutionDir)$(Platform)-$(Configuration)\ $(OutDir)$(ProjectName)\ false + false + + + $(SolutionDir)$(Platform)-$(Configuration)\ + $(OutDir)$(ProjectName)\ + + + $(SolutionDir)$(Platform)-$(Configuration)\ + $(OutDir)$(ProjectName)\ @@ -68,10 +105,28 @@ MachineX86 + + + /bigobj %(AdditionalOptions) + Disabled + ..\..\include;..\..;$(GTestDir);%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + ProgramDatabase + + + true + Console + + /bigobj %(AdditionalOptions) - ..\..\include;..\..;%(AdditionalIncludeDirectories) + ..\..\include;..\..;$(GTestDir);%(AdditionalIncludeDirectories) WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) MultiThreaded @@ -87,6 +142,24 @@ MachineX86 + + + /bigobj %(AdditionalOptions) + ..\..\include;..\..;$(GTestDir);%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreaded + + + Level3 + ProgramDatabase + + + true + Console + true + true + + {e4ef614b-30df-4954-8c53-580a0bf6b589} From fa5d3b3845aa4cc38eef41c2e7ba0e98bfe15b39 Mon Sep 17 00:00:00 2001 From: Alyssa Wilk Date: Mon, 28 Aug 2017 16:13:41 -0400 Subject: [PATCH 09/33] Applying lint checks from upstream google3 --- googlemock/test/gmock-spec-builders_test.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/googlemock/test/gmock-spec-builders_test.cc b/googlemock/test/gmock-spec-builders_test.cc index 34088de1..c649bfd9 100644 --- a/googlemock/test/gmock-spec-builders_test.cc +++ b/googlemock/test/gmock-spec-builders_test.cc @@ -714,13 +714,14 @@ TEST(ExpectCallSyntaxTest, WarningIsErrorWithFlag) { } std::string warning_output = GetCapturedStdout(); EXPECT_PRED_FORMAT2(IsSubstring, "GMOCK WARNING", warning_output); - EXPECT_PRED_FORMAT2(IsSubstring, "Uninteresting mock function call", warning_output); + EXPECT_PRED_FORMAT2(IsSubstring, "Uninteresting mock function call", + warning_output); testing::GMOCK_FLAG(default_mock_behavior) = kFail; EXPECT_NONFATAL_FAILURE({ MockA a; a.DoA(0); - },"Uninteresting mock function call"); + }, "Uninteresting mock function call"); // Out of bounds values are converted to kWarn testing::GMOCK_FLAG(default_mock_behavior) = -1; @@ -731,7 +732,8 @@ TEST(ExpectCallSyntaxTest, WarningIsErrorWithFlag) { } warning_output = GetCapturedStdout(); EXPECT_PRED_FORMAT2(IsSubstring, "GMOCK WARNING", warning_output); - EXPECT_PRED_FORMAT2(IsSubstring, "Uninteresting mock function call", warning_output); + EXPECT_PRED_FORMAT2(IsSubstring, "Uninteresting mock function call", + warning_output); testing::GMOCK_FLAG(default_mock_behavior) = 3; CaptureStdout(); { @@ -740,7 +742,8 @@ TEST(ExpectCallSyntaxTest, WarningIsErrorWithFlag) { } warning_output = GetCapturedStdout(); EXPECT_PRED_FORMAT2(IsSubstring, "GMOCK WARNING", warning_output); - EXPECT_PRED_FORMAT2(IsSubstring, "Uninteresting mock function call", warning_output); + EXPECT_PRED_FORMAT2(IsSubstring, "Uninteresting mock function call", + warning_output); testing::GMOCK_FLAG(default_mock_behavior) = original_behavior; } From daaed2b6cb7ba4165636a7de20a691e4e78a7d38 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Mon, 14 Aug 2017 18:07:55 +0200 Subject: [PATCH 10/33] fix typo in comment and string (SetUpTestCase) --- googletest/test/gtest_unittest.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index 1d3c7c7a..0ae8e035 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -3115,13 +3115,13 @@ TEST(DISABLED_TestCase, DISABLED_TestShouldNotRun) { FAIL() << "Unexpected failure: Test in disabled test case should not be run."; } -// Check that when all tests in a test case are disabled, SetupTestCase() and +// Check that when all tests in a test case are disabled, SetUpTestCase() and // TearDownTestCase() are not called. class DisabledTestsTest : public Test { protected: static void SetUpTestCase() { FAIL() << "Unexpected failure: All tests disabled in test case. " - "SetupTestCase() should not be called."; + "SetUpTestCase() should not be called."; } static void TearDownTestCase() { From fe760e9c6d92f55c04c000ae65df2336ede42eea Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Tue, 29 Aug 2017 15:27:54 +0200 Subject: [PATCH 11/33] fix typo: xUnit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3efd2ebf..f858833d 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ in its interior [googletest/README.md](googletest/README.md) file. ## Features ## - * An [XUnit](https://en.wikipedia.org/wiki/XUnit) test framework. + * An [xUnit](https://en.wikipedia.org/wiki/XUnit) test framework. * Test discovery. * A rich set of assertions. * User-defined assertions. From 8364718500dac72c141aa55dcb2483177356717d Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Tue, 29 Aug 2017 16:35:41 +0200 Subject: [PATCH 12/33] remove non-existing gmock_build_samples switch --- travis.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/travis.sh b/travis.sh index bdecbd96..cb36e989 100755 --- a/travis.sh +++ b/travis.sh @@ -6,7 +6,6 @@ mkdir build || true mkdir build/$GTEST_TARGET || true cd build/$GTEST_TARGET cmake -Dgtest_build_samples=ON \ - -Dgmock_build_samples=ON \ -Dgtest_build_tests=ON \ -Dgmock_build_tests=ON \ -DCMAKE_CXX_FLAGS=$CXX_FLAGS \ From 4a451575895dc665db33cd940b47f38e804a291d Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Tue, 29 Aug 2017 17:04:15 +0200 Subject: [PATCH 13/33] switch on verbose make --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3204dfac..a8c27409 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,9 +36,9 @@ compiler: script: ./travis.sh env: matrix: - - GTEST_TARGET=googletest SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug VERBOSE_MAKE=true VERBOSE - - GTEST_TARGET=googlemock SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug VERBOSE_MAKE=true VERBOSE - - GTEST_TARGET=googlemock SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug CXX_FLAGS=-std=c++11 VERBOSE_MAKE=true VERBOSE + - GTEST_TARGET=googletest SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug VERBOSE=1 + - GTEST_TARGET=googlemock SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug VERBOSE=1 + - GTEST_TARGET=googlemock SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug VERBOSE=1 CXX_FLAGS=-std=c++11 # - GTEST_TARGET=googletest SHARED_LIB=ON STATIC_LIB=ON CMAKE_PKG=ON BUILD_TYPE=release VERBOSE_MAKE=false # - GTEST_TARGET=googlemock SHARED_LIB=ON STATIC_LIB=ON CMAKE_PKG=ON BUILD_TYPE=release VERBOSE_MAKE=false notifications: From d33861dca6fac5482f0c82a413a2571172d16fac Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Tue, 29 Aug 2017 17:41:26 +0200 Subject: [PATCH 14/33] run combined build only There is no need for separate 'googlemock' and 'googletest' builds, as the 'googlemock' build includes 'googletest' and it's unit tests. --- .travis.yml | 7 ++----- travis.sh | 5 ++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index a8c27409..c155e571 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,11 +36,8 @@ compiler: script: ./travis.sh env: matrix: - - GTEST_TARGET=googletest SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug VERBOSE=1 - - GTEST_TARGET=googlemock SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug VERBOSE=1 - - GTEST_TARGET=googlemock SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug VERBOSE=1 CXX_FLAGS=-std=c++11 -# - GTEST_TARGET=googletest SHARED_LIB=ON STATIC_LIB=ON CMAKE_PKG=ON BUILD_TYPE=release VERBOSE_MAKE=false -# - GTEST_TARGET=googlemock SHARED_LIB=ON STATIC_LIB=ON CMAKE_PKG=ON BUILD_TYPE=release VERBOSE_MAKE=false + - SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug VERBOSE=1 + - SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug VERBOSE=1 CXX_FLAGS=-std=c++11 notifications: email: false sudo: false diff --git a/travis.sh b/travis.sh index bdecbd96..1b23a3d4 100755 --- a/travis.sh +++ b/travis.sh @@ -3,13 +3,12 @@ set -evx env | sort mkdir build || true -mkdir build/$GTEST_TARGET || true -cd build/$GTEST_TARGET +cd build cmake -Dgtest_build_samples=ON \ -Dgmock_build_samples=ON \ -Dgtest_build_tests=ON \ -Dgmock_build_tests=ON \ -DCMAKE_CXX_FLAGS=$CXX_FLAGS \ - ../../$GTEST_TARGET + .. make CTEST_OUTPUT_ON_FAILURE=1 make test From 29c07aa9dbeb622a6f8f0d1d07c9f139e18b5dca Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Tue, 29 Aug 2017 21:19:45 +0200 Subject: [PATCH 15/33] remove Yob's comma mentioned in issue #1105 --- googlemock/docs/CookBook.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googlemock/docs/CookBook.md b/googlemock/docs/CookBook.md index 6ea7f3a9..fa2d2fd0 100644 --- a/googlemock/docs/CookBook.md +++ b/googlemock/docs/CookBook.md @@ -148,7 +148,7 @@ Note that the mock class doesn't define `AppendPacket()`, unlike the real class. That's fine as long as the test doesn't need to call it. Next, you need a way to say that you want to use -`ConcretePacketStream` in production code, and use `MockPacketStream` +`ConcretePacketStream` in production code and to use `MockPacketStream` in tests. Since the functions are not virtual and the two classes are unrelated, you must specify your choice at _compile time_ (as opposed to run time). From bb8399e1baf9d984894a54ba1e6e9e4d20c11a35 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Tue, 29 Aug 2017 21:20:46 +0200 Subject: [PATCH 16/33] use plural verb as mentioned in issue #1105 --- googlemock/docs/CookBook.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googlemock/docs/CookBook.md b/googlemock/docs/CookBook.md index fa2d2fd0..753c6dd3 100644 --- a/googlemock/docs/CookBook.md +++ b/googlemock/docs/CookBook.md @@ -706,7 +706,7 @@ type `m` accepts): 1. When both `T` and `U` are built-in arithmetic types (`bool`, integers, and floating-point numbers), the conversion from `T` to `U` is not lossy (in other words, any value representable by `T` can also be represented by `U`); and 1. When `U` is a reference, `T` must also be a reference (as the underlying matcher may be interested in the address of the `U` value). -The code won't compile if any of these conditions isn't met. +The code won't compile if any of these conditions aren't met. Here's one example: From c3d1d33560462c923f06adb8e9c2f77ffbafa46c Mon Sep 17 00:00:00 2001 From: Scott Graham Date: Tue, 29 Aug 2017 12:45:26 -0700 Subject: [PATCH 17/33] Detect Fuchsia, and set GTEST_HAS_PTHREAD on GTEST_OS_FUCHSIA --- googletest/include/gtest/internal/gtest-port-arch.h | 2 ++ googletest/include/gtest/internal/gtest-port.h | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/googletest/include/gtest/internal/gtest-port-arch.h b/googletest/include/gtest/internal/gtest-port-arch.h index f32fc06b..bb206167 100644 --- a/googletest/include/gtest/internal/gtest-port-arch.h +++ b/googletest/include/gtest/internal/gtest-port-arch.h @@ -69,6 +69,8 @@ # endif #elif defined __FreeBSD__ # define GTEST_OS_FREEBSD 1 +#elif defined __Fuchsia__ +# define GTEST_OS_FUCHSIA 1 #elif defined __linux__ # define GTEST_OS_LINUX 1 # if defined __ANDROID__ diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index c2a9f5f3..643beff9 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -122,6 +122,7 @@ // GTEST_OS_AIX - IBM AIX // GTEST_OS_CYGWIN - Cygwin // GTEST_OS_FREEBSD - FreeBSD +// GTEST_OS_FUCHSIA - Fuchsia // GTEST_OS_HPUX - HP-UX // GTEST_OS_LINUX - Linux // GTEST_OS_LINUX_ANDROID - Google Android @@ -607,8 +608,9 @@ 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) +#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) #endif // GTEST_HAS_PTHREAD #if GTEST_HAS_PTHREAD From cc246ecb5675983a879af97b0b466c6d7d64d308 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Wed, 30 Aug 2017 11:59:36 +0200 Subject: [PATCH 18/33] use build type set in .travis.yml The BUILD_TYPE variable of .travis.yml was ignored up to now. --- travis.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/travis.sh b/travis.sh index 1b23a3d4..819e366c 100755 --- a/travis.sh +++ b/travis.sh @@ -9,6 +9,7 @@ cmake -Dgtest_build_samples=ON \ -Dgtest_build_tests=ON \ -Dgmock_build_tests=ON \ -DCMAKE_CXX_FLAGS=$CXX_FLAGS \ + -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ .. make CTEST_OUTPUT_ON_FAILURE=1 make test From dae044d4b9869db985f32eeec78889440f646fb7 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Wed, 30 Aug 2017 12:00:24 +0200 Subject: [PATCH 19/33] use upper-case build type While cmake does not complain on build type 'debug', the cmake documentation always spells it 'Debug', so take this. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c155e571..417d2c51 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,8 +36,8 @@ compiler: script: ./travis.sh env: matrix: - - SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug VERBOSE=1 - - SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug VERBOSE=1 CXX_FLAGS=-std=c++11 + - SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=Debug VERBOSE=1 + - SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=Debug VERBOSE=1 CXX_FLAGS=-std=c++11 notifications: email: false sudo: false From f0c72bfe09af0c5b6d48eb48456e2c4fca8858d7 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Wed, 30 Aug 2017 12:19:59 +0200 Subject: [PATCH 20/33] fix SetUp/TearDownTestCase() in AdvancedGuide fixes issue #1087 --- googletest/docs/AdvancedGuide.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/googletest/docs/AdvancedGuide.md b/googletest/docs/AdvancedGuide.md index a454bf45..1076496d 100644 --- a/googletest/docs/AdvancedGuide.md +++ b/googletest/docs/AdvancedGuide.md @@ -1623,8 +1623,8 @@ printf("We are in test %s of test case %s.\n", ``` `current_test_info()` returns a null pointer if no test is running. In -particular, you cannot find the test case name in `TestCaseSetUp()`, -`TestCaseTearDown()` (where you know the test case name implicitly), or +particular, you cannot find the test case name in `SetUpTestCase()`, +`TearDownTestCase()` (where you know the test case name implicitly), or functions called from them. _Availability:_ Linux, Windows, Mac. From 7529c8aa05c281d51db4e22a533d9b201f461993 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Wed, 30 Aug 2017 12:48:28 +0200 Subject: [PATCH 21/33] remove obsolete comment regarding python tests on linux --- googletest/cmake/internal_utils.cmake | 2 -- 1 file changed, 2 deletions(-) diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index f0f54d02..fb1fb683 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -236,8 +236,6 @@ 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) - # We are not supporting Python tests on Linux yet as they consider - # all Linux environments to be google3 and try to use google3 features. if (PYTHONINTERP_FOUND) # ${CMAKE_BINARY_DIR} is known at configuration time, so we can # directly bind it from cmake. ${CTEST_CONFIGURATION_TYPE} is known From 73d58dd4c83883b46697798e978d576b28b1d24e Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Wed, 30 Aug 2017 12:59:06 +0200 Subject: [PATCH 22/33] ask cmake for per-configuration output subdir On single-configuration build systems as Makefile Generators, there is no subdirectory for the configuration in the build tree - therefore ask cmake for the subdir by using CMAKE_CFG_INTDIR, which is just '.' on single-configuration build systems (Linux et al.). --- googletest/cmake/internal_utils.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index fb1fb683..cdaeb7a1 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -245,7 +245,7 @@ function(py_test name) add_test( NAME ${name} COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py - --build_dir=${CMAKE_CURRENT_BINARY_DIR}/$) + --build_dir=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}) else (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1) add_test( ${name} From 47ad2993b68250d8fd5eb604d5a88ff976bb1a3e Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Wed, 30 Aug 2017 15:14:34 +0200 Subject: [PATCH 23/33] Revert "ask cmake for per-configuration output subdir" This reverts commit 73d58dd4c83883b46697798e978d576b28b1d24e. Unfortunately, ${CMAKE_CFG_INTDIR} is set during build only and doesn't help here. --- googletest/cmake/internal_utils.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index cdaeb7a1..fb1fb683 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -245,7 +245,7 @@ function(py_test name) add_test( NAME ${name} COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py - --build_dir=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}) + --build_dir=${CMAKE_CURRENT_BINARY_DIR}/$) else (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1) add_test( ${name} From 9ba7946bde6349d9fd8621d527137c226f69bd83 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Wed, 30 Aug 2017 19:17:26 +0200 Subject: [PATCH 24/33] create different python based tests for single and multi configuration build generators --- googletest/cmake/internal_utils.cmake | 30 +++++++++++++++++++-------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index fb1fb683..ec5d08c0 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -237,20 +237,32 @@ endfunction() # test/name.py. It does nothing if Python is not installed. function(py_test name) if (PYTHONINTERP_FOUND) - # ${CMAKE_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. if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1) - add_test( - NAME ${name} - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py - --build_dir=${CMAKE_CURRENT_BINARY_DIR}/$) + 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}/$) + 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}) + endif (CMAKE_CONFIGURATION_TYPES) else (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1) + # ${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} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py --build_dir=${CMAKE_CURRENT_BINARY_DIR}/\${CTEST_CONFIGURATION_TYPE}) endif (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1) - endif() + endif(PYTHONINTERP_FOUND) endfunction() From 0eb49f4d6b59c0f21707a84f87948ffdfb3ce809 Mon Sep 17 00:00:00 2001 From: Scott Graham Date: Wed, 30 Aug 2017 11:29:06 -0700 Subject: [PATCH 25/33] Note that it is preferable for Googlers to create a CL internally first --- googletest/docs/DevGuide.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/googletest/docs/DevGuide.md b/googletest/docs/DevGuide.md index 4333a8e0..7bd78888 100644 --- a/googletest/docs/DevGuide.md +++ b/googletest/docs/DevGuide.md @@ -101,6 +101,10 @@ Please do submit code. Here's what you need to do: 1. Sign a Contributor License Agreement. 1. Create a Pull Request in the usual way. +If you are a Googler, it is preferable to first create an internal change and +have it reviewed and submitted, and then create a trivial upstreaming pull +request here. See go/gmock-contribute. + ## Google Test Committers ## The current members of the Google Test engineering team are the only From c4e01616af01e0518b48aa12a488347a63e0839c Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Wed, 30 Aug 2017 14:50:40 -0400 Subject: [PATCH 26/33] removed internal link ( not allowed in OSS) --- googletest/docs/DevGuide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/docs/DevGuide.md b/googletest/docs/DevGuide.md index 7bd78888..cffbe8f5 100644 --- a/googletest/docs/DevGuide.md +++ b/googletest/docs/DevGuide.md @@ -103,7 +103,7 @@ Please do submit code. Here's what you need to do: If you are a Googler, it is preferable to first create an internal change and have it reviewed and submitted, and then create a trivial upstreaming pull -request here. See go/gmock-contribute. +request here. ## Google Test Committers ## From fa70b84ab51e9af75d5c6ce0299a3d1950bde686 Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Wed, 30 Aug 2017 14:51:36 -0400 Subject: [PATCH 27/33] Removed "Trivial" Who knows? may not be very trivial given the code drift between internal and OSS --- googletest/docs/DevGuide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/docs/DevGuide.md b/googletest/docs/DevGuide.md index cffbe8f5..88a3de9f 100644 --- a/googletest/docs/DevGuide.md +++ b/googletest/docs/DevGuide.md @@ -102,7 +102,7 @@ Please do submit code. Here's what you need to do: 1. Create a Pull Request in the usual way. If you are a Googler, it is preferable to first create an internal change and -have it reviewed and submitted, and then create a trivial upstreaming pull +have it reviewed and submitted, and then create an upstreaming pull request here. ## Google Test Committers ## From 5dde668e093151f334e47da8410c83d675f1be81 Mon Sep 17 00:00:00 2001 From: Arkadiy Shapkin Date: Mon, 5 Sep 2016 00:55:42 +0300 Subject: [PATCH 28/33] AppVeyor MinGW-w64 test build --- appveyor.yml | 89 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 53 insertions(+), 36 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index d613fd60..f129d7c5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,68 +4,85 @@ os: Visual Studio 2015 environment: matrix: - - Toolset: v140 - - Toolset: v120 - - Toolset: v110 - - Toolset: v100 + - compiler: msvc-14-seh + generator: "Visual Studio 14 2015" -platform: - - Win32 - - x64 + - compiler: msvc-14-seh + generator: "Visual Studio 14 2015 Win64" + + - compiler: msvc-12-seh + generator: "Visual Studio 12 2013" + + - compiler: msvc-12-seh + generator: "Visual Studio 12 2013 Win64" + + - compiler: msvc-11-seh + generator: "Visual Studio 11 2012" + + - compiler: msvc-11-seh + generator: "Visual Studio 11 2012 Win64" + + - compiler: msvc-10-seh + generator: "Visual Studio 10 2010" + + - compiler: gcc-5.3.0-posix + generator: "MinGW Makefiles" + cxx_path: 'C:\mingw-w64\i686-5.3.0-posix-dwarf-rt_v4-rev0\mingw32\bin' + + - compiler: gcc-6.3.0-posix + generator: "MinGW Makefiles" + cxx_path: 'C:\mingw-w64\i686-6.3.0-posix-dwarf-rt_v5-rev1\mingw32\bin' configuration: -# - Release - Debug + #- Release build: verbosity: minimal -artifacts: - - path: '_build/Testing/Temporary/*' - name: test_results - -before_build: +install: - ps: | - Write-Output "Configuration: $env:CONFIGURATION" - Write-Output "Platform: $env:PLATFORM" - $generator = switch ($env:TOOLSET) - { - "v140" {"Visual Studio 14 2015"} - "v120" {"Visual Studio 12 2013"} - "v110" {"Visual Studio 11 2012"} - "v100" {"Visual Studio 10 2010"} - } - if ($env:PLATFORM -eq "x64") - { - $generator = "$generator Win64" + Write-Output "Compiler: $env:compiler" + Write-Output "Generator: $env:generator" + + # git bash conflicts with MinGW makefiles + if ($env:generator -eq "MinGW Makefiles") { + $env:path = $env:path.replace("C:\Program Files\Git\usr\bin;", "") + if ($env:cxx_path -ne "") { + $env:path += ";$env:cxx_path" + } } build_script: - ps: | - if (($env:TOOLSET -eq "v100") -and ($env:PLATFORM -eq "x64")) - { - return - } md _build -Force | Out-Null cd _build - & cmake -G "$generator" -DCMAKE_CONFIGURATION_TYPES="Debug;Release" -Dgtest_build_tests=ON -Dgtest_build_samples=ON -Dgmock_build_tests=ON .. + $conf = if ($env:generator -eq "MinGW Makefiles") {"-DCMAKE_BUILD_TYPE=$env:configuration"} else {"-DCMAKE_CONFIGURATION_TYPES=Debug;Release"} + # Disable test for MinGW (gtest tests fail, gmock tests can not build) + $gtest_build_tests = if ($env:generator -eq "MinGW Makefiles") {"-Dgtest_build_tests=OFF"} else {"-Dgtest_build_tests=ON"} + $gmock_build_tests = if ($env:generator -eq "MinGW Makefiles") {"-Dgmock_build_tests=OFF"} else {"-Dgmock_build_tests=ON"} + & cmake -G "$env:generator" $conf -Dgtest_build_samples=ON $gtest_build_tests $gmock_build_tests .. if ($LastExitCode -ne 0) { throw "Exec: $ErrorMessage" } - & cmake --build . --config $env:CONFIGURATION + & cmake --build . --config $env:configuration if ($LastExitCode -ne 0) { throw "Exec: $ErrorMessage" } test_script: - ps: | - if (($env:Toolset -eq "v100") -and ($env:PLATFORM -eq "x64")) - { - return + if ($env:generator -eq "MinGW Makefiles") { + return # No test available for MinGW } - - & ctest -C $env:CONFIGURATION --output-on-failure + & ctest -C $env:configuration --timeout 300 --output-on-failure if ($LastExitCode -ne 0) { throw "Exec: $ErrorMessage" } + +artifacts: + - path: '_build/CMakeFiles/*.log' + name: logs + - path: '_build/Testing/**/*.xml' + name: test_results From 14cf7f574a4fac65525620e552577b7f57c9b867 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Thu, 31 Aug 2017 16:10:36 +0200 Subject: [PATCH 29/33] fix example's comment --- googletest/docs/FAQ.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/googletest/docs/FAQ.md b/googletest/docs/FAQ.md index 36f5f7fb..76c23727 100644 --- a/googletest/docs/FAQ.md +++ b/googletest/docs/FAQ.md @@ -1034,7 +1034,7 @@ namespace bar { TEST(CoolTest, DoSomething) { SUCCEED(); } -} // namespace foo +} // namespace bar ``` However, the following code is **not allowed** and will produce a runtime error from Google Test because the test methods are using different test fixture classes with the same test case name. @@ -1052,7 +1052,7 @@ class CoolTest : public ::testing::Test {}; // Fixture: bar::CoolTest TEST_F(CoolTest, DoSomething) { SUCCEED(); } -} // namespace foo +} // namespace bar ``` ## How do I build Google Testing Framework with Xcode 4? ## From e033d8c73de8d757fa30d22626ae026f43be6bd5 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Thu, 31 Aug 2017 18:12:17 +0200 Subject: [PATCH 30/33] change links from former code.google.com to current github repository --- googlemock/README.md | 6 +++--- googlemock/docs/DevGuide.md | 4 ++-- 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/scripts/fuse_gmock_files.py | 2 +- googletest/docs/PumpManual.md | 2 +- googletest/scripts/fuse_gtest_files.py | 2 +- googletest/src/gtest.cc | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/googlemock/README.md b/googlemock/README.md index f0ea6a0e..f941f158 100644 --- a/googlemock/README.md +++ b/googlemock/README.md @@ -78,7 +78,7 @@ posting a question on the Google Mock is not a testing framework itself. Instead, it needs a testing framework for writing tests. Google Mock works seamlessly -with [Google Test](http://code.google.com/p/googletest/), but +with [Google Test](https://github.com/google/googletest), but you can also use it with [any C++ testing framework](../../master/googlemock/docs/ForDummies.md#using-google-mock-with-any-testing-framework). ### Requirements for End Users ### @@ -333,8 +333,8 @@ may need to tweak your compiler and/or linker flags. Please see the If you have custom matchers defined using `MatcherInterface` or `MakePolymorphicMatcher()`, you'll need to update their definitions to use the new matcher API ( -[monomorphic](http://code.google.com/p/googlemock/wiki/CookBook#Writing_New_Monomorphic_Matchers), -[polymorphic](http://code.google.com/p/googlemock/wiki/CookBook#Writing_New_Polymorphic_Matchers)). +[monomorphic](./docs/CookBook.md#writing-new-monomorphic-matchers), +[polymorphic](./docs/CookBook.md#writing-new-polymorphic-matchers)). Matchers defined using `MATCHER()` or `MATCHER_P*()` aren't affected. ### Developing Google Mock ### diff --git a/googlemock/docs/DevGuide.md b/googlemock/docs/DevGuide.md index adb74fe1..cae07e70 100644 --- a/googlemock/docs/DevGuide.md +++ b/googlemock/docs/DevGuide.md @@ -64,7 +64,7 @@ compile it in the [README](../README.md) file. A mocking framework is of no good if itself is not thoroughly tested. Tests should be written for any new code, and changes should be verified to not break existing tests before they are submitted for -review. To perform the tests, follow the instructions in [README](http://code.google.com/p/googlemock/source/browse/trunk/README) and +review. To perform the tests, follow the instructions in [README](../README.md) and verify that there are no failures. # Contributing Code # @@ -98,7 +98,7 @@ to conform to the style outlined [here](https://google.github.io/styleguide/cppg Please do submit code. Here's what you need to do: 1. Normally you should make your change against the SVN trunk instead of a branch or a tag, as the latter two are for release control and should be treated mostly as read-only. - 1. Decide which code you want to submit. A submission should be a set of changes that addresses one issue in the [Google Mock issue tracker](http://code.google.com/p/googlemock/issues/list). 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 tracker, please create one. + 1. Decide which code you want to submit. A submission should be a set of changes that addresses one issue in the [Google Mock issue tracker](https://github.com/google/googletest/issues). 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 tracker, please create one. 1. Also, coordinate with team members that are listed on the issue in question. This ensures that work isn't being duplicated and communicating your plan early also generally leads to better patches. 1. Ensure that your code adheres to the [Google Mock source code style](#Coding_Style.md). 1. Ensure that there are unit tests for your code. diff --git a/googlemock/include/gmock/gmock-generated-actions.h b/googlemock/include/gmock/gmock-generated-actions.h index b5a889c0..be4ebe4f 100644 --- a/googlemock/include/gmock/gmock-generated-actions.h +++ b/googlemock/include/gmock/gmock-generated-actions.h @@ -875,7 +875,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 http://code.google.com/p/googlemock/wiki/CookBook. +// on 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 66d9f9d5..712f65d6 100644 --- a/googlemock/include/gmock/gmock-generated-actions.h.pump +++ b/googlemock/include/gmock/gmock-generated-actions.h.pump @@ -357,7 +357,7 @@ $range j2 2..i // MORE INFORMATION: // // To learn more about using these macros, please search for 'ACTION' -// on http://code.google.com/p/googlemock/wiki/CookBook. +// on 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 57056fd9..525f8a71 100644 --- a/googlemock/include/gmock/gmock-generated-matchers.h +++ b/googlemock/include/gmock/gmock-generated-matchers.h @@ -1376,7 +1376,7 @@ AnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) { // ================ // // To learn more about using these macros, please search for 'MATCHER' -// on http://code.google.com/p/googlemock/wiki/CookBook. +// on 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 de30c2c9..f91b1eab 100644 --- a/googlemock/include/gmock/gmock-generated-matchers.h.pump +++ b/googlemock/include/gmock/gmock-generated-matchers.h.pump @@ -587,7 +587,7 @@ $$ // show up in the generated code. // ================ // // To learn more about using these macros, please search for 'MATCHER' -// on http://code.google.com/p/googlemock/wiki/CookBook. +// on https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md $range i 0..n $for i diff --git a/googlemock/scripts/fuse_gmock_files.py b/googlemock/scripts/fuse_gmock_files.py index cb7fdf2f..9b6956f2 100755 --- a/googlemock/scripts/fuse_gmock_files.py +++ b/googlemock/scripts/fuse_gmock_files.py @@ -55,7 +55,7 @@ EXAMPLES This tool is experimental. In particular, it assumes that there is no conditional inclusion of Google Mock or Google Test headers. Please report any problems to googlemock@googlegroups.com. You can read -http://code.google.com/p/googlemock/wiki/CookBook for more +https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md for more information. """ diff --git a/googletest/docs/PumpManual.md b/googletest/docs/PumpManual.md index 109c7f2c..827bb24b 100644 --- a/googletest/docs/PumpManual.md +++ b/googletest/docs/PumpManual.md @@ -40,7 +40,7 @@ maintain. ## Highlights ## * The implementation is in a single Python script and thus ultra portable: no build or installation is needed and it works cross platforms. - * Pump tries to be smart with respect to [Google's style guide](http://code.google.com/p/google-styleguide/): it breaks long lines (easy to have when they are generated) at acceptable places to fit within 80 columns and indent the continuation lines correctly. + * Pump tries to be smart with respect to [Google's style guide](https://github.com/google/styleguide): it breaks long lines (easy to have when they are generated) at acceptable places to fit within 80 columns and indent the continuation lines correctly. * The format is human-readable and more concise than XML. * The format works relatively well with Emacs' C++ mode. diff --git a/googletest/scripts/fuse_gtest_files.py b/googletest/scripts/fuse_gtest_files.py index 3f3e9f36..9a5c8d36 100755 --- a/googletest/scripts/fuse_gtest_files.py +++ b/googletest/scripts/fuse_gtest_files.py @@ -52,7 +52,7 @@ EXAMPLES This tool is experimental. In particular, it assumes that there is no conditional inclusion of Google Test headers. Please report any problems to googletestframework@googlegroups.com. You can read -http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide for +https://github.com/google/googletest/blob/master/googletest/docs/AdvancedGuide.md for more information. """ diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index b6087f9b..2484caf5 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -4812,7 +4812,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 -// http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide. +// https://github.com/google/googletest/blob/master/googletest/docs/AdvancedGuide.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 1a62d1b088062a3d1869e4cd33e99ab02f6f44e6 Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Fri, 30 Dec 2016 10:46:39 +0300 Subject: [PATCH 31/33] CMake: use threads if allowed and found, not just if found. If the user's cmakelists.txt first look for threads using find_package(Threads), then set(gtest_disable_pthreads ON), and then include googletest. GoogleTest will not look for threads. But since they have already been found before in user's cmakelists, it will use them regardless. This helped me fix build issue in darktable-org/rawspeed on windows/MSYS2, even though there are threads, and they are usable, googletest build was failing with issues about AutoHandle. I was first looking for threads, and only then including googletest, so no matter the value of gtest_disable_pthreads, it failed. The other obvious solution is for user to first include googletest, and only then look for threads by himself. --- googlemock/CMakeLists.txt | 2 +- googletest/cmake/internal_utils.cmake | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/googlemock/CMakeLists.txt b/googlemock/CMakeLists.txt index bd759dfd..724fdd5f 100644 --- a/googlemock/CMakeLists.txt +++ b/googlemock/CMakeLists.txt @@ -164,7 +164,7 @@ if (gmock_build_tests) cxx_test(gmock_link_test gmock_main test/gmock_link2_test.cc) cxx_test(gmock_test gmock_main) - if (CMAKE_USE_PTHREADS_INIT) + if (DEFINED GTEST_HAS_PTHREAD) cxx_test(gmock_stress_test gmock) endif() diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index ec5d08c0..ce947337 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -48,10 +48,14 @@ endmacro() macro(config_compiler_and_linker) # Note: pthreads on MinGW is not supported, even if available # 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. set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads) + if (CMAKE_USE_PTHREADS_INIT) + set(GTEST_HAS_PTHREAD ON) + endif() endif() fix_default_compiler_settings_() @@ -126,7 +130,8 @@ macro(config_compiler_and_linker) set(cxx_no_rtti_flags "") endif() - if (CMAKE_USE_PTHREADS_INIT) # The pthreads library is available and allowed. + # The pthreads library is available and allowed? + if (DEFINED GTEST_HAS_PTHREAD) set(GTEST_HAS_PTHREAD_MACRO "-DGTEST_HAS_PTHREAD=1") else() set(GTEST_HAS_PTHREAD_MACRO "-DGTEST_HAS_PTHREAD=0") @@ -159,7 +164,7 @@ function(cxx_library_with_type name type cxx_flags) PROPERTIES COMPILE_DEFINITIONS "GTEST_CREATE_SHARED_LIBRARY=1") endif() - if (CMAKE_USE_PTHREADS_INIT) + if (DEFINED GTEST_HAS_PTHREAD) target_link_libraries(${name} ${CMAKE_THREAD_LIBS_INIT}) endif() endfunction() From d96a038e8b2bce971192669f3ea3965612678633 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Mon, 4 Sep 2017 18:19:06 +0200 Subject: [PATCH 32/33] set MAKEFLAGS to use multiple processors on Travis CI --- travis.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/travis.sh b/travis.sh index bd226a8d..3a6c297a 100755 --- a/travis.sh +++ b/travis.sh @@ -1,5 +1,16 @@ #!/usr/bin/env sh set -evx + +# if possible, ask for the precise number of processors, +# otherwise take 2 processors as reasonable default; see +# https://docs.travis-ci.com/user/speeding-up-the-build/#Makefile-optimization +if [ -x /usr/bin/getconf ]; then + MAKEFLAGS=j$(/usr/bin/getconf _NPROCESSORS_ONLN) +else + MAKEFLAGS="j2" +fi +export MAKEFLAGS + env | sort mkdir build || true From fe97312e24effcf20554b0334be84619a7a30274 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Mon, 4 Sep 2017 18:56:52 +0200 Subject: [PATCH 33/33] limit processors to use in Travis build to 4 --- travis.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/travis.sh b/travis.sh index 3a6c297a..24a557e9 100755 --- a/travis.sh +++ b/travis.sh @@ -5,10 +5,19 @@ set -evx # otherwise take 2 processors as reasonable default; see # https://docs.travis-ci.com/user/speeding-up-the-build/#Makefile-optimization if [ -x /usr/bin/getconf ]; then - MAKEFLAGS=j$(/usr/bin/getconf _NPROCESSORS_ONLN) + NPROCESSORS=$(/usr/bin/getconf _NPROCESSORS_ONLN) else - MAKEFLAGS="j2" + NPROCESSORS=2 fi +# as of 2017-09-04 Travis CI reports 32 processors, but GCC build +# crashes if parallelized too much (maybe memory consumption problem), +# so limit to 4 processors for the time being. +if [ $NPROCESSORS -gt 4 ] ; then + echo "$0:Note: Limiting processors to use by make from $NPROCESSORS to 4." + NPROCESSORS=4 +fi +# Tell make to use the processors. No preceding '-' required. +MAKEFLAGS="j${NPROCESSORS}" export MAKEFLAGS env | sort