mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-22 11:23:29 +01:00
assertionEnded event in reporters no longer returns bool
This commit is contained in:
parent
013edc208b
commit
f314fa1f8c
@ -366,10 +366,9 @@ struct MyListener : Catch::EventListenerBase {
|
||||
print( std::cout, 1, "- assertionInfo", assertionInfo );
|
||||
}
|
||||
|
||||
bool assertionEnded( Catch::AssertionStats const& assertionStats ) override {
|
||||
void assertionEnded( Catch::AssertionStats const& assertionStats ) override {
|
||||
std::cout << "\nEvent: assertionEnded:\n";
|
||||
print( std::cout, 1, "- assertionStats", assertionStats );
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -189,8 +189,7 @@ namespace Catch {
|
||||
|
||||
virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0;
|
||||
|
||||
// The return value indicates if the messages buffer should be cleared:
|
||||
virtual bool assertionEnded( AssertionStats const& assertionStats ) = 0;
|
||||
virtual void assertionEnded( AssertionStats const& assertionStats ) = 0;
|
||||
|
||||
virtual void sectionEnded( SectionStats const& sectionStats ) = 0;
|
||||
//! Called _every time_ a TEST_CASE is entered, including repeats (due to sections)
|
||||
|
@ -249,9 +249,7 @@ namespace Catch {
|
||||
m_lastAssertionPassed = true;
|
||||
}
|
||||
|
||||
// We have no use for the return value (whether messages should be cleared), because messages were made scoped
|
||||
// and should be let to clear themselves out.
|
||||
static_cast<void>(m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals)));
|
||||
m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals));
|
||||
|
||||
if (result.getResultType() != ResultWas::Warning)
|
||||
m_messageScopes.clear();
|
||||
|
@ -24,12 +24,7 @@ namespace Catch {
|
||||
return "Reports test results in the format of Automake .trs files"s;
|
||||
}
|
||||
|
||||
void assertionStarting( AssertionInfo const& ) override {}
|
||||
|
||||
bool assertionEnded( AssertionStats const& /*_assertionStats*/ ) override { return true; }
|
||||
|
||||
void testCaseEnded(TestCaseStats const& _testCaseStats) override;
|
||||
|
||||
void skipTest(TestCaseInfo const& testInfo) override;
|
||||
|
||||
};
|
||||
|
@ -222,9 +222,7 @@ namespace Catch {
|
||||
namespace Catch {
|
||||
void EventListenerBase::assertionStarting( AssertionInfo const& ) {}
|
||||
|
||||
bool EventListenerBase::assertionEnded( AssertionStats const& ) {
|
||||
return false;
|
||||
}
|
||||
void EventListenerBase::assertionEnded( AssertionStats const& ) {}
|
||||
void EventListenerBase::listReporters(
|
||||
std::vector<ReporterDescription> const& ) {}
|
||||
void EventListenerBase::listTests( std::vector<TestCaseHandle> const& ) {}
|
||||
|
@ -262,9 +262,7 @@ private:
|
||||
stream << "No test cases matched '" << unmatchedSpec << "'\n";
|
||||
}
|
||||
|
||||
void CompactReporter::assertionStarting( AssertionInfo const& ) {}
|
||||
|
||||
bool CompactReporter::assertionEnded( AssertionStats const& _assertionStats ) {
|
||||
void CompactReporter::assertionEnded( AssertionStats const& _assertionStats ) {
|
||||
AssertionResult const& result = _assertionStats.assertionResult;
|
||||
|
||||
bool printInfoMessages = true;
|
||||
@ -272,7 +270,7 @@ private:
|
||||
// Drop out if result was successful and we're not printing those
|
||||
if( !m_config->includeSuccessfulResults() && result.isOk() ) {
|
||||
if( result.getResultType() != ResultWas::Warning )
|
||||
return false;
|
||||
return;
|
||||
printInfoMessages = false;
|
||||
}
|
||||
|
||||
@ -280,7 +278,6 @@ private:
|
||||
printer.print();
|
||||
|
||||
stream << '\n' << std::flush;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CompactReporter::sectionEnded(SectionStats const& _sectionStats) {
|
||||
|
@ -24,9 +24,7 @@ namespace Catch {
|
||||
|
||||
void noMatchingTestCases( StringRef unmatchedSpec ) override;
|
||||
|
||||
void assertionStarting(AssertionInfo const&) override;
|
||||
|
||||
bool assertionEnded(AssertionStats const& _assertionStats) override;
|
||||
void assertionEnded(AssertionStats const& _assertionStats) override;
|
||||
|
||||
void sectionEnded(SectionStats const& _sectionStats) override;
|
||||
|
||||
|
@ -391,21 +391,20 @@ void ConsoleReporter::reportInvalidArguments( StringRef arg ) {
|
||||
|
||||
void ConsoleReporter::assertionStarting(AssertionInfo const&) {}
|
||||
|
||||
bool ConsoleReporter::assertionEnded(AssertionStats const& _assertionStats) {
|
||||
void ConsoleReporter::assertionEnded(AssertionStats const& _assertionStats) {
|
||||
AssertionResult const& result = _assertionStats.assertionResult;
|
||||
|
||||
bool includeResults = m_config->includeSuccessfulResults() || !result.isOk();
|
||||
|
||||
// Drop out if result was successful but we're not printing them.
|
||||
if (!includeResults && result.getResultType() != ResultWas::Warning)
|
||||
return false;
|
||||
return;
|
||||
|
||||
lazyPrint();
|
||||
|
||||
ConsoleAssertionPrinter printer(stream, _assertionStats, includeResults);
|
||||
printer.print();
|
||||
stream << '\n' << std::flush;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ConsoleReporter::sectionStarting(SectionInfo const& _sectionInfo) {
|
||||
|
@ -28,7 +28,7 @@ namespace Catch {
|
||||
|
||||
void assertionStarting(AssertionInfo const&) override;
|
||||
|
||||
bool assertionEnded(AssertionStats const& _assertionStats) override;
|
||||
void assertionEnded(AssertionStats const& _assertionStats) override;
|
||||
|
||||
void sectionStarting(SectionInfo const& _sectionInfo) override;
|
||||
void sectionEnded(SectionStats const& _sectionStats) override;
|
||||
|
@ -64,7 +64,7 @@ namespace Catch {
|
||||
m_sectionStack.push_back( node );
|
||||
}
|
||||
|
||||
bool CumulativeReporterBase::assertionEnded(
|
||||
void CumulativeReporterBase::assertionEnded(
|
||||
AssertionStats const& assertionStats ) {
|
||||
assert( !m_sectionStack.empty() );
|
||||
// AssertionResult holds a pointer to a temporary DecomposedExpression,
|
||||
@ -76,7 +76,6 @@ namespace Catch {
|
||||
assertionStats.assertionResult.getExpandedExpression() );
|
||||
SectionNode& sectionNode = *m_sectionStack.back();
|
||||
sectionNode.assertions.push_back( assertionStats );
|
||||
return true;
|
||||
}
|
||||
|
||||
void CumulativeReporterBase::sectionEnded( SectionStats const& sectionStats ) {
|
||||
|
@ -62,7 +62,7 @@ namespace Catch {
|
||||
|
||||
void assertionStarting( AssertionInfo const& ) override {}
|
||||
|
||||
bool assertionEnded( AssertionStats const& assertionStats ) override;
|
||||
void assertionEnded( AssertionStats const& assertionStats ) override;
|
||||
void sectionEnded( SectionStats const& sectionStats ) override;
|
||||
void testCasePartialEnded( TestCaseStats const&, uint64_t ) override {}
|
||||
void testCaseEnded( TestCaseStats const& testCaseStats ) override;
|
||||
|
@ -27,7 +27,7 @@ namespace Catch {
|
||||
void reportInvalidArguments( StringRef unmatchedSpec ) override;
|
||||
|
||||
void assertionStarting( AssertionInfo const& assertionInfo ) override;
|
||||
bool assertionEnded( AssertionStats const& assertionStats ) override;
|
||||
void assertionEnded( AssertionStats const& assertionStats ) override;
|
||||
|
||||
void listReporters(
|
||||
std::vector<ReporterDescription> const& descriptions ) override;
|
||||
|
@ -81,10 +81,10 @@ namespace Catch {
|
||||
m_okToFail = testCaseInfo.okToFail();
|
||||
}
|
||||
|
||||
bool JunitReporter::assertionEnded( AssertionStats const& assertionStats ) {
|
||||
void JunitReporter::assertionEnded( AssertionStats const& assertionStats ) {
|
||||
if( assertionStats.assertionResult.getResultType() == ResultWas::ThrewException && !m_okToFail )
|
||||
unexpectedExceptions++;
|
||||
return CumulativeReporterBase::assertionEnded( assertionStats );
|
||||
CumulativeReporterBase::assertionEnded( assertionStats );
|
||||
}
|
||||
|
||||
void JunitReporter::testCaseEnded( TestCaseStats const& testCaseStats ) {
|
||||
|
@ -26,7 +26,7 @@ namespace Catch {
|
||||
void testRunStarting(TestRunInfo const& runInfo) override;
|
||||
|
||||
void testCaseStarting(TestCaseInfo const& testCaseInfo) override;
|
||||
bool assertionEnded(AssertionStats const& assertionStats) override;
|
||||
void assertionEnded(AssertionStats const& assertionStats) override;
|
||||
|
||||
void testCaseEnded(TestCaseStats const& testCaseStats) override;
|
||||
|
||||
|
@ -100,11 +100,11 @@ namespace Catch {
|
||||
}
|
||||
|
||||
// The return value indicates if the messages buffer should be cleared:
|
||||
bool ListeningReporter::assertionEnded( AssertionStats const& assertionStats ) {
|
||||
void ListeningReporter::assertionEnded( AssertionStats const& assertionStats ) {
|
||||
for( auto& listener : m_listeners ) {
|
||||
static_cast<void>( listener->assertionEnded( assertionStats ) );
|
||||
listener->assertionEnded( assertionStats );
|
||||
}
|
||||
return m_reporter->assertionEnded( assertionStats );
|
||||
m_reporter->assertionEnded( assertionStats );
|
||||
}
|
||||
|
||||
void ListeningReporter::sectionEnded( SectionStats const& sectionStats ) {
|
||||
|
@ -45,8 +45,7 @@ namespace Catch {
|
||||
void sectionStarting( SectionInfo const& sectionInfo ) override;
|
||||
void assertionStarting( AssertionInfo const& assertionInfo ) override;
|
||||
|
||||
// The return value indicates if the messages buffer should be cleared:
|
||||
bool assertionEnded( AssertionStats const& assertionStats ) override;
|
||||
void assertionEnded( AssertionStats const& assertionStats ) override;
|
||||
void sectionEnded( SectionStats const& sectionStats ) override;
|
||||
void testCasePartialEnded(TestCaseStats const& testInfo, uint64_t partNumber) override;
|
||||
void testCaseEnded( TestCaseStats const& testCaseStats ) override;
|
||||
|
@ -56,7 +56,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
void assertionStarting( AssertionInfo const& ) override {}
|
||||
bool assertionEnded( AssertionStats const& ) override { return true; }
|
||||
void assertionEnded( AssertionStats const& ) override {}
|
||||
|
||||
void sectionEnded(SectionStats const& /* _sectionStats */) override {
|
||||
m_sectionStack.pop_back();
|
||||
|
@ -198,7 +198,7 @@ namespace Catch {
|
||||
stream << "# No test cases matched '" << unmatchedSpec << "'\n";
|
||||
}
|
||||
|
||||
bool TAPReporter::assertionEnded(AssertionStats const& _assertionStats) {
|
||||
void TAPReporter::assertionEnded(AssertionStats const& _assertionStats) {
|
||||
++counter;
|
||||
|
||||
stream << "# " << currentTestCaseInfo->name << '\n';
|
||||
@ -206,7 +206,6 @@ namespace Catch {
|
||||
printer.print();
|
||||
|
||||
stream << '\n' << std::flush;
|
||||
return true;
|
||||
}
|
||||
|
||||
void TAPReporter::testRunEnded(TestRunStats const& _testRunStats) {
|
||||
|
@ -27,9 +27,7 @@ namespace Catch {
|
||||
|
||||
void noMatchingTestCases( StringRef unmatchedSpec ) override;
|
||||
|
||||
void assertionStarting( AssertionInfo const& ) override {}
|
||||
|
||||
bool assertionEnded(AssertionStats const& _assertionStats) override;
|
||||
void assertionEnded(AssertionStats const& _assertionStats) override;
|
||||
|
||||
void testRunEnded(TestRunStats const& _testRunStats) override;
|
||||
|
||||
|
@ -56,7 +56,7 @@ namespace Catch {
|
||||
<< escape( runStats.runInfo.name ) << "']\n";
|
||||
}
|
||||
|
||||
bool TeamCityReporter::assertionEnded(AssertionStats const& assertionStats) {
|
||||
void TeamCityReporter::assertionEnded(AssertionStats const& assertionStats) {
|
||||
AssertionResult const& result = assertionStats.assertionResult;
|
||||
if (!result.isOk()) {
|
||||
|
||||
@ -124,7 +124,6 @@ namespace Catch {
|
||||
}
|
||||
}
|
||||
stream.flush();
|
||||
return true;
|
||||
}
|
||||
|
||||
void TeamCityReporter::testCaseStarting(TestCaseInfo const& testInfo) {
|
||||
|
@ -38,9 +38,7 @@ namespace Catch {
|
||||
void testRunEnded( TestRunStats const& testGroupStats ) override;
|
||||
|
||||
|
||||
void assertionStarting(AssertionInfo const&) override {}
|
||||
|
||||
bool assertionEnded(AssertionStats const& assertionStats) override;
|
||||
void assertionEnded(AssertionStats const& assertionStats) override;
|
||||
|
||||
void sectionStarting(SectionInfo const& sectionInfo) override {
|
||||
m_headerPrintedForThisSection = false;
|
||||
|
@ -86,7 +86,7 @@ namespace Catch {
|
||||
|
||||
void XmlReporter::assertionStarting( AssertionInfo const& ) { }
|
||||
|
||||
bool XmlReporter::assertionEnded( AssertionStats const& assertionStats ) {
|
||||
void XmlReporter::assertionEnded( AssertionStats const& assertionStats ) {
|
||||
|
||||
AssertionResult const& result = assertionStats.assertionResult;
|
||||
|
||||
@ -107,7 +107,7 @@ namespace Catch {
|
||||
|
||||
// Drop out if result was successful but we're not printing them.
|
||||
if( !includeResults && result.getResultType() != ResultWas::Warning )
|
||||
return true;
|
||||
return;
|
||||
|
||||
|
||||
// Print the expression if there is one.
|
||||
@ -157,8 +157,6 @@ namespace Catch {
|
||||
|
||||
if( result.hasExpression() )
|
||||
m_xml.endElement();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void XmlReporter::sectionEnded( SectionStats const& sectionStats ) {
|
||||
|
@ -37,7 +37,7 @@ namespace Catch {
|
||||
|
||||
void assertionStarting(AssertionInfo const&) override;
|
||||
|
||||
bool assertionEnded(AssertionStats const& assertionStats) override;
|
||||
void assertionEnded(AssertionStats const& assertionStats) override;
|
||||
|
||||
void sectionEnded(SectionStats const& sectionStats) override;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user