Most of system now uses Ptr<IConfig const>

This commit is contained in:
Phil Nash 2013-05-28 18:51:53 +01:00
parent e1459955f1
commit ca9b92f8fa
7 changed files with 19 additions and 18 deletions

View File

@ -39,7 +39,7 @@ namespace Catch {
filterGroups.push_back( filterGroup ); filterGroups.push_back( filterGroup );
} }
Runner context( m_config, m_reporter ); // This Runner will be renamed Context Runner context( m_config.get(), m_reporter ); // This Runner will be renamed Context
Totals totals; Totals totals;
for( std::size_t i=0; i < filterGroups.size() && !context.aborting(); ++i ) { for( std::size_t i=0; i < filterGroups.size() && !context.aborting(); ++i ) {

View File

@ -141,7 +141,7 @@ namespace Catch {
m_data.filters.push_back( filters ); m_data.filters.push_back( filters );
} }
int getCutoff() const { int abortAfter() const {
return m_data.cutoff; return m_data.cutoff;
} }

View File

@ -32,7 +32,7 @@ namespace Catch {
virtual IRunner& getRunner() = 0; virtual IRunner& getRunner() = 0;
virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) = 0; virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) = 0;
virtual bool advanceGeneratorsForCurrentTest() = 0; virtual bool advanceGeneratorsForCurrentTest() = 0;
virtual Ptr<IConfig> getConfig() const = 0; virtual Ptr<IConfig const> getConfig() const = 0;
}; };
struct IMutableContext : IContext struct IMutableContext : IContext
@ -40,7 +40,7 @@ namespace Catch {
virtual ~IMutableContext(); virtual ~IMutableContext();
virtual void setResultCapture( IResultCapture* resultCapture ) = 0; virtual void setResultCapture( IResultCapture* resultCapture ) = 0;
virtual void setRunner( IRunner* runner ) = 0; virtual void setRunner( IRunner* runner ) = 0;
virtual void setConfig( Ptr<IConfig> const& config ) = 0; virtual void setConfig( Ptr<IConfig const> const& config ) = 0;
}; };
IContext& getCurrentContext(); IContext& getCurrentContext();

View File

@ -38,7 +38,7 @@ namespace Catch {
return generators && generators->moveNext(); return generators && generators->moveNext();
} }
virtual Ptr<IConfig> getConfig() const { virtual Ptr<IConfig const> getConfig() const {
return m_config; return m_config;
} }
@ -49,7 +49,7 @@ namespace Catch {
virtual void setRunner( IRunner* runner ) { virtual void setRunner( IRunner* runner ) {
m_runner = runner; m_runner = runner;
} }
virtual void setConfig( Ptr<IConfig> const& config ) { virtual void setConfig( Ptr<IConfig const> const& config ) {
m_config = config; m_config = config;
} }
@ -79,7 +79,7 @@ namespace Catch {
private: private:
IRunner* m_runner; IRunner* m_runner;
IResultCapture* m_resultCapture; IResultCapture* m_resultCapture;
Ptr<IConfig> m_config; Ptr<IConfig const> m_config;
std::map<std::string, IGeneratorsForTest*> m_generatorsByTestName; std::map<std::string, IGeneratorsForTest*> m_generatorsByTestName;
}; };

View File

@ -23,7 +23,9 @@ namespace Catch {
virtual std::ostream& stream() const = 0; virtual std::ostream& stream() const = 0;
virtual std::string name() const = 0; virtual std::string name() const = 0;
virtual bool includeSuccessfulResults() const = 0; virtual bool includeSuccessfulResults() const = 0;
virtual bool shouldDebugBreak() const = 0;
virtual bool warnAboutMissingAssertions() const = 0; virtual bool warnAboutMissingAssertions() const = 0;
virtual int abortAfter() const = 0;
}; };
} }

View File

@ -56,7 +56,7 @@ namespace Catch {
public: public:
explicit Runner( Ptr<Config> const& config, Ptr<IStreamingReporter> const& reporter ) explicit Runner( Ptr<IConfig const> const& config, Ptr<IStreamingReporter> const& reporter )
: m_runInfo( config->name() ), : m_runInfo( config->name() ),
m_context( getCurrentMutableContext() ), m_context( getCurrentMutableContext() ),
m_runningTest( NULL ), m_runningTest( NULL ),
@ -67,7 +67,7 @@ namespace Catch {
m_prevConfig( m_context.getConfig() ) m_prevConfig( m_context.getConfig() )
{ {
m_context.setRunner( this ); m_context.setRunner( this );
m_context.setConfig( m_config.get() ); m_context.setConfig( m_config );
m_context.setResultCapture( this ); m_context.setResultCapture( this );
m_reporter->testRunStarting( m_runInfo ); m_reporter->testRunStarting( m_runInfo );
} }
@ -126,8 +126,7 @@ namespace Catch {
Totals deltaTotals = m_totals.delta( prevTotals ); Totals deltaTotals = m_totals.delta( prevTotals );
bool missingAssertions = false; bool missingAssertions = false;
if( deltaTotals.assertions.total() == 0 && if( deltaTotals.assertions.total() == 0 && m_config->warnAboutMissingAssertions() ) {
( 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 );
missingAssertions = true; missingAssertions = true;
@ -149,7 +148,7 @@ namespace Catch {
return deltaTotals; return deltaTotals;
} }
Ptr<Config> config() const { Ptr<IConfig const> config() const {
return m_config; return m_config;
} }
@ -209,7 +208,7 @@ namespace Catch {
Counts assertions = m_totals.assertions - prevAssertions; Counts assertions = m_totals.assertions - prevAssertions;
bool missingAssertions = false; bool missingAssertions = false;
if( assertions.total() == 0 && if( assertions.total() == 0 &&
( m_config->data().warnings & ConfigData::WarnAbout::NoAssertions ) && m_config->warnAboutMissingAssertions() &&
!m_runningTest->isBranchSection() ) { !m_runningTest->isBranchSection() ) {
m_totals.assertions.failed++; m_totals.assertions.failed++;
assertions.failed++; assertions.failed++;
@ -247,7 +246,7 @@ namespace Catch {
public: public:
// !TBD We need to do this another way! // !TBD We need to do this another way!
bool aborting() const { bool aborting() const {
return m_totals.assertions.failed == static_cast<std::size_t>( m_config->getCutoff() ); return m_totals.assertions.failed == static_cast<std::size_t>( m_config->abortAfter() );
} }
private: private:
@ -315,13 +314,13 @@ namespace Catch {
RunningTest* m_runningTest; RunningTest* m_runningTest;
AssertionResult m_lastResult; AssertionResult m_lastResult;
Ptr<Config> m_config; Ptr<IConfig const> m_config;
Totals m_totals; Totals m_totals;
Ptr<IStreamingReporter> m_reporter; Ptr<IStreamingReporter> m_reporter;
std::vector<MessageInfo> m_messages; std::vector<MessageInfo> m_messages;
IRunner* m_prevRunner; IRunner* m_prevRunner;
IResultCapture* m_prevResultCapture; IResultCapture* m_prevResultCapture;
Ptr<IConfig> m_prevConfig; Ptr<IConfig const> m_prevConfig;
AssertionInfo m_lastAssertionInfo; AssertionInfo m_lastAssertionInfo;
std::vector<UnfinishedSections> m_unfinishedSections; std::vector<UnfinishedSections> m_unfinishedSections;
}; };

View File

@ -22,7 +22,7 @@ namespace Catch{
// Scoped because Runner doesn't report EndTesting until its destructor // Scoped because Runner doesn't report EndTesting until its destructor
{ {
Runner runner( config, m_reporter.get() ); Runner runner( config.get(), m_reporter.get() );
totals = runner.runMatching( rawTestSpec, groupIndex, groupsCount ); totals = runner.runMatching( rawTestSpec, groupIndex, groupsCount );
} }
return totals; return totals;