mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Tightened up ReporterConfig and added it to LegacyReporterAdapter
This commit is contained in:
parent
f9d92634f5
commit
4b36001698
@ -45,7 +45,7 @@ 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 );
|
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() );
|
reporter.testGroupStarting( it->getName() );
|
||||||
@ -100,7 +100,7 @@ namespace Catch {
|
|||||||
? "basic"
|
? "basic"
|
||||||
: m_config.reporter;
|
: m_config.reporter;
|
||||||
|
|
||||||
ReporterConfig reporterConfig( m_config.name, m_configWrapper.stream(), m_config.includeWhichResults == Include::SuccessfulResults, m_config );
|
ReporterConfig reporterConfig( m_configWrapper.stream(), m_config );
|
||||||
|
|
||||||
m_reporter = getRegistryHub().getReporterRegistry().create( reporterName, reporterConfig );
|
m_reporter = getRegistryHub().getReporterRegistry().create( reporterName, reporterConfig );
|
||||||
if( !m_reporter ) {
|
if( !m_reporter ) {
|
||||||
|
@ -23,31 +23,17 @@ namespace Catch
|
|||||||
{
|
{
|
||||||
struct ReporterConfig
|
struct ReporterConfig
|
||||||
{
|
{
|
||||||
ReporterConfig( const std::string& _name,
|
ReporterConfig( std::ostream& _stream, const ConfigData& _fullConfig )
|
||||||
std::ostream& _stream,
|
: m_stream( &_stream ), m_fullConfig( _fullConfig ) {}
|
||||||
bool _includeSuccessfulResults,
|
|
||||||
const ConfigData& _fullConfig )
|
|
||||||
: name( _name ),
|
|
||||||
stream( _stream ),
|
|
||||||
includeSuccessfulResults( _includeSuccessfulResults ),
|
|
||||||
fullConfig( _fullConfig )
|
|
||||||
{}
|
|
||||||
|
|
||||||
ReporterConfig( const ReporterConfig& other )
|
|
||||||
: name( other.name ),
|
|
||||||
stream( other.stream ),
|
|
||||||
includeSuccessfulResults( other.includeSuccessfulResults ),
|
|
||||||
fullConfig( other.fullConfig )
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
std::string name;
|
std::ostream& stream() { return *m_stream; }
|
||||||
std::ostream& stream;
|
std::string name() const { return m_fullConfig.name; }
|
||||||
bool includeSuccessfulResults;
|
bool includeSuccessfulResults() const { return m_fullConfig.includeWhichResults == Include::SuccessfulResults; }
|
||||||
ConfigData fullConfig;
|
bool warnAboutMissingAssertions() const { return m_fullConfig.warnings & ConfigData::WarnAbout::NoAssertions; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void operator=(const ReporterConfig&);
|
std::ostream* m_stream;
|
||||||
|
ConfigData m_fullConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AssertionStats {
|
struct AssertionStats {
|
||||||
@ -67,11 +53,13 @@ namespace Catch
|
|||||||
const Totals& _totals,
|
const Totals& _totals,
|
||||||
const std::string& _stdOut,
|
const std::string& _stdOut,
|
||||||
const std::string& _stdErr,
|
const std::string& _stdErr,
|
||||||
|
bool _missingAssertions,
|
||||||
bool _aborting )
|
bool _aborting )
|
||||||
: testInfo( _testInfo ),
|
: testInfo( _testInfo ),
|
||||||
totals( _totals ),
|
totals( _totals ),
|
||||||
stdOut( _stdOut ),
|
stdOut( _stdOut ),
|
||||||
stdErr( _stdErr ),
|
stdErr( _stdErr ),
|
||||||
|
missingAssertions( _missingAssertions ),
|
||||||
aborting( _aborting )
|
aborting( _aborting )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -79,6 +67,7 @@ namespace Catch
|
|||||||
Totals totals;
|
Totals totals;
|
||||||
std::string stdOut;
|
std::string stdOut;
|
||||||
std::string stdErr;
|
std::string stdErr;
|
||||||
|
bool missingAssertions;
|
||||||
bool aborting;
|
bool aborting;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -166,8 +155,9 @@ namespace Catch
|
|||||||
class LegacyReporterAdapter : public SharedImpl<IStreamingReporter>
|
class LegacyReporterAdapter : public SharedImpl<IStreamingReporter>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LegacyReporterAdapter( const Ptr<IReporter>& legacyReporter )
|
LegacyReporterAdapter( const Ptr<IReporter>& legacyReporter, const ReporterConfig& config )
|
||||||
: m_legacyReporter( legacyReporter )
|
: m_legacyReporter( legacyReporter ),
|
||||||
|
m_config( config )
|
||||||
{}
|
{}
|
||||||
virtual ~LegacyReporterAdapter();
|
virtual ~LegacyReporterAdapter();
|
||||||
|
|
||||||
@ -189,6 +179,8 @@ namespace Catch
|
|||||||
m_legacyReporter->Result( assertionStats.assertionResult );
|
m_legacyReporter->Result( assertionStats.assertionResult );
|
||||||
}
|
}
|
||||||
virtual void testCaseEnding( const TestCaseStats& testCaseStats ) {
|
virtual void testCaseEnding( const TestCaseStats& testCaseStats ) {
|
||||||
|
if( testCaseStats.missingAssertions )
|
||||||
|
m_legacyReporter->NoAssertionsInTestCase( testCaseStats.testInfo.name );
|
||||||
m_legacyReporter->EndTestCase( testCaseStats.testInfo, testCaseStats.totals, testCaseStats.stdOut, testCaseStats.stdErr );
|
m_legacyReporter->EndTestCase( testCaseStats.testInfo, testCaseStats.totals, testCaseStats.stdOut, testCaseStats.stdErr );
|
||||||
}
|
}
|
||||||
virtual void testGroupEnding( const TestGroupStats& testGroupStats ) {
|
virtual void testGroupEnding( const TestGroupStats& testGroupStats ) {
|
||||||
@ -202,6 +194,7 @@ namespace Catch
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Ptr<IReporter> m_legacyReporter;
|
Ptr<IReporter> m_legacyReporter;
|
||||||
|
ReporterConfig m_config;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,11 +68,11 @@ 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 ).testRunStarting( "" ); // !TBD - name
|
LegacyReporterAdapter( m_reporter, ReporterConfig( m_config.stream(), m_config.data() ) ).testRunStarting( "" ); // !TBD - name
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~Runner() {
|
virtual ~Runner() {
|
||||||
LegacyReporterAdapter( m_reporter ).testRunEnding( TestRunStats( "", m_totals, aborting() ) ); // !TBD - name
|
LegacyReporterAdapter( m_reporter, ReporterConfig( m_config.stream(), m_config.data() ) ).testRunEnding( 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 );
|
||||||
@ -85,7 +85,7 @@ namespace Catch {
|
|||||||
|
|
||||||
Totals totals;
|
Totals totals;
|
||||||
|
|
||||||
LegacyReporterAdapter reporter( m_reporter );
|
LegacyReporterAdapter reporter( m_reporter, ReporterConfig( m_config.stream(), m_config.data() ) );
|
||||||
|
|
||||||
reporter.testGroupStarting( testSpec );
|
reporter.testGroupStarting( testSpec );
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ namespace Catch {
|
|||||||
|
|
||||||
TestCaseInfo testInfo = testCase.getTestCaseInfo();
|
TestCaseInfo testInfo = testCase.getTestCaseInfo();
|
||||||
|
|
||||||
LegacyReporterAdapter reporter( m_reporter );
|
LegacyReporterAdapter reporter( m_reporter, ReporterConfig( m_config.stream(), m_config.data() ) );
|
||||||
reporter.testCaseStarting( testInfo );
|
reporter.testCaseStarting( testInfo );
|
||||||
|
|
||||||
m_runningTest = new RunningTest( &testCase );
|
m_runningTest = new RunningTest( &testCase );
|
||||||
@ -120,15 +120,17 @@ namespace Catch {
|
|||||||
while( getCurrentContext().advanceGeneratorsForCurrentTest() && !aborting() );
|
while( getCurrentContext().advanceGeneratorsForCurrentTest() && !aborting() );
|
||||||
|
|
||||||
Totals deltaTotals = m_totals.delta( prevTotals );
|
Totals deltaTotals = m_totals.delta( prevTotals );
|
||||||
|
bool missingAssertions = false;
|
||||||
if( deltaTotals.assertions.total() == 0 &&
|
if( deltaTotals.assertions.total() == 0 &&
|
||||||
( m_config.data().warnings & ConfigData::WarnAbout::NoAssertions ) ) {
|
( m_config.data().warnings & ConfigData::WarnAbout::NoAssertions ) ) {
|
||||||
m_totals.assertions.failed++;
|
m_totals.assertions.failed++;
|
||||||
deltaTotals = m_totals.delta( prevTotals );
|
deltaTotals = m_totals.delta( prevTotals );
|
||||||
m_reporter->NoAssertionsInTestCase( testInfo.name );
|
missingAssertions = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_totals.testCases += deltaTotals.testCases;
|
m_totals.testCases += deltaTotals.testCases;
|
||||||
|
|
||||||
TestCaseStats stats( testInfo, deltaTotals, redirectedCout, redirectedCerr , aborting() );
|
TestCaseStats stats( testInfo, deltaTotals, redirectedCout, redirectedCerr, missingAssertions, aborting() );
|
||||||
reporter.testCaseEnding( stats );
|
reporter.testCaseEnding( stats );
|
||||||
|
|
||||||
|
|
||||||
@ -150,7 +152,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void testEnded( const AssertionResult& result ) {
|
virtual void testEnded( const AssertionResult& result ) {
|
||||||
LegacyReporterAdapter reporter( m_reporter );
|
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++;
|
||||||
}
|
}
|
||||||
|
@ -54,27 +54,27 @@ namespace Catch {
|
|||||||
|
|
||||||
void ReportCounts( const std::string& label, const Counts& counts, const std::string& allPrefix = "All " ) {
|
void ReportCounts( const std::string& label, const Counts& counts, const std::string& allPrefix = "All " ) {
|
||||||
if( counts.passed )
|
if( counts.passed )
|
||||||
m_config.stream << counts.failed << " of " << counts.total() << " " << label << "s failed";
|
m_config.stream() << counts.failed << " of " << counts.total() << " " << label << "s failed";
|
||||||
else
|
else
|
||||||
m_config.stream << ( counts.failed > 1 ? allPrefix : "" ) << pluralise( counts.failed, label ) << " failed";
|
m_config.stream() << ( counts.failed > 1 ? allPrefix : "" ) << pluralise( counts.failed, label ) << " failed";
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportCounts( const Totals& totals, const std::string& allPrefix = "All " ) {
|
void ReportCounts( const Totals& totals, const std::string& allPrefix = "All " ) {
|
||||||
if( totals.assertions.total() == 0 ) {
|
if( totals.assertions.total() == 0 ) {
|
||||||
m_config.stream << "No tests ran";
|
m_config.stream() << "No tests ran";
|
||||||
}
|
}
|
||||||
else if( totals.assertions.failed ) {
|
else if( totals.assertions.failed ) {
|
||||||
TextColour colour( TextColour::ResultError );
|
TextColour colour( TextColour::ResultError );
|
||||||
ReportCounts( "test case", totals.testCases, allPrefix );
|
ReportCounts( "test case", totals.testCases, allPrefix );
|
||||||
if( totals.testCases.failed > 0 ) {
|
if( totals.testCases.failed > 0 ) {
|
||||||
m_config.stream << " (";
|
m_config.stream() << " (";
|
||||||
ReportCounts( "assertion", totals.assertions, allPrefix );
|
ReportCounts( "assertion", totals.assertions, allPrefix );
|
||||||
m_config.stream << ")";
|
m_config.stream() << ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
TextColour colour( TextColour::ResultSuccess );
|
TextColour colour( TextColour::ResultSuccess );
|
||||||
m_config.stream << allPrefix << "tests passed ("
|
m_config.stream() << allPrefix << "tests passed ("
|
||||||
<< pluralise( totals.assertions.passed, "assertion" ) << " in "
|
<< pluralise( totals.assertions.passed, "assertion" ) << " in "
|
||||||
<< pluralise( totals.testCases.passed, "test case" ) << ")";
|
<< pluralise( totals.testCases.passed, "test case" ) << ")";
|
||||||
}
|
}
|
||||||
@ -97,14 +97,14 @@ namespace Catch {
|
|||||||
virtual void EndTesting( const Totals& totals ) {
|
virtual void EndTesting( const Totals& totals ) {
|
||||||
// Output the overall test results even if "Started Testing" was not emitted
|
// Output the overall test results even if "Started Testing" was not emitted
|
||||||
if( m_aborted ) {
|
if( m_aborted ) {
|
||||||
m_config.stream << "\n[Testing aborted. ";
|
m_config.stream() << "\n[Testing aborted. ";
|
||||||
ReportCounts( totals, "The first " );
|
ReportCounts( totals, "The first " );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_config.stream << "\n[Testing completed. ";
|
m_config.stream() << "\n[Testing completed. ";
|
||||||
ReportCounts( totals );
|
ReportCounts( totals );
|
||||||
}
|
}
|
||||||
m_config.stream << "]\n" << std::endl;
|
m_config.stream() << "]\n" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void StartGroup( const std::string& groupName ) {
|
virtual void StartGroup( const std::string& groupName ) {
|
||||||
@ -113,9 +113,9 @@ namespace Catch {
|
|||||||
|
|
||||||
virtual void EndGroup( const std::string& groupName, const Totals& totals ) {
|
virtual void EndGroup( const std::string& groupName, const Totals& totals ) {
|
||||||
if( m_groupSpan.emitted && !groupName.empty() ) {
|
if( m_groupSpan.emitted && !groupName.empty() ) {
|
||||||
m_config.stream << "[End of group: '" << groupName << "'. ";
|
m_config.stream() << "[End of group: '" << groupName << "'. ";
|
||||||
ReportCounts( totals );
|
ReportCounts( totals );
|
||||||
m_config.stream << "]\n" << std::endl;
|
m_config.stream() << "]\n" << std::endl;
|
||||||
m_groupSpan = SpanInfo();
|
m_groupSpan = SpanInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -131,19 +131,19 @@ namespace Catch {
|
|||||||
virtual void NoAssertionsInSection( const std::string& sectionName ) {
|
virtual void NoAssertionsInSection( const std::string& sectionName ) {
|
||||||
startSpansLazily();
|
startSpansLazily();
|
||||||
TextColour colour( TextColour::ResultError );
|
TextColour colour( TextColour::ResultError );
|
||||||
m_config.stream << "\nNo assertions in section, '" << sectionName << "'\n" << std::endl;
|
m_config.stream() << "\nNo assertions in section, '" << sectionName << "'\n" << std::endl;
|
||||||
}
|
}
|
||||||
virtual void NoAssertionsInTestCase( const std::string& testName ) {
|
virtual void NoAssertionsInTestCase( const std::string& testName ) {
|
||||||
startSpansLazily();
|
startSpansLazily();
|
||||||
TextColour colour( TextColour::ResultError );
|
TextColour colour( TextColour::ResultError );
|
||||||
m_config.stream << "\nNo assertions in test case, '" << testName << "'\n" << std::endl;
|
m_config.stream() << "\nNo assertions in test case, '" << testName << "'\n" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void EndSection( const std::string& sectionName, const Counts& assertions ) {
|
virtual void EndSection( const std::string& sectionName, const Counts& assertions ) {
|
||||||
|
|
||||||
SpanInfo& sectionSpan = m_sectionSpans.back();
|
SpanInfo& sectionSpan = m_sectionSpans.back();
|
||||||
if( sectionSpan.emitted && !sectionSpan.name.empty() ) {
|
if( sectionSpan.emitted && !sectionSpan.name.empty() ) {
|
||||||
m_config.stream << "[End of section: '" << sectionName << "' ";
|
m_config.stream() << "[End of section: '" << sectionName << "' ";
|
||||||
|
|
||||||
if( assertions.failed ) {
|
if( assertions.failed ) {
|
||||||
TextColour colour( TextColour::ResultError );
|
TextColour colour( TextColour::ResultError );
|
||||||
@ -151,38 +151,38 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
TextColour colour( TextColour::ResultSuccess );
|
TextColour colour( TextColour::ResultSuccess );
|
||||||
m_config.stream << ( assertions.passed > 1 ? "All " : "" )
|
m_config.stream() << ( assertions.passed > 1 ? "All " : "" )
|
||||||
<< pluralise( assertions.passed, "assertion" ) << " passed" ;
|
<< pluralise( assertions.passed, "assertion" ) << " passed" ;
|
||||||
}
|
}
|
||||||
m_config.stream << "]\n" << std::endl;
|
m_config.stream() << "]\n" << std::endl;
|
||||||
}
|
}
|
||||||
m_sectionSpans.pop_back();
|
m_sectionSpans.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Result( const AssertionResult& assertionResult ) {
|
virtual void Result( const AssertionResult& assertionResult ) {
|
||||||
if( !m_config.includeSuccessfulResults && assertionResult.getResultType() == ResultWas::Ok )
|
if( !m_config.includeSuccessfulResults() && assertionResult.getResultType() == ResultWas::Ok )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
startSpansLazily();
|
startSpansLazily();
|
||||||
|
|
||||||
if( !assertionResult.getSourceInfo().empty() ) {
|
if( !assertionResult.getSourceInfo().empty() ) {
|
||||||
TextColour colour( TextColour::FileName );
|
TextColour colour( TextColour::FileName );
|
||||||
m_config.stream << assertionResult.getSourceInfo();
|
m_config.stream() << assertionResult.getSourceInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( assertionResult.hasExpression() ) {
|
if( assertionResult.hasExpression() ) {
|
||||||
TextColour colour( TextColour::OriginalExpression );
|
TextColour colour( TextColour::OriginalExpression );
|
||||||
m_config.stream << assertionResult.getExpression();
|
m_config.stream() << assertionResult.getExpression();
|
||||||
if( assertionResult.succeeded() ) {
|
if( assertionResult.succeeded() ) {
|
||||||
TextColour successColour( TextColour::Success );
|
TextColour successColour( TextColour::Success );
|
||||||
m_config.stream << " succeeded";
|
m_config.stream() << " succeeded";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
TextColour errorColour( TextColour::Error );
|
TextColour errorColour( TextColour::Error );
|
||||||
m_config.stream << " failed";
|
m_config.stream() << " failed";
|
||||||
if( assertionResult.isOk() ) {
|
if( assertionResult.isOk() ) {
|
||||||
TextColour okAnywayColour( TextColour::Success );
|
TextColour okAnywayColour( TextColour::Success );
|
||||||
m_config.stream << " - but was ok";
|
m_config.stream() << " - but was ok";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -191,19 +191,19 @@ namespace Catch {
|
|||||||
{
|
{
|
||||||
TextColour colour( TextColour::Error );
|
TextColour colour( TextColour::Error );
|
||||||
if( assertionResult.hasExpression() )
|
if( assertionResult.hasExpression() )
|
||||||
m_config.stream << " with unexpected";
|
m_config.stream() << " with unexpected";
|
||||||
else
|
else
|
||||||
m_config.stream << "Unexpected";
|
m_config.stream() << "Unexpected";
|
||||||
m_config.stream << " exception with message: '" << assertionResult.getMessage() << "'";
|
m_config.stream() << " exception with message: '" << assertionResult.getMessage() << "'";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ResultWas::DidntThrowException:
|
case ResultWas::DidntThrowException:
|
||||||
{
|
{
|
||||||
TextColour colour( TextColour::Error );
|
TextColour colour( TextColour::Error );
|
||||||
if( assertionResult.hasExpression() )
|
if( assertionResult.hasExpression() )
|
||||||
m_config.stream << " because no exception was thrown where one was expected";
|
m_config.stream() << " because no exception was thrown where one was expected";
|
||||||
else
|
else
|
||||||
m_config.stream << "No exception thrown where one was expected";
|
m_config.stream() << "No exception thrown where one was expected";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ResultWas::Info:
|
case ResultWas::Info:
|
||||||
@ -221,7 +221,7 @@ namespace Catch {
|
|||||||
case ResultWas::ExplicitFailure:
|
case ResultWas::ExplicitFailure:
|
||||||
{
|
{
|
||||||
TextColour colour( TextColour::Error );
|
TextColour colour( TextColour::Error );
|
||||||
m_config.stream << "failed with message: '" << assertionResult.getMessage() << "'";
|
m_config.stream() << "failed with message: '" << assertionResult.getMessage() << "'";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ResultWas::Unknown: // These cases are here to prevent compiler warnings
|
case ResultWas::Unknown: // These cases are here to prevent compiler warnings
|
||||||
@ -232,19 +232,19 @@ namespace Catch {
|
|||||||
if( !assertionResult.hasExpression() ) {
|
if( !assertionResult.hasExpression() ) {
|
||||||
if( assertionResult.succeeded() ) {
|
if( assertionResult.succeeded() ) {
|
||||||
TextColour colour( TextColour::Success );
|
TextColour colour( TextColour::Success );
|
||||||
m_config.stream << " succeeded";
|
m_config.stream() << " succeeded";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
TextColour colour( TextColour::Error );
|
TextColour colour( TextColour::Error );
|
||||||
m_config.stream << " failed";
|
m_config.stream() << " failed";
|
||||||
if( assertionResult.isOk() ) {
|
if( assertionResult.isOk() ) {
|
||||||
TextColour okAnywayColour( TextColour::Success );
|
TextColour okAnywayColour( TextColour::Success );
|
||||||
m_config.stream << " - but was ok";
|
m_config.stream() << " - but was ok";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( assertionResult.hasMessage() ) {
|
if( assertionResult.hasMessage() ) {
|
||||||
m_config.stream << "\n";
|
m_config.stream() << "\n";
|
||||||
TextColour colour( TextColour::ReconstructedExpression );
|
TextColour colour( TextColour::ReconstructedExpression );
|
||||||
streamVariableLengthText( "with message", assertionResult.getMessage() );
|
streamVariableLengthText( "with message", assertionResult.getMessage() );
|
||||||
}
|
}
|
||||||
@ -252,16 +252,16 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( assertionResult.hasExpandedExpression() ) {
|
if( assertionResult.hasExpandedExpression() ) {
|
||||||
m_config.stream << " for: ";
|
m_config.stream() << " for: ";
|
||||||
if( assertionResult.getExpandedExpression().size() > 40 ) {
|
if( assertionResult.getExpandedExpression().size() > 40 ) {
|
||||||
m_config.stream << "\n";
|
m_config.stream() << "\n";
|
||||||
if( assertionResult.getExpandedExpression().size() < 70 )
|
if( assertionResult.getExpandedExpression().size() < 70 )
|
||||||
m_config.stream << "\t";
|
m_config.stream() << "\t";
|
||||||
}
|
}
|
||||||
TextColour colour( TextColour::ReconstructedExpression );
|
TextColour colour( TextColour::ReconstructedExpression );
|
||||||
m_config.stream << assertionResult.getExpandedExpression();
|
m_config.stream() << assertionResult.getExpandedExpression();
|
||||||
}
|
}
|
||||||
m_config.stream << std::endl;
|
m_config.stream() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void EndTestCase( const TestCaseInfo& testInfo,
|
virtual void EndTestCase( const TestCaseInfo& testInfo,
|
||||||
@ -279,9 +279,9 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( m_testSpan.emitted ) {
|
if( m_testSpan.emitted ) {
|
||||||
m_config.stream << "[Finished: '" << testInfo.name << "' ";
|
m_config.stream() << "[Finished: '" << testInfo.name << "' ";
|
||||||
ReportCounts( totals );
|
ReportCounts( totals );
|
||||||
m_config.stream << "]" << std::endl;
|
m_config.stream() << "]" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,20 +289,20 @@ namespace Catch {
|
|||||||
|
|
||||||
void startSpansLazily() {
|
void startSpansLazily() {
|
||||||
if( !m_testingSpan.emitted ) {
|
if( !m_testingSpan.emitted ) {
|
||||||
if( m_config.name.empty() )
|
if( m_config.name().empty() )
|
||||||
m_config.stream << "[Started testing]" << std::endl;
|
m_config.stream() << "[Started testing]" << std::endl;
|
||||||
else
|
else
|
||||||
m_config.stream << "[Started testing: " << m_config.name << "]" << std::endl;
|
m_config.stream() << "[Started testing: " << m_config.name() << "]" << std::endl;
|
||||||
m_testingSpan.emitted = true;
|
m_testingSpan.emitted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !m_groupSpan.emitted && !m_groupSpan.name.empty() ) {
|
if( !m_groupSpan.emitted && !m_groupSpan.name.empty() ) {
|
||||||
m_config.stream << "[Started group: '" << m_groupSpan.name << "']" << std::endl;
|
m_config.stream() << "[Started group: '" << m_groupSpan.name << "']" << std::endl;
|
||||||
m_groupSpan.emitted = true;
|
m_groupSpan.emitted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !m_testSpan.emitted ) {
|
if( !m_testSpan.emitted ) {
|
||||||
m_config.stream << std::endl << "[Running: " << m_testSpan.name << "]" << std::endl;
|
m_config.stream() << std::endl << "[Running: " << m_testSpan.name << "]" << std::endl;
|
||||||
m_testSpan.emitted = true;
|
m_testSpan.emitted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,7 +310,7 @@ namespace Catch {
|
|||||||
SpanInfo& sectionSpan = m_sectionSpans.back();
|
SpanInfo& sectionSpan = m_sectionSpans.back();
|
||||||
if( !sectionSpan.emitted && !sectionSpan.name.empty() ) {
|
if( !sectionSpan.emitted && !sectionSpan.name.empty() ) {
|
||||||
if( m_firstSectionInTestCase ) {
|
if( m_firstSectionInTestCase ) {
|
||||||
m_config.stream << "\n";
|
m_config.stream() << "\n";
|
||||||
m_firstSectionInTestCase = false;
|
m_firstSectionInTestCase = false;
|
||||||
}
|
}
|
||||||
std::vector<SpanInfo>::iterator it = m_sectionSpans.begin();
|
std::vector<SpanInfo>::iterator it = m_sectionSpans.begin();
|
||||||
@ -318,7 +318,7 @@ namespace Catch {
|
|||||||
for(; it != itEnd; ++it ) {
|
for(; it != itEnd; ++it ) {
|
||||||
SpanInfo& prevSpan = *it;
|
SpanInfo& prevSpan = *it;
|
||||||
if( !prevSpan.emitted && !prevSpan.name.empty() ) {
|
if( !prevSpan.emitted && !prevSpan.name.empty() ) {
|
||||||
m_config.stream << "[Started section: '" << prevSpan.name << "']" << std::endl;
|
m_config.stream() << "[Started section: '" << prevSpan.name << "']" << std::endl;
|
||||||
prevSpan.emitted = true;
|
prevSpan.emitted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -329,10 +329,10 @@ namespace Catch {
|
|||||||
void streamVariableLengthText( const std::string& prefix, const std::string& text ) {
|
void streamVariableLengthText( const std::string& prefix, const std::string& text ) {
|
||||||
std::string trimmed = trim( text );
|
std::string trimmed = trim( text );
|
||||||
if( trimmed.find_first_of( "\r\n" ) == std::string::npos ) {
|
if( trimmed.find_first_of( "\r\n" ) == std::string::npos ) {
|
||||||
m_config.stream << "[" << prefix << ": " << trimmed << "]";
|
m_config.stream() << "[" << prefix << ": " << trimmed << "]";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_config.stream << "\n[" << prefix << "] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" << trimmed
|
m_config.stream() << "\n[" << prefix << "] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" << trimmed
|
||||||
<< "\n[end of " << prefix << "] <<<<<<<<<<<<<<<<<<<<<<<<\n";
|
<< "\n[end of " << prefix << "] <<<<<<<<<<<<<<<<<<<<<<<<\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ namespace Catch {
|
|||||||
|
|
||||||
virtual void StartGroup( const std::string& groupName ) {
|
virtual void StartGroup( const std::string& groupName ) {
|
||||||
if( groupName.empty() )
|
if( groupName.empty() )
|
||||||
m_statsForSuites.push_back( Stats( m_config.name ) );
|
m_statsForSuites.push_back( Stats( m_config.name() ) );
|
||||||
else
|
else
|
||||||
m_statsForSuites.push_back( Stats( groupName ) );
|
m_statsForSuites.push_back( Stats( groupName ) );
|
||||||
m_currentStats = &m_statsForSuites.back();
|
m_currentStats = &m_statsForSuites.back();
|
||||||
@ -108,7 +108,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void Result( const Catch::AssertionResult& assertionResult ) {
|
virtual void Result( const Catch::AssertionResult& assertionResult ) {
|
||||||
if( assertionResult.getResultType() != ResultWas::Ok || m_config.includeSuccessfulResults ) {
|
if( assertionResult.getResultType() != ResultWas::Ok || m_config.includeSuccessfulResults() ) {
|
||||||
TestCaseStats& testCaseStats = m_currentStats->m_testCaseStats.back();
|
TestCaseStats& testCaseStats = m_currentStats->m_testCaseStats.back();
|
||||||
TestStats stats;
|
TestStats stats;
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
@ -168,32 +168,29 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void EndTesting( const Totals& ) {
|
virtual void EndTesting( const Totals& ) {
|
||||||
std::ostream& str = m_config.stream;
|
XmlWriter xml( m_config.stream() );
|
||||||
{
|
|
||||||
XmlWriter xml( str );
|
if( m_statsForSuites.size() > 0 )
|
||||||
|
xml.startElement( "testsuites" );
|
||||||
|
|
||||||
|
std::vector<Stats>::const_iterator it = m_statsForSuites.begin();
|
||||||
|
std::vector<Stats>::const_iterator itEnd = m_statsForSuites.end();
|
||||||
|
|
||||||
|
for(; it != itEnd; ++it ) {
|
||||||
|
XmlWriter::ScopedElement e = xml.scopedElement( "testsuite" );
|
||||||
|
xml.writeAttribute( "name", it->m_name );
|
||||||
|
xml.writeAttribute( "errors", it->m_errorsCount );
|
||||||
|
xml.writeAttribute( "failures", it->m_failuresCount );
|
||||||
|
xml.writeAttribute( "tests", it->m_testsCount );
|
||||||
|
xml.writeAttribute( "hostname", "tbd" );
|
||||||
|
xml.writeAttribute( "time", "tbd" );
|
||||||
|
xml.writeAttribute( "timestamp", "tbd" );
|
||||||
|
|
||||||
if( m_statsForSuites.size() > 0 )
|
OutputTestCases( xml, *it );
|
||||||
xml.startElement( "testsuites" );
|
|
||||||
|
|
||||||
std::vector<Stats>::const_iterator it = m_statsForSuites.begin();
|
|
||||||
std::vector<Stats>::const_iterator itEnd = m_statsForSuites.end();
|
|
||||||
|
|
||||||
for(; it != itEnd; ++it ) {
|
|
||||||
XmlWriter::ScopedElement e = xml.scopedElement( "testsuite" );
|
|
||||||
xml.writeAttribute( "name", it->m_name );
|
|
||||||
xml.writeAttribute( "errors", it->m_errorsCount );
|
|
||||||
xml.writeAttribute( "failures", it->m_failuresCount );
|
|
||||||
xml.writeAttribute( "tests", it->m_testsCount );
|
|
||||||
xml.writeAttribute( "hostname", "tbd" );
|
|
||||||
xml.writeAttribute( "time", "tbd" );
|
|
||||||
xml.writeAttribute( "timestamp", "tbd" );
|
|
||||||
|
|
||||||
OutputTestCases( xml, *it );
|
|
||||||
}
|
|
||||||
|
|
||||||
xml.scopedElement( "system-out" ).writeText( trim( m_stdOut.str() ), false );
|
|
||||||
xml.scopedElement( "system-err" ).writeText( trim( m_stdErr.str() ), false );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xml.scopedElement( "system-out" ).writeText( trim( m_stdOut.str() ), false );
|
||||||
|
xml.scopedElement( "system-err" ).writeText( trim( m_stdErr.str() ), false );
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputTestCases( XmlWriter& xml, const Stats& stats ) {
|
void OutputTestCases( XmlWriter& xml, const Stats& stats ) {
|
||||||
|
@ -30,10 +30,10 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void StartTesting() {
|
virtual void StartTesting() {
|
||||||
m_xml = XmlWriter( m_config.stream );
|
m_xml = XmlWriter( m_config.stream() );
|
||||||
m_xml.startElement( "Catch" );
|
m_xml.startElement( "Catch" );
|
||||||
if( !m_config.name.empty() )
|
if( !m_config.name().empty() )
|
||||||
m_xml.writeAttribute( "name", m_config.name );
|
m_xml.writeAttribute( "name", m_config.name() );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void EndTesting( const Totals& totals ) {
|
virtual void EndTesting( const Totals& totals ) {
|
||||||
@ -76,7 +76,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void Result( const Catch::AssertionResult& assertionResult ) {
|
virtual void Result( const Catch::AssertionResult& assertionResult ) {
|
||||||
if( !m_config.includeSuccessfulResults && assertionResult.getResultType() == ResultWas::Ok )
|
if( !m_config.includeSuccessfulResults() && assertionResult.getResultType() == ResultWas::Ok )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( assertionResult.hasExpression() ) {
|
if( assertionResult.hasExpression() ) {
|
||||||
|
@ -196,12 +196,12 @@
|
|||||||
[Running: ./succeeding/conditions/ptr]
|
[Running: ./succeeding/conditions/ptr]
|
||||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:285: p == __null succeeded for: __null == 0
|
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:285: p == __null succeeded for: __null == 0
|
||||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:286: p == pNULL succeeded for: __null == __null
|
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:286: p == pNULL succeeded for: __null == __null
|
||||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:291: p != __null succeeded for: 0x7fff5c7c3f58 != 0
|
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:291: p != __null succeeded for: 0x7fff55ab3d88 != 0
|
||||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:294: cp != __null succeeded for: 0x7fff5c7c3f58 != 0
|
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:294: cp != __null succeeded for: 0x7fff55ab3d88 != 0
|
||||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:297: cpc != __null succeeded for: 0x7fff5c7c3f58 != 0
|
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:297: cpc != __null succeeded for: 0x7fff55ab3d88 != 0
|
||||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:299: returnsNull() == __null succeeded for: {null string} == 0
|
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:299: returnsNull() == __null succeeded for: {null string} == 0
|
||||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:300: returnsConstNull() == __null succeeded for: {null string} == 0
|
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:300: returnsConstNull() == __null succeeded for: {null string} == 0
|
||||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:302: __null != p succeeded for: 0 != 0x7fff5c7c3f58
|
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/ConditionTests.cpp:302: __null != p succeeded for: 0 != 0x7fff55ab3d88
|
||||||
[Finished: './succeeding/conditions/ptr' All tests passed (8 assertions in 1 test case)]
|
[Finished: './succeeding/conditions/ptr' All tests passed (8 assertions in 1 test case)]
|
||||||
|
|
||||||
[Running: ./succeeding/conditions/not]
|
[Running: ./succeeding/conditions/not]
|
||||||
@ -1357,7 +1357,7 @@ No assertions in test case, './inprogress/failing/Tricky/compound lhs'
|
|||||||
[Finished: './inprogress/failing/Tricky/compound lhs' 1 test case failed (1 assertion failed)]
|
[Finished: './inprogress/failing/Tricky/compound lhs' 1 test case failed (1 assertion failed)]
|
||||||
|
|
||||||
[Running: ./failing/Tricky/non streamable type]
|
[Running: ./failing/Tricky/non streamable type]
|
||||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/TrickyTests.cpp:95: &o1 == &o2 failed for: 0x7fff5c7c4738 == 0x7fff5c7c4730
|
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/TrickyTests.cpp:95: &o1 == &o2 failed for: 0x7fff55ab4568 == 0x7fff55ab4560
|
||||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/TrickyTests.cpp:96: o1 == o2 failed for: {?} == {?}
|
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/TrickyTests.cpp:96: o1 == o2 failed for: {?} == {?}
|
||||||
[Finished: './failing/Tricky/non streamable type' 1 test case failed (All 2 assertions failed)]
|
[Finished: './failing/Tricky/non streamable type' 1 test case failed (All 2 assertions failed)]
|
||||||
|
|
||||||
@ -1383,7 +1383,7 @@ No assertions in test case, './inprogress/failing/Tricky/compound lhs'
|
|||||||
[Finished: './succeeding/enum/bits' All tests passed (1 assertion in 1 test case)]
|
[Finished: './succeeding/enum/bits' All tests passed (1 assertion in 1 test case)]
|
||||||
|
|
||||||
[Running: ./succeeding/boolean member]
|
[Running: ./succeeding/boolean member]
|
||||||
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/TrickyTests.cpp:239: obj.prop != __null succeeded for: 0x7fff5c7c4730 != 0
|
/Users/Phil/Dev/OSS/Catch/projects/XCode4/CatchSelfTest/CatchSelfTest/../../../SelfTest/TrickyTests.cpp:239: obj.prop != __null succeeded for: 0x7fff55ab4560 != 0
|
||||||
[Finished: './succeeding/boolean member' All tests passed (1 assertion in 1 test case)]
|
[Finished: './succeeding/boolean member' All tests passed (1 assertion in 1 test case)]
|
||||||
|
|
||||||
[Running: ./succeeding/unimplemented static bool]
|
[Running: ./succeeding/unimplemented static bool]
|
||||||
|
Loading…
Reference in New Issue
Block a user