From 4565b826cff3f8c11325c23d1536ded6acd8fa78 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 --- src/catch2/internal/catch_run_context.cpp | 27 +- .../internal/catch_test_case_tracker.cpp | 3 +- .../internal/catch_test_case_tracker.hpp | 5 +- .../Baselines/automake.sw.approved.txt | 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 + tests/SelfTest/Baselines/tap.sw.approved.txt | 86 +++- .../Baselines/teamcity.sw.approved.txt | 10 + tests/SelfTest/Baselines/xml.sw.approved.txt | 344 +++++++++++++- .../IntrospectiveTests/PartTracker.tests.cpp | 48 ++ 14 files changed, 1420 insertions(+), 18 deletions(-) diff --git a/src/catch2/internal/catch_run_context.cpp b/src/catch2/internal/catch_run_context.cpp index 7ea6fbaf..af656143 100644 --- a/src/catch2/internal/catch_run_context.cpp +++ b/src/catch2/internal/catch_run_context.cpp @@ -52,7 +52,7 @@ namespace Catch { currentTracker.addChild( tracker ); } - if( !ctx.completedCycle() && !tracker->isComplete() ) { + if( !tracker->isComplete() ) { tracker->open(); } @@ -66,8 +66,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; } @@ -200,7 +220,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/src/catch2/internal/catch_test_case_tracker.cpp b/src/catch2/internal/catch_test_case_tracker.cpp index 57399912..188d3ae1 100644 --- a/src/catch2/internal/catch_test_case_tracker.cpp +++ b/src/catch2/internal/catch_test_case_tracker.cpp @@ -186,7 +186,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/src/catch2/internal/catch_test_case_tracker.hpp b/src/catch2/internal/catch_test_case_tracker.hpp index ff8095ac..5d78009e 100644 --- a/src/catch2/internal/catch_test_case_tracker.hpp +++ b/src/catch2/internal/catch_test_case_tracker.hpp @@ -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/tests/SelfTest/Baselines/automake.sw.approved.txt b/tests/SelfTest/Baselines/automake.sw.approved.txt index d6cf5cc6..1f74267e 100644 --- a/tests/SelfTest/Baselines/automake.sw.approved.txt +++ b/tests/SelfTest/Baselines/automake.sw.approved.txt @@ -16,6 +16,11 @@ Nor would this :test-result: PASS #1912 -- test spec parser handles escaping :test-result: PASS #1913 - GENERATE inside a for loop should not keep recreating the generator :test-result: PASS #1913 - GENERATEs can share a line +:test-result: PASS #1938 - GENERATE after a section +:test-result: PASS #1938 - Section followed by flat generate +:test-result: PASS #1938 - flat generate +:test-result: PASS #1938 - mixed sections and generates +:test-result: PASS #1938 - nested generate :test-result: PASS #1954 - 7 arg template test case sig compiles - 1, 1, 1, 1, 1, 0, 0 :test-result: PASS #1954 - 7 arg template test case sig compiles - 5, 1, 1, 1, 1, 0, 0 :test-result: PASS #1954 - 7 arg template test case sig compiles - 5, 3, 1, 1, 1, 0, 0 diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt index fc8ce18b..6fd517fd 100644 --- a/tests/SelfTest/Baselines/compact.sw.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.approved.txt @@ -35,6 +35,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/tests/SelfTest/Baselines/console.std.approved.txt b/tests/SelfTest/Baselines/console.std.approved.txt index 75813901..fbcee17a 100644 --- a/tests/SelfTest/Baselines/console.std.approved.txt +++ b/tests/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: 343 | 269 passed | 70 failed | 4 failed as expected -assertions: 1941 | 1789 passed | 131 failed | 21 failed as expected +test cases: 348 | 274 passed | 70 failed | 4 failed as expected +assertions: 1983 | 1831 passed | 131 failed | 21 failed as expected diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt index be013f5c..084bb78c 100644 --- a/tests/SelfTest/Baselines/console.sw.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.approved.txt @@ -302,6 +302,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 ------------------------------------------------------------------------------- @@ -15194,6 +15612,6 @@ Misc.tests.cpp: Misc.tests.cpp:: PASSED: =============================================================================== -test cases: 343 | 253 passed | 86 failed | 4 failed as expected -assertions: 1958 | 1789 passed | 148 failed | 21 failed as expected +test cases: 348 | 258 passed | 86 failed | 4 failed as expected +assertions: 2000 | 1831 passed | 148 failed | 21 failed as expected diff --git a/tests/SelfTest/Baselines/console.swa4.approved.txt b/tests/SelfTest/Baselines/console.swa4.approved.txt index 7a40dace..ee504415 100644 --- a/tests/SelfTest/Baselines/console.swa4.approved.txt +++ b/tests/SelfTest/Baselines/console.swa4.approved.txt @@ -302,6 +302,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 ------------------------------------------------------------------------------- @@ -506,6 +924,6 @@ Condition.tests.cpp:: FAILED: CHECK( true != true ) =============================================================================== -test cases: 26 | 21 passed | 3 failed | 2 failed as expected -assertions: 57 | 50 passed | 4 failed | 3 failed as expected +test cases: 31 | 26 passed | 3 failed | 2 failed as expected +assertions: 99 | 92 passed | 4 failed | 3 failed as expected diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt index 9b42e725..3c24a3a6 100644 --- a/tests/SelfTest/Baselines/junit.sw.approved.txt +++ b/tests/SelfTest/Baselines/junit.sw.approved.txt @@ -1,7 +1,7 @@ - + @@ -35,6 +35,15 @@ Nor would this + + + + + + + + + diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt index 7c9b5f18..e51e53cc 100644 --- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt +++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt @@ -122,6 +122,15 @@ + + + + + + + + + diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt index 7d9b2ac8..8f615e30 100644 --- a/tests/SelfTest/Baselines/tap.sw.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.approved.txt @@ -68,6 +68,90 @@ ok {test-number} - i != j for: 1 != 4 ok {test-number} - i != j for: 2 != 3 # #1913 - GENERATEs can share a line ok {test-number} - i != j for: 2 != 4 +# #1938 - GENERATE after a section +ok {test-number} - with 1 message: 'A' +# #1938 - GENERATE after a section +ok {test-number} - m for: 1 +# #1938 - GENERATE after a section +ok {test-number} - m for: 2 +# #1938 - GENERATE after a section +ok {test-number} - m for: 3 +# #1938 - Section followed by flat generate +ok {test-number} - 1 +# #1938 - Section followed by flat generate +ok {test-number} - m for: 2 +# #1938 - Section followed by flat generate +ok {test-number} - m for: 3 +# #1938 - flat generate +ok {test-number} - m for: 1 +# #1938 - flat generate +ok {test-number} - m for: 2 +# #1938 - flat generate +ok {test-number} - m for: 3 +# #1938 - mixed sections and generates +ok {test-number} - with 1 message: 'A' +# #1938 - mixed sections and generates +ok {test-number} - with 3 messages: 'i := 1' and 'j := 3' and 'k := 5' +# #1938 - mixed sections and generates +ok {test-number} - with 1 message: 'B' +# #1938 - mixed sections and generates +ok {test-number} - with 3 messages: 'i := 1' and 'j := 3' and 'k := 6' +# #1938 - mixed sections and generates +ok {test-number} - with 1 message: 'B' +# #1938 - mixed sections and generates +ok {test-number} - with 3 messages: 'i := 1' and 'j := 4' and 'k := 5' +# #1938 - mixed sections and generates +ok {test-number} - with 3 messages: 'i := 1' and 'j := 4' and 'k := 6' +# #1938 - mixed sections and generates +ok {test-number} - with 1 message: 'A' +# #1938 - mixed sections and generates +ok {test-number} - with 3 messages: 'i := 2' and 'j := 3' and 'k := 5' +# #1938 - mixed sections and generates +ok {test-number} - with 1 message: 'B' +# #1938 - mixed sections and generates +ok {test-number} - with 3 messages: 'i := 2' and 'j := 3' and 'k := 6' +# #1938 - mixed sections and generates +ok {test-number} - with 1 message: 'B' +# #1938 - mixed sections and generates +ok {test-number} - with 3 messages: 'i := 2' and 'j := 4' and 'k := 5' +# #1938 - mixed sections and generates +ok {test-number} - with 3 messages: 'i := 2' and 'j := 4' and 'k := 6' +# #1938 - nested generate +ok {test-number} - m for: 1 +# #1938 - nested generate +ok {test-number} - n for: 1 +# #1938 - nested generate +ok {test-number} - m for: 1 +# #1938 - nested generate +ok {test-number} - n for: 2 +# #1938 - nested generate +ok {test-number} - m for: 1 +# #1938 - nested generate +ok {test-number} - n for: 3 +# #1938 - nested generate +ok {test-number} - m for: 2 +# #1938 - nested generate +ok {test-number} - n for: 1 +# #1938 - nested generate +ok {test-number} - m for: 2 +# #1938 - nested generate +ok {test-number} - n for: 2 +# #1938 - nested generate +ok {test-number} - m for: 2 +# #1938 - nested generate +ok {test-number} - n for: 3 +# #1938 - nested generate +ok {test-number} - m for: 3 +# #1938 - nested generate +ok {test-number} - n for: 1 +# #1938 - nested generate +ok {test-number} - m for: 3 +# #1938 - nested generate +ok {test-number} - n for: 2 +# #1938 - nested generate +ok {test-number} - m for: 3 +# #1938 - nested generate +ok {test-number} - n for: 3 # #1954 - 7 arg template test case sig compiles - 1, 1, 1, 1, 1, 0, 0 ok {test-number} - # #1954 - 7 arg template test case sig compiles - 5, 1, 1, 1, 1, 0, 0 @@ -3908,5 +3992,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0 ok {test-number} - # xmlentitycheck ok {test-number} - -1..1950 +1..1992 diff --git a/tests/SelfTest/Baselines/teamcity.sw.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.approved.txt index 703935f8..7a66092b 100644 --- a/tests/SelfTest/Baselines/teamcity.sw.approved.txt +++ b/tests/SelfTest/Baselines/teamcity.sw.approved.txt @@ -34,6 +34,16 @@ Tricky.tests.cpp:|nexplicit failure with message:|n "1514"'] ##teamcity[testFinished name='#1913 - GENERATE inside a for loop should not keep recreating the generator' duration="{duration}"] ##teamcity[testStarted name='#1913 - GENERATEs can share a line'] ##teamcity[testFinished name='#1913 - GENERATEs can share a line' duration="{duration}"] +##teamcity[testStarted name='#1938 - GENERATE after a section'] +##teamcity[testFinished name='#1938 - GENERATE after a section' duration="{duration}"] +##teamcity[testStarted name='#1938 - Section followed by flat generate'] +##teamcity[testFinished name='#1938 - Section followed by flat generate' duration="{duration}"] +##teamcity[testStarted name='#1938 - flat generate'] +##teamcity[testFinished name='#1938 - flat generate' duration="{duration}"] +##teamcity[testStarted name='#1938 - mixed sections and generates'] +##teamcity[testFinished name='#1938 - mixed sections and generates' duration="{duration}"] +##teamcity[testStarted name='#1938 - nested generate'] +##teamcity[testFinished name='#1938 - nested generate' duration="{duration}"] ##teamcity[testStarted name='#1954 - 7 arg template test case sig compiles - 1, 1, 1, 1, 1, 0, 0'] ##teamcity[testFinished name='#1954 - 7 arg template test case sig compiles - 1, 1, 1, 1, 1, 0, 0' duration="{duration}"] ##teamcity[testStarted name='#1954 - 7 arg template test case sig compiles - 5, 1, 1, 1, 1, 0, 0'] diff --git a/tests/SelfTest/Baselines/xml.sw.approved.txt b/tests/SelfTest/Baselines/xml.sw.approved.txt index 4bd9ca3d..f9617bd0 100644 --- a/tests/SelfTest/Baselines/xml.sw.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.approved.txt @@ -305,6 +305,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 + + + + @@ -18175,9 +18511,9 @@ loose text artifact
- - + + - - + + diff --git a/tests/SelfTest/IntrospectiveTests/PartTracker.tests.cpp b/tests/SelfTest/IntrospectiveTests/PartTracker.tests.cpp index fd40abfa..c56adc5e 100644 --- a/tests/SelfTest/IntrospectiveTests/PartTracker.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/PartTracker.tests.cpp @@ -4,6 +4,7 @@ */ #include +#include #include @@ -201,3 +202,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); +}