From 5c58edd9fbf65d22da1ab9694ed959974ac4519b Mon Sep 17 00:00:00 2001 From: akasakariko <148060537+akasakariko@users.noreply.github.com> Date: Fri, 13 Nov 2026 12:40:44 +0900 Subject: [PATCH] Fix crash when re-entering exhausted generator after earlier sections When preceding sections take more cycles than a following GENERATE has elements, GeneratorTracker completes and exhausts its underlying generator before all sibling sections finish. Re-entering GENERATE in a later cycle then dereferences the exhausted generator. Track exhaustion on GeneratorTracker, reset the underlying generator on re-entry while keeping CompletedSuccessfully, and handle nested generators created under an already completed tracker. Closes #2809 --- src/catch2/internal/catch_run_context.cpp | 65 ++++++++++-- .../Baselines/automake.sw.approved.txt | 1 + .../Baselines/automake.sw.multi.approved.txt | 1 + .../Baselines/compact.sw.approved.txt | 14 ++- .../Baselines/compact.sw.multi.approved.txt | 14 ++- .../Baselines/console.std.approved.txt | 4 +- .../Baselines/console.sw.approved.txt | 98 ++++++++++++++++++- .../Baselines/console.sw.multi.approved.txt | 98 ++++++++++++++++++- .../Baselines/console.swa4.approved.txt | 98 ++++++++++++++++++- .../SelfTest/Baselines/junit.sw.approved.txt | 9 +- .../Baselines/junit.sw.multi.approved.txt | 9 +- .../Baselines/sonarqube.sw.approved.txt | 7 ++ .../Baselines/sonarqube.sw.multi.approved.txt | 7 ++ tests/SelfTest/Baselines/tap.sw.approved.txt | 22 ++++- .../Baselines/tap.sw.multi.approved.txt | 22 ++++- .../Baselines/teamcity.sw.approved.txt | 2 + .../Baselines/teamcity.sw.multi.approved.txt | 2 + tests/SelfTest/Baselines/xml.sw.approved.txt | 79 ++++++++++++++- .../Baselines/xml.sw.multi.approved.txt | 79 ++++++++++++++- .../IntrospectiveTests/PartTracker.tests.cpp | 19 ++++ 20 files changed, 621 insertions(+), 29 deletions(-) diff --git a/src/catch2/internal/catch_run_context.cpp b/src/catch2/internal/catch_run_context.cpp index 18e01f75a7..9881ffde73 100644 --- a/src/catch2/internal/catch_run_context.cpp +++ b/src/catch2/internal/catch_run_context.cpp @@ -41,6 +41,9 @@ namespace Catch { // Filtered generator has moved to specific index due to // a filter, it needs special handling of `countedNext()` bool m_isFiltered = false; + // Tracks whether countedNext() returned false so we know + // m_generator is exhausted and cannot be dereferenced. + bool m_isExhausted = false; GeneratorTracker( TestCaseTracking::NameAndLocation&& nameAndLocation, @@ -119,14 +122,37 @@ namespace Catch { return nullptr; } - if ( !tracker->isComplete() ) { tracker->open(); } + if ( !tracker->isComplete() ) { + tracker->open(); + } else if ( tracker->m_isExhausted ) { + return nullptr; + } else { + ctx.setCurrentTracker( tracker ); + } return tracker; } + void resetGenerator( GeneratorBasePtr&& generator ) { + m_generator = CATCH_MOVE( generator ); + m_isExhausted = false; + m_ctx.setCurrentTracker( this ); + } + + void enterAsCompleted() { + m_runState = CompletedSuccessfully; + m_ctx.setCurrentTracker( this ); + } + // TrackerBase interface bool isGeneratorTracker() const override { return true; } void close() override { + if ( m_runState == CompletedSuccessfully ) { + assert( &m_ctx.currentTracker() == this ); + m_ctx.setCurrentTracker( m_parent ); + m_ctx.completeCycle(); + return; + } TrackerBase::close(); // If a generator has a child (it is followed by a section) // and none of its children have started, then we must wait @@ -183,12 +209,17 @@ namespace Catch { // value, but we do not want to invoke the side-effect if // this generator is still waiting for any child to start. assert( m_generator && "Tracker without generator" ); - if ( should_wait_for_child - || ( m_runState == CompletedSuccessfully - && !m_isFiltered // filtered generators cannot meaningfully move forward, as they would get past the filter - && m_generator->countedNext() ) ) { + if ( should_wait_for_child ) { m_children.clear(); m_runState = Executing; + } else if ( m_runState == CompletedSuccessfully && + !m_isFiltered ) { // filtered generators cannot meaningfully move forward, as they would get past the filter + if ( m_generator->countedNext() ) { + m_children.clear(); + m_runState = Executing; + } else { + m_isExhausted = true; + } } } @@ -542,15 +573,26 @@ namespace Catch { SourceLineInfo lineInfo, Generators::GeneratorBasePtr&& generator ) { - auto nameAndLoc = TestCaseTracking::NameAndLocation( static_cast( generatorName ), lineInfo ); + auto nameAndLocRef = TestCaseTracking::NameAndLocationRef( generatorName, lineInfo ); auto& currentTracker = m_trackerContext.currentTracker(); assert( - currentTracker.nameAndLocation() != nameAndLoc && + !( currentTracker.nameAndLocation() == nameAndLocRef ) && "Trying to create tracker for a generator that already has one" ); + if ( auto* existing = currentTracker.findChild( nameAndLocRef ) ) { + assert( existing->isGeneratorTracker() ); + assert( existing->isComplete() ); + auto* genTracker = + static_cast( existing ); + assert( genTracker->m_isExhausted ); + genTracker->resetGenerator( CATCH_MOVE( generator ) ); + return genTracker; + } + auto newTracker = Catch::Detail::make_unique( - CATCH_MOVE( nameAndLoc ), + TestCaseTracking::NameAndLocation( + static_cast( generatorName ), lineInfo ), m_trackerContext, ¤tTracker, CATCH_MOVE( generator ) ); @@ -568,9 +610,14 @@ namespace Catch { } auto returnPtr = newTracker.get(); + const bool parentAlreadyComplete = currentTracker.isComplete(); currentTracker.addChild( CATCH_MOVE( newTracker ) ); - returnPtr->open(); + if ( parentAlreadyComplete ) { + returnPtr->enterAsCompleted(); + } else { + returnPtr->open(); + } return returnPtr; } diff --git a/tests/SelfTest/Baselines/automake.sw.approved.txt b/tests/SelfTest/Baselines/automake.sw.approved.txt index ca5ca4e532..eea86eed75 100644 --- a/tests/SelfTest/Baselines/automake.sw.approved.txt +++ b/tests/SelfTest/Baselines/automake.sw.approved.txt @@ -26,6 +26,7 @@ Nor would this :test-result: PASS #2152 - ULP checks between differently signed values were wrong - double :test-result: PASS #2152 - ULP checks between differently signed values were wrong - float :test-result: XFAIL #2615 - Throwing in constructor generator fails test case but does not abort +:test-result: PASS #2809 - Sections taking more cycles than following GENERATE :test-result: PASS #3001: Enum-based bitfields can be captured :test-result: XFAIL #748 - captures with unexpected exceptions :test-result: PASS #809 diff --git a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt index 3593a21f75..b8fd73ecb5 100644 --- a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt @@ -24,6 +24,7 @@ :test-result: PASS #2152 - ULP checks between differently signed values were wrong - double :test-result: PASS #2152 - ULP checks between differently signed values were wrong - float :test-result: XFAIL #2615 - Throwing in constructor generator fails test case but does not abort +:test-result: PASS #2809 - Sections taking more cycles than following GENERATE :test-result: PASS #3001: Enum-based bitfields can be captured :test-result: XFAIL #748 - captures with unexpected exceptions :test-result: PASS #809 diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt index 21be159d5d..fd0bcc1515 100644 --- a/tests/SelfTest/Baselines/compact.sw.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.approved.txt @@ -85,6 +85,16 @@ Matchers.tests.cpp:: passed: smallest_non_zero, !WithinULP( -smalle Matchers.tests.cpp:: passed: smallest_non_zero, WithinULP( -smallest_non_zero, 2 ) for: 0.0f is within 2 ULPs of -1.40129846e-45f ([-4.20389539e-45, 1.40129846e-45]) Matchers.tests.cpp:: passed: smallest_non_zero, !WithinULP( -smallest_non_zero, 1 ) for: 0.0f not is within 1 ULPs of -1.40129846e-45f ([-2.80259693e-45, -0.00000000e+00]) Generators.tests.cpp:: failed: unexpected exception with message: 'failure to init'; expression was: {Unknown expression after the reported line} +PartTracker.tests.cpp:: passed: +PartTracker.tests.cpp:: passed: (g == true || g == false) for: true +PartTracker.tests.cpp:: passed: +PartTracker.tests.cpp:: passed: (g == true || g == false) for: true +PartTracker.tests.cpp:: passed: +PartTracker.tests.cpp:: passed: (g == true || g == false) for: true +PartTracker.tests.cpp:: passed: (nested == 1 || nested == 2) for: true +PartTracker.tests.cpp:: passed: +PartTracker.tests.cpp:: passed: (g == true || g == false) for: true +PartTracker.tests.cpp:: passed: (nested == 1 || nested == 2) for: true Compilation.tests.cpp:: passed: bf.e == 1 for: 1 == 1 Compilation.tests.cpp:: passed: 1 == bf.e for: 1 == 1 Exception.tests.cpp:: failed: unexpected exception with message: 'expected exception'; expression was: {Unknown expression after the reported line} @@ -3036,7 +3046,7 @@ InternalBenchmark.tests.cpp:: passed: med == 18. for: 18.0 == 18.0 InternalBenchmark.tests.cpp:: passed: q3 == 23. for: 23.0 == 23.0 Misc.tests.cpp:: passed: Misc.tests.cpp:: passed: -test cases: 456 | 336 passed | 96 failed | 6 skipped | 18 failed as expected -assertions: 2444 | 2243 passed | 158 failed | 43 failed as expected +test cases: 457 | 337 passed | 96 failed | 6 skipped | 18 failed as expected +assertions: 2454 | 2253 passed | 158 failed | 43 failed as expected diff --git a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt index f21ad6619d..1748c0a44f 100644 --- a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt @@ -83,6 +83,16 @@ Matchers.tests.cpp:: passed: smallest_non_zero, !WithinULP( -smalle Matchers.tests.cpp:: passed: smallest_non_zero, WithinULP( -smallest_non_zero, 2 ) for: 0.0f is within 2 ULPs of -1.40129846e-45f ([-4.20389539e-45, 1.40129846e-45]) Matchers.tests.cpp:: passed: smallest_non_zero, !WithinULP( -smallest_non_zero, 1 ) for: 0.0f not is within 1 ULPs of -1.40129846e-45f ([-2.80259693e-45, -0.00000000e+00]) Generators.tests.cpp:: failed: unexpected exception with message: 'failure to init'; expression was: {Unknown expression after the reported line} +PartTracker.tests.cpp:: passed: +PartTracker.tests.cpp:: passed: (g == true || g == false) for: true +PartTracker.tests.cpp:: passed: +PartTracker.tests.cpp:: passed: (g == true || g == false) for: true +PartTracker.tests.cpp:: passed: +PartTracker.tests.cpp:: passed: (g == true || g == false) for: true +PartTracker.tests.cpp:: passed: (nested == 1 || nested == 2) for: true +PartTracker.tests.cpp:: passed: +PartTracker.tests.cpp:: passed: (g == true || g == false) for: true +PartTracker.tests.cpp:: passed: (nested == 1 || nested == 2) for: true Compilation.tests.cpp:: passed: bf.e == 1 for: 1 == 1 Compilation.tests.cpp:: passed: 1 == bf.e for: 1 == 1 Exception.tests.cpp:: failed: unexpected exception with message: 'expected exception'; expression was: {Unknown expression after the reported line} @@ -3025,7 +3035,7 @@ InternalBenchmark.tests.cpp:: passed: med == 18. for: 18.0 == 18.0 InternalBenchmark.tests.cpp:: passed: q3 == 23. for: 23.0 == 23.0 Misc.tests.cpp:: passed: Misc.tests.cpp:: passed: -test cases: 456 | 336 passed | 96 failed | 6 skipped | 18 failed as expected -assertions: 2444 | 2243 passed | 158 failed | 43 failed as expected +test cases: 457 | 337 passed | 96 failed | 6 skipped | 18 failed as expected +assertions: 2454 | 2253 passed | 158 failed | 43 failed as expected diff --git a/tests/SelfTest/Baselines/console.std.approved.txt b/tests/SelfTest/Baselines/console.std.approved.txt index dd8c08850d..fa4b478c3b 100644 --- a/tests/SelfTest/Baselines/console.std.approved.txt +++ b/tests/SelfTest/Baselines/console.std.approved.txt @@ -1743,6 +1743,6 @@ due to unexpected exception with message: Why would you throw a std::string? =============================================================================== -test cases: 456 | 354 passed | 76 failed | 7 skipped | 19 failed as expected -assertions: 2422 | 2243 passed | 136 failed | 43 failed as expected +test cases: 457 | 355 passed | 76 failed | 7 skipped | 19 failed as expected +assertions: 2432 | 2253 passed | 136 failed | 43 failed as expected diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt index b37e3a5347..3337028865 100644 --- a/tests/SelfTest/Baselines/console.sw.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.approved.txt @@ -772,6 +772,100 @@ Generators.tests.cpp:: FAILED: due to unexpected exception with message: failure to init +------------------------------------------------------------------------------- +#2809 - Sections taking more cycles than following GENERATE + a + aa +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + +------------------------------------------------------------------------------- +#2809 - Sections taking more cycles than following GENERATE +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( (g == true || g == false) ) +with expansion: + true + +------------------------------------------------------------------------------- +#2809 - Sections taking more cycles than following GENERATE + a + ab +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + +------------------------------------------------------------------------------- +#2809 - Sections taking more cycles than following GENERATE +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( (g == true || g == false) ) +with expansion: + true + +------------------------------------------------------------------------------- +#2809 - Sections taking more cycles than following GENERATE + b + ba +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + +------------------------------------------------------------------------------- +#2809 - Sections taking more cycles than following GENERATE +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( (g == true || g == false) ) +with expansion: + true + +PartTracker.tests.cpp:: PASSED: + REQUIRE( (nested == 1 || nested == 2) ) +with expansion: + true + +------------------------------------------------------------------------------- +#2809 - Sections taking more cycles than following GENERATE + b + bb +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + +------------------------------------------------------------------------------- +#2809 - Sections taking more cycles than following GENERATE +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( (g == true || g == false) ) +with expansion: + true + +PartTracker.tests.cpp:: PASSED: + REQUIRE( (nested == 1 || nested == 2) ) +with expansion: + true + ------------------------------------------------------------------------------- #3001: Enum-based bitfields can be captured ------------------------------------------------------------------------------- @@ -20371,6 +20465,6 @@ Misc.tests.cpp: Misc.tests.cpp:: PASSED: =============================================================================== -test cases: 456 | 336 passed | 96 failed | 6 skipped | 18 failed as expected -assertions: 2444 | 2243 passed | 158 failed | 43 failed as expected +test cases: 457 | 337 passed | 96 failed | 6 skipped | 18 failed as expected +assertions: 2454 | 2253 passed | 158 failed | 43 failed as expected diff --git a/tests/SelfTest/Baselines/console.sw.multi.approved.txt b/tests/SelfTest/Baselines/console.sw.multi.approved.txt index 68807f619a..cb45ab0440 100644 --- a/tests/SelfTest/Baselines/console.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.multi.approved.txt @@ -770,6 +770,100 @@ Generators.tests.cpp:: FAILED: due to unexpected exception with message: failure to init +------------------------------------------------------------------------------- +#2809 - Sections taking more cycles than following GENERATE + a + aa +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + +------------------------------------------------------------------------------- +#2809 - Sections taking more cycles than following GENERATE +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( (g == true || g == false) ) +with expansion: + true + +------------------------------------------------------------------------------- +#2809 - Sections taking more cycles than following GENERATE + a + ab +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + +------------------------------------------------------------------------------- +#2809 - Sections taking more cycles than following GENERATE +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( (g == true || g == false) ) +with expansion: + true + +------------------------------------------------------------------------------- +#2809 - Sections taking more cycles than following GENERATE + b + ba +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + +------------------------------------------------------------------------------- +#2809 - Sections taking more cycles than following GENERATE +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( (g == true || g == false) ) +with expansion: + true + +PartTracker.tests.cpp:: PASSED: + REQUIRE( (nested == 1 || nested == 2) ) +with expansion: + true + +------------------------------------------------------------------------------- +#2809 - Sections taking more cycles than following GENERATE + b + bb +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + +------------------------------------------------------------------------------- +#2809 - Sections taking more cycles than following GENERATE +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( (g == true || g == false) ) +with expansion: + true + +PartTracker.tests.cpp:: PASSED: + REQUIRE( (nested == 1 || nested == 2) ) +with expansion: + true + ------------------------------------------------------------------------------- #3001: Enum-based bitfields can be captured ------------------------------------------------------------------------------- @@ -20360,6 +20454,6 @@ Misc.tests.cpp: Misc.tests.cpp:: PASSED: =============================================================================== -test cases: 456 | 336 passed | 96 failed | 6 skipped | 18 failed as expected -assertions: 2444 | 2243 passed | 158 failed | 43 failed as expected +test cases: 457 | 337 passed | 96 failed | 6 skipped | 18 failed as expected +assertions: 2454 | 2253 passed | 158 failed | 43 failed as expected diff --git a/tests/SelfTest/Baselines/console.swa4.approved.txt b/tests/SelfTest/Baselines/console.swa4.approved.txt index 63fb21133b..04d536d3fd 100644 --- a/tests/SelfTest/Baselines/console.swa4.approved.txt +++ b/tests/SelfTest/Baselines/console.swa4.approved.txt @@ -772,6 +772,100 @@ Generators.tests.cpp:: FAILED: due to unexpected exception with message: failure to init +------------------------------------------------------------------------------- +#2809 - Sections taking more cycles than following GENERATE + a + aa +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + +------------------------------------------------------------------------------- +#2809 - Sections taking more cycles than following GENERATE +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( (g == true || g == false) ) +with expansion: + true + +------------------------------------------------------------------------------- +#2809 - Sections taking more cycles than following GENERATE + a + ab +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + +------------------------------------------------------------------------------- +#2809 - Sections taking more cycles than following GENERATE +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( (g == true || g == false) ) +with expansion: + true + +------------------------------------------------------------------------------- +#2809 - Sections taking more cycles than following GENERATE + b + ba +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + +------------------------------------------------------------------------------- +#2809 - Sections taking more cycles than following GENERATE +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( (g == true || g == false) ) +with expansion: + true + +PartTracker.tests.cpp:: PASSED: + REQUIRE( (nested == 1 || nested == 2) ) +with expansion: + true + +------------------------------------------------------------------------------- +#2809 - Sections taking more cycles than following GENERATE + b + bb +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + +------------------------------------------------------------------------------- +#2809 - Sections taking more cycles than following GENERATE +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( (g == true || g == false) ) +with expansion: + true + +PartTracker.tests.cpp:: PASSED: + REQUIRE( (nested == 1 || nested == 2) ) +with expansion: + true + ------------------------------------------------------------------------------- #3001: Enum-based bitfields can be captured ------------------------------------------------------------------------------- @@ -968,6 +1062,6 @@ Condition.tests.cpp:: FAILED: CHECK( true != true ) =============================================================================== -test cases: 34 | 28 passed | 3 failed | 3 failed as expected -assertions: 104 | 96 passed | 4 failed | 4 failed as expected +test cases: 35 | 29 passed | 3 failed | 3 failed as expected +assertions: 114 | 106 passed | 4 failed | 4 failed as expected diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt index 123e3e7c19..a85ce2dab6 100644 --- a/tests/SelfTest/Baselines/junit.sw.approved.txt +++ b/tests/SelfTest/Baselines/junit.sw.approved.txt @@ -1,7 +1,7 @@ - + @@ -60,6 +60,13 @@ failure to init at Generators.tests.cpp: + + + + + + + diff --git a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt index e67bb206df..a091863727 100644 --- a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt @@ -1,6 +1,6 @@ - + @@ -59,6 +59,13 @@ failure to init at Generators.tests.cpp: + + + + + + + diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt index 2467a2b36c..f50db10111 100644 --- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt +++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt @@ -291,6 +291,13 @@ at AssertionHandler.tests.cpp: + + + + + + + diff --git a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt index ebaff4e023..69c0497027 100644 --- a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt @@ -290,6 +290,13 @@ at AssertionHandler.tests.cpp: + + + + + + + diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt index ef6a595031..a5ca2f7b55 100644 --- a/tests/SelfTest/Baselines/tap.sw.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.approved.txt @@ -166,6 +166,26 @@ ok {test-number} - smallest_non_zero, WithinULP( -smallest_non_zero, 2 ) for: 0. ok {test-number} - smallest_non_zero, !WithinULP( -smallest_non_zero, 1 ) for: 0.0f not is within 1 ULPs of -1.40129846e-45f ([-2.80259693e-45, -0.00000000e+00]) # #2615 - Throwing in constructor generator fails test case but does not abort not ok {test-number} - unexpected exception with message: 'failure to init'; expression was: {Unknown expression after the reported line} +# #2809 - Sections taking more cycles than following GENERATE +ok {test-number} - +# #2809 - Sections taking more cycles than following GENERATE +ok {test-number} - (g == true || g == false) for: true +# #2809 - Sections taking more cycles than following GENERATE +ok {test-number} - +# #2809 - Sections taking more cycles than following GENERATE +ok {test-number} - (g == true || g == false) for: true +# #2809 - Sections taking more cycles than following GENERATE +ok {test-number} - +# #2809 - Sections taking more cycles than following GENERATE +ok {test-number} - (g == true || g == false) for: true +# #2809 - Sections taking more cycles than following GENERATE +ok {test-number} - (nested == 1 || nested == 2) for: true +# #2809 - Sections taking more cycles than following GENERATE +ok {test-number} - +# #2809 - Sections taking more cycles than following GENERATE +ok {test-number} - (g == true || g == false) for: true +# #2809 - Sections taking more cycles than following GENERATE +ok {test-number} - (nested == 1 || nested == 2) for: true # #3001: Enum-based bitfields can be captured ok {test-number} - bf.e == 1 for: 1 == 1 # #3001: Enum-based bitfields can be captured @@ -4907,5 +4927,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0 ok {test-number} - # xmlentitycheck ok {test-number} - -1..2456 +1..2466 diff --git a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt index 0c88e530b0..88c3e2a444 100644 --- a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt @@ -164,6 +164,26 @@ ok {test-number} - smallest_non_zero, WithinULP( -smallest_non_zero, 2 ) for: 0. ok {test-number} - smallest_non_zero, !WithinULP( -smallest_non_zero, 1 ) for: 0.0f not is within 1 ULPs of -1.40129846e-45f ([-2.80259693e-45, -0.00000000e+00]) # #2615 - Throwing in constructor generator fails test case but does not abort not ok {test-number} - unexpected exception with message: 'failure to init'; expression was: {Unknown expression after the reported line} +# #2809 - Sections taking more cycles than following GENERATE +ok {test-number} - +# #2809 - Sections taking more cycles than following GENERATE +ok {test-number} - (g == true || g == false) for: true +# #2809 - Sections taking more cycles than following GENERATE +ok {test-number} - +# #2809 - Sections taking more cycles than following GENERATE +ok {test-number} - (g == true || g == false) for: true +# #2809 - Sections taking more cycles than following GENERATE +ok {test-number} - +# #2809 - Sections taking more cycles than following GENERATE +ok {test-number} - (g == true || g == false) for: true +# #2809 - Sections taking more cycles than following GENERATE +ok {test-number} - (nested == 1 || nested == 2) for: true +# #2809 - Sections taking more cycles than following GENERATE +ok {test-number} - +# #2809 - Sections taking more cycles than following GENERATE +ok {test-number} - (g == true || g == false) for: true +# #2809 - Sections taking more cycles than following GENERATE +ok {test-number} - (nested == 1 || nested == 2) for: true # #3001: Enum-based bitfields can be captured ok {test-number} - bf.e == 1 for: 1 == 1 # #3001: Enum-based bitfields can be captured @@ -4896,5 +4916,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0 ok {test-number} - # xmlentitycheck ok {test-number} - -1..2456 +1..2466 diff --git a/tests/SelfTest/Baselines/teamcity.sw.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.approved.txt index 4b6104d5e6..fc55be8f03 100644 --- a/tests/SelfTest/Baselines/teamcity.sw.approved.txt +++ b/tests/SelfTest/Baselines/teamcity.sw.approved.txt @@ -55,6 +55,8 @@ ##teamcity[testStarted name='#2615 - Throwing in constructor generator fails test case but does not abort'] ##teamcity[testIgnored name='#2615 - Throwing in constructor generator fails test case but does not abort' message='Generators.tests.cpp:|n...............................................................................|n|nGenerators.tests.cpp:|nunexpected exception with message:|n "failure to init"|n {Unknown expression after the reported line}|nwith expansion:|n {Unknown expression after the reported line}|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testFinished name='#2615 - Throwing in constructor generator fails test case but does not abort' duration="{duration}"] +##teamcity[testStarted name='#2809 - Sections taking more cycles than following GENERATE'] +##teamcity[testFinished name='#2809 - Sections taking more cycles than following GENERATE' duration="{duration}"] ##teamcity[testStarted name='#3001: Enum-based bitfields can be captured'] ##teamcity[testFinished name='#3001: Enum-based bitfields can be captured' duration="{duration}"] ##teamcity[testStarted name='#748 - captures with unexpected exceptions'] diff --git a/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt index 42b0120fa6..feefae9183 100644 --- a/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt @@ -55,6 +55,8 @@ ##teamcity[testStarted name='#2615 - Throwing in constructor generator fails test case but does not abort'] ##teamcity[testIgnored name='#2615 - Throwing in constructor generator fails test case but does not abort' message='Generators.tests.cpp:|n...............................................................................|n|nGenerators.tests.cpp:|nunexpected exception with message:|n "failure to init"|n {Unknown expression after the reported line}|nwith expansion:|n {Unknown expression after the reported line}|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testFinished name='#2615 - Throwing in constructor generator fails test case but does not abort' duration="{duration}"] +##teamcity[testStarted name='#2809 - Sections taking more cycles than following GENERATE'] +##teamcity[testFinished name='#2809 - Sections taking more cycles than following GENERATE' duration="{duration}"] ##teamcity[testStarted name='#3001: Enum-based bitfields can be captured'] ##teamcity[testFinished name='#3001: Enum-based bitfields can be captured' duration="{duration}"] ##teamcity[testStarted name='#748 - captures with unexpected exceptions'] diff --git a/tests/SelfTest/Baselines/xml.sw.approved.txt b/tests/SelfTest/Baselines/xml.sw.approved.txt index 44a07c79d9..1a66756c80 100644 --- a/tests/SelfTest/Baselines/xml.sw.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.approved.txt @@ -681,6 +681,81 @@ Nor would this + +
+
+ +
+ +
+ + + (g == true || g == false) + + + true + + +
+
+ +
+ +
+ + + (g == true || g == false) + + + true + + +
+
+ +
+ +
+ + + (g == true || g == false) + + + true + + + + + (nested == 1 || nested == 2) + + + true + + +
+
+ +
+ +
+ + + (g == true || g == false) + + + true + + + + + (nested == 1 || nested == 2) + + + true + + + +
@@ -23652,6 +23727,6 @@ Approx( -1.95996398454005449 ) - - + + diff --git a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt index a72c451457..e66940d2a6 100644 --- a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt @@ -681,6 +681,81 @@ Nor would this
+ +
+
+ +
+ +
+ + + (g == true || g == false) + + + true + + +
+
+ +
+ +
+ + + (g == true || g == false) + + + true + + +
+
+ +
+ +
+ + + (g == true || g == false) + + + true + + + + + (nested == 1 || nested == 2) + + + true + + +
+
+ +
+ +
+ + + (g == true || g == false) + + + true + + + + + (nested == 1 || nested == 2) + + + true + + + +
@@ -23651,6 +23726,6 @@ Approx( -1.95996398454005449 ) - - + + diff --git a/tests/SelfTest/IntrospectiveTests/PartTracker.tests.cpp b/tests/SelfTest/IntrospectiveTests/PartTracker.tests.cpp index 09c765aa3c..a0814796c9 100644 --- a/tests/SelfTest/IntrospectiveTests/PartTracker.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/PartTracker.tests.cpp @@ -255,3 +255,22 @@ TEST_CASE("#1938 - Section followed by flat generate", "[.][regression][generato auto m = GENERATE(2, 3); REQUIRE(m); } + +TEST_CASE("#2809 - Sections taking more cycles than following GENERATE", "[regression][generators]") { + bool enterNested = false; + SECTION("a") { + SECTION("aa") { SUCCEED(); } + SECTION("ab") { SUCCEED(); } + } + SECTION("b") { + SECTION("ba") { enterNested = true; SUCCEED(); } + SECTION("bb") { enterNested = true; SUCCEED(); } + } + + auto g = GENERATE(true, false); + REQUIRE((g == true || g == false)); + if (enterNested) { + auto nested = GENERATE(1, 2); + REQUIRE((nested == 1 || nested == 2)); + } +}