ResultCapture -> RunContext

This commit is contained in:
Phil Nash 2015-11-19 17:45:56 +00:00
parent b77b45a390
commit 73968f29a5
10 changed files with 24 additions and 24 deletions

View File

@ -44,12 +44,12 @@
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \
INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \
if( Catch::getResultCapture().getLastResult()->succeeded() )
if( Catch::getCurrentRunContext().getLastResult()->succeeded() )
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_ELSE( expr, resultDisposition, macroName ) \
INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \
if( !Catch::getResultCapture().getLastResult()->succeeded() )
if( !Catch::getCurrentRunContext().getLastResult()->succeeded() )
///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_NO_THROW( expr, resultDisposition, macroName ) \

View File

@ -18,7 +18,7 @@ namespace Catch {
class TestCase;
class Stream;
struct IResultCapture;
struct IRunContext;
struct IRunner;
struct IConfig;
@ -26,7 +26,7 @@ namespace Catch {
{
virtual ~IContext();
virtual IResultCapture* getResultCapture() = 0;
virtual IRunContext* getCurrentRunContext() = 0;
virtual IRunner* getRunner() = 0;
virtual IConfig const* getConfig() const = 0;
};
@ -34,7 +34,7 @@ namespace Catch {
struct IMutableContext : IContext
{
virtual ~IMutableContext();
virtual void setResultCapture( IResultCapture* resultCapture ) = 0;
virtual void setResultCapture( IRunContext* resultCapture ) = 0;
virtual void setRunner( IRunner* runner ) = 0;
virtual void setConfig( Ptr<IConfig const> const& config ) = 0;
};

View File

@ -22,7 +22,7 @@ namespace Catch {
void operator=( Context const& );
public: // IContext
virtual IResultCapture* getResultCapture() {
virtual IRunContext* getCurrentRunContext() {
return m_resultCapture;
}
virtual IRunner* getRunner() {
@ -33,7 +33,7 @@ namespace Catch {
}
public: // IMutableContext
virtual void setResultCapture( IResultCapture* resultCapture ) {
virtual void setResultCapture( IRunContext* resultCapture ) {
m_resultCapture = resultCapture;
}
virtual void setRunner( IRunner* runner ) {
@ -48,7 +48,7 @@ namespace Catch {
private:
Ptr<IConfig const> m_config;
IRunner* m_runner;
IResultCapture* m_resultCapture;
IRunContext* m_resultCapture;
};
namespace {

View File

@ -15,8 +15,8 @@ namespace Catch {
// Report the error condition then exit the process
inline void fatal( std::string const& message, int exitCode ) {
IContext& context = Catch::getCurrentContext();
IResultCapture* resultCapture = context.getResultCapture();
resultCapture->handleFatalErrorCondition( message );
IRunContext* runContext = context.getCurrentRunContext();
runContext->handleFatalErrorCondition( message );
if( Catch::alwaysTrue() ) // avoids "no return" warnings
exit( exitCode );

View File

@ -53,7 +53,7 @@ namespace Catch {
DebugOutStream::~DebugOutStream() CATCH_NOEXCEPT {}
StreamBufBase::~StreamBufBase() CATCH_NOEXCEPT {}
IContext::~IContext() {}
IResultCapture::~IResultCapture() {}
IRunContext::~IRunContext() {}
ITestCase::~ITestCase() {}
ITestCaseRegistry::~ITestCaseRegistry() {}
IRegistryHub::~IRegistryHub() {}

View File

@ -23,9 +23,9 @@ namespace Catch {
class ScopedMessageBuilder;
struct Counts;
struct IResultCapture {
struct IRunContext {
virtual ~IResultCapture();
virtual ~IRunContext();
virtual void assertionEnded( AssertionResult const& result ) = 0;
virtual bool sectionStarted( SectionInfo const& sectionInfo,
@ -41,7 +41,7 @@ namespace Catch {
virtual void handleFatalErrorCondition( std::string const& message ) = 0;
};
IResultCapture& getResultCapture();
IRunContext& getCurrentRunContext();
}
#endif // TWOBLUECUBES_CATCH_INTERFACES_CAPTURE_H_INCLUDED

View File

@ -31,14 +31,14 @@ namespace Catch {
: m_info( builder.m_info )
{
m_info.message = builder.m_stream.str();
getResultCapture().pushScopedMessage( m_info );
getCurrentRunContext().pushScopedMessage( m_info );
}
ScopedMessage::ScopedMessage( ScopedMessage const& other )
: m_info( other.m_info )
{}
ScopedMessage::~ScopedMessage() {
getResultCapture().popScopedMessage( m_info );
getCurrentRunContext().popScopedMessage( m_info );
}

View File

@ -98,7 +98,7 @@ namespace Catch {
}
void ResultBuilder::handleResult( AssertionResult const& result )
{
getResultCapture().assertionEnded( result );
getCurrentRunContext().assertionEnded( result );
if( !result.isOk() ) {
if( getCurrentConfig()->shouldDebugBreak() )

View File

@ -52,7 +52,7 @@ namespace Catch {
///////////////////////////////////////////////////////////////////////////
class RunContext : public IResultCapture, public IRunner {
class RunContext : public IRunContext, public IRunner {
RunContext( RunContext const& );
void operator =( RunContext const& );
@ -119,7 +119,7 @@ namespace Catch {
return m_config;
}
private: // IResultCapture
private: // IRunContext
virtual void assertionEnded( AssertionResult const& result ) {
@ -337,8 +337,8 @@ namespace Catch {
std::vector<MessageInfo> m_messages;
};
IResultCapture& getResultCapture() {
if( IResultCapture* capture = getCurrentContext().getResultCapture() )
IRunContext& getCurrentRunContext() {
if( IRunContext* capture = getCurrentContext().getCurrentRunContext() )
return *capture;
else
throw std::logic_error( "No result capture instance" );

View File

@ -26,7 +26,7 @@ namespace Catch {
Section::Section( SectionInfo const& info )
: m_info( info ),
m_sectionIncluded( getResultCapture().sectionStarted( m_info, m_assertions ) )
m_sectionIncluded( getCurrentRunContext().sectionStarted( m_info, m_assertions ) )
{
m_timer.start();
}
@ -35,9 +35,9 @@ namespace Catch {
if( m_sectionIncluded ) {
SectionEndInfo endInfo( m_info, m_assertions, m_timer.getElapsedSeconds() );
if( std::uncaught_exception() )
getResultCapture().sectionEndedEarly( endInfo );
getCurrentRunContext().sectionEndedEarly( endInfo );
else
getResultCapture().sectionEnded( endInfo );
getCurrentRunContext().sectionEnded( endInfo );
}
}