diff --git a/.gitignore b/.gitignore index 56e1d5cfcc..08a67cdb31 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # Ignore CI build directory build/ +_build/ # Visual Studio files *.sdf diff --git a/appveyor.yml b/appveyor.yml index c6e618f6e3..d613fd6027 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -14,83 +14,58 @@ platform: - x64 configuration: - - Release +# - Release - Debug build: verbosity: minimal -build_script: +artifacts: + - path: '_build/Testing/Temporary/*' + name: test_results + +before_build: - ps: | Write-Output "Configuration: $env:CONFIGURATION" Write-Output "Platform: $env:PLATFORM" - if (($env:Toolset -eq "v100") -and ($env:PLATFORM -eq "x64")) + $generator = switch ($env:TOOLSET) { - return + "v140" {"Visual Studio 14 2015"} + "v120" {"Visual Studio 12 2013"} + "v110" {"Visual Studio 11 2012"} + "v100" {"Visual Studio 10 2010"} } - & .\change_toolset.ps1 $env:Toolset - $solutions = @("googletest\msvc\2010\gtest.sln", - "googletest\msvc\2010\gtest-md.sln", - "googlemock\msvc\2010\gmock.sln") - - foreach ($sln in $solutions) { - msbuild /v:m /p:"Configuration=$env:CONFIGURATION" /p:Platform="$env:PLATFORM" "$sln" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" - if ($LastExitCode -ne 0) { - throw "Exec: $ErrorMessage" - } + if ($env:PLATFORM -eq "x64") + { + $generator = "$generator Win64" } -test_script: +build_script: - ps: | - if (($env:Toolset -eq "v100") -and ($env:PLATFORM -eq "x64")) + if (($env:TOOLSET -eq "v100") -and ($env:PLATFORM -eq "x64")) { return } + md _build -Force | Out-Null + cd _build - function Add-GTest-Result($testResult) - { - $testsuites = ([xml](get-content $testResult)).testsuites - $testsCount = 0 - $anyFailures = $FALSE - - foreach ($testsuite in $testsuites.testsuite) { - foreach ($testcase in $testsuite.testcase) { - $testsCount++ - if ($testcase.failure) { - $time = ([double]$testcase.time * 1000) - Add-AppveyorTest $testcase.name -Outcome Failed -FileName $testsuite.name -Duration $time -ErrorMessage $testcase.failure.message - Add-AppveyorMessage "$($testcase.name) failed" -Category Error - $anyFailures = $TRUE - } - elseif ($testcase.skipped) { - Add-AppveyorTest $testcase.name -Outcome Ignored -Filename $testsuite.name - } - else { - $time = ([double]$testcase.time * 1000) - Add-AppveyorTest $testcase.name -Outcome Passed -FileName $testsuite.name -Duration $time - } - } - } - return $testsCount, $anyFailures + & cmake -G "$generator" -DCMAKE_CONFIGURATION_TYPES="Debug;Release" -Dgtest_build_tests=ON -Dgtest_build_samples=ON -Dgmock_build_tests=ON .. + if ($LastExitCode -ne 0) { + throw "Exec: $ErrorMessage" + } + & cmake --build . --config $env:CONFIGURATION + if ($LastExitCode -ne 0) { + throw "Exec: $ErrorMessage" } - $testsCount = 0 - $anyFailures = $FALSE - - # Run tests and upload results to AppVeyor one by one - Get-ChildItem ".\*test.exe" -Recurse | foreach { - $testfile = "$($_.FullName).xml" - & $_.FullName "--gtest_output=`"xml:$testfile`"" - if (Test-Path $testfile) - { - $count, $testsResult = Add-GTest-Result $testfile - Write-Output "Found $testfile with $count tests" - $testsCount = $testsCount + $count - $anyFailures = $anyFailures -or $testsResult - } +test_script: +- ps: | + if (($env:Toolset -eq "v100") -and ($env:PLATFORM -eq "x64")) + { + return } - if ($anyFailures -eq $TRUE){ - Write-Output "Failing build as there are broken tests" - $host.SetShouldExit(1) + & ctest -C $env:CONFIGURATION --output-on-failure + if ($LastExitCode -ne 0) { + throw "Exec: $ErrorMessage" } diff --git a/change_toolset.ps1 b/change_toolset.ps1 deleted file mode 100644 index c23a21f38c..0000000000 --- a/change_toolset.ps1 +++ /dev/null @@ -1,21 +0,0 @@ -Param( - [Parameter(Mandatory=$True,Position=1)] - [string]$toolset -) - -$files = Get-ChildItem -path . -filter *.vcxproj -recurse -foreach ($file in $files) { - $content = gc $file.fullname - $regex = [regex]"(v[\d\w_]+)<\/PlatformToolset>" - $oldtoolset = $regex.matches($content) - if ($oldtoolset.groups.count -ge 1) - { - " $($file.name) ($($oldtoolset.groups[1].value) - $toolset)" - $content = $content -replace "(v[\d\w_]+)<\/PlatformToolset>","$toolset" - $content | sc $file.fullname - } - else - { - "Toolset not set for $($file.name)" - } -} diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc index f594665a71..514edc6c7f 100644 --- a/googlemock/test/gmock-matchers_test.cc +++ b/googlemock/test/gmock-matchers_test.cc @@ -58,6 +58,11 @@ # include // NOLINT #endif +// Disable MSVC warning: "decorated name length exceeded, name was truncated". +#ifdef _MSC_VER +# pragma warning(disable:4503) +#endif + namespace testing { namespace internal { diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index 93e6dbb7c1..777b91ed4b 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -80,6 +80,10 @@ macro(config_compiler_and_linker) # http://stackoverflow.com/questions/3232669 explains the issue. set(cxx_base_flags "${cxx_base_flags} -wd4702") endif() + if (NOT (MSVC_VERSION GREATER 1900)) # 1900 is Visual Studio 2015 + # BigObj required for tests. + set(cxx_base_flags "${cxx_base_flags} -bigobj") + endif() set(cxx_base_flags "${cxx_base_flags} -D_UNICODE -DUNICODE -DWIN32 -D_WIN32") set(cxx_base_flags "${cxx_base_flags} -DSTRICT -DWIN32_LEAN_AND_MEAN") @@ -235,8 +239,16 @@ function(py_test name) # 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 + 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}/$) + else (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1) + 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() endfunction() diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 7d6e465819..7fc83ae856 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -323,7 +323,7 @@ // -std={c,gnu}++{0x,11} is passed. The C++11 standard specifies a // value for __cplusplus, and recent versions of clang, gcc, and // probably other compilers set that too in C++11 mode. -# if __GXX_EXPERIMENTAL_CXX0X__ || __cplusplus >= 201103L +# if __GXX_EXPERIMENTAL_CXX0X__ || __cplusplus >= 201103L || _MSC_VER >= 1900 // Compiling in at least C++11 mode. # define GTEST_LANG_CXX11 1 # else @@ -355,7 +355,9 @@ #if GTEST_STDLIB_CXX11 # define GTEST_HAS_STD_BEGIN_AND_END_ 1 # define GTEST_HAS_STD_FORWARD_LIST_ 1 -# define GTEST_HAS_STD_FUNCTION_ 1 +# if !defined(_MSC_VER) || (_MSC_FULL_VER >= 190023824) // works only with VS2015U2 and better +# define GTEST_HAS_STD_FUNCTION_ 1 +# endif # define GTEST_HAS_STD_INITIALIZER_LIST_ 1 # define GTEST_HAS_STD_MOVE_ 1 # define GTEST_HAS_STD_SHARED_PTR_ 1 @@ -616,12 +618,21 @@ struct _RTL_CRITICAL_SECTION; // Determines if hash_map/hash_set are available. // Only used for testing against those containers. #if !defined(GTEST_HAS_HASH_MAP_) -# if _MSC_VER +# if defined(_MSC_VER) && (_MSC_VER < 1900) # define GTEST_HAS_HASH_MAP_ 1 // Indicates that hash_map is available. # define GTEST_HAS_HASH_SET_ 1 // Indicates that hash_set is available. # endif // _MSC_VER #endif // !defined(GTEST_HAS_HASH_MAP_) +// Determines if unordered_map/unordered_set are available. +// Only used for testing against those containers. +#if !defined(GTEST_HAS_UNORDERED_MAP_) +# if defined(_MSC_VER) && (_MSC_VER >= 1900) +# define GTEST_HAS_UNORDERED_MAP_ 1 // Indicates that unordered_map is available. +# define GTEST_HAS_UNORDERED_SET_ 1 // Indicates that unordered_set is available. +# endif // _MSC_VER +#endif // !defined(GTEST_HAS_UNORDERED_MAP_) + // Determines whether Google Test can use tr1/tuple. You can define // this macro to 0 to prevent Google Test from using tuple (any // feature depending on tuple with be disabled in this mode). diff --git a/googletest/test/gtest-printers_test.cc b/googletest/test/gtest-printers_test.cc index 3e97cc24ab..6320563e26 100644 --- a/googletest/test/gtest-printers_test.cc +++ b/googletest/test/gtest-printers_test.cc @@ -51,10 +51,15 @@ #include "gtest/gtest.h" // hash_map and hash_set are available under Visual C++, or on Linux. -#if GTEST_HAS_HASH_MAP_ +#if GTEST_HAS_UNORDERED_MAP_ +# include // NOLINT +#elif GTEST_HAS_HASH_MAP_ # include // NOLINT #endif // GTEST_HAS_HASH_MAP_ -#if GTEST_HAS_HASH_SET_ + +#if GTEST_HAS_UNORDERED_SET_ +# include // NOLINT +#elif GTEST_HAS_HASH_SET_ # include // NOLINT #endif // GTEST_HAS_HASH_SET_ @@ -217,18 +222,46 @@ using ::testing::internal::string; // The hash_* classes are not part of the C++ standard. STLport // defines them in namespace std. MSVC defines them in ::stdext. GCC // defines them in ::. +#if GTEST_HAS_UNORDERED_MAP_ + +#define GTEST_HAS_HASH_MAP_ 1 +template +using hash_map = ::std::unordered_map; +template +using hash_multimap = ::std::unordered_multimap; + +#elif GTEST_HAS_HASH_MAP_ + #ifdef _STLP_HASH_MAP // We got from STLport. using ::std::hash_map; -using ::std::hash_set; using ::std::hash_multimap; -using ::std::hash_multiset; #elif _MSC_VER using ::stdext::hash_map; -using ::stdext::hash_set; using ::stdext::hash_multimap; +#endif + +#endif + +#if GTEST_HAS_UNORDERED_SET_ + +#define GTEST_HAS_HASH_SET_ 1 +template +using hash_set = ::std::unordered_set; +template +using hash_multiset = ::std::unordered_multiset; + +#elif GTEST_HAS_HASH_SET_ + +#ifdef _STLP_HASH_MAP // We got from STLport. +using ::std::hash_set; +using ::std::hash_multiset; +#elif _MSC_VER +using ::stdext::hash_set; using ::stdext::hash_multiset; #endif +#endif + // Prints a value to a string using the universal value printer. This // is a helper for testing UniversalPrinter::Print() for various types. template diff --git a/googletest/test/gtest_catch_exceptions_test_.cc b/googletest/test/gtest_catch_exceptions_test_.cc index d0fc82c998..c6d953c04a 100644 --- a/googletest/test/gtest_catch_exceptions_test_.cc +++ b/googletest/test/gtest_catch_exceptions_test_.cc @@ -138,7 +138,7 @@ TEST_F(CxxExceptionInConstructorTest, ThrowsExceptionInConstructor) { } // Exceptions in destructors are not supported in C++11. -#if !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L +#if !GTEST_LANG_CXX11 class CxxExceptionInDestructorTest : public Test { public: static void TearDownTestCase() { diff --git a/googletest/test/gtest_list_tests_unittest.py b/googletest/test/gtest_list_tests_unittest.py index 925b09d9cb..f2d2fd1b1c 100755 --- a/googletest/test/gtest_list_tests_unittest.py +++ b/googletest/test/gtest_list_tests_unittest.py @@ -71,7 +71,7 @@ TypedTest/0\. # TypeParam = (VeryLo{245}|class VeryLo{239})\.\.\. TestA TestB -TypedTest/1\. # TypeParam = int\s*\* +TypedTest/1\. # TypeParam = int\s*\*( __ptr64)? TestA TestB TypedTest/2\. # TypeParam = .*MyArray @@ -80,7 +80,7 @@ My/TypeParamTest/0\. # TypeParam = (VeryLo{245}|class VeryLo{239})\.\.\. TestA TestB -My/TypeParamTest/1\. # TypeParam = int\s*\* +My/TypeParamTest/1\. # TypeParam = int\s*\*( __ptr64)? TestA TestB My/TypeParamTest/2\. # TypeParam = .*MyArray diff --git a/travis.sh b/travis.sh index 20fe3e393d..bdecbd964d 100755 --- a/travis.sh +++ b/travis.sh @@ -12,4 +12,4 @@ cmake -Dgtest_build_samples=ON \ -DCMAKE_CXX_FLAGS=$CXX_FLAGS \ ../../$GTEST_TARGET make -make test +CTEST_OUTPUT_ON_FAILURE=1 make test