Main() functions deal with raw ConfigData

This commit is contained in:
Phil Nash 2013-05-28 18:59:29 +01:00
parent ca9b92f8fa
commit 43fe6c6e9e
1 changed files with 7 additions and 17 deletions

View File

@ -24,8 +24,8 @@ namespace Catch {
class Runner2 { // This will become Runner when Runner becomes Context class Runner2 { // This will become Runner when Runner becomes Context
public: public:
Runner2( Ptr<Config> const& config ) Runner2( ConfigData const& config )
: m_config( config ) : m_config( new Config( config ) )
{ {
openStream(); openStream();
makeReporter(); makeReporter();
@ -110,13 +110,11 @@ namespace Catch {
std::set<TestCase> m_testsAlreadyRun; std::set<TestCase> m_testsAlreadyRun;
}; };
inline int Main( Ptr<Config> const& config ) { inline int Main( ConfigData const& configData ) {
int result = 0; int result = 0;
try try
{ {
Runner2 runner( config ); Runner2 runner( configData );
const ConfigData& configData = config->data();
// Handle list request // Handle list request
if( configData.listSpec != List::None ) { if( configData.listSpec != List::None ) {
@ -173,7 +171,7 @@ namespace Catch {
} }
} }
inline int Main( int argc, char* const argv[], Ptr<Config> const& config ) { inline int Main( int argc, char* const argv[], ConfigData configData = ConfigData() ) {
try { try {
CommandParser parser( argc, argv ); CommandParser parser( argc, argv );
@ -189,7 +187,7 @@ namespace Catch {
AllOptions options; AllOptions options;
options.parseIntoConfig( parser, config->data() ); options.parseIntoConfig( parser, configData );
} }
catch( std::exception& ex ) { catch( std::exception& ex ) {
std::cerr << ex.what() << "\n\nUsage: ...\n\n"; std::cerr << ex.what() << "\n\nUsage: ...\n\n";
@ -198,15 +196,7 @@ namespace Catch {
return (std::numeric_limits<int>::max)(); return (std::numeric_limits<int>::max)();
} }
return Main( config ); return Main( configData );
}
inline int Main( int argc, char* const argv[] ) {
Ptr<Config> config = new Config();
// !TBD: This doesn't always work, for some reason
// if( isDebuggerActive() )
// config.useStream( "debug" );
return Main( argc, argv, config );
} }
} // end namespace Catch } // end namespace Catch