mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-23 11:43:29 +01:00
Cleaned up config class a bit
This commit is contained in:
parent
2885339287
commit
bfc1ee6c62
@ -16,11 +16,8 @@
|
|||||||
|
|
||||||
Later:
|
Later:
|
||||||
Finish command line parser (list as xml, specify FP tolerance)
|
Finish command line parser (list as xml, specify FP tolerance)
|
||||||
INFO() stores messages until next result
|
|
||||||
Revisit Approx()
|
Revisit Approx()
|
||||||
Extra reports
|
|
||||||
Tags?
|
Tags?
|
||||||
Detect caught "Catch" exception, offer continuation based iteration instead
|
|
||||||
Finish macros, listed here, later (just CHECK_NOFAIL now)
|
Finish macros, listed here, later (just CHECK_NOFAIL now)
|
||||||
*/
|
*/
|
||||||
#ifndef TWOBLUECUBES_CATCH_HPP_INCLUDED
|
#ifndef TWOBLUECUBES_CATCH_HPP_INCLUDED
|
||||||
|
@ -30,9 +30,9 @@ namespace Catch
|
|||||||
Config config;
|
Config config;
|
||||||
ArgParser( argc, argv, config );
|
ArgParser( argc, argv, config );
|
||||||
|
|
||||||
if( !config.m_message.empty() )
|
if( !config.getMessage().empty() )
|
||||||
{
|
{
|
||||||
std::cerr << config.m_message << std::endl;
|
std::cerr << config.getMessage() << std::endl;
|
||||||
return std::numeric_limits<int>::max();
|
return std::numeric_limits<int>::max();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ namespace Catch
|
|||||||
Runner runner( config );
|
Runner runner( config );
|
||||||
|
|
||||||
// Run test specs specified on the command line - or default to all
|
// Run test specs specified on the command line - or default to all
|
||||||
if( config.m_testSpecs.size() == 0 )
|
if( !config.testsSpecified() )
|
||||||
{
|
{
|
||||||
config.getReporter()->StartGroup( "" );
|
config.getReporter()->StartGroup( "" );
|
||||||
runner.runAll();
|
runner.runAll();
|
||||||
@ -87,8 +87,8 @@ namespace Catch
|
|||||||
{
|
{
|
||||||
// !TBD We should get all the testcases upfront, report any missing,
|
// !TBD We should get all the testcases upfront, report any missing,
|
||||||
// then just run them
|
// then just run them
|
||||||
std::vector<std::string>::const_iterator it = config.m_testSpecs.begin();
|
std::vector<std::string>::const_iterator it = config.getTestSpecs().begin();
|
||||||
std::vector<std::string>::const_iterator itEnd = config.m_testSpecs.end();
|
std::vector<std::string>::const_iterator itEnd = config.getTestSpecs().end();
|
||||||
for(; it != itEnd; ++it )
|
for(; it != itEnd; ++it )
|
||||||
{
|
{
|
||||||
size_t prevSuccess = runner.getSuccessCount();
|
size_t prevSuccess = runner.getSuccessCount();
|
||||||
|
@ -131,7 +131,7 @@ namespace Catch
|
|||||||
else
|
else
|
||||||
return setErrorMode( m_command + " expected [xml] or [text] but recieved: [" + m_args[1] + "]" );
|
return setErrorMode( m_command + " expected [xml] or [text] but recieved: [" + m_args[1] + "]" );
|
||||||
}
|
}
|
||||||
m_config.m_listSpec = (Config::List::What)( m_config.m_listSpec | listSpec );
|
m_config.setListSpec( (Config::List::What)( m_config.getListSpec() | listSpec ) );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case modeTest:
|
case modeTest:
|
||||||
|
@ -85,6 +85,24 @@ namespace Catch
|
|||||||
m_testSpecs.push_back( testSpec );
|
m_testSpecs.push_back( testSpec );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
bool testsSpecified() const
|
||||||
|
{
|
||||||
|
return !m_testSpecs.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
const std::vector<std::string>& getTestSpecs() const
|
||||||
|
{
|
||||||
|
return m_testSpecs;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
List::What getListSpec( void ) const
|
||||||
|
{
|
||||||
|
return m_listSpec;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
void setListSpec( List::What listSpec )
|
void setListSpec( List::What listSpec )
|
||||||
{
|
{
|
||||||
@ -98,11 +116,17 @@ namespace Catch
|
|||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
std::string getFilename()
|
const std::string& getFilename() const
|
||||||
{
|
{
|
||||||
return m_filename;
|
return m_filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
const std::string& getMessage() const
|
||||||
|
{
|
||||||
|
return m_message;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
void setError( const std::string& errorMessage )
|
void setError( const std::string& errorMessage )
|
||||||
{
|
{
|
||||||
@ -115,18 +139,12 @@ namespace Catch
|
|||||||
m_reporter = std::auto_ptr<IReporter>( reporter );
|
m_reporter = std::auto_ptr<IReporter>( reporter );
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
IReporter* getReporter()
|
|
||||||
{
|
|
||||||
if( !m_reporter.get() )
|
|
||||||
setReporter( Hub::getReporterRegistry().create( "basic", *this ) );
|
|
||||||
return m_reporter.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
IReporter* getReporter() const
|
IReporter* getReporter() const
|
||||||
{
|
{
|
||||||
return const_cast<Config*>( this )->getReporter();
|
if( !m_reporter.get() )
|
||||||
|
const_cast<Config*>( this )->setReporter( Hub::getReporterRegistry().create( "basic", *this ) );
|
||||||
|
return m_reporter.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
@ -200,7 +218,7 @@ namespace Catch
|
|||||||
return m_includeWhat == Include::SuccessfulResults;
|
return m_includeWhat == Include::SuccessfulResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
std::auto_ptr<IReporter> m_reporter;
|
std::auto_ptr<IReporter> m_reporter;
|
||||||
std::string m_filename;
|
std::string m_filename;
|
||||||
std::string m_message;
|
std::string m_message;
|
||||||
|
@ -54,7 +54,7 @@ namespace Catch
|
|||||||
{
|
{
|
||||||
std::cerr << "Reporters ignored when listing" << std::endl;
|
std::cerr << "Reporters ignored when listing" << std::endl;
|
||||||
}
|
}
|
||||||
if( config.m_testSpecs.size() == 0 )
|
if( !config.testsSpecified() )
|
||||||
{
|
{
|
||||||
std::cerr << "Test specs ignored when listing" << std::endl;
|
std::cerr << "Test specs ignored when listing" << std::endl;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user