Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMartin Hořeňovský2026-04-02 22:58:33 +0200
committerMartin Hořeňovský2026-04-03 10:19:05 +0200
commit9f1b48a94fdc7a54aa87fc9bd26d6b1b3f560d4c (patch)
tree1b855cdbffa4268957d8e8d7dffb5ff9df77e455
parentf4e83daa184595cee80a8d37f145cb5d6b9b21ba (diff)
downloadcatch3-9f1b48a94fdc7a54aa87fc9bd26d6b1b3f560d4c.tar.gz
Inline SKIP/FAIL in RunContext to fix build failure with prefixed macros
Closes #3087
-rw-r--r--src/catch2/internal/catch_run_context.cpp19
-rw-r--r--tests/ExtraTests/CMakeLists.txt6
2 files changed, 17 insertions, 8 deletions
diff --git a/src/catch2/internal/catch_run_context.cpp b/src/catch2/internal/catch_run_context.cpp
index 93bcdf66..fd4b7a38 100644
--- a/src/catch2/internal/catch_run_context.cpp
+++ b/src/catch2/internal/catch_run_context.cpp
@@ -60,9 +60,14 @@ namespace Catch {
// can be, so the tracker has to throw for a wrong
// filter to stop the execution flow.
if (filter.type == PathFilter::For::Section) {
- // TBD: Explicit SKIP, or new exception that says
- // "don't continue", but doesn't show in totals?
- SKIP();
+ // We want the semantics of `SKIP()`, but we inline it
+ // to avoid issues with conditionally prefixed macros
+ INTERNAL_CATCH_MSG(
+ "SKIP",
+ Catch::ResultWas::ExplicitSkip,
+ Catch::ResultDisposition::Normal,
+ "" );
+ Catch::Detail::Unreachable();
}
// '*' is the wildcard for "all elements in generator"
// used for filtering sections below the generator, but
@@ -519,8 +524,12 @@ namespace Catch {
// TBD: Do we want to avoid the warning if the generator is filtered?
if ( m_config->warnAboutInfiniteGenerators() &&
!generator->isFinite() ) {
- // TBD: Would it be better to expand this macro inline?
- FAIL( "GENERATE() would run infinitely" );
+ // We want the semantics of `FAIL()`, but we inline it
+ // to avoid issues with conditionally prefixed macros
+ INTERNAL_CATCH_MSG( "FAIL",
+ Catch::ResultWas::ExplicitFailure,
+ Catch::ResultDisposition::Normal,
+ "GENERATE() would run infinitely" );
}
auto nameAndLoc = TestCaseTracking::NameAndLocation( static_cast<std::string>( generatorName ), lineInfo );
diff --git a/tests/ExtraTests/CMakeLists.txt b/tests/ExtraTests/CMakeLists.txt
index def88be5..886c059e 100644
--- a/tests/ExtraTests/CMakeLists.txt
+++ b/tests/ExtraTests/CMakeLists.txt
@@ -56,9 +56,9 @@ set(TESTS_DIR ${CATCH_DIR}/tests/ExtraTests)
add_executable(PrefixedMacros ${TESTS_DIR}/X01-PrefixedMacros.cpp)
target_compile_definitions(PrefixedMacros PRIVATE CATCH_CONFIG_PREFIX_ALL CATCH_CONFIG_RUNTIME_STATIC_REQUIRE)
-# Macro configuration does not touch the compiled parts, so we can link
-# it against the main library
-target_link_libraries(PrefixedMacros Catch2WithMain)
+# We want to verify that the main library can also be built with prefixed
+# macros, regression test for #3087.
+target_link_libraries(PrefixedMacros Catch2_buildall_interface)
add_test(NAME CATCH_CONFIG_PREFIX_ALL COMMAND PrefixedMacros -s)
set_tests_properties(CATCH_CONFIG_PREFIX_ALL