Skip to content

Commit

Permalink
Use SKIP_RETURN_CODE test property in catch_discover_tests
Browse files Browse the repository at this point in the history
I also added `SKIP_IS_FAILURE` option to the `catch_discover_tests`
function, to allow users to get back the old behaviour.

Closes #2873
  • Loading branch information
horenmar committed Sep 17, 2024
1 parent e200443 commit 79f2d66
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions extras/Catch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ same as the Catch name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``.
[OUTPUT_PREFIX prefix]
[OUTPUT_SUFFIX suffix]
[DISCOVERY_MODE <POST_BUILD|PRE_TEST>]
[SKIP_IS_FAILURE]
)

``catch_discover_tests`` sets up a post-build command on the test executable
Expand Down Expand Up @@ -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.
This requires cmake/ctest >= 3.22.

`DISCOVERY_MODE mode``
``DISCOVERY_MODE mode``
Provides control over when ``catch_discover_tests`` performs 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``
Expand All @@ -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
calling ``catch_discover_tests``. This provides a mechanism for globally selecting
a preferred test discovery behavior without having to modify each call site.

``SKIP_IS_FAILURE``
Disables skipped test detection.

#]=======================================================================]

Expand All @@ -151,7 +155,7 @@ function(catch_discover_tests TARGET)

cmake_parse_arguments(
""
""
"SKIP_IS_FAILURE"
"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"
${ARGN}
Expand Down Expand Up @@ -192,6 +196,9 @@ function(catch_discover_tests TARGET)
TARGET ${TARGET}
PROPERTY CROSSCOMPILING_EMULATOR
)
if (NOT _SKIP_IS_FAILURE)
set(_PROPERTIES ${_PROPERTIES} SKIP_RETURN_CODE 4)
endif()

if(_DISCOVERY_MODE STREQUAL "POST_BUILD")
add_custom_command(
Expand Down

0 comments on commit 79f2d66

Please sign in to comment.