First cut of new filtering mechanism

This commit is contained in:
Phil Nash 2012-08-23 20:08:50 +01:00
parent b354da9ab9
commit 56d5c42912
14 changed files with 1535 additions and 1365 deletions

View file

@ -56,7 +56,7 @@ namespace Catch {
public:
explicit Runner( Config& config, const Ptr<IReporter>& reporter )
explicit Runner( const Config& config, const Ptr<IReporter>& reporter )
: m_context( getCurrentMutableContext() ),
m_runningTest( NULL ),
m_config( config ),
@ -78,34 +78,22 @@ namespace Catch {
m_context.setResultCapture( m_prevResultCapture );
m_context.setConfig( m_prevConfig );
}
virtual Totals runAll() {
return runTests( "", getRegistryHub().getTestCaseRegistry().getAllTests() );
}
virtual Totals runAllNonHidden() {
return runTests( "", getRegistryHub().getTestCaseRegistry().getAllNonHiddenTests() );
}
Totals runMatching( const std::string& testSpec ) {
virtual Totals runMatching( const std::string& rawTestSpec ) {
const std::vector<TestCaseInfo>& matchingTests = getRegistryHub().getTestCaseRegistry().getMatchingTestCases( rawTestSpec );
return runTests( rawTestSpec, matchingTests );
}
virtual Totals runTests( const std::string& groupName, const std::vector<TestCaseInfo>& testCases ) {
std::vector<TestCaseInfo> matchingTests = getRegistryHub().getTestCaseRegistry().getMatchingTestCases( testSpec );
Totals totals;
m_reporter->StartGroup( groupName );
for( std::size_t i=0; i < testCases.size(); ++i ) {
if( aborting() ) {
m_reporter->Aborted();
break;
}
totals += runTest( testCases[i] );
}
m_reporter->EndGroup( groupName, totals );
m_reporter->StartGroup( testSpec );
std::vector<TestCaseInfo>::const_iterator it = matchingTests.begin();
std::vector<TestCaseInfo>::const_iterator itEnd = matchingTests.end();
for(; it != itEnd; ++it )
totals += runTest( *it );
// !TBD use std::accumulate?
m_reporter->EndGroup( testSpec, totals );
return totals;
}
@ -228,13 +216,15 @@ namespace Catch {
virtual const ResultInfo* getLastResult() const {
return &m_lastResult;
}
private:
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() );
}
private:
ResultAction::Value actOnCurrentResult() {
testEnded( m_currentResult );
m_lastResult = m_currentResult;