From b79a83e4aa6641a00c32b760456507b1745fc06e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Sat, 4 Jul 2020 17:45:30 +0200 Subject: [PATCH] Modify generator tracking to allow GENERATEs between SECTIONs This means that code such as ```cpp TEST_CASE() { SECTION("first") { SUCCEED(); } auto _ = GENERATE(1, 2); SECTION("second") { SUCCEED(); } } ``` will run and report 3 assertions, 1 from section "first" and 2 from section "second". This also applies for greater and potentially more confusing nesting, but fundamentally it is up to the user to avoid overly complex and confusing nestings, just as with `SECTION`s. The old behaviour of `GENERATE` as first thing in a `TEST_CASE`, `GENERATE` not followed by a `SECTION`, etc etc should be unchanged. Closes #1938 --- include/internal/catch_run_context.cpp | 27 +- include/internal/catch_test_case_tracker.cpp | 3 +- include/internal/catch_test_case_tracker.h | 5 +- .../Baselines/compact.sw.approved.txt | 42 ++ .../Baselines/console.std.approved.txt | 4 +- .../Baselines/console.sw.approved.txt | 422 +++++++++++++++++- .../Baselines/console.swa4.approved.txt | 422 +++++++++++++++++- .../SelfTest/Baselines/junit.sw.approved.txt | 11 +- .../Baselines/sonarqube.sw.approved.txt | 9 + .../SelfTest/Baselines/xml.sw.approved.txt | 344 +++++++++++++- .../IntrospectiveTests/PartTracker.tests.cpp | 47 ++ .../SelfTest/UsageTests/Generators.tests.cpp | 1 + 12 files changed, 1320 insertions(+), 17 deletions(-) diff --git a/include/internal/catch_run_context.cpp b/include/internal/catch_run_context.cpp index a676e05774..c7a9f203f0 100644 --- a/include/internal/catch_run_context.cpp +++ b/include/internal/catch_run_context.cpp @@ -50,7 +50,7 @@ namespace Catch { currentTracker.addChild( tracker ); } - if( !ctx.completedCycle() && !tracker->isComplete() ) { + if( !tracker->isComplete() ) { tracker->open(); } @@ -64,8 +64,28 @@ namespace Catch { } void close() override { TrackerBase::close(); - // Generator interface only finds out if it has another item on atual move - if (m_runState == CompletedSuccessfully && m_generator->next()) { + // If a generator has a child (it is followed by a section) + // and none of its children have started, then we must wait + // until later to start consuming its values. + // This catches cases where `GENERATE` is placed between two + // `SECTION`s. + // **The check for m_children.empty cannot be removed**. + // doing so would break `GENERATE` _not_ followed by `SECTION`s. + const bool should_wait_for_child = + !m_children.empty() && + std::find_if( m_children.begin(), + m_children.end(), + []( TestCaseTracking::ITrackerPtr tracker ) { + return tracker->hasStarted(); + } ) == m_children.end(); + + // This check is a bit tricky, because m_generator->next() + // has a side-effect, where it consumes generator's current + // value, but we do not want to invoke the side-effect if + // this generator is still waiting for any child to start. + if ( should_wait_for_child || + ( m_runState == CompletedSuccessfully && + m_generator->next() ) ) { m_children.clear(); m_runState = Executing; } @@ -206,7 +226,6 @@ namespace Catch { using namespace Generators; GeneratorTracker& tracker = GeneratorTracker::acquire(m_trackerContext, TestCaseTracking::NameAndLocation( static_cast(generatorName), lineInfo ) ); - assert( tracker.isOpen() ); m_lastAssertionInfo.lineInfo = lineInfo; return tracker; } diff --git a/include/internal/catch_test_case_tracker.cpp b/include/internal/catch_test_case_tracker.cpp index 2399fab4ae..2541a3d17c 100644 --- a/include/internal/catch_test_case_tracker.cpp +++ b/include/internal/catch_test_case_tracker.cpp @@ -187,7 +187,8 @@ namespace TestCaseTracking { bool SectionTracker::isComplete() const { bool complete = true; - if ((m_filters.empty() || m_filters[0] == "") + if (m_filters.empty() + || m_filters[0] == "" || std::find(m_filters.begin(), m_filters.end(), m_trimmed_name) != m_filters.end()) { complete = TrackerBase::isComplete(); } diff --git a/include/internal/catch_test_case_tracker.h b/include/internal/catch_test_case_tracker.h index b79a539a47..131e2ea04b 100644 --- a/include/internal/catch_test_case_tracker.h +++ b/include/internal/catch_test_case_tracker.h @@ -55,6 +55,7 @@ namespace TestCaseTracking { virtual bool isSuccessfullyCompleted() const = 0; virtual bool isOpen() const = 0; // Started but not complete virtual bool hasChildren() const = 0; + virtual bool hasStarted() const = 0; virtual ITracker& parent() = 0; @@ -121,7 +122,9 @@ namespace TestCaseTracking { bool isSuccessfullyCompleted() const override; bool isOpen() const override; bool hasChildren() const override; - + bool hasStarted() const override { + return m_runState != NotStarted; + } void addChild( ITrackerPtr const& child ) override; diff --git a/projects/SelfTest/Baselines/compact.sw.approved.txt b/projects/SelfTest/Baselines/compact.sw.approved.txt index cdff666653..59a909b2f0 100644 --- a/projects/SelfTest/Baselines/compact.sw.approved.txt +++ b/projects/SelfTest/Baselines/compact.sw.approved.txt @@ -36,6 +36,48 @@ Generators.tests.cpp:: passed: i != j for: 1 != 3 Generators.tests.cpp:: passed: i != j for: 1 != 4 Generators.tests.cpp:: passed: i != j for: 2 != 3 Generators.tests.cpp:: passed: i != j for: 2 != 4 +PartTracker.tests.cpp:: passed: with 1 message: 'A' +PartTracker.tests.cpp:: passed: m for: 1 +PartTracker.tests.cpp:: passed: m for: 2 +PartTracker.tests.cpp:: passed: m for: 3 +PartTracker.tests.cpp:: passed: 1 +PartTracker.tests.cpp:: passed: m for: 2 +PartTracker.tests.cpp:: passed: m for: 3 +PartTracker.tests.cpp:: passed: m for: 1 +PartTracker.tests.cpp:: passed: m for: 2 +PartTracker.tests.cpp:: passed: m for: 3 +PartTracker.tests.cpp:: passed: with 1 message: 'A' +PartTracker.tests.cpp:: passed: with 3 messages: 'i := 1' and 'j := 3' and 'k := 5' +PartTracker.tests.cpp:: passed: with 1 message: 'B' +PartTracker.tests.cpp:: passed: with 3 messages: 'i := 1' and 'j := 3' and 'k := 6' +PartTracker.tests.cpp:: passed: with 1 message: 'B' +PartTracker.tests.cpp:: passed: with 3 messages: 'i := 1' and 'j := 4' and 'k := 5' +PartTracker.tests.cpp:: passed: with 3 messages: 'i := 1' and 'j := 4' and 'k := 6' +PartTracker.tests.cpp:: passed: with 1 message: 'A' +PartTracker.tests.cpp:: passed: with 3 messages: 'i := 2' and 'j := 3' and 'k := 5' +PartTracker.tests.cpp:: passed: with 1 message: 'B' +PartTracker.tests.cpp:: passed: with 3 messages: 'i := 2' and 'j := 3' and 'k := 6' +PartTracker.tests.cpp:: passed: with 1 message: 'B' +PartTracker.tests.cpp:: passed: with 3 messages: 'i := 2' and 'j := 4' and 'k := 5' +PartTracker.tests.cpp:: passed: with 3 messages: 'i := 2' and 'j := 4' and 'k := 6' +PartTracker.tests.cpp:: passed: m for: 1 +PartTracker.tests.cpp:: passed: n for: 1 +PartTracker.tests.cpp:: passed: m for: 1 +PartTracker.tests.cpp:: passed: n for: 2 +PartTracker.tests.cpp:: passed: m for: 1 +PartTracker.tests.cpp:: passed: n for: 3 +PartTracker.tests.cpp:: passed: m for: 2 +PartTracker.tests.cpp:: passed: n for: 1 +PartTracker.tests.cpp:: passed: m for: 2 +PartTracker.tests.cpp:: passed: n for: 2 +PartTracker.tests.cpp:: passed: m for: 2 +PartTracker.tests.cpp:: passed: n for: 3 +PartTracker.tests.cpp:: passed: m for: 3 +PartTracker.tests.cpp:: passed: n for: 1 +PartTracker.tests.cpp:: passed: m for: 3 +PartTracker.tests.cpp:: passed: n for: 2 +PartTracker.tests.cpp:: passed: m for: 3 +PartTracker.tests.cpp:: passed: n for: 3 Misc.tests.cpp:: passed: Misc.tests.cpp:: passed: Misc.tests.cpp:: passed: diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index 479fdafc50..c1600545cb 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -1380,6 +1380,6 @@ due to unexpected exception with message: Why would you throw a std::string? =============================================================================== -test cases: 316 | 242 passed | 70 failed | 4 failed as expected -assertions: 1716 | 1564 passed | 131 failed | 21 failed as expected +test cases: 321 | 247 passed | 70 failed | 4 failed as expected +assertions: 1758 | 1606 passed | 131 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index 521de74b80..3603215f9f 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -309,6 +309,424 @@ Generators.tests.cpp:: PASSED: with expansion: 2 != 4 +------------------------------------------------------------------------------- +#1938 - GENERATE after a section + A +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with message: + A + +------------------------------------------------------------------------------- +#1938 - GENERATE after a section + B +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 1 + +------------------------------------------------------------------------------- +#1938 - GENERATE after a section + B +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 2 + +------------------------------------------------------------------------------- +#1938 - GENERATE after a section + B +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 3 + +------------------------------------------------------------------------------- +#1938 - Section followed by flat generate + A +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( 1 ) + +------------------------------------------------------------------------------- +#1938 - Section followed by flat generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 2 + +------------------------------------------------------------------------------- +#1938 - Section followed by flat generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 3 + +------------------------------------------------------------------------------- +#1938 - flat generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 1 + +------------------------------------------------------------------------------- +#1938 - flat generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 2 + +------------------------------------------------------------------------------- +#1938 - flat generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 3 + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates + A +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with message: + A + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with messages: + i := 1 + j := 3 + k := 5 + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates + B +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with message: + B + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with messages: + i := 1 + j := 3 + k := 6 + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates + B +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with message: + B + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with messages: + i := 1 + j := 4 + k := 5 + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with messages: + i := 1 + j := 4 + k := 6 + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates + A +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with message: + A + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with messages: + i := 2 + j := 3 + k := 5 + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates + B +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with message: + B + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with messages: + i := 2 + j := 3 + k := 6 + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates + B +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with message: + B + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with messages: + i := 2 + j := 4 + k := 5 + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with messages: + i := 2 + j := 4 + k := 6 + +------------------------------------------------------------------------------- +#1938 - nested generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 1 + +PartTracker.tests.cpp:: PASSED: + REQUIRE( n ) +with expansion: + 1 + +------------------------------------------------------------------------------- +#1938 - nested generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 1 + +PartTracker.tests.cpp:: PASSED: + REQUIRE( n ) +with expansion: + 2 + +------------------------------------------------------------------------------- +#1938 - nested generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 1 + +PartTracker.tests.cpp:: PASSED: + REQUIRE( n ) +with expansion: + 3 + +------------------------------------------------------------------------------- +#1938 - nested generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 2 + +PartTracker.tests.cpp:: PASSED: + REQUIRE( n ) +with expansion: + 1 + +------------------------------------------------------------------------------- +#1938 - nested generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 2 + +PartTracker.tests.cpp:: PASSED: + REQUIRE( n ) +with expansion: + 2 + +------------------------------------------------------------------------------- +#1938 - nested generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 2 + +PartTracker.tests.cpp:: PASSED: + REQUIRE( n ) +with expansion: + 3 + +------------------------------------------------------------------------------- +#1938 - nested generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 3 + +PartTracker.tests.cpp:: PASSED: + REQUIRE( n ) +with expansion: + 1 + +------------------------------------------------------------------------------- +#1938 - nested generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 3 + +PartTracker.tests.cpp:: PASSED: + REQUIRE( n ) +with expansion: + 2 + +------------------------------------------------------------------------------- +#1938 - nested generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 3 + +PartTracker.tests.cpp:: PASSED: + REQUIRE( n ) +with expansion: + 3 + ------------------------------------------------------------------------------- #1954 - 7 arg template test case sig compiles - 1, 1, 1, 1, 1, 0, 0 ------------------------------------------------------------------------------- @@ -13709,6 +14127,6 @@ Misc.tests.cpp: Misc.tests.cpp:: PASSED: =============================================================================== -test cases: 316 | 226 passed | 86 failed | 4 failed as expected -assertions: 1733 | 1564 passed | 148 failed | 21 failed as expected +test cases: 321 | 231 passed | 86 failed | 4 failed as expected +assertions: 1775 | 1606 passed | 148 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/console.swa4.approved.txt b/projects/SelfTest/Baselines/console.swa4.approved.txt index e91b884500..599382255e 100644 --- a/projects/SelfTest/Baselines/console.swa4.approved.txt +++ b/projects/SelfTest/Baselines/console.swa4.approved.txt @@ -309,6 +309,424 @@ Generators.tests.cpp:: PASSED: with expansion: 2 != 4 +------------------------------------------------------------------------------- +#1938 - GENERATE after a section + A +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with message: + A + +------------------------------------------------------------------------------- +#1938 - GENERATE after a section + B +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 1 + +------------------------------------------------------------------------------- +#1938 - GENERATE after a section + B +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 2 + +------------------------------------------------------------------------------- +#1938 - GENERATE after a section + B +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 3 + +------------------------------------------------------------------------------- +#1938 - Section followed by flat generate + A +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( 1 ) + +------------------------------------------------------------------------------- +#1938 - Section followed by flat generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 2 + +------------------------------------------------------------------------------- +#1938 - Section followed by flat generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 3 + +------------------------------------------------------------------------------- +#1938 - flat generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 1 + +------------------------------------------------------------------------------- +#1938 - flat generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 2 + +------------------------------------------------------------------------------- +#1938 - flat generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 3 + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates + A +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with message: + A + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with messages: + i := 1 + j := 3 + k := 5 + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates + B +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with message: + B + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with messages: + i := 1 + j := 3 + k := 6 + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates + B +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with message: + B + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with messages: + i := 1 + j := 4 + k := 5 + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with messages: + i := 1 + j := 4 + k := 6 + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates + A +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with message: + A + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with messages: + i := 2 + j := 3 + k := 5 + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates + B +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with message: + B + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with messages: + i := 2 + j := 3 + k := 6 + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates + B +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with message: + B + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with messages: + i := 2 + j := 4 + k := 5 + +------------------------------------------------------------------------------- +#1938 - mixed sections and generates +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: +with messages: + i := 2 + j := 4 + k := 6 + +------------------------------------------------------------------------------- +#1938 - nested generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 1 + +PartTracker.tests.cpp:: PASSED: + REQUIRE( n ) +with expansion: + 1 + +------------------------------------------------------------------------------- +#1938 - nested generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 1 + +PartTracker.tests.cpp:: PASSED: + REQUIRE( n ) +with expansion: + 2 + +------------------------------------------------------------------------------- +#1938 - nested generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 1 + +PartTracker.tests.cpp:: PASSED: + REQUIRE( n ) +with expansion: + 3 + +------------------------------------------------------------------------------- +#1938 - nested generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 2 + +PartTracker.tests.cpp:: PASSED: + REQUIRE( n ) +with expansion: + 1 + +------------------------------------------------------------------------------- +#1938 - nested generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 2 + +PartTracker.tests.cpp:: PASSED: + REQUIRE( n ) +with expansion: + 2 + +------------------------------------------------------------------------------- +#1938 - nested generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 2 + +PartTracker.tests.cpp:: PASSED: + REQUIRE( n ) +with expansion: + 3 + +------------------------------------------------------------------------------- +#1938 - nested generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 3 + +PartTracker.tests.cpp:: PASSED: + REQUIRE( n ) +with expansion: + 1 + +------------------------------------------------------------------------------- +#1938 - nested generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 3 + +PartTracker.tests.cpp:: PASSED: + REQUIRE( n ) +with expansion: + 2 + +------------------------------------------------------------------------------- +#1938 - nested generate +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: PASSED: + REQUIRE( m ) +with expansion: + 3 + +PartTracker.tests.cpp:: PASSED: + REQUIRE( n ) +with expansion: + 3 + ------------------------------------------------------------------------------- #1954 - 7 arg template test case sig compiles - 1, 1, 1, 1, 1, 0, 0 ------------------------------------------------------------------------------- @@ -513,6 +931,6 @@ Condition.tests.cpp:: FAILED: CHECK( true != true ) =============================================================================== -test cases: 26 | 21 passed | 3 failed | 2 failed as expected -assertions: 58 | 51 passed | 4 failed | 3 failed as expected +test cases: 31 | 26 passed | 3 failed | 2 failed as expected +assertions: 100 | 93 passed | 4 failed | 3 failed as expected diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index 0a5ccecde5..9c8505340c 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -1,7 +1,7 @@ - + @@ -35,6 +35,15 @@ Nor would this + + + + + + + + + diff --git a/projects/SelfTest/Baselines/sonarqube.sw.approved.txt b/projects/SelfTest/Baselines/sonarqube.sw.approved.txt index 9b161560c5..35360ebcac 100644 --- a/projects/SelfTest/Baselines/sonarqube.sw.approved.txt +++ b/projects/SelfTest/Baselines/sonarqube.sw.approved.txt @@ -99,6 +99,15 @@ + + + + + + + + + diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index d10412bf3b..30d113efe1 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -318,6 +318,342 @@ Nor would this + +
+ +
+
+ + + m + + + 1 + + + +
+
+ + + m + + + 2 + + + +
+
+ + + m + + + 3 + + + +
+ +
+ +
+ + + 1 + + + 1 + + + +
+ + + m + + + 2 + + + + + m + + + 3 + + + +
+ + + + m + + + 1 + + + + + m + + + 2 + + + + + m + + + 3 + + + + + +
+ +
+ + i := 1 + + + j := 3 + + + k := 5 + +
+ +
+ + i := 1 + + + j := 3 + + + k := 6 + +
+ +
+ + i := 1 + + + j := 4 + + + k := 5 + + + i := 1 + + + j := 4 + + + k := 6 + +
+ +
+ + i := 2 + + + j := 3 + + + k := 5 + +
+ +
+ + i := 2 + + + j := 3 + + + k := 6 + +
+ +
+ + i := 2 + + + j := 4 + + + k := 5 + + + i := 2 + + + j := 4 + + + k := 6 + + +
+ + + + m + + + 1 + + + + + n + + + 1 + + + + + m + + + 1 + + + + + n + + + 2 + + + + + m + + + 1 + + + + + n + + + 3 + + + + + m + + + 2 + + + + + n + + + 1 + + + + + m + + + 2 + + + + + n + + + 2 + + + + + m + + + 2 + + + + + n + + + 3 + + + + + m + + + 3 + + + + + n + + + 1 + + + + + m + + + 3 + + + + + n + + + 2 + + + + + m + + + 3 + + + + + n + + + 3 + + + + @@ -16375,9 +16711,9 @@ loose text artifact
- - + + - - + + diff --git a/projects/SelfTest/IntrospectiveTests/PartTracker.tests.cpp b/projects/SelfTest/IntrospectiveTests/PartTracker.tests.cpp index 837d3661b1..41a7bc0a89 100644 --- a/projects/SelfTest/IntrospectiveTests/PartTracker.tests.cpp +++ b/projects/SelfTest/IntrospectiveTests/PartTracker.tests.cpp @@ -204,3 +204,50 @@ TEST_CASE("#1670 regression check", "[.approvals][tracker]") { SECTION("2") SUCCEED(); } } + +// #1938 required a rework on how generator tracking works, so that `GENERATE` +// supports being sandwiched between two `SECTION`s. The following tests check +// various other scenarios through checking output in approval tests. +TEST_CASE("#1938 - GENERATE after a section", "[.][regression][generators]") { + SECTION("A") { + SUCCEED("A"); + } + auto m = GENERATE(1, 2, 3); + SECTION("B") { + REQUIRE(m); + } +} + +TEST_CASE("#1938 - flat generate", "[.][regression][generators]") { + auto m = GENERATE(1, 2, 3); + REQUIRE(m); +} + +TEST_CASE("#1938 - nested generate", "[.][regression][generators]") { + auto m = GENERATE(1, 2, 3); + auto n = GENERATE(1, 2, 3); + REQUIRE(m); + REQUIRE(n); +} + +TEST_CASE("#1938 - mixed sections and generates", "[.][regression][generators]") { + auto i = GENERATE(1, 2); + SECTION("A") { + SUCCEED("A"); + } + auto j = GENERATE(3, 4); + SECTION("B") { + SUCCEED("B"); + } + auto k = GENERATE(5, 6); + CAPTURE(i, j, k); + SUCCEED(); +} + +TEST_CASE("#1938 - Section followed by flat generate", "[.][regression][generators]") { + SECTION("A") { + REQUIRE(1); + } + auto m = GENERATE(2, 3); + REQUIRE(m); +} diff --git a/projects/SelfTest/UsageTests/Generators.tests.cpp b/projects/SelfTest/UsageTests/Generators.tests.cpp index 7ed3e5b3a8..f2906dbf50 100644 --- a/projects/SelfTest/UsageTests/Generators.tests.cpp +++ b/projects/SelfTest/UsageTests/Generators.tests.cpp @@ -267,6 +267,7 @@ TEST_CASE("#1913 - GENERATEs can share a line", "[regression][generators]") { REQUIRE(i != j); } + #if defined(__clang__) #pragma clang diagnostic pop #endif