diff --git a/include/internal/catch_interfaces_reporter.h b/include/internal/catch_interfaces_reporter.h index 6419afc0..654abf32 100644 --- a/include/internal/catch_interfaces_reporter.h +++ b/include/internal/catch_interfaces_reporter.h @@ -208,7 +208,7 @@ namespace Catch virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0; - virtual void assertionEnded( AssertionStats const& assertionStats ) = 0; + virtual bool assertionEnded( AssertionStats const& assertionStats ) = 0; virtual void sectionEnded( SectionStats const& sectionStats ) = 0; virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0; virtual void testGroupEnded( TestGroupStats const& testGroupStats ) = 0; diff --git a/include/internal/catch_legacy_reporter_adapter.h b/include/internal/catch_legacy_reporter_adapter.h index 08bf6854..32d03f15 100644 --- a/include/internal/catch_legacy_reporter_adapter.h +++ b/include/internal/catch_legacy_reporter_adapter.h @@ -25,7 +25,7 @@ namespace Catch virtual void testCaseStarting( TestCaseInfo const& testInfo ); virtual void sectionStarting( SectionInfo const& sectionInfo ); virtual void assertionStarting( AssertionInfo const& ); - virtual void assertionEnded( AssertionStats const& assertionStats ); + virtual bool assertionEnded( AssertionStats const& assertionStats ); virtual void sectionEnded( SectionStats const& sectionStats ); virtual void testCaseEnded( TestCaseStats const& testCaseStats ); virtual void testGroupEnded( TestGroupStats const& testGroupStats ); diff --git a/include/internal/catch_legacy_reporter_adapter.hpp b/include/internal/catch_legacy_reporter_adapter.hpp index 27ffc1e1..412363d4 100644 --- a/include/internal/catch_legacy_reporter_adapter.hpp +++ b/include/internal/catch_legacy_reporter_adapter.hpp @@ -40,7 +40,7 @@ namespace Catch // Not on legacy interface } - void LegacyReporterAdapter::assertionEnded( AssertionStats const& assertionStats ) { + bool LegacyReporterAdapter::assertionEnded( AssertionStats const& assertionStats ) { if( assertionStats.assertionResult.getResultType() != ResultWas::Ok ) { for( std::vector::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end(); it != itEnd; @@ -55,6 +55,7 @@ namespace Catch } } m_legacyReporter->Result( assertionStats.assertionResult ); + return true; } void LegacyReporterAdapter::sectionEnded( SectionStats const& sectionStats ) { if( sectionStats.missingAssertions ) diff --git a/include/internal/catch_runner_impl.hpp b/include/internal/catch_runner_impl.hpp index 7058d827..5191d7fa 100644 --- a/include/internal/catch_runner_impl.hpp +++ b/include/internal/catch_runner_impl.hpp @@ -171,11 +171,11 @@ namespace Catch { m_totals.assertions.failed++; } - m_reporter->assertionEnded( AssertionStats( result, m_messages, m_totals ) ); + if( m_reporter->assertionEnded( AssertionStats( result, m_messages, m_totals ) ) ) + m_messages.clear(); // Reset working state m_lastAssertionInfo = AssertionInfo( "", m_lastAssertionInfo.lineInfo, "{Unknown expression after the reported line}" , m_lastAssertionInfo.resultDisposition ); - m_messages.clear(); } virtual bool sectionStarted ( diff --git a/include/reporters/catch_reporter_console.hpp b/include/reporters/catch_reporter_console.hpp index cd5cd7be..ceccce94 100644 --- a/include/reporters/catch_reporter_console.hpp +++ b/include/reporters/catch_reporter_console.hpp @@ -39,18 +39,19 @@ namespace Catch { virtual void assertionStarting( AssertionInfo const& ) { } - virtual void assertionEnded( AssertionStats const& _assertionStats ) { + virtual bool assertionEnded( AssertionStats const& _assertionStats ) { AssertionResult const& result = _assertionStats.assertionResult; // Drop out if result was successful and we're not printing those if( !m_config->includeSuccessfulResults() && result.isOk() ) - return; + return false; lazyPrint(); AssertionPrinter printer( stream, _assertionStats ); printer.print(); stream << std::endl; + return true; } virtual void sectionStarting( SectionInfo const& _sectionInfo ) { diff --git a/projects/SelfTest/Baselines/approvedResults.txt b/projects/SelfTest/Baselines/approvedResults.txt index 1de7f385..215ed606 100644 --- a/projects/SelfTest/Baselines/approvedResults.txt +++ b/projects/SelfTest/Baselines/approvedResults.txt @@ -397,7 +397,8 @@ MessageTests.cpp:37: FAILED: CHECK( a == 1 ) with expansion: 2 == 1 -with message: +with messages: + this message may be logged later this message should be logged MessageTests.cpp:41: FAILED: @@ -514,7 +515,8 @@ MiscTests.cpp:111: FAILED: CHECK( ( fib[i] % 2 ) == 0 ) with expansion: 1 == 0 -with message: +with messages: + Testing if fib[2] (2) is even Testing if fib[3] (3) is even MiscTests.cpp:111: FAILED: @@ -528,7 +530,8 @@ MiscTests.cpp:111: FAILED: CHECK( ( fib[i] % 2 ) == 0 ) with expansion: 1 == 0 -with message: +with messages: + Testing if fib[5] (8) is even Testing if fib[6] (13) is even MiscTests.cpp:111: FAILED: @@ -2786,7 +2789,7 @@ PASSED: with expansion: 2 == 2 with message: - this message should not be logged + this message may be logged later MessageTests.cpp:37: FAILED: CHECK( a == 1 ) diff --git a/projects/SelfTest/MessageTests.cpp b/projects/SelfTest/MessageTests.cpp index 33f14ce2..9ba6eaec 100644 --- a/projects/SelfTest/MessageTests.cpp +++ b/projects/SelfTest/MessageTests.cpp @@ -28,7 +28,7 @@ TEST_CASE( "./failing/message/info/1", "INFO gets logged on failure" ) TEST_CASE( "./mixed/message/info/2", "INFO gets logged on failure" ) { - INFO( "this message should not be logged" ); + INFO( "this message may be logged later" ); int a = 2; CHECK( a == 2 ); diff --git a/projects/SelfTest/catch_self_test.hpp b/projects/SelfTest/catch_self_test.hpp index 6ce00738..1629644d 100644 --- a/projects/SelfTest/catch_self_test.hpp +++ b/projects/SelfTest/catch_self_test.hpp @@ -46,7 +46,7 @@ namespace Catch { virtual void testCaseStarting( TestCaseInfo const& ) {} virtual void sectionStarting( SectionInfo const& ) {} virtual void assertionStarting( AssertionInfo const& ) {} - virtual void assertionEnded( AssertionStats const& ) {} + virtual bool assertionEnded( AssertionStats const& ) { return false; } virtual void sectionEnded( SectionStats const& ) {} virtual void testCaseEnded( TestCaseStats const& ) {} virtual void testGroupEnded( TestGroupStats const& ) {}