Merge topic 'GoogleTest-DISCOVERY_EXTRA_ARGS'

2dcba446e2 GoogleTest: Add DISCOVERY_EXTRA_ARGS to gtest_discover_tests()
f55f9fd5c1 Help: Mention TEST_LIST with gtest_discover_tests() can omit tests

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9856
This commit is contained in:
Brad King
2024-10-07 13:10:25 +00:00
committed by Kitware Robot
7 changed files with 102 additions and 2 deletions
+16 -1
View File
@@ -166,6 +166,7 @@ same as the Google Test name (i.e. ``suite.testcase``); see also
[DISCOVERY_TIMEOUT seconds]
[XML_OUTPUT_DIR dir]
[DISCOVERY_MODE <POST_BUILD|PRE_TEST>]
[DISCOVERY_EXTRA_ARGS args...]
)
.. versionadded:: 3.10
@@ -186,7 +187,8 @@ same as the Google Test name (i.e. ``suite.testcase``); see also
more fine-grained test control is needed, custom content may be provided
through an external CTest script using the :prop_dir:`TEST_INCLUDE_FILES`
directory property. The set of discovered tests is made accessible to such a
script via the ``<target>_TESTS`` variable.
script via the ``<target>_TESTS`` variable (see the ``TEST_LIST`` option
below for further discussion and limitations).
The options are:
@@ -247,6 +249,11 @@ same as the Google Test name (i.e. ``suite.testcase``); see also
executable is being used in multiple calls to ``gtest_discover_tests()``.
Note that this variable is only available in CTest.
Due to a limitation of CMake's parsing rules, any test with a square
bracket in its name will be omitted from the list of tests stored in
this variable. Such tests will still be defined and executed by
``ctest`` as normal though.
``DISCOVERY_TIMEOUT num``
.. versionadded:: 3.10.3
@@ -294,6 +301,11 @@ same as the Google Test name (i.e. ``suite.testcase``); see also
for globally selecting a preferred test discovery behavior without having
to modify each call site.
``DISCOVERY_EXTRA_ARGS args...``
.. versionadded:: 3.31
Any extra arguments to pass on the command line for the discovery command.
.. versionadded:: 3.29
The :prop_tgt:`TEST_LAUNCHER` target property is honored during test
discovery and test execution.
@@ -540,6 +552,7 @@ function(gtest_discover_tests target)
)
set(multiValueArgs
EXTRA_ARGS
DISCOVERY_EXTRA_ARGS
PROPERTIES
TEST_FILTER
)
@@ -664,6 +677,7 @@ function(gtest_discover_tests target)
-D "TEST_LIST=${arg_TEST_LIST}"
-D "CTEST_FILE=${ctest_tests_file}"
-D "TEST_DISCOVERY_TIMEOUT=${arg_DISCOVERY_TIMEOUT}"
-D "TEST_DISCOVERY_EXTRA_ARGS=${arg_DISCOVERY_EXTRA_ARGS}"
-D "TEST_XML_OUTPUT_DIR=${arg_XML_OUTPUT_DIR}"
-P "${CMAKE_ROOT}/Modules/GoogleTestAddTests.cmake"
VERBATIM
@@ -706,6 +720,7 @@ function(gtest_discover_tests target)
" TEST_LIST" " [==[${arg_TEST_LIST}]==]" "\n"
" CTEST_FILE" " [==[${ctest_tests_file}]==]" "\n"
" TEST_DISCOVERY_TIMEOUT" " [==[${arg_DISCOVERY_TIMEOUT}]==]" "\n"
" TEST_DISCOVERY_EXTRA_ARGS [==[${arg_DISCOVERY_EXTRA_ARGS}]==]" "\n"
" TEST_XML_OUTPUT_DIR" " [==[${arg_XML_OUTPUT_DIR}]==]" "\n"
" )" "\n"
" endif()" "\n"
+10 -1
View File
@@ -83,6 +83,7 @@ function(gtest_discover_tests_impl)
# way to avoid problems with preserving empty list values and escaping.
TEST_FILTER
TEST_EXTRA_ARGS
TEST_DISCOVERY_EXTRA_ARGS
TEST_PROPERTIES
TEST_EXECUTOR
)
@@ -121,9 +122,16 @@ function(gtest_discover_tests_impl)
" Path: '${arg_TEST_EXECUTABLE}'"
)
endif()
set(discovery_extra_args "")
if(NOT "${arg_TEST_DISCOVERY_EXTRA_ARGS}" STREQUAL "")
list(JOIN arg_TEST_DISCOVERY_EXTRA_ARGS "]==] [==[" discovery_extra_args)
set(discovery_extra_args "[==[${discovery_extra_args}]==]")
endif()
cmake_language(EVAL CODE
"execute_process(
COMMAND ${launcherArgs} [==[${arg_TEST_EXECUTABLE}]==] --gtest_list_tests ${filter}
COMMAND ${launcherArgs} [==[${arg_TEST_EXECUTABLE}]==] --gtest_list_tests ${filter} ${discovery_extra_args}
WORKING_DIRECTORY [==[${arg_TEST_WORKING_DIR}]==]
TIMEOUT ${arg_TEST_DISCOVERY_TIMEOUT}
OUTPUT_VARIABLE output
@@ -286,6 +294,7 @@ if(CMAKE_SCRIPT_MODE_FILE)
TEST_DISCOVERY_TIMEOUT ${TEST_DISCOVERY_TIMEOUT}
TEST_XML_OUTPUT_DIR ${TEST_XML_OUTPUT_DIR}
TEST_EXTRA_ARGS "${TEST_EXTRA_ARGS}"
TEST_DISCOVERY_EXTRA_ARGS "${TEST_DISCOVERY_EXTRA_ARGS}"
TEST_PROPERTIES "${TEST_PROPERTIES}"
)
endif()