Use SKIP_RETURN_CODE test property in catch_discover_tests

I also added `SKIP_IS_FAILURE` option to the `catch_discover_tests`
function, to allow users to get back the old behaviour.

Closes #2873
This commit is contained in:
Martin Hořeňovský 2024-09-16 22:18:49 +02:00
parent e200443b84
commit 79f2d66ea3
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A

View File

@ -38,6 +38,7 @@ same as the Catch name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``.
[OUTPUT_PREFIX prefix] [OUTPUT_PREFIX prefix]
[OUTPUT_SUFFIX suffix] [OUTPUT_SUFFIX suffix]
[DISCOVERY_MODE <POST_BUILD|PRE_TEST>] [DISCOVERY_MODE <POST_BUILD|PRE_TEST>]
[SKIP_IS_FAILURE]
) )
``catch_discover_tests`` sets up a post-build command on the test executable ``catch_discover_tests`` sets up a post-build command on the test executable
@ -131,7 +132,7 @@ same as the Catch name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``.
of test cases from the test executable and when the tests are executed themselves. of test cases from the test executable and when the tests are executed themselves.
This requires cmake/ctest >= 3.22. This requires cmake/ctest >= 3.22.
`DISCOVERY_MODE mode`` ``DISCOVERY_MODE mode``
Provides control over when ``catch_discover_tests`` performs test discovery. Provides control over when ``catch_discover_tests`` performs test discovery.
By default, ``POST_BUILD`` sets up a post-build command to perform test discovery By default, ``POST_BUILD`` sets up a post-build command to perform test discovery
at build time. In certain scenarios, like cross-compiling, this ``POST_BUILD`` at build time. In certain scenarios, like cross-compiling, this ``POST_BUILD``
@ -143,6 +144,9 @@ same as the Catch name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``.
``CMAKE_CATCH_DISCOVER_TESTS_DISCOVERY_MODE`` variable if it is not passed when ``CMAKE_CATCH_DISCOVER_TESTS_DISCOVERY_MODE`` variable if it is not passed when
calling ``catch_discover_tests``. This provides a mechanism for globally selecting calling ``catch_discover_tests``. This provides a mechanism for globally selecting
a preferred test discovery behavior without having to modify each call site. a preferred test discovery behavior without having to modify each call site.
``SKIP_IS_FAILURE``
Disables skipped test detection.
#]=======================================================================] #]=======================================================================]
@ -151,7 +155,7 @@ function(catch_discover_tests TARGET)
cmake_parse_arguments( cmake_parse_arguments(
"" ""
"" "SKIP_IS_FAILURE"
"TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST;REPORTER;OUTPUT_DIR;OUTPUT_PREFIX;OUTPUT_SUFFIX;DISCOVERY_MODE" "TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST;REPORTER;OUTPUT_DIR;OUTPUT_PREFIX;OUTPUT_SUFFIX;DISCOVERY_MODE"
"TEST_SPEC;EXTRA_ARGS;PROPERTIES;DL_PATHS;DL_FRAMEWORK_PATHS" "TEST_SPEC;EXTRA_ARGS;PROPERTIES;DL_PATHS;DL_FRAMEWORK_PATHS"
${ARGN} ${ARGN}
@ -192,6 +196,9 @@ function(catch_discover_tests TARGET)
TARGET ${TARGET} TARGET ${TARGET}
PROPERTY CROSSCOMPILING_EMULATOR PROPERTY CROSSCOMPILING_EMULATOR
) )
if (NOT _SKIP_IS_FAILURE)
set(_PROPERTIES ${_PROPERTIES} SKIP_RETURN_CODE 4)
endif()
if(_DISCOVERY_MODE STREQUAL "POST_BUILD") if(_DISCOVERY_MODE STREQUAL "POST_BUILD")
add_custom_command( add_custom_command(