Streaming reporter interface is now used natively.

Legacy reporters are adapted by their factories.
This commit is contained in:
Phil Nash
2012-11-30 19:15:23 +00:00
parent 7f04b56738
commit 4e12e12c1f
6 changed files with 46 additions and 23 deletions

View File

@@ -56,11 +56,11 @@ namespace Catch {
public:
explicit Runner( const Config& config, const Ptr<IReporter>& reporter )
explicit Runner( const Config& config, const Ptr<IStreamingReporter>& reporter )
: m_context( getCurrentMutableContext() ),
m_runningTest( NULL ),
m_config( config ),
m_reporter( reporter, ReporterConfig( m_config.stream(), m_config.data() ) ),
m_reporter( reporter ),
m_prevRunner( &m_context.getRunner() ),
m_prevResultCapture( &m_context.getResultCapture() ),
m_prevConfig( m_context.getConfig() )
@@ -68,11 +68,11 @@ namespace Catch {
m_context.setRunner( this );
m_context.setConfig( &m_config );
m_context.setResultCapture( this );
m_reporter.testRunStarting( "" ); // !TBD - name
m_reporter->testRunStarting( "" ); // !TBD - name
}
virtual ~Runner() {
m_reporter.testRunEnded( new TestRunStats( "", m_totals, aborting() ) ); // !TBD - name
m_reporter->testRunEnded( new TestRunStats( "", m_totals, aborting() ) ); // !TBD - name
m_context.setRunner( m_prevRunner );
m_context.setConfig( NULL );
m_context.setResultCapture( m_prevResultCapture );
@@ -80,10 +80,10 @@ namespace Catch {
}
void testGroupStarting( std::string const& testSpec ) {
m_reporter.testGroupStarting( testSpec );
m_reporter->testGroupStarting( testSpec );
}
void testGroupEnded( std::string const& testSpec, Totals const& totals ) {
m_reporter.testGroupEnded( new TestGroupStats( testSpec, totals, aborting() ) );
m_reporter->testGroupEnded( new TestGroupStats( testSpec, totals, aborting() ) );
}
Totals runMatching( const std::string& testSpec ) {
@@ -111,7 +111,7 @@ namespace Catch {
TestCaseInfo testInfo = testCase.getTestCaseInfo();
m_reporter.testCaseStarting( testInfo );
m_reporter->testCaseStarting( testInfo );
m_runningTest = new RunningTest( testCase );
@@ -134,7 +134,7 @@ namespace Catch {
m_totals.testCases += deltaTotals.testCases;
m_reporter.testCaseEnded( new TestCaseStats( testInfo,
m_reporter->testCaseEnded( new TestCaseStats( testInfo,
deltaTotals,
redirectedCout,
redirectedCerr,
@@ -170,13 +170,13 @@ namespace Catch {
std::vector<ScopedInfo*>::const_iterator it = m_scopedInfos.begin();
std::vector<ScopedInfo*>::const_iterator itEnd = m_scopedInfos.end();
for(; it != itEnd; ++it )
m_reporter.assertionEnded( new AssertionStats( (*it)->buildResult( m_lastAssertionInfo ), m_totals ) );
m_reporter->assertionEnded( new AssertionStats( (*it)->buildResult( m_lastAssertionInfo ), m_totals ) );
}
{
std::vector<AssertionResult>::const_iterator it = m_assertionResults.begin();
std::vector<AssertionResult>::const_iterator itEnd = m_assertionResults.end();
for(; it != itEnd; ++it )
m_reporter.assertionEnded( new AssertionStats( *it, m_totals ) );
m_reporter->assertionEnded( new AssertionStats( *it, m_totals ) );
}
m_assertionResults.clear();
}
@@ -187,7 +187,7 @@ namespace Catch {
m_totals.assertions.info++;
}
else
m_reporter.assertionEnded( new AssertionStats( result, m_totals ) );
m_reporter->assertionEnded( new AssertionStats( result, m_totals ) );
// Reset AssertionInfo
m_lastAssertionInfo = AssertionInfo( "", m_lastAssertionInfo.lineInfo, "{Unknown expression after this line}" , m_lastAssertionInfo.resultDisposition );
@@ -207,7 +207,7 @@ namespace Catch {
m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo;
m_reporter.sectionStarting( sectionInfo );
m_reporter->sectionStarting( sectionInfo );
assertions = m_totals.assertions;
@@ -227,7 +227,7 @@ namespace Catch {
}
m_runningTest->endSection( info.name );
m_reporter.sectionEnded( new SectionStats( info, assertions, missingAssertions ) );
m_reporter->sectionEnded( new SectionStats( info, assertions, missingAssertions ) );
}
virtual void pushScopedInfo( ScopedInfo* scopedInfo ) {
@@ -281,7 +281,7 @@ namespace Catch {
try {
m_lastAssertionInfo = AssertionInfo( "TEST_CASE", m_runningTest->getTestCase().getTestCaseInfo().lineInfo, "", ResultDisposition::Normal );
m_runningTest->reset();
if( m_reporter.getPreferences().shouldRedirectStdOut ) {
if( m_reporter->getPreferences().shouldRedirectStdOut ) {
StreamRedirect coutRedir( std::cout, redirectedCout );
StreamRedirect cerrRedir( std::cerr, redirectedCerr );
m_runningTest->getTestCase().invoke();
@@ -309,7 +309,7 @@ namespace Catch {
const Config& m_config;
Totals m_totals;
LegacyReporterAdapter m_reporter;
Ptr<IStreamingReporter> m_reporter;
std::vector<ScopedInfo*> m_scopedInfos;
std::vector<AssertionResult> m_assertionResults;
IRunner* m_prevRunner;