mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Reference to legacy reporter adapter localised to one place
This commit is contained in:
parent
ad6701d222
commit
f4774d9642
@ -45,12 +45,10 @@ namespace Catch {
|
|||||||
std::vector<TestCaseFilters>::const_iterator it = filterGroups.begin();
|
std::vector<TestCaseFilters>::const_iterator it = filterGroups.begin();
|
||||||
std::vector<TestCaseFilters>::const_iterator itEnd = filterGroups.end();
|
std::vector<TestCaseFilters>::const_iterator itEnd = filterGroups.end();
|
||||||
|
|
||||||
LegacyReporterAdapter reporter( m_reporter, ReporterConfig( m_configWrapper.stream(), m_config ) );
|
|
||||||
|
|
||||||
for(; it != itEnd && !context.aborting(); ++it ) {
|
for(; it != itEnd && !context.aborting(); ++it ) {
|
||||||
reporter.testGroupStarting( it->getName() );
|
context.testGroupStarting( it->getName() );
|
||||||
totals += runTestsForGroup( context, *it );
|
totals += runTestsForGroup( context, *it );
|
||||||
reporter.testGroupEnded( TestGroupStats( it->getName(), totals, context.aborting() ) );
|
context.testGroupEnded( it->getName(), totals );
|
||||||
}
|
}
|
||||||
return totals;
|
return totals;
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ namespace Catch {
|
|||||||
: m_context( getCurrentMutableContext() ),
|
: m_context( getCurrentMutableContext() ),
|
||||||
m_runningTest( NULL ),
|
m_runningTest( NULL ),
|
||||||
m_config( config ),
|
m_config( config ),
|
||||||
m_reporter( reporter ),
|
m_reporter( reporter, ReporterConfig( m_config.stream(), m_config.data() ) ),
|
||||||
m_prevRunner( &m_context.getRunner() ),
|
m_prevRunner( &m_context.getRunner() ),
|
||||||
m_prevResultCapture( &m_context.getResultCapture() ),
|
m_prevResultCapture( &m_context.getResultCapture() ),
|
||||||
m_prevConfig( m_context.getConfig() )
|
m_prevConfig( m_context.getConfig() )
|
||||||
@ -68,33 +68,38 @@ namespace Catch {
|
|||||||
m_context.setRunner( this );
|
m_context.setRunner( this );
|
||||||
m_context.setConfig( &m_config );
|
m_context.setConfig( &m_config );
|
||||||
m_context.setResultCapture( this );
|
m_context.setResultCapture( this );
|
||||||
LegacyReporterAdapter( m_reporter, ReporterConfig( m_config.stream(), m_config.data() ) ).testRunStarting( "" ); // !TBD - name
|
m_reporter.testRunStarting( "" ); // !TBD - name
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~Runner() {
|
virtual ~Runner() {
|
||||||
LegacyReporterAdapter( m_reporter, ReporterConfig( m_config.stream(), m_config.data() ) ).testRunEnded( TestRunStats( "", m_totals, aborting() ) ); // !TBD - name
|
m_reporter.testRunEnded( TestRunStats( "", m_totals, aborting() ) ); // !TBD - name
|
||||||
m_context.setRunner( m_prevRunner );
|
m_context.setRunner( m_prevRunner );
|
||||||
m_context.setConfig( NULL );
|
m_context.setConfig( NULL );
|
||||||
m_context.setResultCapture( m_prevResultCapture );
|
m_context.setResultCapture( m_prevResultCapture );
|
||||||
m_context.setConfig( m_prevConfig );
|
m_context.setConfig( m_prevConfig );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void testGroupStarting( std::string const& testSpec ) {
|
||||||
|
m_reporter.testGroupStarting( testSpec );
|
||||||
|
}
|
||||||
|
void testGroupEnded( std::string const& testSpec, Totals const& totals ) {
|
||||||
|
m_reporter.testGroupEnded( TestGroupStats( testSpec, totals, aborting() ) );
|
||||||
|
}
|
||||||
|
|
||||||
Totals runMatching( const std::string& testSpec ) {
|
Totals runMatching( const std::string& testSpec ) {
|
||||||
|
|
||||||
std::vector<TestCase> matchingTests = getRegistryHub().getTestCaseRegistry().getMatchingTestCases( testSpec );
|
std::vector<TestCase> matchingTests = getRegistryHub().getTestCaseRegistry().getMatchingTestCases( testSpec );
|
||||||
|
|
||||||
Totals totals;
|
Totals totals;
|
||||||
|
|
||||||
LegacyReporterAdapter reporter( m_reporter, ReporterConfig( m_config.stream(), m_config.data() ) );
|
testGroupStarting( testSpec );
|
||||||
|
|
||||||
reporter.testGroupStarting( testSpec );
|
|
||||||
|
|
||||||
std::vector<TestCase>::const_iterator it = matchingTests.begin();
|
std::vector<TestCase>::const_iterator it = matchingTests.begin();
|
||||||
std::vector<TestCase>::const_iterator itEnd = matchingTests.end();
|
std::vector<TestCase>::const_iterator itEnd = matchingTests.end();
|
||||||
for(; it != itEnd; ++it )
|
for(; it != itEnd; ++it )
|
||||||
totals += runTest( *it );
|
totals += runTest( *it );
|
||||||
|
|
||||||
reporter.testGroupEnded( TestGroupStats( testSpec, totals, aborting() ) );
|
testGroupEnded( testSpec, totals );
|
||||||
return totals;
|
return totals;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,8 +111,7 @@ namespace Catch {
|
|||||||
|
|
||||||
TestCaseInfo testInfo = testCase.getTestCaseInfo();
|
TestCaseInfo testInfo = testCase.getTestCaseInfo();
|
||||||
|
|
||||||
LegacyReporterAdapter reporter( m_reporter, ReporterConfig( m_config.stream(), m_config.data() ) );
|
m_reporter.testCaseStarting( testInfo );
|
||||||
reporter.testCaseStarting( testInfo );
|
|
||||||
|
|
||||||
m_runningTest = new RunningTest( testCase );
|
m_runningTest = new RunningTest( testCase );
|
||||||
|
|
||||||
@ -131,7 +135,7 @@ namespace Catch {
|
|||||||
m_totals.testCases += deltaTotals.testCases;
|
m_totals.testCases += deltaTotals.testCases;
|
||||||
|
|
||||||
TestCaseStats stats( testInfo, deltaTotals, redirectedCout, redirectedCerr, missingAssertions, aborting() );
|
TestCaseStats stats( testInfo, deltaTotals, redirectedCout, redirectedCerr, missingAssertions, aborting() );
|
||||||
reporter.testCaseEnded( stats );
|
m_reporter.testCaseEnded( stats );
|
||||||
|
|
||||||
|
|
||||||
delete m_runningTest;
|
delete m_runningTest;
|
||||||
@ -152,7 +156,6 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void testEnded( const AssertionResult& result ) {
|
virtual void testEnded( const AssertionResult& result ) {
|
||||||
LegacyReporterAdapter reporter( m_reporter, ReporterConfig( m_config.stream(), m_config.data() ) );
|
|
||||||
if( result.getResultType() == ResultWas::Ok ) {
|
if( result.getResultType() == ResultWas::Ok ) {
|
||||||
m_totals.assertions.passed++;
|
m_totals.assertions.passed++;
|
||||||
}
|
}
|
||||||
@ -163,13 +166,13 @@ namespace Catch {
|
|||||||
std::vector<ScopedInfo*>::const_iterator it = m_scopedInfos.begin();
|
std::vector<ScopedInfo*>::const_iterator it = m_scopedInfos.begin();
|
||||||
std::vector<ScopedInfo*>::const_iterator itEnd = m_scopedInfos.end();
|
std::vector<ScopedInfo*>::const_iterator itEnd = m_scopedInfos.end();
|
||||||
for(; it != itEnd; ++it )
|
for(; it != itEnd; ++it )
|
||||||
reporter.assertionEnded( AssertionStats( (*it)->buildResult( m_lastAssertionInfo ), m_totals ) );
|
m_reporter.assertionEnded( AssertionStats( (*it)->buildResult( m_lastAssertionInfo ), m_totals ) );
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::vector<AssertionResult>::const_iterator it = m_assertionResults.begin();
|
std::vector<AssertionResult>::const_iterator it = m_assertionResults.begin();
|
||||||
std::vector<AssertionResult>::const_iterator itEnd = m_assertionResults.end();
|
std::vector<AssertionResult>::const_iterator itEnd = m_assertionResults.end();
|
||||||
for(; it != itEnd; ++it )
|
for(; it != itEnd; ++it )
|
||||||
reporter.assertionEnded( AssertionStats( *it, m_totals ) );
|
m_reporter.assertionEnded( AssertionStats( *it, m_totals ) );
|
||||||
}
|
}
|
||||||
m_assertionResults.clear();
|
m_assertionResults.clear();
|
||||||
}
|
}
|
||||||
@ -180,7 +183,7 @@ namespace Catch {
|
|||||||
m_totals.assertions.info++;
|
m_totals.assertions.info++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
reporter.assertionEnded( AssertionStats( result, m_totals ) );
|
m_reporter.assertionEnded( AssertionStats( result, m_totals ) );
|
||||||
|
|
||||||
// Reset AssertionInfo
|
// Reset AssertionInfo
|
||||||
m_lastAssertionInfo = AssertionInfo( "", m_lastAssertionInfo.lineInfo, "{Unknown expression after this line}" , m_lastAssertionInfo.resultDisposition );
|
m_lastAssertionInfo = AssertionInfo( "", m_lastAssertionInfo.lineInfo, "{Unknown expression after this line}" , m_lastAssertionInfo.resultDisposition );
|
||||||
@ -200,7 +203,7 @@ namespace Catch {
|
|||||||
|
|
||||||
m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo;
|
m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo;
|
||||||
|
|
||||||
LegacyReporterAdapter( m_reporter, ReporterConfig( m_config.stream(), m_config.data() ) ).sectionStarting( sectionInfo );
|
m_reporter.sectionStarting( sectionInfo );
|
||||||
|
|
||||||
assertions = m_totals.assertions;
|
assertions = m_totals.assertions;
|
||||||
|
|
||||||
@ -221,7 +224,7 @@ namespace Catch {
|
|||||||
m_runningTest->endSection( info.name );
|
m_runningTest->endSection( info.name );
|
||||||
|
|
||||||
SectionStats stats( info, assertions, missingAssertions );
|
SectionStats stats( info, assertions, missingAssertions );
|
||||||
LegacyReporterAdapter( m_reporter, ReporterConfig( m_config.stream(), m_config.data() ) ).sectionEnded( stats );
|
m_reporter.sectionEnded( stats );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void pushScopedInfo( ScopedInfo* scopedInfo ) {
|
virtual void pushScopedInfo( ScopedInfo* scopedInfo ) {
|
||||||
@ -275,8 +278,7 @@ namespace Catch {
|
|||||||
try {
|
try {
|
||||||
m_lastAssertionInfo = AssertionInfo( "TEST_CASE", m_runningTest->getTestCase().getTestCaseInfo().lineInfo, "", ResultDisposition::Normal );
|
m_lastAssertionInfo = AssertionInfo( "TEST_CASE", m_runningTest->getTestCase().getTestCaseInfo().lineInfo, "", ResultDisposition::Normal );
|
||||||
m_runningTest->reset();
|
m_runningTest->reset();
|
||||||
LegacyReporterAdapter reporter( m_reporter, ReporterConfig( m_config.stream(), m_config.data() ) );
|
if( m_reporter.getPreferences().shouldRedirectStdOut ) {
|
||||||
if( reporter.getPreferences().shouldRedirectStdOut ) {
|
|
||||||
StreamRedirect coutRedir( std::cout, redirectedCout );
|
StreamRedirect coutRedir( std::cout, redirectedCout );
|
||||||
StreamRedirect cerrRedir( std::cerr, redirectedCerr );
|
StreamRedirect cerrRedir( std::cerr, redirectedCerr );
|
||||||
m_runningTest->getTestCase().invoke();
|
m_runningTest->getTestCase().invoke();
|
||||||
@ -304,7 +306,7 @@ namespace Catch {
|
|||||||
|
|
||||||
const Config& m_config;
|
const Config& m_config;
|
||||||
Totals m_totals;
|
Totals m_totals;
|
||||||
Ptr<IReporter> m_reporter;
|
LegacyReporterAdapter m_reporter;
|
||||||
std::vector<ScopedInfo*> m_scopedInfos;
|
std::vector<ScopedInfo*> m_scopedInfos;
|
||||||
std::vector<AssertionResult> m_assertionResults;
|
std::vector<AssertionResult> m_assertionResults;
|
||||||
IRunner* m_prevRunner;
|
IRunner* m_prevRunner;
|
||||||
|
Loading…
Reference in New Issue
Block a user