diff options
author | Brad King <brad.king@kitware.com> | 2021-11-17 13:44:12 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-11-17 13:44:29 (GMT) |
commit | 908d2cd136be3165d391c18777890798a18f96c3 (patch) | |
tree | d81f26df818afca3ef252c30ab93241b89c17ca4 | |
parent | d2e10c4d8dd7dc32ae775a6382c5277308639271 (diff) | |
parent | 1bf6d5979d7fceae8b8a32129b5816bae459fb96 (diff) | |
download | CMake-908d2cd136be3165d391c18777890798a18f96c3.zip CMake-908d2cd136be3165d391c18777890798a18f96c3.tar.gz CMake-908d2cd136be3165d391c18777890798a18f96c3.tar.bz2 |
Merge topic 'gtest_discover_tests-PRE_TEST-dep'
1bf6d5979d gtest_discover_tests: Re-run PRE_TEST discovery on any arg change
715af43124 Tests: Fix and update wrongly named GoogleTest stdout file
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6728
-rw-r--r-- | Modules/GoogleTest.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/GoogleTest/GoogleTest-discovery-arg-change-basic-stdout.txt | 7 | ||||
-rw-r--r-- | Tests/RunCMake/GoogleTest/GoogleTest-discovery-arg-change-typed-stdout.txt | 5 | ||||
-rw-r--r-- | Tests/RunCMake/GoogleTest/GoogleTest-skip-test-stdout.txt (renamed from Tests/RunCMake/GoogleTest/GoogleTest-skip-timeout-stdout.txt) | 6 | ||||
-rw-r--r-- | Tests/RunCMake/GoogleTest/GoogleTestDiscoveryArgChange.cmake | 14 | ||||
-rw-r--r-- | Tests/RunCMake/GoogleTest/RunCMakeTest.cmake | 51 |
6 files changed, 82 insertions, 4 deletions
diff --git a/Modules/GoogleTest.cmake b/Modules/GoogleTest.cmake index efc33e3..f5f4f02 100644 --- a/Modules/GoogleTest.cmake +++ b/Modules/GoogleTest.cmake @@ -516,7 +516,8 @@ function(gtest_discover_tests TARGET) string(CONCAT ctest_include_content "if(EXISTS \"$<TARGET_FILE:${TARGET}>\")" "\n" " if(NOT EXISTS \"${ctest_tests_file}\" OR" "\n" - " NOT \"${ctest_tests_file}\" IS_NEWER_THAN \"$<TARGET_FILE:${TARGET}>\")" "\n" + " NOT \"${ctest_tests_file}\" IS_NEWER_THAN \"$<TARGET_FILE:${TARGET}>\" OR\n" + " NOT \"${ctest_tests_file}\" IS_NEWER_THAN \"\${CMAKE_CURRENT_LIST_FILE}\")\n" " include(\"${_GOOGLETEST_DISCOVER_TESTS_SCRIPT}\")" "\n" " gtest_discover_tests_impl(" "\n" " TEST_EXECUTABLE" " [==[" "$<TARGET_FILE:${TARGET}>" "]==]" "\n" diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-arg-change-basic-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-arg-change-basic-stdout.txt new file mode 100644 index 0000000..385159d --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-arg-change-basic-stdout.txt @@ -0,0 +1,7 @@ +Test project .*/Tests/RunCMake/GoogleTest/GoogleTest-discovery-arg-change + Test #1: basic\.case_foo + Test #2: basic\.case_bar + Test #3: basic\.disabled_case \(Disabled\) + Test #4: basic\.DISABLEDnot_really_case + +Total Tests: 4 diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-arg-change-typed-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-arg-change-typed-stdout.txt new file mode 100644 index 0000000..095fdcd --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-arg-change-typed-stdout.txt @@ -0,0 +1,5 @@ +Test project .*/Tests/RunCMake/GoogleTest/GoogleTest-discovery-arg-change + Test #1: typed/short\.case + Test #2: typed/float\.case + +Total Tests: 2 diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-skip-timeout-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-skip-test-stdout.txt index eeecb6a..d06cd0a 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest-skip-timeout-stdout.txt +++ b/Tests/RunCMake/GoogleTest/GoogleTest-skip-test-stdout.txt @@ -1,10 +1,10 @@ Test project .* - Start 20: skip_test.test1 -1/1 Test #20: skip_test.test1 \.+\*\*\*Skipped +[0-9.]+ sec + Start 36: skip_test.test1 +1/1 Test #36: skip_test.test1 \.+\*\*\*Skipped +[0-9.]+ sec 100% tests passed, 0 tests failed out of 1 Total Test time \(real\) = +[0-9.]+ sec The following tests did not run: -.*20 - skip_test\.test1 \(Skipped\) +.*36 - skip_test\.test1 \(Skipped\) diff --git a/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryArgChange.cmake b/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryArgChange.cmake new file mode 100644 index 0000000..e4e13c5 --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryArgChange.cmake @@ -0,0 +1,14 @@ +enable_language(CXX) +include(GoogleTest) + +enable_testing() + +include(xcode_sign_adhoc.cmake) + +add_executable(fake_gtest fake_gtest.cpp) +xcode_sign_adhoc(fake_gtest) + +gtest_discover_tests( + fake_gtest + TEST_FILTER "${TEST_FILTER}*" +) diff --git a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake index c5c5925..33a4b43 100644 --- a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake +++ b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake @@ -1,5 +1,12 @@ include(RunCMake) +if(RunCMake_GENERATOR STREQUAL "Borland Makefiles" OR + RunCMake_GENERATOR STREQUAL "Watcom WMake") + set(fs_delay 3) +else() + set(fs_delay 1.125) +endif() + function(run_GoogleTest DISCOVERY_MODE) # Use a single build tree for a few tests without cleaning. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GoogleTest-build) @@ -153,6 +160,46 @@ function(run_GoogleTest_discovery_timeout DISCOVERY_MODE) ) endfunction() +function(run_GoogleTest_discovery_arg_change DISCOVERY_MODE) + # Use a single build tree for a few tests without cleaning. + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GoogleTest-discovery-arg-change) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake_with_options(GoogleTestDiscoveryArgChange + -DCMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE=${DISCOVERY_MODE} + -DTEST_FILTER=basic + ) + run_cmake_command(GoogleTest-discovery-arg-change-build + ${CMAKE_COMMAND} + --build . + --config Release + --target fake_gtest + ) + run_cmake_command(GoogleTest-discovery-arg-change-basic + ${CMAKE_CTEST_COMMAND} + -C Release + -N + ) + execute_process(COMMAND ${CMAKE_COMMAND} -E sleep ${fs_delay}) # handle 1s resolution + run_cmake_with_options(GoogleTestDiscoveryArgChange + -DCMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE=${DISCOVERY_MODE} + -DTEST_FILTER=typed + ) + run_cmake_command(GoogleTest-discovery-arg-change-build + ${CMAKE_COMMAND} + --build . + --config Release + --target fake_gtest + ) + run_cmake_command(GoogleTest-discovery-arg-change-typed + ${CMAKE_CTEST_COMMAND} + -C Release + -N + ) +endfunction() + function(run_GoogleTest_discovery_multi_config) # Use a single build tree for a few tests without cleaning. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GoogleTest-discovery-multi-config) @@ -195,6 +242,10 @@ foreach(DISCOVERY_MODE POST_BUILD PRE_TEST) run_GoogleTestXML(${DISCOVERY_MODE}) message("Testing ${DISCOVERY_MODE} discovery mode via DISCOVERY_MODE option...") run_GoogleTest_discovery_timeout(${DISCOVERY_MODE}) + if(# VS 9 does not rebuild if POST_BUILD command changes. + NOT "${DISCOVERY_MODE};${RunCMake_GENERATOR}" MATCHES "^POST_BUILD;Visual Studio 9") + run_GoogleTest_discovery_arg_change(${DISCOVERY_MODE}) + endif() endforeach() if(RunCMake_GENERATOR_IS_MULTI_CONFIG) |