diff options
author | Brad King <brad.king@kitware.com> | 2021-08-10 13:26:40 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-08-10 13:26:49 (GMT) |
commit | 1b3d892ac2b1650f07ae89a80665f1965dbb21be (patch) | |
tree | 4c1d8fd0c9b0dd338a0ab45af4653d5c6df302dc /Modules | |
parent | 8706f7a6170577369d7410c111a743986ec26e8f (diff) | |
parent | ea6a7dd1c2e76533d6aa4725e04acc3d8e1ed912 (diff) | |
download | CMake-1b3d892ac2b1650f07ae89a80665f1965dbb21be.zip CMake-1b3d892ac2b1650f07ae89a80665f1965dbb21be.tar.gz CMake-1b3d892ac2b1650f07ae89a80665f1965dbb21be.tar.bz2 |
Merge topic 'GoogleTest-gtest-filter'
ea6a7dd1c2 GoogleTest: Add TEST_FILTER arg to gtest_discover_tests
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6406
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/GoogleTest.cmake | 11 | ||||
-rw-r--r-- | Modules/GoogleTestAddTests.cmake | 11 |
2 files changed, 19 insertions, 3 deletions
diff --git a/Modules/GoogleTest.cmake b/Modules/GoogleTest.cmake index 80d8e23..a483c03 100644 --- a/Modules/GoogleTest.cmake +++ b/Modules/GoogleTest.cmake @@ -151,6 +151,7 @@ same as the Google Test name (i.e. ``suite.testcase``); see also [WORKING_DIRECTORY dir] [TEST_PREFIX prefix] [TEST_SUFFIX suffix] + [TEST_FILTER expr] [NO_PRETTY_TYPES] [NO_PRETTY_VALUES] [PROPERTIES name1 value1...] [TEST_LIST var] @@ -204,6 +205,12 @@ same as the Google Test name (i.e. ``suite.testcase``); see also every discovered test case. Both ``TEST_PREFIX`` and ``TEST_SUFFIX`` may be specified. + ``TEST_FILTER expr`` + .. versionadded:: 3.22 + + Filter expression to pass to ``--gtest_filter`` argument during test + discovery. + ``NO_PRETTY_TYPES`` By default, the type index of type-parameterized tests is replaced by the actual type name in the CTest test name. If this behavior is undesirable @@ -411,7 +418,7 @@ function(gtest_discover_tests TARGET) "" "NO_PRETTY_TYPES;NO_PRETTY_VALUES" "TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST;DISCOVERY_TIMEOUT;XML_OUTPUT_DIR;DISCOVERY_MODE" - "EXTRA_ARGS;PROPERTIES" + "EXTRA_ARGS;PROPERTIES;TEST_FILTER" ${ARGN} ) @@ -475,6 +482,7 @@ function(gtest_discover_tests TARGET) -D "TEST_PROPERTIES=${_PROPERTIES}" -D "TEST_PREFIX=${_TEST_PREFIX}" -D "TEST_SUFFIX=${_TEST_SUFFIX}" + -D "TEST_FILTER=${_TEST_FILTER}" -D "NO_PRETTY_TYPES=${_NO_PRETTY_TYPES}" -D "NO_PRETTY_VALUES=${_NO_PRETTY_VALUES}" -D "TEST_LIST=${_TEST_LIST}" @@ -515,6 +523,7 @@ function(gtest_discover_tests TARGET) " TEST_PROPERTIES" " [==[" "${_PROPERTIES}" "]==]" "\n" " TEST_PREFIX" " [==[" "${_TEST_PREFIX}" "]==]" "\n" " TEST_SUFFIX" " [==[" "${_TEST_SUFFIX}" "]==]" "\n" + " TEST_FILTER" " [==[" "${_TEST_FILTER}" "]==]" "\n" " NO_PRETTY_TYPES" " [==[" "${_NO_PRETTY_TYPES}" "]==]" "\n" " NO_PRETTY_VALUES" " [==[" "${_NO_PRETTY_VALUES}" "]==]" "\n" " TEST_LIST" " [==[" "${_TEST_LIST}" "]==]" "\n" diff --git a/Modules/GoogleTestAddTests.cmake b/Modules/GoogleTestAddTests.cmake index 0f79c9a..6b3bf34 100644 --- a/Modules/GoogleTestAddTests.cmake +++ b/Modules/GoogleTestAddTests.cmake @@ -44,7 +44,7 @@ function(gtest_discover_tests_impl) cmake_parse_arguments( "" "" - "NO_PRETTY_TYPES;NO_PRETTY_VALUES;TEST_EXECUTABLE;TEST_WORKING_DIR;TEST_PREFIX;TEST_SUFFIX;TEST_LIST;CTEST_FILE;TEST_DISCOVERY_TIMEOUT;TEST_XML_OUTPUT_DIR" + "NO_PRETTY_TYPES;NO_PRETTY_VALUES;TEST_EXECUTABLE;TEST_WORKING_DIR;TEST_PREFIX;TEST_SUFFIX;TEST_LIST;CTEST_FILE;TEST_DISCOVERY_TIMEOUT;TEST_XML_OUTPUT_DIR;TEST_FILTER" "TEST_EXTRA_ARGS;TEST_PROPERTIES;TEST_EXECUTOR" ${ARGN} ) @@ -58,6 +58,12 @@ function(gtest_discover_tests_impl) set(tests) set(tests_buffer) + if(_TEST_FILTER) + set(filter "--gtest_filter=${_TEST_FILTER}") + else() + set(filter) + endif() + # Run test executable to get list of available tests if(NOT EXISTS "${_TEST_EXECUTABLE}") message(FATAL_ERROR @@ -66,7 +72,7 @@ function(gtest_discover_tests_impl) ) endif() execute_process( - COMMAND ${_TEST_EXECUTOR} "${_TEST_EXECUTABLE}" --gtest_list_tests + COMMAND ${_TEST_EXECUTOR} "${_TEST_EXECUTABLE}" --gtest_list_tests ${filter} WORKING_DIRECTORY "${_TEST_WORKING_DIR}" TIMEOUT ${_TEST_DISCOVERY_TIMEOUT} OUTPUT_VARIABLE output @@ -178,6 +184,7 @@ if(CMAKE_SCRIPT_MODE_FILE) TEST_WORKING_DIR ${TEST_WORKING_DIR} TEST_PREFIX ${TEST_PREFIX} TEST_SUFFIX ${TEST_SUFFIX} + TEST_FILTER ${TEST_FILTER} TEST_LIST ${TEST_LIST} CTEST_FILE ${CTEST_FILE} TEST_DISCOVERY_TIMEOUT ${TEST_DISCOVERY_TIMEOUT} |