Don't redirect stout for basic reporter

This commit is contained in:
Phil Nash 2012-02-17 09:28:21 +00:00
parent 93b8a39c38
commit a57b025c9c
6 changed files with 38 additions and 3 deletions

View File

@ -78,6 +78,7 @@ namespace Catch
config.getReporter()->EndGroup( *it, runner.getSuccessCount()-prevSuccess, runner.getFailureCount()-prevFail ); config.getReporter()->EndGroup( *it, runner.getSuccessCount()-prevSuccess, runner.getFailureCount()-prevFail );
} }
} }
return static_cast<int>( runner.getFailureCount() ); return static_cast<int>( runner.getFailureCount() );
} }

View File

@ -47,6 +47,9 @@ namespace Catch
virtual ~IReporter virtual ~IReporter
(){} (){}
virtual bool shouldRedirectStdout
() const = 0;
virtual void StartTesting virtual void StartTesting
() = 0; () = 0;

View File

@ -585,9 +585,16 @@ namespace Catch
try try
{ {
m_runningTest->reset(); m_runningTest->reset();
if( m_reporter->shouldRedirectStdout() )
{
StreamRedirect coutRedir( std::cout, redirectedCout ); StreamRedirect coutRedir( std::cout, redirectedCout );
StreamRedirect cerrRedir( std::cerr, redirectedCerr ); StreamRedirect cerrRedir( std::cerr, redirectedCerr );
m_runningTest->getTestCaseInfo().invoke(); m_runningTest->getTestCaseInfo().invoke();
}
else
{
m_runningTest->getTestCaseInfo().invoke();
}
m_runningTest->ranToCompletion(); m_runningTest->ranToCompletion();
} }
catch( TestFailureException& ) catch( TestFailureException& )

View File

@ -79,6 +79,14 @@ namespace Catch
private: // IReporter private: // IReporter
///////////////////////////////////////////////////////////////////////////
virtual bool shouldRedirectStdout
()
const
{
return false;
}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
virtual void StartTesting virtual void StartTesting
() ()

View File

@ -82,6 +82,14 @@ namespace Catch
private: // IReporter private: // IReporter
///////////////////////////////////////////////////////////////////////////
virtual bool shouldRedirectStdout
()
const
{
return true;
}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
virtual void StartTesting() virtual void StartTesting()
{ {

View File

@ -40,6 +40,14 @@ namespace Catch
private: // IReporter private: // IReporter
///////////////////////////////////////////////////////////////////////////
virtual bool shouldRedirectStdout
()
const
{
return true;
}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
virtual void StartTesting virtual void StartTesting
() ()