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 );
}
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;
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 );
}
int getCutoff() const {
int abortAfter() const {
return m_data.cutoff;
}

View File

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

View File

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

View File

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

View File

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

View File

@ -22,7 +22,7 @@ namespace Catch{
// 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 );
}
return totals;