From 08d76be4cc597863f6e6b43accbf299d0055ac54 Mon Sep 17 00:00:00 2001 From: Tobias Markus Date: Sun, 22 May 2016 18:35:47 +0200 Subject: [PATCH 01/51] 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 8b278bb94b..857f6c5e53 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 88e94134b9..78257fb9cd 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/51] 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 ce310bc357..1da12d1cf6 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 4b7be4b91b..0000000000 --- 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/51] 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 ef4451b878..c94c2dac9e 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/51] 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 cc592e1583..254c8c4b31 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/51] 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 3b740f205e..1ed0767e91 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 8f04622cc1507a3954490a03a1dfcff9e340359e Mon Sep 17 00:00:00 2001 From: gpetit Date: Mon, 14 Aug 2017 13:45:27 -0400 Subject: [PATCH 06/51] Use GTEST_LOG instead of printf --- googletest/src/gtest.cc | 49 ++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index d882ab2e36..b8579d3cd2 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -2571,10 +2571,10 @@ void ReportInvalidTestCaseType(const char* test_case_name, << "probably rename one of the classes to put the tests into different\n" << "test cases."; - fprintf(stderr, "%s %s", - FormatFileLocation(code_location.file.c_str(), - code_location.line).c_str(), - errors.GetString().c_str()); + GTEST_LOG_(ERROR) + << FormatFileLocation(code_location.file.c_str(), + code_location.line), + << " " << errors.GetString(); } #endif // GTEST_HAS_PARAM_TEST @@ -3422,8 +3422,10 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener { XmlUnitTestResultPrinter::XmlUnitTestResultPrinter(const char* output_file) : output_file_(output_file) { if (output_file_.c_str() == NULL || output_file_.empty()) { - fprintf(stderr, "XML output file may not be null\n"); - fflush(stderr); + { + // scoped to make sure the log is flushed before we exit + GTEST_LOG_(FATAL) << "XML output file may not be null"; + } exit(EXIT_FAILURE); } } @@ -3449,10 +3451,10 @@ void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test, // 3. To interpret the meaning of errno in a thread-safe way, // we need the strerror_r() function, which is not available on // Windows. - fprintf(stderr, - "Unable to open file \"%s\"\n", - output_file_.c_str()); - fflush(stderr); + { // scoped to ensure the log is flushed before we exit + GTEST_LOG_(FATAL) << "Unable to open file \"" + << output_file_ << "\""; + } exit(EXIT_FAILURE); } std::stringstream stream; @@ -4403,9 +4405,9 @@ void UnitTestImpl::ConfigureXmlOutput() { listeners()->SetDefaultXmlGenerator(new XmlUnitTestResultPrinter( UnitTestOptions::GetAbsolutePathToOutputFile().c_str())); } else if (output_format != "") { - printf("WARNING: unrecognized output format \"%s\" ignored.\n", - output_format.c_str()); - fflush(stdout); + GTEST_LOG_(WARNING) << "WARNING: unrecognized output format \"" + << output_format + << "\" ignored."; } } @@ -4420,9 +4422,9 @@ void UnitTestImpl::ConfigureStreamingOutput() { listeners()->Append(new StreamingListener(target.substr(0, pos), target.substr(pos+1))); } else { - printf("WARNING: unrecognized streaming target \"%s\" ignored.\n", - target.c_str()); - fflush(stdout); + GTEST_LOG_(WARNING) << "unrecognized streaming target \"" + << target + << "\" ignored."; } } } @@ -4551,9 +4553,9 @@ static void TearDownEnvironment(Environment* env) { env->TearDown(); } bool UnitTestImpl::RunAllTests() { // Makes sure InitGoogleTest() was called. if (!GTestIsInitialized()) { - printf("%s", - "\nThis test program did NOT call ::testing::InitGoogleTest " - "before calling RUN_ALL_TESTS(). Please fix it.\n"); + GTEST_LOG_(ERROR) << + "\nThis test program did NOT call ::testing::InitGoogleTest " + "before calling RUN_ALL_TESTS(). Please fix it."; return false; } @@ -5253,10 +5255,11 @@ bool ParseGoogleTestFlag(const char* const arg) { void LoadFlagsFromFile(const std::string& path) { FILE* flagfile = posix::FOpen(path.c_str(), "r"); if (!flagfile) { - fprintf(stderr, - "Unable to open file \"%s\"\n", - GTEST_FLAG(flagfile).c_str()); - fflush(stderr); + { // scoped to ensure the log is flushed before we exit + GTEST_LOG_(FATAL) << "Unable to open file \"" + << GTEST_FLAG(flagfile) + << "\""; + } exit(EXIT_FAILURE); } std::string contents(ReadEntireFile(flagfile)); From ca76206f4268a009427afa96dfd792012db64583 Mon Sep 17 00:00:00 2001 From: gpetit Date: Mon, 14 Aug 2017 15:30:01 -0400 Subject: [PATCH 07/51] Removed extra colon in error log --- googletest/src/gtest.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 07b028b64d..b2d2a2827b 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -2571,7 +2571,7 @@ void ReportInvalidTestCaseType(const char* test_case_name, GTEST_LOG_(ERROR) << FormatFileLocation(code_location.file.c_str(), - code_location.line), + code_location.line) << " " << errors.GetString(); } #endif // GTEST_HAS_PARAM_TEST From b567aadd1b3eeccdb85305cdb65664f0245e90bc Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Tue, 9 May 2017 18:54:04 +0200 Subject: [PATCH 08/51] remove unused TestCase import --- googletest/samples/sample10_unittest.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/googletest/samples/sample10_unittest.cc b/googletest/samples/sample10_unittest.cc index 977e5ff6e7..10aa7620f0 100644 --- a/googletest/samples/sample10_unittest.cc +++ b/googletest/samples/sample10_unittest.cc @@ -38,7 +38,6 @@ using ::testing::EmptyTestEventListener; using ::testing::InitGoogleTest; using ::testing::Test; -using ::testing::TestCase; using ::testing::TestEventListeners; using ::testing::TestInfo; using ::testing::TestPartResult; From 8364718500dac72c141aa55dcb2483177356717d Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Tue, 29 Aug 2017 16:35:41 +0200 Subject: [PATCH 09/51] remove non-existing gmock_build_samples switch --- travis.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/travis.sh b/travis.sh index bdecbd964d..cb36e989b9 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 c3d1d33560462c923f06adb8e9c2f77ffbafa46c Mon Sep 17 00:00:00 2001 From: Scott Graham Date: Tue, 29 Aug 2017 12:45:26 -0700 Subject: [PATCH 10/51] 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 f32fc06b9b..bb206167ba 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 c2a9f5f371..643beff994 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 11/51] 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 1b23a3d4b9..819e366c7d 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 12/51] 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 c155e571d0..417d2c5121 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 7529c8aa05c281d51db4e22a533d9b201f461993 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Wed, 30 Aug 2017 12:48:28 +0200 Subject: [PATCH 13/51] 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 f0f54d0215..fb1fb6834e 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 14/51] 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 fb1fb6834e..cdaeb7a127 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 15/51] 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 cdaeb7a127..fb1fb6834e 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 16/51] 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 fb1fb6834e..ec5d08c0f6 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 17/51] 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 4333a8e087..7bd78888e5 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 18/51] 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 7bd78888e5..cffbe8f5a1 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 19/51] 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 cffbe8f5a1..88a3de9f89 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 20/51] AppVeyor MinGW-w64 test build --- appveyor.yml | 89 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 53 insertions(+), 36 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index d613fd6027..f129d7c548 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 21/51] 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 36f5f7fb39..76c237278d 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 22/51] 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 f0ea6a0e5a..f941f15836 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 adb74fe1dd..cae07e7027 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 b5a889c0c3..be4ebe4f06 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 66d9f9d551..712f65d62d 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 57056fd91d..525f8a71cb 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 de30c2c92b..f91b1eab6b 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 cb7fdf2f78..9b6956f2be 100755 --- a/googlemock/scripts/fuse_gmock_files.py +++ b/googlemock/scripts/fuse_gmock_files.py @@ -55,7 +55,7 @@ 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 109c7f2c7b..827bb24b04 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 3f3e9f36d6..9a5c8d367f 100755 --- a/googletest/scripts/fuse_gtest_files.py +++ b/googletest/scripts/fuse_gtest_files.py @@ -52,7 +52,7 @@ 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 b6087f9ba4..2484caf5db 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 23/51] 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 bd759dfd3e..724fdd5f05 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 ec5d08c0f6..ce94733704 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 d15b8b4524063e065263316e67e74a47f7dc4af2 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Wed, 30 Aug 2017 21:25:34 +0200 Subject: [PATCH 24/51] switch one build to Release mode This turns on optimization which allows the compiler to discover more problems and omit some more warnings. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 417d2c5121..81692dd949 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,7 +37,7 @@ 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=Release VERBOSE=1 CXX_FLAGS=-std=c++11 notifications: email: false sudo: false From 520ad96b78179fde7110ea29f7c22a6a9b32ed09 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Wed, 30 Aug 2017 21:42:33 +0200 Subject: [PATCH 25/51] treat all warnings as errors for GCC (-Werror) --- 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 ec5d08c0f6..0b41e3abad 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -94,7 +94,7 @@ macro(config_compiler_and_linker) set(cxx_no_exception_flags "-D_HAS_EXCEPTIONS=0") set(cxx_no_rtti_flags "-GR-") elseif (CMAKE_COMPILER_IS_GNUCXX) - set(cxx_base_flags "-Wall -Wshadow") + set(cxx_base_flags "-Wall -Wshadow -Werror") set(cxx_exception_flags "-fexceptions") set(cxx_no_exception_flags "-fno-exceptions") # Until version 4.3.2, GCC doesn't define a macro to indicate From e7c9e80e63e5cdcd3252ed81c9d3dbf0a7fb6841 Mon Sep 17 00:00:00 2001 From: Bernhard Bauer Date: Thu, 4 Feb 2016 11:50:08 +0000 Subject: [PATCH 26/51] Allow macros inside of parametrized test names. This allows doing things like TEST_P(TestFixture, MAYBE(TestName)) for nicer conditional test disabling. --- googletest/include/gtest/gtest-param-test.h | 15 +++++++++------ googletest/include/gtest/gtest-param-test.h.pump | 9 ++++++--- googletest/test/gtest-param-test_test.cc | 16 ++++++++++++++++ 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/googletest/include/gtest/gtest-param-test.h b/googletest/include/gtest/gtest-param-test.h index 038f9ba79e..e01c3ff6a3 100644 --- a/googletest/include/gtest/gtest-param-test.h +++ b/googletest/include/gtest/gtest-param-test.h @@ -1375,7 +1375,10 @@ internal::CartesianProductHolder10AddTestPattern(\ - #test_case_name, \ - #test_name, \ + GTEST_STRINGIFY_(test_case_name), \ + GTEST_STRINGIFY_(test_name), \ new ::testing::internal::TestMetaFactory< \ GTEST_TEST_CLASS_NAME_(\ test_case_name, test_name)>()); \ @@ -1412,11 +1415,11 @@ internal::CartesianProductHolder10, and return std::string. // // testing::PrintToStringParamName is a builtin test suffix generator that -// returns the value of testing::PrintToString(GetParam()). It does not work -// for std::string or C strings. +// returns the value of testing::PrintToString(GetParam()). // // Note: test names must be non-empty, unique, and may only contain ASCII -// alphanumeric characters or underscore. +// alphanumeric characters or underscore. Because PrintToString adds quotes +// to std::string and C strings, it won't work for these types. # define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator, ...) \ ::testing::internal::ParamGenerator \ diff --git a/googletest/include/gtest/gtest-param-test.h.pump b/googletest/include/gtest/gtest-param-test.h.pump index 3078d6d2a1..8ab18dd001 100644 --- a/googletest/include/gtest/gtest-param-test.h.pump +++ b/googletest/include/gtest/gtest-param-test.h.pump @@ -441,7 +441,10 @@ internal::CartesianProductHolder$i<$for j, [[Generator$j]]> Combine( ]] # endif // GTEST_HAS_COMBINE - +// Use a macro to stringify the test (case) name, because direct stringification +// does not work if one of the arguments is itself a macro +// (https://gcc.gnu.org/onlinedocs/cpp/Stringification.html). +# define GTEST_STRINGIFY_(name) #name # define TEST_P(test_case_name, test_name) \ class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \ @@ -456,8 +459,8 @@ internal::CartesianProductHolder$i<$for j, [[Generator$j]]> Combine( #test_case_name, \ ::testing::internal::CodeLocation(\ __FILE__, __LINE__))->AddTestPattern(\ - #test_case_name, \ - #test_name, \ + GTEST_STRINGIFY_(test_case_name), \ + GTEST_STRINGIFY_(test_name), \ new ::testing::internal::TestMetaFactory< \ GTEST_TEST_CLASS_NAME_(\ test_case_name, test_name)>()); \ diff --git a/googletest/test/gtest-param-test_test.cc b/googletest/test/gtest-param-test_test.cc index 857f6c5e53..a6ecef6528 100644 --- a/googletest/test/gtest-param-test_test.cc +++ b/googletest/test/gtest-param-test_test.cc @@ -809,6 +809,22 @@ TEST_P(NamingTest, TestsReportCorrectNamesAndParameters) { INSTANTIATE_TEST_CASE_P(ZeroToFiveSequence, NamingTest, Range(0, 5)); +// Tests that macros in test names are expanded correctly. +class MacroNamingTest : public TestWithParam {}; + +#define PREFIX_WITH_FOO(test_name) FOO_##test_name +#define PREFIX_WITH_MACRO(test_name) Macro##test_name + +TEST_P(PREFIX_WITH_MACRO(NamingTest), PREFIX_WITH_FOO(SomeTestName)) { + const ::testing::TestInfo* const test_info = + ::testing::UnitTest::GetInstance()->current_test_info(); + + EXPECT_STREQ("FortyTwo/MacroNamingTest", test_info->test_case_name()); + EXPECT_STREQ("FOO_SomeTestName", test_info->name()); +} + +INSTANTIATE_TEST_CASE_P(FortyTwo, MacroNamingTest, Values(42)); + // Tests that user supplied custom parameter names are working correctly. // Runs the test with a builtin helper method which uses PrintToString, // as well as a custom function and custom functor to ensure all possible From 86e5f0083e5217e37eb94a391a2f7349bcef4660 Mon Sep 17 00:00:00 2001 From: Bernhard Bauer Date: Wed, 10 Feb 2016 17:41:18 +0000 Subject: [PATCH 27/51] Add a non-parametrized test. --- googletest/test/gtest-param-test_test.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/googletest/test/gtest-param-test_test.cc b/googletest/test/gtest-param-test_test.cc index a6ecef6528..f6f59558c2 100644 --- a/googletest/test/gtest-param-test_test.cc +++ b/googletest/test/gtest-param-test_test.cc @@ -825,6 +825,18 @@ TEST_P(PREFIX_WITH_MACRO(NamingTest), PREFIX_WITH_FOO(SomeTestName)) { INSTANTIATE_TEST_CASE_P(FortyTwo, MacroNamingTest, Values(42)); +// Tests the same thing for non-parametrized tests. +class MacroNamingTestNonParametrized : public ::testing::Test {}; + +TEST_F(PREFIX_WITH_MACRO(NamingTestNonParametrized), + PREFIX_WITH_FOO(SomeTestName)) { + const ::testing::TestInfo* const test_info = + ::testing::UnitTest::GetInstance()->current_test_info(); + + EXPECT_STREQ("MacroNamingTestNonParametrized", test_info->test_case_name()); + EXPECT_STREQ("FOO_SomeTestName", test_info->name()); +} + // Tests that user supplied custom parameter names are working correctly. // Runs the test with a builtin helper method which uses PrintToString, // as well as a custom function and custom functor to ensure all possible From 8abacca52eeb9e9502b5cc2c3b4733d8adf3c42b Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Mon, 4 Sep 2017 13:23:08 +0200 Subject: [PATCH 28/51] avoid -Wshadow warning on GCC When using INSTANTIATE_TEST_CASE_P with a lambda function which uses 'info' as parameter name, GCC complains that this would shadow parameter 'info' used in the macro's VA_ARGS call. --- googletest/test/gtest-param-test_test.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/googletest/test/gtest-param-test_test.cc b/googletest/test/gtest-param-test_test.cc index 857f6c5e53..d1b0644f6f 100644 --- a/googletest/test/gtest-param-test_test.cc +++ b/googletest/test/gtest-param-test_test.cc @@ -857,8 +857,8 @@ TEST_P(CustomLambdaNamingTest, CustomTestNames) {} INSTANTIATE_TEST_CASE_P(CustomParamNameLambda, CustomLambdaNamingTest, Values(std::string("LambdaName")), - [](const ::testing::TestParamInfo& info) { - return info.param; + [](const ::testing::TestParamInfo& tpinfo) { + return tpinfo.param; }); #endif // GTEST_LANG_CXX11 From 55fd999adf5a8ecfcd502f07b0ea4b691ca7215f Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Wed, 30 Aug 2017 21:43:37 +0200 Subject: [PATCH 29/51] avoid warning about unused variable --- googletest/test/gtest_unittest.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index f84def90a8..78f3ee2b7c 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -2096,7 +2096,7 @@ class UnitTestRecordPropertyTestEnvironment : public Environment { }; // This will test property recording outside of any test or test case. -static Environment* record_property_env = +Environment* record_property_env = AddGlobalTestEnvironment(new UnitTestRecordPropertyTestEnvironment); // This group of tests is for predicate assertions (ASSERT_PRED*, etc) @@ -4188,6 +4188,12 @@ TEST(AssertionSyntaxTest, WorksWithConst) { } // namespace +// we don't use the variable further, just avoid compiler warning +// by defining a function which uses it +void dummy_use_of_record_property_env() { + (void) record_property_env; +} + namespace testing { // Tests that Google Test tracks SUCCEED*. From 48b06628803c56e90d110f4cd0ca2a11b3132196 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Sat, 2 Sep 2017 19:07:44 +0200 Subject: [PATCH 30/51] cache ccache --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 417d2c5121..e517782916 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,6 +30,7 @@ os: - linux - osx language: cpp +cache: ccache compiler: - gcc - clang From d96a038e8b2bce971192669f3ea3965612678633 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Mon, 4 Sep 2017 18:19:06 +0200 Subject: [PATCH 31/51] 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 bd226a8d5d..3a6c297a66 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 98f2f152539ed24cce004a14bbd1307215a925cc Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Mon, 4 Sep 2017 14:06:14 +0200 Subject: [PATCH 32/51] install ccache on travis osx build slave --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index e517782916..b7ee780b48 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,8 @@ install: - if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi # /usr/bin/clang is 3.4, lets override with modern one. - if [ "$CXX" = "clang++" ] && [ "$TRAVIS_OS_NAME" = "linux" ]; then export CXX="clang++-3.7" CC="clang-3.7"; fi +# ccache on OS X needs installation first +- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew install ccache; export PATH="/usr/local/opt/ccache/libexec:$PATH"; fi - echo ${PATH} - echo ${CXX} - ${CXX} --version From fe97312e24effcf20554b0334be84619a7a30274 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Mon, 4 Sep 2017 18:56:52 +0200 Subject: [PATCH 33/51] 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 3a6c297a66..24a557e98a 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 From e8c6942ac1570c9598cf2d177f6c69cc5ab2bd7b Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Tue, 5 Sep 2017 12:01:14 +0200 Subject: [PATCH 34/51] remove obsolete link_directories command It's not necessary, as the target_link_libraries command contains an absolute path already, and the path given doesn't exist anymore, leading only to linker warnings like: ld: warning: directory not found for option '-L/Users/travis/build/google/googletest/build/googlemock/gtest/src' --- googletest/CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/googletest/CMakeLists.txt b/googletest/CMakeLists.txt index 59343ed2b0..8391dbd019 100644 --- a/googletest/CMakeLists.txt +++ b/googletest/CMakeLists.txt @@ -75,9 +75,6 @@ include_directories( ${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR}) -# Where Google Test's libraries can be found. -link_directories(${gtest_BINARY_DIR}/src) - # Summary of tuple support for Microsoft Visual Studio: # Compiler version(MS) version(cmake) Support # ---------- ----------- -------------- ----------------------------- From 9a8794faed3c6a7c80205122d73d93dcb376dd57 Mon Sep 17 00:00:00 2001 From: Stepan Khapugin Date: Tue, 5 Sep 2017 14:10:53 +0200 Subject: [PATCH 35/51] add a cast --- googletest/include/gtest/gtest-printers.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h index fba7661483..129fc68e7e 100644 --- a/googletest/include/gtest/gtest-printers.h +++ b/googletest/include/gtest/gtest-printers.h @@ -137,7 +137,8 @@ class TypeWithoutFormatter { public: // This default version is called when kTypeKind is kOtherType. static void PrintValue(const T& value, ::std::ostream* os) { - PrintBytesInObjectTo(reinterpret_cast(&value), + PrintBytesInObjectTo(reinterpret_cast( + reinterpret_cast(&value)), sizeof(value), os); } }; From 83d8dd0e9c5e0ed212e88f006e7e752d9a44e616 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Tue, 5 Sep 2017 15:23:55 +0200 Subject: [PATCH 36/51] call clang via ccache on Linux --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b7ee780b48..c63909d90c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ install: # /usr/bin/gcc is 4.6 always, but gcc-X.Y is available. - if [ "$CXX" = "g++" ]; then export CXX="g++-4.9" CC="gcc-4.9"; fi # /usr/bin/clang is 3.4, lets override with modern one. -- if [ "$CXX" = "clang++" ] && [ "$TRAVIS_OS_NAME" = "linux" ]; then export CXX="clang++-3.7" CC="clang-3.7"; fi +- if [ "$CXX" = "clang++" ] && [ "$TRAVIS_OS_NAME" = "linux" ]; then export CXX="clang++-3.7" CC="clang-3.7"; ln -sf /usr/bin/ccache /$HOME/bin/$CXX; ln -sf /usr/bin/ccache /$HOME/bin/$CC; fi # ccache on OS X needs installation first - if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew install ccache; export PATH="/usr/local/opt/ccache/libexec:$PATH"; fi - echo ${PATH} From 56f8222a148d0089356063619362e5671bfa782b Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Tue, 5 Sep 2017 13:53:31 +0200 Subject: [PATCH 37/51] show ccache statistics in log --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index c63909d90c..31cea0a1ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,6 +33,9 @@ os: - osx language: cpp cache: ccache +before_cache: + # print statistics before uploading new cache + - ccache --show-stats compiler: - gcc - clang From dd8e4a635893a32dec691ab245c08f7311a2784b Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Tue, 5 Sep 2017 15:46:34 +0200 Subject: [PATCH 38/51] reset ccache statistics at install --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 31cea0a1ed..ad6dc19c8b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,8 @@ install: - if [ "$CXX" = "clang++" ] && [ "$TRAVIS_OS_NAME" = "linux" ]; then export CXX="clang++-3.7" CC="clang-3.7"; ln -sf /usr/bin/ccache /$HOME/bin/$CXX; ln -sf /usr/bin/ccache /$HOME/bin/$CC; fi # ccache on OS X needs installation first - if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew install ccache; export PATH="/usr/local/opt/ccache/libexec:$PATH"; fi +# reset ccache statistics +- ccache --zero-stats - echo ${PATH} - echo ${CXX} - ${CXX} --version From beca85ff4afb247e75ce0ba886ea461b01e788f8 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Tue, 5 Sep 2017 17:39:04 +0200 Subject: [PATCH 39/51] drop unused valgrind package from installation ... and remove explicit gcc installation (will be installed with g++ automatically) --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 417d2c5121..164bfae75f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,10 +22,8 @@ addons: - ubuntu-toolchain-r-test - llvm-toolchain-precise-3.7 packages: - - gcc-4.9 - g++-4.9 - clang-3.7 - - valgrind os: - linux - osx From be94bf501e649dfa6790b3cce2bbe300949b6e74 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Tue, 5 Sep 2017 17:45:48 +0200 Subject: [PATCH 40/51] remove unused variables from travis environment --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 417d2c5121..270946768c 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 + - BUILD_TYPE=Debug VERBOSE=1 + - BUILD_TYPE=Debug VERBOSE=1 CXX_FLAGS=-std=c++11 notifications: email: false sudo: false From f6dde80e94b982fa74b7da78e56263eee59e4887 Mon Sep 17 00:00:00 2001 From: Gasprd Petit Date: Thu, 7 Sep 2017 07:47:09 -0400 Subject: [PATCH 41/51] Removed flush scopes around GTEST_LOG(FATAL) and exit call since FATAL is expected to abort() --- googletest/src/gtest.cc | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 0895b42a81..fa170e756d 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -3449,11 +3449,7 @@ class XmlUnitTestResultPrinter : public EmptyTestEventListener { XmlUnitTestResultPrinter::XmlUnitTestResultPrinter(const char* output_file) : output_file_(output_file) { if (output_file_.c_str() == NULL || output_file_.empty()) { - { - // scoped to make sure the log is flushed before we exit - GTEST_LOG_(FATAL) << "XML output file may not be null"; - } - exit(EXIT_FAILURE); + GTEST_LOG_(FATAL) << "XML output file may not be null"; } } @@ -3478,11 +3474,8 @@ void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test, // 3. To interpret the meaning of errno in a thread-safe way, // we need the strerror_r() function, which is not available on // Windows. - { // scoped to ensure the log is flushed before we exit - GTEST_LOG_(FATAL) << "Unable to open file \"" - << output_file_ << "\""; - } - exit(EXIT_FAILURE); + GTEST_LOG_(FATAL) << "Unable to open file \"" + << output_file_ << "\""; } std::stringstream stream; PrintXmlUnitTest(&stream, unit_test); @@ -5283,12 +5276,9 @@ bool ParseGoogleTestFlag(const char* const arg) { void LoadFlagsFromFile(const std::string& path) { FILE* flagfile = posix::FOpen(path.c_str(), "r"); if (!flagfile) { - { // scoped to ensure the log is flushed before we exit - GTEST_LOG_(FATAL) << "Unable to open file \"" - << GTEST_FLAG(flagfile) - << "\""; - } - exit(EXIT_FAILURE); + GTEST_LOG_(FATAL) << "Unable to open file \"" + << GTEST_FLAG(flagfile) + << "\""; } std::string contents(ReadEntireFile(flagfile)); posix::FClose(flagfile); From 6c0146fd0075aae0beb394c19285a8869745cc2c Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Thu, 7 Sep 2017 17:33:19 +0200 Subject: [PATCH 42/51] use GTEST_ATTRIBUTE_UNUSED_ instead of dummy function --- googletest/test/gtest_unittest.cc | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index 78f3ee2b7c..745c9506a6 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -2096,7 +2096,7 @@ class UnitTestRecordPropertyTestEnvironment : public Environment { }; // This will test property recording outside of any test or test case. -Environment* record_property_env = +Environment* record_property_env GTEST_ATTRIBUTE_UNUSED_ = AddGlobalTestEnvironment(new UnitTestRecordPropertyTestEnvironment); // This group of tests is for predicate assertions (ASSERT_PRED*, etc) @@ -4188,12 +4188,6 @@ TEST(AssertionSyntaxTest, WorksWithConst) { } // namespace -// we don't use the variable further, just avoid compiler warning -// by defining a function which uses it -void dummy_use_of_record_property_env() { - (void) record_property_env; -} - namespace testing { // Tests that Google Test tracks SUCCEED*. From 4f68ab5b84dda2b364ea3350fc2a96d1cb15adf5 Mon Sep 17 00:00:00 2001 From: Alex Yursha <31780593+yursha@users.noreply.github.com> Date: Fri, 8 Sep 2017 17:20:59 -0700 Subject: [PATCH 43/51] Fix ellipsis position in examples --- googlemock/docs/ForDummies.md | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/googlemock/docs/ForDummies.md b/googlemock/docs/ForDummies.md index 0bf528e949..769105698c 100644 --- a/googlemock/docs/ForDummies.md +++ b/googlemock/docs/ForDummies.md @@ -217,7 +217,8 @@ The macro can be followed by some optional _clauses_ that provide more informati This syntax is designed to make an expectation read like English. For example, you can probably guess that ``` -using ::testing::Return;... +using ::testing::Return; +... EXPECT_CALL(turtle, GetX()) .Times(5) .WillOnce(Return(100)) @@ -251,7 +252,8 @@ EXPECT_CALL(turtle, Forward(_)); A list of built-in matchers can be found in the [CheatSheet](CheatSheet.md). For example, here's the `Ge` (greater than or equal) matcher: ``` -using ::testing::Ge;... +using ::testing::Ge; +... EXPECT_CALL(turtle, Forward(Ge(100))); ``` @@ -280,7 +282,8 @@ First, if the return type of a mock function is a built-in type or a pointer, th Second, if a mock function doesn't have a default action, or the default action doesn't suit you, you can specify the action to be taken each time the expectation matches using a series of `WillOnce()` clauses followed by an optional `WillRepeatedly()`. For example, ``` -using ::testing::Return;... +using ::testing::Return; +... EXPECT_CALL(turtle, GetX()) .WillOnce(Return(100)) .WillOnce(Return(200)) @@ -290,7 +293,8 @@ EXPECT_CALL(turtle, GetX()) This says that `turtle.GetX()` will be called _exactly three times_ (Google Mock inferred this from how many `WillOnce()` clauses we've written, since we didn't explicitly write `Times()`), and will return 100, 200, and 300 respectively. ``` -using ::testing::Return;... +using ::testing::Return; +... EXPECT_CALL(turtle, GetY()) .WillOnce(Return(100)) .WillOnce(Return(200)) @@ -317,7 +321,8 @@ Instead of returning 100, 101, 102, ..., consecutively, this mock function will Time for another quiz! What do you think the following means? ``` -using ::testing::Return;... +using ::testing::Return; +... EXPECT_CALL(turtle, GetY()) .Times(4) .WillOnce(Return(100)); @@ -331,7 +336,8 @@ So far we've only shown examples where you have a single expectation. More reali By default, when a mock method is invoked, Google Mock will search the expectations in the **reverse order** they are defined, and stop when an active expectation that matches the arguments is found (you can think of it as "newer rules override older ones."). If the matching expectation cannot take any more calls, you will get an upper-bound-violated failure. Here's an example: ``` -using ::testing::_;... +using ::testing::_; +... EXPECT_CALL(turtle, Forward(_)); // #1 EXPECT_CALL(turtle, Forward(10)) // #2 .Times(2); @@ -347,7 +353,8 @@ By default, an expectation can match a call even though an earlier expectation h Sometimes, you may want all the expected calls to occur in a strict order. To say this in Google Mock is easy: ``` -using ::testing::InSequence;... +using ::testing::InSequence; +... TEST(FooTest, DrawsLineSegment) { ... { @@ -373,7 +380,8 @@ Now let's do a quick quiz to see how well you can use this mock stuff already. H After you've come up with your answer, take a look at ours and compare notes (solve it yourself first - don't cheat!): ``` -using ::testing::_;... +using ::testing::_; +... EXPECT_CALL(turtle, GoTo(_, _)) // #1 .Times(AnyNumber()); EXPECT_CALL(turtle, GoTo(0, 0)) // #2 From c9cf07a8ba4de21e528a2f2e0e38767c34d54412 Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Fri, 1 Sep 2017 14:21:43 +0100 Subject: [PATCH 44/51] Make the failure messages from EXPECT_EQ and friends actually symmetric, instead of reading more like reversing the former "expected" and "actual" roles of the LHS and RHS arguments. This patch is manually applied from internal version (125109873) --- googletest/src/gtest.cc | 9 +- .../test/gtest_output_test_golden_lin.txt | 134 ++++++++++-------- googletest/test/gtest_unittest.cc | 106 ++++++++------ googletest/test/gtest_xml_output_unittest.py | 21 +-- 4 files changed, 152 insertions(+), 118 deletions(-) diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index fa170e756d..2d1b5b98c1 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -1313,13 +1313,14 @@ AssertionResult EqFailure(const char* lhs_expression, const std::string& rhs_value, bool ignoring_case) { Message msg; - msg << " Expected: " << lhs_expression; + msg << "Expected equality of these values:"; + msg << "\n " << lhs_expression; if (lhs_value != lhs_expression) { - msg << "\n Which is: " << lhs_value; + msg << "\n Which is: " << lhs_value; } - msg << "\nTo be equal to: " << rhs_expression; + msg << "\n " << rhs_expression; if (rhs_value != rhs_expression) { - msg << "\n Which is: " << rhs_value; + msg << "\n Which is: " << rhs_value; } if (ignoring_case) { diff --git a/googletest/test/gtest_output_test_golden_lin.txt b/googletest/test/gtest_output_test_golden_lin.txt index 2223d560e2..677d9f40e8 100644 --- a/googletest/test/gtest_output_test_golden_lin.txt +++ b/googletest/test/gtest_output_test_golden_lin.txt @@ -5,8 +5,9 @@ Value of: false Actual: false Expected: true gtest_output_test_.cc:#: Failure - Expected: 2 -To be equal to: 3 +Expected equality of these values: + 2 + 3 [==========] Running 66 tests from 29 test cases. [----------] Global test environment set-up. FooEnvironment::SetUp() called. @@ -34,21 +35,24 @@ BarEnvironment::SetUp() called. [----------] 2 tests from NonfatalFailureTest [ RUN ] NonfatalFailureTest.EscapesStringOperands gtest_output_test_.cc:#: Failure - Expected: kGoldenString - Which is: "\"Line" -To be equal to: actual - Which is: "actual \"string\"" -gtest_output_test_.cc:#: Failure - Expected: golden - Which is: "\"Line" -To be equal to: actual - Which is: "actual \"string\"" +Expected equality of these values: + kGoldenString + Which is: "\"Line" + actual + Which is: "actual \"string\"" +gtest_output_test_.cc:#: Failure +Expected equality of these values: + golden + Which is: "\"Line" + actual + Which is: "actual \"string\"" [ FAILED ] NonfatalFailureTest.EscapesStringOperands [ RUN ] NonfatalFailureTest.DiffForLongStrings gtest_output_test_.cc:#: Failure - Expected: golden_str - Which is: "\"Line\0 1\"\nLine 2" -To be equal to: "Line 2" +Expected equality of these values: + golden_str + Which is: "\"Line\0 1\"\nLine 2" + "Line 2" With diff: @@ -1,2 @@ -\"Line\0 1\" @@ -59,16 +63,18 @@ With diff: [ RUN ] FatalFailureTest.FatalFailureInSubroutine (expecting a failure that x should be 1) gtest_output_test_.cc:#: Failure - Expected: 1 -To be equal to: x - Which is: 2 +Expected equality of these values: + 1 + x + Which is: 2 [ FAILED ] FatalFailureTest.FatalFailureInSubroutine [ RUN ] FatalFailureTest.FatalFailureInNestedSubroutine (expecting a failure that x should be 1) gtest_output_test_.cc:#: Failure - Expected: 1 -To be equal to: x - Which is: 2 +Expected equality of these values: + 1 + x + Which is: 2 [ FAILED ] FatalFailureTest.FatalFailureInNestedSubroutine [ RUN ] FatalFailureTest.NonfatalFailureInSubroutine (expecting a failure on false) @@ -107,39 +113,44 @@ This failure is expected, and shouldn't have a trace. [ RUN ] SCOPED_TRACETest.WorksInLoop (expected to fail) gtest_output_test_.cc:#: Failure - Expected: 2 -To be equal to: n - Which is: 1 +Expected equality of these values: + 2 + n + Which is: 1 Google Test trace: gtest_output_test_.cc:#: i = 1 gtest_output_test_.cc:#: Failure - Expected: 1 -To be equal to: n - Which is: 2 +Expected equality of these values: + 1 + n + Which is: 2 Google Test trace: gtest_output_test_.cc:#: i = 2 [ FAILED ] SCOPED_TRACETest.WorksInLoop [ RUN ] SCOPED_TRACETest.WorksInSubroutine (expected to fail) gtest_output_test_.cc:#: Failure - Expected: 2 -To be equal to: n - Which is: 1 +Expected equality of these values: + 2 + n + Which is: 1 Google Test trace: gtest_output_test_.cc:#: n = 1 gtest_output_test_.cc:#: Failure - Expected: 1 -To be equal to: n - Which is: 2 +Expected equality of these values: + 1 + n + Which is: 2 Google Test trace: gtest_output_test_.cc:#: n = 2 [ FAILED ] SCOPED_TRACETest.WorksInSubroutine [ RUN ] SCOPED_TRACETest.CanBeNested (expected to fail) gtest_output_test_.cc:#: Failure - Expected: 1 -To be equal to: n - Which is: 2 +Expected equality of these values: + 1 + n + Which is: 2 Google Test trace: gtest_output_test_.cc:#: n = 2 gtest_output_test_.cc:#: @@ -437,9 +448,10 @@ Expected: 1 fatal failure [ OK ] TypedTest/0.Success [ RUN ] TypedTest/0.Failure gtest_output_test_.cc:#: Failure - Expected: 1 -To be equal to: TypeParam() - Which is: 0 +Expected equality of these values: + 1 + TypeParam() + Which is: 0 Expected failure [ FAILED ] TypedTest/0.Failure, where TypeParam = int [----------] 2 tests from Unsigned/TypedTestP/0, where TypeParam = unsigned char @@ -447,10 +459,11 @@ Expected failure [ OK ] Unsigned/TypedTestP/0.Success [ RUN ] Unsigned/TypedTestP/0.Failure gtest_output_test_.cc:#: Failure - Expected: 1U - Which is: 1 -To be equal to: TypeParam() - Which is: '\0' +Expected equality of these values: + 1U + Which is: 1 + TypeParam() + Which is: '\0' Expected failure [ FAILED ] Unsigned/TypedTestP/0.Failure, where TypeParam = unsigned char [----------] 2 tests from Unsigned/TypedTestP/1, where TypeParam = unsigned int @@ -458,10 +471,11 @@ Expected failure [ OK ] Unsigned/TypedTestP/1.Success [ RUN ] Unsigned/TypedTestP/1.Failure gtest_output_test_.cc:#: Failure - Expected: 1U - Which is: 1 -To be equal to: TypeParam() - Which is: 0 +Expected equality of these values: + 1U + Which is: 1 + TypeParam() + Which is: 0 Expected failure [ FAILED ] Unsigned/TypedTestP/1.Failure, where TypeParam = unsigned int [----------] 4 tests from ExpectFailureTest @@ -597,18 +611,20 @@ Expected non-fatal failure. [----------] 1 test from PrintingFailingParams/FailingParamTest [ RUN ] PrintingFailingParams/FailingParamTest.Fails/0 gtest_output_test_.cc:#: Failure - Expected: 1 -To be equal to: GetParam() - Which is: 2 +Expected equality of these values: + 1 + GetParam() + Which is: 2 [ FAILED ] PrintingFailingParams/FailingParamTest.Fails/0, where GetParam() = 2 [----------] 2 tests from PrintingStrings/ParamTest [ RUN ] PrintingStrings/ParamTest.Success/a [ OK ] PrintingStrings/ParamTest.Success/a [ RUN ] PrintingStrings/ParamTest.Failure/a gtest_output_test_.cc:#: Failure - Expected: "b" -To be equal to: GetParam() - Which is: "a" +Expected equality of these values: + "b" + GetParam() + Which is: "a" Expected failure [ FAILED ] PrintingStrings/ParamTest.Failure/a, where GetParam() = "a" [----------] Global test environment tear-down @@ -678,16 +694,18 @@ Expected fatal failure. [ RUN ] FatalFailureTest.FatalFailureInSubroutine (expecting a failure that x should be 1) gtest_output_test_.cc:#: Failure - Expected: 1 -To be equal to: x - Which is: 2 +Expected equality of these values: + 1 + x + Which is: 2 [ FAILED ] FatalFailureTest.FatalFailureInSubroutine (? ms) [ RUN ] FatalFailureTest.FatalFailureInNestedSubroutine (expecting a failure that x should be 1) gtest_output_test_.cc:#: Failure - Expected: 1 -To be equal to: x - Which is: 2 +Expected equality of these values: + 1 + x + Which is: 2 [ FAILED ] FatalFailureTest.FatalFailureInNestedSubroutine (? ms) [ RUN ] FatalFailureTest.NonfatalFailureInSubroutine (expecting a failure on false) diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index 745c9506a6..00d9f061b7 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -2429,8 +2429,9 @@ TEST(StringAssertionTest, ASSERT_STREQ) { const char p2[] = "good"; ASSERT_STREQ(p1, p2); - EXPECT_FATAL_FAILURE(ASSERT_STREQ("bad", "good"), - "Expected: \"bad\""); + EXPECT_FATAL_FAILURE( + ASSERT_STREQ("bad", "good"), + "Expected equality of these values:\n \"bad\"\n \"good\""); } // Tests ASSERT_STREQ with NULL arguments. @@ -3528,35 +3529,39 @@ TEST(AssertionTest, EqFailure) { EqFailure("foo", "bar", foo_val, bar_val, false) .failure_message()); EXPECT_STREQ( - " Expected: foo\n" - " Which is: 5\n" - "To be equal to: bar\n" - " Which is: 6", + "Expected equality of these values:\n" + " foo\n" + " Which is: 5\n" + " bar\n" + " Which is: 6", msg1.c_str()); const std::string msg2( EqFailure("foo", "6", foo_val, bar_val, false) .failure_message()); EXPECT_STREQ( - " Expected: foo\n" - " Which is: 5\n" - "To be equal to: 6", + "Expected equality of these values:\n" + " foo\n" + " Which is: 5\n" + " 6", msg2.c_str()); const std::string msg3( EqFailure("5", "bar", foo_val, bar_val, false) .failure_message()); EXPECT_STREQ( - " Expected: 5\n" - "To be equal to: bar\n" - " Which is: 6", + "Expected equality of these values:\n" + " 5\n" + " bar\n" + " Which is: 6", msg3.c_str()); const std::string msg4( EqFailure("5", "6", foo_val, bar_val, false).failure_message()); EXPECT_STREQ( - " Expected: 5\n" - "To be equal to: 6", + "Expected equality of these values:\n" + " 5\n" + " 6", msg4.c_str()); const std::string msg5( @@ -3564,10 +3569,11 @@ TEST(AssertionTest, EqFailure) { std::string("\"x\""), std::string("\"y\""), true).failure_message()); EXPECT_STREQ( - " Expected: foo\n" - " Which is: \"x\"\n" - "To be equal to: bar\n" - " Which is: \"y\"\n" + "Expected equality of these values:\n" + " foo\n" + " Which is: \"x\"\n" + " bar\n" + " Which is: \"y\"\n" "Ignoring case", msg5.c_str()); } @@ -3580,11 +3586,12 @@ TEST(AssertionTest, EqFailureWithDiff) { const std::string msg1( EqFailure("left", "right", left, right, false).failure_message()); EXPECT_STREQ( - " Expected: left\n" - " Which is: " + "Expected equality of these values:\n" + " left\n" + " Which is: " "1\\n2XXX\\n3\\n5\\n6\\n7\\n8\\n9\\n10\\n11\\n12XXX\\n13\\n14\\n15\n" - "To be equal to: right\n" - " Which is: 1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n11\\n12\\n13\\n14\n" + " right\n" + " Which is: 1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n11\\n12\\n13\\n14\n" "With diff:\n@@ -1,5 +1,6 @@\n 1\n-2XXX\n+2\n 3\n+4\n 5\n 6\n" "@@ -7,8 +8,6 @@\n 8\n 9\n-10\n 11\n-12XXX\n+12\n 13\n 14\n-15\n", msg1.c_str()); @@ -3679,9 +3686,10 @@ TEST(ExpectTest, ASSERT_EQ_Double) { TEST(AssertionTest, ASSERT_EQ) { ASSERT_EQ(5, 2 + 3); EXPECT_FATAL_FAILURE(ASSERT_EQ(5, 2*3), - " Expected: 5\n" - "To be equal to: 2*3\n" - " Which is: 6"); + "Expected equality of these values:\n" + " 5\n" + " 2*3\n" + " Which is: 6"); } // Tests ASSERT_EQ(NULL, pointer). @@ -3698,7 +3706,7 @@ TEST(AssertionTest, ASSERT_EQ_NULL) { // A failure. static int n = 0; EXPECT_FATAL_FAILURE(ASSERT_EQ(NULL, &n), - "To be equal to: &n\n"); + " &n\n Which is:"); } #endif // GTEST_CAN_COMPARE_NULL @@ -3714,7 +3722,7 @@ TEST(ExpectTest, ASSERT_EQ_0) { // A failure. EXPECT_FATAL_FAILURE(ASSERT_EQ(0, 5.6), - "Expected: 0"); + " 0\n 5.6"); } // Tests ASSERT_NE. @@ -3813,7 +3821,7 @@ void TestEq1(int x) { // Tests calling a test subroutine that's not part of a fixture. TEST(AssertionTest, NonFixtureSubroutine) { EXPECT_FATAL_FAILURE(TestEq1(2), - "To be equal to: x"); + "Which is: 2"); } // An uncopyable class. @@ -3862,7 +3870,8 @@ TEST(AssertionTest, AssertWorksWithUncopyableObject) { EXPECT_FATAL_FAILURE(TestAssertNonPositive(), "IsPositiveUncopyable(y) evaluates to false, where\ny evaluates to -1"); EXPECT_FATAL_FAILURE(TestAssertEqualsUncopyable(), - "Expected: x\n Which is: 5\nTo be equal to: y\n Which is: -1"); + "Expected equality of these values:\n" + " x\n Which is: 5\n y\n Which is: -1"); } // Tests that uncopyable objects can be used in expects. @@ -3874,7 +3883,8 @@ TEST(AssertionTest, ExpectWorksWithUncopyableObject) { "IsPositiveUncopyable(y) evaluates to false, where\ny evaluates to -1"); EXPECT_EQ(x, x); EXPECT_NONFATAL_FAILURE(EXPECT_EQ(x, y), - "Expected: x\n Which is: 5\nTo be equal to: y\n Which is: -1"); + "Expected equality of these values:\n" + " x\n Which is: 5\n y\n Which is: -1"); } enum NamedEnum { @@ -3950,7 +3960,7 @@ TEST(AssertionTest, AnonymousEnum) { // ICE's in C++Builder. EXPECT_FATAL_FAILURE(ASSERT_EQ(kCaseA, kCaseB), - "To be equal to: kCaseB"); + "kCaseB"); EXPECT_FATAL_FAILURE(ASSERT_EQ(kCaseA, kCaseC), "Which is: 42"); # endif @@ -4390,9 +4400,10 @@ TEST(ExpectTest, ExpectFalseWithAssertionResult) { TEST(ExpectTest, EXPECT_EQ) { EXPECT_EQ(5, 2 + 3); EXPECT_NONFATAL_FAILURE(EXPECT_EQ(5, 2*3), - " Expected: 5\n" - "To be equal to: 2*3\n" - " Which is: 6"); + "Expected equality of these values:\n" + " 5\n" + " 2*3\n" + " Which is: 6"); EXPECT_NONFATAL_FAILURE(EXPECT_EQ(5, 2 - 3), "2 - 3"); } @@ -4423,7 +4434,7 @@ TEST(ExpectTest, EXPECT_EQ_NULL) { // A failure. int n = 0; EXPECT_NONFATAL_FAILURE(EXPECT_EQ(NULL, &n), - "To be equal to: &n\n"); + "&n\n"); } #endif // GTEST_CAN_COMPARE_NULL @@ -4439,7 +4450,7 @@ TEST(ExpectTest, EXPECT_EQ_0) { // A failure. EXPECT_NONFATAL_FAILURE(EXPECT_EQ(0, 5.6), - "Expected: 0"); + "Expected equality of these values:\n 0\n 5.6"); } // Tests EXPECT_NE. @@ -4539,7 +4550,7 @@ TEST(ExpectTest, EXPECT_ANY_THROW) { TEST(ExpectTest, ExpectPrecedence) { EXPECT_EQ(1 < 2, true); EXPECT_NONFATAL_FAILURE(EXPECT_EQ(true, true && false), - "To be equal to: true && false"); + "true && false"); } @@ -4686,7 +4697,7 @@ TEST(EqAssertionTest, Bool) { EXPECT_FATAL_FAILURE({ bool false_value = false; ASSERT_EQ(false_value, true); - }, "To be equal to: true"); + }, "Which is: false"); } // Tests using int values in {EXPECT|ASSERT}_EQ. @@ -4720,10 +4731,11 @@ TEST(EqAssertionTest, WideChar) { EXPECT_EQ(L'b', L'b'); EXPECT_NONFATAL_FAILURE(EXPECT_EQ(L'\0', L'x'), - " Expected: L'\0'\n" - " Which is: L'\0' (0, 0x0)\n" - "To be equal to: L'x'\n" - " Which is: L'x' (120, 0x78)"); + "Expected equality of these values:\n" + " L'\0'\n" + " Which is: L'\0' (0, 0x0)\n" + " L'x'\n" + " Which is: L'x' (120, 0x78)"); static wchar_t wchar; wchar = L'b'; @@ -4731,7 +4743,7 @@ TEST(EqAssertionTest, WideChar) { "wchar"); wchar = 0x8119; EXPECT_FATAL_FAILURE(ASSERT_EQ(static_cast(0x8120), wchar), - "To be equal to: wchar"); + "wchar"); } // Tests using ::std::string values in {EXPECT|ASSERT}_EQ. @@ -4760,8 +4772,8 @@ TEST(EqAssertionTest, StdString) { static ::std::string str3(str1); str3.at(2) = '\0'; EXPECT_FATAL_FAILURE(ASSERT_EQ(str1, str3), - "To be equal to: str3\n" - " Which is: \"A \\0 in the middle\""); + " str3\n" + " Which is: \"A \\0 in the middle\""); } #if GTEST_HAS_STD_WSTRING @@ -4881,7 +4893,7 @@ TEST(EqAssertionTest, CharPointer) { ASSERT_EQ(p1, p1); EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p0, p2), - "To be equal to: p2"); + "p2"); EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p1, p2), "p2"); EXPECT_FATAL_FAILURE(ASSERT_EQ(reinterpret_cast(0x1234), @@ -4903,7 +4915,7 @@ TEST(EqAssertionTest, WideCharPointer) { EXPECT_EQ(p0, p0); EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p0, p2), - "To be equal to: p2"); + "p2"); EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p1, p2), "p2"); void* pv3 = (void*)0x1234; // NOLINT diff --git a/googletest/test/gtest_xml_output_unittest.py b/googletest/test/gtest_xml_output_unittest.py index e940a5aa67..9f92f982dd 100755 --- a/googletest/test/gtest_xml_output_unittest.py +++ b/googletest/test/gtest_xml_output_unittest.py @@ -64,20 +64,23 @@ - + - - + + From 9681b4c8e6aae36ac1d0ae0c4e99bdf013b41913 Mon Sep 17 00:00:00 2001 From: ly2048 <31530391+ly2048@users.noreply.github.com> Date: Thu, 14 Sep 2017 13:22:04 +0800 Subject: [PATCH 45/51] Add explicit `CMAKE_DEBUG_POSTFIX` option Enable generating different library name to be compatible with CMake's `FindGTest`. --- googletest/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/googletest/CMakeLists.txt b/googletest/CMakeLists.txt index 8391dbd019..b9a920b7ad 100644 --- a/googletest/CMakeLists.txt +++ b/googletest/CMakeLists.txt @@ -27,6 +27,8 @@ option( "Build gtest with internal symbols hidden in shared libraries." OFF) +set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Generate debug library name with a postfix.") + # Defines pre_project_set_up_hermetic_build() and set_up_hermetic_build(). include(cmake/hermetic_build.cmake OPTIONAL) From d4af64ca13173c76f6da1aa32dcda7dd3abeb522 Mon Sep 17 00:00:00 2001 From: Benjamin Kircher Date: Sat, 16 Sep 2017 11:51:36 +0200 Subject: [PATCH 46/51] Remove redundant declaration TempDir() function is declared twice, once in `internal/gtest-port.h` and a second time in `gtest.h`. Fixes a warning with GCC when -Wredundant-decls is given. --- googletest/include/gtest/internal/gtest-port.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 643beff994..12bdb4c34e 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -2591,10 +2591,6 @@ std::string StringFromGTestEnv(const char* flag, const char* default_val); } // namespace internal -// Returns a path to temporary directory. -// Tries to determine an appropriate directory for the platform. -GTEST_API_ std::string TempDir(); - } // namespace testing #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_ From cf512a099cd59a05ff981db778d08ab3cf143969 Mon Sep 17 00:00:00 2001 From: "stkhapugin@chromium.org" Date: Tue, 19 Sep 2017 12:44:52 +0200 Subject: [PATCH 47/51] Swap reinterpret_cast for static_cast Swap reinterpret_cast for static_cast --- googletest/include/gtest/gtest-printers.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h index 129fc68e7e..282a2dac03 100644 --- a/googletest/include/gtest/gtest-printers.h +++ b/googletest/include/gtest/gtest-printers.h @@ -137,8 +137,8 @@ class TypeWithoutFormatter { public: // This default version is called when kTypeKind is kOtherType. static void PrintValue(const T& value, ::std::ostream* os) { - PrintBytesInObjectTo(reinterpret_cast( - reinterpret_cast(&value)), + PrintBytesInObjectTo(static_cast( + reinterpret_cast(&value)), sizeof(value), os); } }; From d30a37e743e45de88b85333756bb938d2f6eeecd Mon Sep 17 00:00:00 2001 From: Gennadiy Civil Date: Thu, 21 Sep 2017 10:54:14 -0400 Subject: [PATCH 48/51] Revert "Allow macros inside of parametrized test names." --- googletest/include/gtest/gtest-param-test.h | 15 ++++------ .../include/gtest/gtest-param-test.h.pump | 9 ++---- googletest/test/gtest-param-test_test.cc | 28 ------------------- 3 files changed, 9 insertions(+), 43 deletions(-) diff --git a/googletest/include/gtest/gtest-param-test.h b/googletest/include/gtest/gtest-param-test.h index e01c3ff6a3..038f9ba79e 100644 --- a/googletest/include/gtest/gtest-param-test.h +++ b/googletest/include/gtest/gtest-param-test.h @@ -1375,10 +1375,7 @@ internal::CartesianProductHolder10AddTestPattern(\ - GTEST_STRINGIFY_(test_case_name), \ - GTEST_STRINGIFY_(test_name), \ + #test_case_name, \ + #test_name, \ new ::testing::internal::TestMetaFactory< \ GTEST_TEST_CLASS_NAME_(\ test_case_name, test_name)>()); \ @@ -1415,11 +1412,11 @@ internal::CartesianProductHolder10, and return std::string. // // testing::PrintToStringParamName is a builtin test suffix generator that -// returns the value of testing::PrintToString(GetParam()). +// returns the value of testing::PrintToString(GetParam()). It does not work +// for std::string or C strings. // // Note: test names must be non-empty, unique, and may only contain ASCII -// alphanumeric characters or underscore. Because PrintToString adds quotes -// to std::string and C strings, it won't work for these types. +// alphanumeric characters or underscore. # define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator, ...) \ ::testing::internal::ParamGenerator \ diff --git a/googletest/include/gtest/gtest-param-test.h.pump b/googletest/include/gtest/gtest-param-test.h.pump index 8ab18dd001..3078d6d2a1 100644 --- a/googletest/include/gtest/gtest-param-test.h.pump +++ b/googletest/include/gtest/gtest-param-test.h.pump @@ -441,10 +441,7 @@ internal::CartesianProductHolder$i<$for j, [[Generator$j]]> Combine( ]] # endif // GTEST_HAS_COMBINE -// Use a macro to stringify the test (case) name, because direct stringification -// does not work if one of the arguments is itself a macro -// (https://gcc.gnu.org/onlinedocs/cpp/Stringification.html). -# define GTEST_STRINGIFY_(name) #name + # define TEST_P(test_case_name, test_name) \ class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \ @@ -459,8 +456,8 @@ internal::CartesianProductHolder$i<$for j, [[Generator$j]]> Combine( #test_case_name, \ ::testing::internal::CodeLocation(\ __FILE__, __LINE__))->AddTestPattern(\ - GTEST_STRINGIFY_(test_case_name), \ - GTEST_STRINGIFY_(test_name), \ + #test_case_name, \ + #test_name, \ new ::testing::internal::TestMetaFactory< \ GTEST_TEST_CLASS_NAME_(\ test_case_name, test_name)>()); \ diff --git a/googletest/test/gtest-param-test_test.cc b/googletest/test/gtest-param-test_test.cc index 9d6f09fde3..d1b0644f6f 100644 --- a/googletest/test/gtest-param-test_test.cc +++ b/googletest/test/gtest-param-test_test.cc @@ -809,34 +809,6 @@ TEST_P(NamingTest, TestsReportCorrectNamesAndParameters) { INSTANTIATE_TEST_CASE_P(ZeroToFiveSequence, NamingTest, Range(0, 5)); -// Tests that macros in test names are expanded correctly. -class MacroNamingTest : public TestWithParam {}; - -#define PREFIX_WITH_FOO(test_name) FOO_##test_name -#define PREFIX_WITH_MACRO(test_name) Macro##test_name - -TEST_P(PREFIX_WITH_MACRO(NamingTest), PREFIX_WITH_FOO(SomeTestName)) { - const ::testing::TestInfo* const test_info = - ::testing::UnitTest::GetInstance()->current_test_info(); - - EXPECT_STREQ("FortyTwo/MacroNamingTest", test_info->test_case_name()); - EXPECT_STREQ("FOO_SomeTestName", test_info->name()); -} - -INSTANTIATE_TEST_CASE_P(FortyTwo, MacroNamingTest, Values(42)); - -// Tests the same thing for non-parametrized tests. -class MacroNamingTestNonParametrized : public ::testing::Test {}; - -TEST_F(PREFIX_WITH_MACRO(NamingTestNonParametrized), - PREFIX_WITH_FOO(SomeTestName)) { - const ::testing::TestInfo* const test_info = - ::testing::UnitTest::GetInstance()->current_test_info(); - - EXPECT_STREQ("MacroNamingTestNonParametrized", test_info->test_case_name()); - EXPECT_STREQ("FOO_SomeTestName", test_info->name()); -} - // Tests that user supplied custom parameter names are working correctly. // Runs the test with a builtin helper method which uses PrintToString, // as well as a custom function and custom functor to ensure all possible From b70cf1a663ad30f77ab9867095a87d3d5429450d Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Wed, 27 Sep 2017 13:31:13 +0100 Subject: [PATCH 49/51] Use gender-neutral pronouns in comments and docs --- googlemock/docs/CookBook.md | 2 +- googlemock/docs/FrequentlyAskedQuestions.md | 2 +- googlemock/include/gmock/gmock-spec-builders.h | 2 +- googlemock/src/gmock-internal-utils.cc | 2 +- googlemock/src/gmock-spec-builders.cc | 4 ++-- googlemock/test/gmock-cardinalities_test.cc | 2 +- googlemock/test/gmock-internal-utils_test.cc | 2 +- googlemock/test/gmock-spec-builders_test.cc | 2 +- googletest/docs/AdvancedGuide.md | 2 +- googletest/docs/FAQ.md | 4 ++-- googletest/include/gtest/internal/gtest-port.h | 2 +- googletest/src/gtest.cc | 2 +- googletest/test/gtest-death-test_test.cc | 2 +- googletest/test/gtest-filepath_test.cc | 2 +- googletest/test/gtest-options_test.cc | 2 +- googletest/test/gtest-port_test.cc | 2 +- googletest/test/gtest_color_test_.cc | 2 +- googletest/test/gtest_output_test_.cc | 2 +- googletest/test/gtest_repeat_test.cc | 2 +- googletest/test/gtest_unittest.cc | 2 +- 20 files changed, 22 insertions(+), 22 deletions(-) diff --git a/googlemock/docs/CookBook.md b/googlemock/docs/CookBook.md index 753c6dd315..3d07e68b82 100644 --- a/googlemock/docs/CookBook.md +++ b/googlemock/docs/CookBook.md @@ -227,7 +227,7 @@ If a mock method has no `EXPECT_CALL` spec but is called, Google Mock will print a warning about the "uninteresting call". The rationale is: * New methods may be added to an interface after a test is written. We shouldn't fail a test just because a method it doesn't know about is called. - * However, this may also mean there's a bug in the test, so Google Mock shouldn't be silent either. If the user believes these calls are harmless, he can add an `EXPECT_CALL()` to suppress the warning. + * However, this may also mean there's a bug in the test, so Google Mock shouldn't be silent either. If the user believes these calls are harmless, they can add an `EXPECT_CALL()` to suppress the warning. However, sometimes you may want to suppress all "uninteresting call" warnings, while sometimes you may want the opposite, i.e. to treat all diff --git a/googlemock/docs/FrequentlyAskedQuestions.md b/googlemock/docs/FrequentlyAskedQuestions.md index 5eac83f4b9..ccaa3d7a87 100644 --- a/googlemock/docs/FrequentlyAskedQuestions.md +++ b/googlemock/docs/FrequentlyAskedQuestions.md @@ -240,7 +240,7 @@ You cannot mock a variadic function (i.e. a function taking ellipsis The problem is that in general, there is _no way_ for a mock object to know how many arguments are passed to the variadic method, and what the arguments' types are. Only the _author of the base class_ knows -the protocol, and we cannot look into his head. +the protocol, and we cannot look into their head. Therefore, to mock such a function, the _user_ must teach the mock object how to figure out the number of arguments and their types. One diff --git a/googlemock/include/gmock/gmock-spec-builders.h b/googlemock/include/gmock/gmock-spec-builders.h index 9680244418..a8347bd86d 100644 --- a/googlemock/include/gmock/gmock-spec-builders.h +++ b/googlemock/include/gmock/gmock-spec-builders.h @@ -1774,7 +1774,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase { // There is no generally useful and implementable semantics of // copying a mock object, so copying a mock is usually a user error. // Thus we disallow copying function mockers. If the user really - // wants to copy a mock object, he should implement his own copy + // wants to copy a mock object, they should implement their own copy // operation, for example: // // class MockFoo : public Foo { diff --git a/googlemock/src/gmock-internal-utils.cc b/googlemock/src/gmock-internal-utils.cc index 6464abc241..91bf3fd92e 100644 --- a/googlemock/src/gmock-internal-utils.cc +++ b/googlemock/src/gmock-internal-utils.cc @@ -71,7 +71,7 @@ GTEST_API_ string ConvertIdentifierNameToWords(const char* id_name) { } // This class reports Google Mock failures as Google Test failures. A -// user can define another class in a similar fashion if he intends to +// user can define another class in a similar fashion if they intend to // use Google Mock with a testing framework other than Google Test. class GoogleTestFailureReporter : public FailureReporterInterface { public: diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc index 0eaaee75ef..fc4968baab 100644 --- a/googlemock/src/gmock-spec-builders.cc +++ b/googlemock/src/gmock-spec-builders.cc @@ -353,10 +353,10 @@ UntypedFunctionMockerBase::UntypedInvokeWith(const void* const untyped_args) // the behavior of ReportUninterestingCall(). const bool need_to_report_uninteresting_call = // If the user allows this uninteresting call, we print it - // only when he wants informational messages. + // only when they want informational messages. reaction == kAllow ? LogIsVisible(kInfo) : // If the user wants this to be a warning, we print it only - // when he wants to see warnings. + // when they want to see warnings. reaction == kWarn ? LogIsVisible(kWarning) : // Otherwise, the user wants this to be an error, and we // should always print detailed information in the error. diff --git a/googlemock/test/gmock-cardinalities_test.cc b/googlemock/test/gmock-cardinalities_test.cc index 64815e57a3..04c792b5c5 100644 --- a/googlemock/test/gmock-cardinalities_test.cc +++ b/googlemock/test/gmock-cardinalities_test.cc @@ -391,7 +391,7 @@ TEST(ExactlyTest, HasCorrectBounds) { EXPECT_EQ(3, c.ConservativeUpperBound()); } -// Tests that a user can make his own cardinality by implementing +// Tests that a user can make their own cardinality by implementing // CardinalityInterface and calling MakeCardinality(). class EvenCardinality : public CardinalityInterface { diff --git a/googlemock/test/gmock-internal-utils_test.cc b/googlemock/test/gmock-internal-utils_test.cc index 9c2423ecd3..72d9a854ae 100644 --- a/googlemock/test/gmock-internal-utils_test.cc +++ b/googlemock/test/gmock-internal-utils_test.cc @@ -49,7 +49,7 @@ // implementation. It must come before gtest-internal-inl.h is // included, or there will be a compiler error. This trick is to // prevent a user from accidentally including gtest-internal-inl.h in -// his code. +// their code. #define GTEST_IMPLEMENTATION_ 1 #include "src/gtest-internal-inl.h" #undef GTEST_IMPLEMENTATION_ diff --git a/googlemock/test/gmock-spec-builders_test.cc b/googlemock/test/gmock-spec-builders_test.cc index c649bfd92f..a7bf03e5a0 100644 --- a/googlemock/test/gmock-spec-builders_test.cc +++ b/googlemock/test/gmock-spec-builders_test.cc @@ -2682,7 +2682,7 @@ TEST(SynchronizationTest, CanCallMockMethodInAction) { } // namespace -// Allows the user to define his own main and then invoke gmock_main +// Allows the user to define their own main and then invoke gmock_main // from it. This might be necessary on some platforms which require // specific setup and teardown. #if GMOCK_RENAME_MAIN diff --git a/googletest/docs/AdvancedGuide.md b/googletest/docs/AdvancedGuide.md index 1076496d28..e4dd94dee3 100644 --- a/googletest/docs/AdvancedGuide.md +++ b/googletest/docs/AdvancedGuide.md @@ -1263,7 +1263,7 @@ known as abstract tests. As an example of its application, when you are designing an interface you can write a standard suite of abstract tests (perhaps using a factory function as the test parameter) that all implementations of the interface are expected to pass. When -someone implements the interface, he can instantiate your suite to get +someone implements the interface, they can instantiate your suite to get all the interface-conformance tests for free. To define abstract tests, you should organize your code like this: diff --git a/googletest/docs/FAQ.md b/googletest/docs/FAQ.md index 76c237278d..c39b625410 100644 --- a/googletest/docs/FAQ.md +++ b/googletest/docs/FAQ.md @@ -102,9 +102,9 @@ Then every user of your machine can write tests without recompiling Google Test. This seemed like a good idea, but it has a -got-cha: every user needs to compile his tests using the _same_ compiler +got-cha: every user needs to compile their tests using the _same_ compiler flags used to compile the installed Google Test libraries; otherwise -he may run into undefined behaviors (i.e. the tests can behave +they may run into undefined behaviors (i.e. the tests can behave strangely and may even crash for no obvious reasons). Why? Because C++ has this thing called the One-Definition Rule: if diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 12bdb4c34e..5529ba5441 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -741,7 +741,7 @@ using ::std::tuple_size; # define _TR1_FUNCTIONAL 1 # include # undef _TR1_FUNCTIONAL // Allows the user to #include - // if he chooses to. + // if they choose to. # else # include // NOLINT # endif // !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302 diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 2d1b5b98c1..d77f676d47 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -137,7 +137,7 @@ // implementation. It must come before gtest-internal-inl.h is // included, or there will be a compiler error. This trick is to // prevent a user from accidentally including gtest-internal-inl.h in -// his code. +// their code. #define GTEST_IMPLEMENTATION_ 1 #include "src/gtest-internal-inl.h" #undef GTEST_IMPLEMENTATION_ diff --git a/googletest/test/gtest-death-test_test.cc b/googletest/test/gtest-death-test_test.cc index 957fe38244..85021e352d 100644 --- a/googletest/test/gtest-death-test_test.cc +++ b/googletest/test/gtest-death-test_test.cc @@ -61,7 +61,7 @@ using testing::internal::AlwaysTrue; // implementation. It must come before gtest-internal-inl.h is // included, or there will be a compiler error. This trick is to // prevent a user from accidentally including gtest-internal-inl.h in -// his code. +// their code. # define GTEST_IMPLEMENTATION_ 1 # include "src/gtest-internal-inl.h" # undef GTEST_IMPLEMENTATION_ diff --git a/googletest/test/gtest-filepath_test.cc b/googletest/test/gtest-filepath_test.cc index da72986926..22f4ed68cd 100644 --- a/googletest/test/gtest-filepath_test.cc +++ b/googletest/test/gtest-filepath_test.cc @@ -45,7 +45,7 @@ // implementation. It must come before gtest-internal-inl.h is // included, or there will be a compiler error. This trick is to // prevent a user from accidentally including gtest-internal-inl.h in -// his code. +// their code. #define GTEST_IMPLEMENTATION_ 1 #include "src/gtest-internal-inl.h" #undef GTEST_IMPLEMENTATION_ diff --git a/googletest/test/gtest-options_test.cc b/googletest/test/gtest-options_test.cc index 5586dc3b1b..88c6e9a4ec 100644 --- a/googletest/test/gtest-options_test.cc +++ b/googletest/test/gtest-options_test.cc @@ -50,7 +50,7 @@ // implementation. It must come before gtest-internal-inl.h is // included, or there will be a compiler error. This trick is to // prevent a user from accidentally including gtest-internal-inl.h in -// his code. +// their code. #define GTEST_IMPLEMENTATION_ 1 #include "src/gtest-internal-inl.h" #undef GTEST_IMPLEMENTATION_ diff --git a/googletest/test/gtest-port_test.cc b/googletest/test/gtest-port_test.cc index 1d25ee6ba2..62ee11b026 100644 --- a/googletest/test/gtest-port_test.cc +++ b/googletest/test/gtest-port_test.cc @@ -50,7 +50,7 @@ // implementation. It must come before gtest-internal-inl.h is // included, or there will be a compiler error. This trick is to // prevent a user from accidentally including gtest-internal-inl.h in -// his code. +// their code. #define GTEST_IMPLEMENTATION_ 1 #include "src/gtest-internal-inl.h" #undef GTEST_IMPLEMENTATION_ diff --git a/googletest/test/gtest_color_test_.cc b/googletest/test/gtest_color_test_.cc index f61ebb89b8..672069c7b8 100644 --- a/googletest/test/gtest_color_test_.cc +++ b/googletest/test/gtest_color_test_.cc @@ -41,7 +41,7 @@ // implementation. It must come before gtest-internal-inl.h is // included, or there will be a compiler error. This trick is to // prevent a user from accidentally including gtest-internal-inl.h in -// his code. +// their code. #define GTEST_IMPLEMENTATION_ 1 #include "src/gtest-internal-inl.h" #undef GTEST_IMPLEMENTATION_ diff --git a/googletest/test/gtest_output_test_.cc b/googletest/test/gtest_output_test_.cc index 1070a9f26f..e5fa764e3c 100644 --- a/googletest/test/gtest_output_test_.cc +++ b/googletest/test/gtest_output_test_.cc @@ -42,7 +42,7 @@ // implementation. It must come before gtest-internal-inl.h is // included, or there will be a compiler error. This trick is to // prevent a user from accidentally including gtest-internal-inl.h in -// his code. +// their code. #define GTEST_IMPLEMENTATION_ 1 #include "src/gtest-internal-inl.h" #undef GTEST_IMPLEMENTATION_ diff --git a/googletest/test/gtest_repeat_test.cc b/googletest/test/gtest_repeat_test.cc index 481012adc2..165d2021bc 100644 --- a/googletest/test/gtest_repeat_test.cc +++ b/googletest/test/gtest_repeat_test.cc @@ -39,7 +39,7 @@ // implementation. It must come before gtest-internal-inl.h is // included, or there will be a compiler error. This trick is to // prevent a user from accidentally including gtest-internal-inl.h in -// his code. +// their code. #define GTEST_IMPLEMENTATION_ 1 #include "src/gtest-internal-inl.h" #undef GTEST_IMPLEMENTATION_ diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index 00d9f061b7..e4f743b735 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -71,7 +71,7 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) { // implementation. It must come before gtest-internal-inl.h is // included, or there will be a compiler error. This trick is to // prevent a user from accidentally including gtest-internal-inl.h in -// his code. +// their code. #define GTEST_IMPLEMENTATION_ 1 #include "src/gtest-internal-inl.h" #undef GTEST_IMPLEMENTATION_ From 4597ec587ca2a5e35cfb8e44257ce2340624b22a Mon Sep 17 00:00:00 2001 From: Joe Alam Date: Sat, 7 Oct 2017 23:34:53 +0100 Subject: [PATCH 50/51] Updated README with information about C runtime dynamic/static linking issues in Windows --- googletest/README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/googletest/README.md b/googletest/README.md index 0a3474c02b..0f6d6d59ad 100644 --- a/googletest/README.md +++ b/googletest/README.md @@ -182,6 +182,17 @@ technique is discussed in more detail in which also contains a link to a fully generalized implementation of the technique. +##### Visual Studio Dynamic vs Static Runtimes ##### + +By default, new Visual Studio projects link the C runtimes dynamically +but Google Test links them statically. +This will generate an error that looks something like the following: + gtest.lib(gtest-all.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in main.obj + +Google Test already has a CMake option for this: `gtest_force_shared_crt` + +Enabling this option will make gtest link the runtimes dynamically too, +and match the project in which it is included. ### Legacy Build Scripts ### From ecb1c3ddb6cf7d7df10bfbafdd374ca3d412992b Mon Sep 17 00:00:00 2001 From: Dariusz Ostolski Date: Sat, 14 Oct 2017 18:33:19 +0200 Subject: [PATCH 51/51] #1282: Doc typo fix --- 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 c94c2dac9e..c6367fdd13 100644 --- a/googlemock/docs/CheatSheet.md +++ b/googlemock/docs/CheatSheet.md @@ -65,7 +65,7 @@ can specify it by appending `_WITH_CALLTYPE` to any of the macros described in the previous two sections and supplying the calling convention as the first argument to the macro. For example, ``` - MOCK_METHOD_1_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo, bool(int n)); + MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, Foo, bool(int n)); MOCK_CONST_METHOD2_WITH_CALLTYPE(STDMETHODCALLTYPE, Bar, int(double x, double y)); ``` where `STDMETHODCALLTYPE` is defined by `` on Windows.