Skip to content

Commit 9f1b48a

Browse files
committed
Inline SKIP/FAIL in RunContext to fix build failure with prefixed macros
Closes #3087
1 parent f4e83da commit 9f1b48a

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

src/catch2/internal/catch_run_context.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,14 @@ namespace Catch {
6060
// can be, so the tracker has to throw for a wrong
6161
// filter to stop the execution flow.
6262
if (filter.type == PathFilter::For::Section) {
63-
// TBD: Explicit SKIP, or new exception that says
64-
// "don't continue", but doesn't show in totals?
65-
SKIP();
63+
// We want the semantics of `SKIP()`, but we inline it
64+
// to avoid issues with conditionally prefixed macros
65+
INTERNAL_CATCH_MSG(
66+
"SKIP",
67+
Catch::ResultWas::ExplicitSkip,
68+
Catch::ResultDisposition::Normal,
69+
"" );
70+
Catch::Detail::Unreachable();
6671
}
6772
// '*' is the wildcard for "all elements in generator"
6873
// used for filtering sections below the generator, but
@@ -519,8 +524,12 @@ namespace Catch {
519524
// TBD: Do we want to avoid the warning if the generator is filtered?
520525
if ( m_config->warnAboutInfiniteGenerators() &&
521526
!generator->isFinite() ) {
522-
// TBD: Would it be better to expand this macro inline?
523-
FAIL( "GENERATE() would run infinitely" );
527+
// We want the semantics of `FAIL()`, but we inline it
528+
// to avoid issues with conditionally prefixed macros
529+
INTERNAL_CATCH_MSG( "FAIL",
530+
Catch::ResultWas::ExplicitFailure,
531+
Catch::ResultDisposition::Normal,
532+
"GENERATE() would run infinitely" );
524533
}
525534

526535
auto nameAndLoc = TestCaseTracking::NameAndLocation( static_cast<std::string>( generatorName ), lineInfo );

tests/ExtraTests/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ set(TESTS_DIR ${CATCH_DIR}/tests/ExtraTests)
5656

5757
add_executable(PrefixedMacros ${TESTS_DIR}/X01-PrefixedMacros.cpp)
5858
target_compile_definitions(PrefixedMacros PRIVATE CATCH_CONFIG_PREFIX_ALL CATCH_CONFIG_RUNTIME_STATIC_REQUIRE)
59-
# Macro configuration does not touch the compiled parts, so we can link
60-
# it against the main library
61-
target_link_libraries(PrefixedMacros Catch2WithMain)
59+
# We want to verify that the main library can also be built with prefixed
60+
# macros, regression test for #3087.
61+
target_link_libraries(PrefixedMacros Catch2_buildall_interface)
6262

6363
add_test(NAME CATCH_CONFIG_PREFIX_ALL COMMAND PrefixedMacros -s)
6464
set_tests_properties(CATCH_CONFIG_PREFIX_ALL

0 commit comments

Comments
 (0)