From 79f2d66ea3f018c00ed78b1ed89806e6f86b1ef0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Mon, 16 Sep 2024 22:18:49 +0200 Subject: [PATCH] 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 --- extras/Catch.cmake | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/extras/Catch.cmake b/extras/Catch.cmake index e080665b..c1712885 100644 --- a/extras/Catch.cmake +++ b/extras/Catch.cmake @@ -38,6 +38,7 @@ same as the Catch name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``. [OUTPUT_PREFIX prefix] [OUTPUT_SUFFIX suffix] [DISCOVERY_MODE ] + [SKIP_IS_FAILURE] ) ``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. 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`` @@ -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. #]=======================================================================] @@ -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} @@ -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(