From 336fd36fee0e95a28a6f5f8ea77e36a2eb7c583e Mon Sep 17 00:00:00 2001 From: dmauro Date: Wed, 11 Nov 2020 12:52:39 -0500 Subject: [PATCH] Googletest export Rollback change from https://github.com/google/googletest/pull/1836. This change generates a script on Windows to actually run each test, but the script itself doesn't correctly report if the test passed. This change will "break tests" that were already broken on Windows, but weren't being reported as such. PiperOrigin-RevId: 341850671 --- googlemock/CMakeLists.txt | 14 --------- googletest/CMakeLists.txt | 14 --------- googletest/cmake/internal_utils.cmake | 45 ++++++--------------------- 3 files changed, 9 insertions(+), 64 deletions(-) diff --git a/googlemock/CMakeLists.txt b/googlemock/CMakeLists.txt index 18879427..1fc11e78 100644 --- a/googlemock/CMakeLists.txt +++ b/googlemock/CMakeLists.txt @@ -138,20 +138,6 @@ if (gmock_build_tests) # 'make test' or ctest. enable_testing() - if (WIN32) - file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/$/RunTest.ps1" - CONTENT -"$project_bin = \"${CMAKE_BINARY_DIR}/bin/$\" -$env:Path = \"$project_bin;$env:Path\" -& $args") - elseif (MINGW OR CYGWIN) - file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/RunTest.ps1" - CONTENT -"$project_bin = (cygpath --windows ${CMAKE_BINARY_DIR}/bin) -$env:Path = \"$project_bin;$env:Path\" -& $args") - endif() - if (MINGW OR CYGWIN) if (CMAKE_VERSION VERSION_LESS "2.8.12") add_compile_options("-Wa,-mbig-obj") diff --git a/googletest/CMakeLists.txt b/googletest/CMakeLists.txt index cf63c602..5e546ece 100644 --- a/googletest/CMakeLists.txt +++ b/googletest/CMakeLists.txt @@ -184,20 +184,6 @@ if (gtest_build_tests) # 'make test' or ctest. enable_testing() - if (WIN32) - file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/$/RunTest.ps1" - CONTENT -"$project_bin = \"${CMAKE_BINARY_DIR}/bin/$\" -$env:Path = \"$project_bin;$env:Path\" -& $args") - elseif (MINGW OR CYGWIN) - file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/RunTest.ps1" - CONTENT -"$project_bin = (cygpath --windows ${CMAKE_BINARY_DIR}/bin) -$env:Path = \"$project_bin;$env:Path\" -& $args") - endif() - ############################################################ # C++ tests built with standard compiler flags. diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index b3e8b819..2a05f01d 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -252,13 +252,7 @@ find_package(PythonInterp) # from the given source files with the given compiler flags. function(cxx_test_with_flags name cxx_flags libs) cxx_executable_with_flags(${name} "${cxx_flags}" "${libs}" ${ARGN}) - if (WIN32 OR MINGW) - add_test(NAME ${name} - COMMAND "powershell" "-Command" "${CMAKE_CURRENT_BINARY_DIR}/$/RunTest.ps1" "$") - else() - add_test(NAME ${name} - COMMAND "$") - endif() + add_test(NAME ${name} COMMAND "$") endfunction() # cxx_test(name libs srcs...) @@ -282,45 +276,24 @@ function(py_test name) # 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. - if (WIN32 OR MINGW) - add_test(NAME ${name} - COMMAND powershell -Command ${CMAKE_CURRENT_BINARY_DIR}/$/RunTest.ps1 - ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py + add_test(NAME ${name} + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py --build_dir=${CMAKE_CURRENT_BINARY_DIR}/$ ${ARGN}) - else() - add_test(NAME ${name} - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py - --build_dir=${CMAKE_CURRENT_BINARY_DIR}/$ ${ARGN}) - endif() else (CMAKE_CONFIGURATION_TYPES) # Single-configuration build generators like Makefile generators # don't have subdirs below CMAKE_CURRENT_BINARY_DIR. - if (WIN32 OR MINGW) - add_test(NAME ${name} - COMMAND powershell -Command ${CMAKE_CURRENT_BINARY_DIR}/RunTest.ps1 - ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py - --build_dir=${CMAKE_CURRENT_BINARY_DIR} ${ARGN}) - else() - add_test(NAME ${name} - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py - --build_dir=${CMAKE_CURRENT_BINARY_DIR} ${ARGN}) - endif() + add_test(NAME ${name} + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py + --build_dir=${CMAKE_CURRENT_BINARY_DIR} ${ARGN}) endif (CMAKE_CONFIGURATION_TYPES) else() # ${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. - if (WIN32 OR MINGW) - add_test(NAME ${name} - COMMAND powershell -Command ${CMAKE_CURRENT_BINARY_DIR}/RunTest.ps1 - ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py - --build_dir=${CMAKE_CURRENT_BINARY_DIR}/\${CTEST_CONFIGURATION_TYPE} ${ARGN}) - else() - add_test(NAME ${name} - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py - --build_dir=${CMAKE_CURRENT_BINARY_DIR}/\${CTEST_CONFIGURATION_TYPE} ${ARGN}) - endif() + add_test(NAME ${name} + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py + --build_dir=${CMAKE_CURRENT_BINARY_DIR}/\${CTEST_CONFIGURATION_TYPE} ${ARGN}) endif() endif(PYTHONINTERP_FOUND) endfunction()