2010-11-10 00:24:00 +01:00
|
|
|
/*
|
|
|
|
* Created by Phil on 02/11/2010.
|
|
|
|
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
|
|
|
|
*
|
|
|
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
*/
|
|
|
|
#ifndef TWOBLUECUBES_CATCH_COMMANDLINE_HPP_INCLUDED
|
|
|
|
#define TWOBLUECUBES_CATCH_COMMANDLINE_HPP_INCLUDED
|
|
|
|
|
2011-01-01 01:29:58 +01:00
|
|
|
#include "catch_config.hpp"
|
2012-08-23 21:08:50 +02:00
|
|
|
#include "catch_common.h"
|
2010-11-10 00:24:00 +01:00
|
|
|
|
2012-05-16 00:58:23 +02:00
|
|
|
namespace Catch {
|
|
|
|
|
2012-05-31 20:40:26 +02:00
|
|
|
class Command {
|
2010-11-10 00:24:00 +01:00
|
|
|
public:
|
2012-05-31 20:40:26 +02:00
|
|
|
Command(){}
|
2010-11-10 00:24:00 +01:00
|
|
|
|
2012-08-27 22:42:55 +02:00
|
|
|
explicit Command( const std::string& name ) : m_name( name ) {
|
|
|
|
}
|
2012-05-31 20:40:26 +02:00
|
|
|
|
|
|
|
Command& operator += ( const std::string& arg ) {
|
|
|
|
m_args.push_back( arg );
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
Command& operator += ( const Command& other ) {
|
|
|
|
std::copy( other.m_args.begin(), other.m_args.end(), std::back_inserter( m_args ) );
|
|
|
|
if( m_name.empty() )
|
|
|
|
m_name = other.m_name;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
Command operator + ( const Command& other ) {
|
|
|
|
Command newCommand( *this );
|
|
|
|
newCommand += other;
|
|
|
|
return newCommand;
|
2010-11-10 00:24:00 +01:00
|
|
|
}
|
|
|
|
|
2012-05-31 20:40:26 +02:00
|
|
|
operator SafeBool::type() const {
|
2012-08-24 19:54:56 +02:00
|
|
|
return SafeBool::makeSafe( !m_name.empty() || !m_args.empty() );
|
2010-11-10 00:24:00 +01:00
|
|
|
}
|
|
|
|
|
2012-05-31 20:40:26 +02:00
|
|
|
std::string name() const { return m_name; }
|
|
|
|
std::string operator[]( std::size_t i ) const { return m_args[i]; }
|
|
|
|
std::size_t argsCount() const { return m_args.size(); }
|
2012-08-13 08:46:10 +02:00
|
|
|
|
|
|
|
CATCH_ATTRIBUTE_NORETURN
|
2012-05-31 20:40:26 +02:00
|
|
|
void raiseError( const std::string& message ) const {
|
|
|
|
std::ostringstream oss;
|
2012-08-27 22:42:55 +02:00
|
|
|
if( m_name.empty() )
|
|
|
|
oss << "Error while parsing " << m_name << ". " << message << ".";
|
|
|
|
else
|
|
|
|
oss << "Error while parsing arguments. " << message << ".";
|
|
|
|
|
2012-05-31 20:40:26 +02:00
|
|
|
if( m_args.size() > 0 )
|
2012-08-27 22:42:55 +02:00
|
|
|
oss << " Arguments were:";
|
2012-05-31 20:40:26 +02:00
|
|
|
for( std::size_t i = 0; i < m_args.size(); ++i )
|
|
|
|
oss << " " << m_args[i];
|
|
|
|
throw std::domain_error( oss.str() );
|
2010-11-10 00:24:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2012-05-31 20:40:26 +02:00
|
|
|
std::string m_name;
|
2010-11-10 00:24:00 +01:00
|
|
|
std::vector<std::string> m_args;
|
|
|
|
};
|
|
|
|
|
2012-05-31 20:40:26 +02:00
|
|
|
class CommandParser {
|
|
|
|
public:
|
2012-06-03 00:08:07 +02:00
|
|
|
CommandParser( int argc, char const * const * argv ) : m_argc( static_cast<std::size_t>( argc ) ), m_argv( argv ) {}
|
2012-05-31 20:40:26 +02:00
|
|
|
|
|
|
|
Command find( const std::string& arg1, const std::string& arg2, const std::string& arg3 ) const {
|
|
|
|
return find( arg1 ) + find( arg2 ) + find( arg3 );
|
|
|
|
}
|
|
|
|
|
|
|
|
Command find( const std::string& shortArg, const std::string& longArg ) const {
|
|
|
|
return find( shortArg ) + find( longArg );
|
|
|
|
}
|
|
|
|
Command find( const std::string& arg ) const {
|
2012-08-25 22:26:05 +02:00
|
|
|
if( arg.empty() )
|
|
|
|
return getArgs( "", 1 );
|
|
|
|
else
|
|
|
|
for( std::size_t i = 1; i < m_argc; ++i )
|
|
|
|
if( m_argv[i] == arg )
|
|
|
|
return getArgs( m_argv[i], i+1 );
|
2012-05-31 20:40:26 +02:00
|
|
|
return Command();
|
|
|
|
}
|
2012-08-24 19:54:56 +02:00
|
|
|
Command getDefaultArgs() const {
|
|
|
|
return getArgs( "", 1 );
|
|
|
|
}
|
|
|
|
|
2012-05-31 20:40:26 +02:00
|
|
|
private:
|
2012-08-24 19:54:56 +02:00
|
|
|
Command getArgs( const std::string& cmdName, std::size_t from ) const {
|
|
|
|
Command command( cmdName );
|
|
|
|
for( std::size_t i = from; i < m_argc && m_argv[i][0] != '-'; ++i )
|
2012-05-31 20:40:26 +02:00
|
|
|
command += m_argv[i];
|
|
|
|
return command;
|
|
|
|
}
|
|
|
|
|
2012-06-03 00:08:07 +02:00
|
|
|
std::size_t m_argc;
|
2012-05-31 20:40:26 +02:00
|
|
|
char const * const * m_argv;
|
|
|
|
};
|
2012-08-25 22:26:05 +02:00
|
|
|
|
2012-08-27 13:19:07 +02:00
|
|
|
class OptionParser : public SharedImpl<IShared> {
|
2012-08-25 22:26:05 +02:00
|
|
|
public:
|
2012-08-27 22:42:55 +02:00
|
|
|
OptionParser( int minArgs = 0, int maxArgs = 0 )
|
|
|
|
: m_minArgs( minArgs ), m_maxArgs( maxArgs )
|
|
|
|
{}
|
|
|
|
|
2012-08-25 22:26:05 +02:00
|
|
|
virtual ~OptionParser() {}
|
|
|
|
|
2012-08-27 13:19:07 +02:00
|
|
|
Command find( const CommandParser& parser ) const {
|
2012-08-25 22:26:05 +02:00
|
|
|
Command cmd;
|
|
|
|
for( std::vector<std::string>::const_iterator it = m_optionNames.begin();
|
|
|
|
it != m_optionNames.end();
|
|
|
|
++it )
|
|
|
|
cmd += parser.find( *it );
|
2012-08-27 13:19:07 +02:00
|
|
|
return cmd;
|
|
|
|
}
|
2012-08-25 22:26:05 +02:00
|
|
|
|
2012-08-27 22:42:55 +02:00
|
|
|
void validateArgs( const Command& args ) const {
|
|
|
|
if( tooFewArgs( args ) || tooManyArgs( args ) ) {
|
|
|
|
std::ostringstream oss;
|
|
|
|
if( m_maxArgs == -1 )
|
|
|
|
oss <<"Expected at least " << pluralise( static_cast<std::size_t>( m_minArgs ), "argument" );
|
|
|
|
else if( m_minArgs == m_maxArgs )
|
|
|
|
oss <<"Expected " << pluralise( static_cast<std::size_t>( m_minArgs ), "argument" );
|
|
|
|
else
|
|
|
|
oss <<"Expected between " << m_minArgs << " and " << m_maxArgs << " argument";
|
|
|
|
args.raiseError( oss.str() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-27 13:19:07 +02:00
|
|
|
void parseIntoConfig( const CommandParser& parser, ConfigData& config ) {
|
2012-08-27 22:42:55 +02:00
|
|
|
if( Command cmd = find( parser ) ) {
|
|
|
|
validateArgs( cmd );
|
2012-08-25 22:26:05 +02:00
|
|
|
parseIntoConfig( cmd, config );
|
2012-08-27 22:42:55 +02:00
|
|
|
}
|
2012-08-25 22:26:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) = 0;
|
|
|
|
virtual std::string argsSynopsis() const = 0;
|
|
|
|
virtual std::string optionSummary() const = 0;
|
2012-08-27 13:19:07 +02:00
|
|
|
|
|
|
|
std::string optionNames() const {
|
|
|
|
std::string names;
|
|
|
|
for( std::vector<std::string>::const_iterator it = m_optionNames.begin();
|
|
|
|
it != m_optionNames.end();
|
|
|
|
++it ) {
|
|
|
|
if( !it->empty() ) {
|
|
|
|
if( !names.empty() )
|
|
|
|
names += ", ";
|
|
|
|
names += *it;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
names = "[" + names;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( names[0] == '[' )
|
|
|
|
names += "]";
|
|
|
|
return names;
|
|
|
|
}
|
2012-06-08 09:22:56 +02:00
|
|
|
|
2012-08-25 22:26:05 +02:00
|
|
|
protected:
|
2012-08-27 22:42:55 +02:00
|
|
|
|
|
|
|
bool tooFewArgs( const Command& args ) const {
|
|
|
|
return args.argsCount() < static_cast<std::size_t>( m_minArgs );
|
|
|
|
}
|
|
|
|
bool tooManyArgs( const Command& args ) const {
|
|
|
|
return m_maxArgs >= 0 && args.argsCount() > static_cast<std::size_t>( m_maxArgs );
|
|
|
|
}
|
2012-08-25 22:26:05 +02:00
|
|
|
std::vector<std::string> m_optionNames;
|
2012-08-27 22:42:55 +02:00
|
|
|
int m_minArgs;
|
|
|
|
int m_maxArgs;
|
2012-08-25 22:26:05 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
namespace Options {
|
|
|
|
|
2012-08-27 13:19:07 +02:00
|
|
|
class HelpOptionParser : public OptionParser {
|
|
|
|
public:
|
|
|
|
HelpOptionParser() {
|
|
|
|
m_optionNames.push_back( "-?" );
|
|
|
|
m_optionNames.push_back( "-h" );
|
|
|
|
m_optionNames.push_back( "--help" );
|
|
|
|
}
|
|
|
|
virtual std::string argsSynopsis() const {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
virtual std::string optionSummary() const {
|
|
|
|
return "Shows this usage summary";
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void parseIntoConfig( const Command&, ConfigData& ) {
|
|
|
|
// Does not affect config
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-08-25 22:26:05 +02:00
|
|
|
class TestCaseOptionParser : public OptionParser {
|
|
|
|
public:
|
2012-08-27 22:42:55 +02:00
|
|
|
TestCaseOptionParser() : OptionParser( 1, -1 ) {
|
2012-08-25 22:26:05 +02:00
|
|
|
m_optionNames.push_back( "-t" );
|
|
|
|
m_optionNames.push_back( "--test" );
|
|
|
|
m_optionNames.push_back( "" ); // default option
|
2012-05-31 20:40:26 +02:00
|
|
|
}
|
2012-08-25 22:26:05 +02:00
|
|
|
virtual std::string argsSynopsis() const {
|
|
|
|
return "<testspec> [<testspec>...]";
|
|
|
|
}
|
|
|
|
virtual std::string optionSummary() const {
|
|
|
|
return "Specify which test case or cases to run";
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
|
|
|
|
std::string groupName;
|
|
|
|
for( std::size_t i = 0; i < cmd.argsCount(); ++i ) {
|
|
|
|
if( i != 0 )
|
|
|
|
groupName += " ";
|
|
|
|
groupName += cmd[i];
|
|
|
|
}
|
|
|
|
TestCaseFilters filters( groupName );
|
|
|
|
for( std::size_t i = 0; i < cmd.argsCount(); ++i ) {
|
|
|
|
if( startsWith( cmd[i], "exclude:" ) )
|
|
|
|
filters.addFilter( TestCaseFilter( cmd[i].substr( 8 ), IfFilterMatches::ExcludeTests ) );
|
|
|
|
else if( startsWith( cmd[i], "~" ) )
|
|
|
|
filters.addFilter( TestCaseFilter( cmd[i].substr( 1 ), IfFilterMatches::ExcludeTests ) );
|
|
|
|
else
|
|
|
|
filters.addFilter( TestCaseFilter( cmd[i] ) );
|
|
|
|
}
|
|
|
|
config.filters.push_back( filters );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class ListOptionParser : public OptionParser {
|
|
|
|
public:
|
2012-08-27 22:42:55 +02:00
|
|
|
ListOptionParser() : OptionParser( 0, 2 ) {
|
2012-08-25 22:26:05 +02:00
|
|
|
m_optionNames.push_back( "-l" );
|
|
|
|
m_optionNames.push_back( "--list" );
|
|
|
|
}
|
|
|
|
virtual std::string argsSynopsis() const {
|
2012-08-27 13:19:07 +02:00
|
|
|
return "[all | tests | reporters [xml]]";
|
2012-08-25 22:26:05 +02:00
|
|
|
}
|
|
|
|
virtual std::string optionSummary() const {
|
|
|
|
return "!TBD";
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
|
|
|
|
config.listSpec = List::TestNames;
|
|
|
|
if( cmd.argsCount() >= 1 ) {
|
|
|
|
if( cmd[0] == "all" )
|
|
|
|
config.listSpec = List::All;
|
|
|
|
else if( cmd[0] == "tests" )
|
|
|
|
config.listSpec = List::Tests;
|
|
|
|
else if( cmd[0] == "reporters" )
|
|
|
|
config.listSpec = List::Reports;
|
|
|
|
else
|
|
|
|
cmd.raiseError( "Expected [tests] or [reporters]" );
|
|
|
|
}
|
|
|
|
if( cmd.argsCount() >= 2 ) {
|
|
|
|
if( cmd[1] == "xml" )
|
|
|
|
config.listSpec = static_cast<List::What>( config.listSpec | List::AsXml );
|
|
|
|
else if( cmd[1] == "text" )
|
|
|
|
config.listSpec = static_cast<List::What>( config.listSpec | List::AsText );
|
|
|
|
else
|
|
|
|
cmd.raiseError( "Expected [xml] or [text]" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class ReporterOptionParser : public OptionParser {
|
|
|
|
public:
|
2012-08-27 22:42:55 +02:00
|
|
|
ReporterOptionParser() : OptionParser( 1, 1 ) {
|
2012-08-25 22:26:05 +02:00
|
|
|
m_optionNames.push_back( "-r" );
|
|
|
|
m_optionNames.push_back( "--reporter" );
|
|
|
|
}
|
|
|
|
virtual std::string argsSynopsis() const {
|
2012-08-27 13:19:07 +02:00
|
|
|
return "<reporter name>";
|
2012-08-25 22:26:05 +02:00
|
|
|
}
|
|
|
|
virtual std::string optionSummary() const {
|
|
|
|
return "!TBD";
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
|
|
|
|
config.reporter = cmd[0];
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class OutputOptionParser : public OptionParser {
|
|
|
|
public:
|
2012-08-27 22:42:55 +02:00
|
|
|
OutputOptionParser() : OptionParser( 1, 1 ) {
|
2012-08-25 22:26:05 +02:00
|
|
|
m_optionNames.push_back( "-o" );
|
|
|
|
m_optionNames.push_back( "--out" );
|
|
|
|
}
|
|
|
|
virtual std::string argsSynopsis() const {
|
2012-08-27 13:19:07 +02:00
|
|
|
return "<file name>|<%stream name>";
|
2012-08-25 22:26:05 +02:00
|
|
|
}
|
|
|
|
virtual std::string optionSummary() const {
|
|
|
|
return "!TBD";
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
|
|
|
|
if( cmd[0][0] == '%' )
|
|
|
|
config.stream = cmd[0].substr( 1 );
|
2012-08-23 21:08:50 +02:00
|
|
|
else
|
2012-08-25 22:26:05 +02:00
|
|
|
config.outputFilename = cmd[0];
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class SuccesssOptionParser : public OptionParser {
|
|
|
|
public:
|
|
|
|
SuccesssOptionParser() {
|
|
|
|
m_optionNames.push_back( "-s" );
|
|
|
|
m_optionNames.push_back( "--success" );
|
|
|
|
}
|
|
|
|
virtual std::string argsSynopsis() const {
|
2012-08-27 13:19:07 +02:00
|
|
|
return "";
|
2012-08-25 22:26:05 +02:00
|
|
|
}
|
|
|
|
virtual std::string optionSummary() const {
|
|
|
|
return "!TBD";
|
2012-08-23 21:08:50 +02:00
|
|
|
}
|
|
|
|
|
2012-08-27 22:48:15 +02:00
|
|
|
virtual void parseIntoConfig( const Command&, ConfigData& config ) {
|
2012-08-25 22:26:05 +02:00
|
|
|
config.includeWhichResults = Include::SuccessfulResults;
|
|
|
|
}
|
|
|
|
};
|
2012-06-08 09:22:56 +02:00
|
|
|
|
2012-08-25 22:26:05 +02:00
|
|
|
class DebugBreakOptionParser : public OptionParser {
|
|
|
|
public:
|
|
|
|
DebugBreakOptionParser() {
|
|
|
|
m_optionNames.push_back( "-b" );
|
|
|
|
m_optionNames.push_back( "--break" );
|
|
|
|
}
|
|
|
|
virtual std::string argsSynopsis() const {
|
2012-08-27 13:19:07 +02:00
|
|
|
return "";
|
2012-08-25 22:26:05 +02:00
|
|
|
}
|
|
|
|
virtual std::string optionSummary() const {
|
|
|
|
return "!TBD";
|
|
|
|
}
|
2012-06-01 20:40:27 +02:00
|
|
|
|
2012-08-27 22:48:15 +02:00
|
|
|
virtual void parseIntoConfig( const Command&, ConfigData& config ) {
|
2012-08-25 22:26:05 +02:00
|
|
|
config.shouldDebugBreak = true;
|
|
|
|
}
|
|
|
|
};
|
2012-06-08 09:22:56 +02:00
|
|
|
|
2012-08-25 22:26:05 +02:00
|
|
|
class NameOptionParser : public OptionParser {
|
|
|
|
public:
|
2012-08-27 22:42:55 +02:00
|
|
|
NameOptionParser() : OptionParser( 1, 1 ) {
|
2012-08-25 22:26:05 +02:00
|
|
|
m_optionNames.push_back( "-n" );
|
|
|
|
m_optionNames.push_back( "--name" );
|
|
|
|
}
|
|
|
|
virtual std::string argsSynopsis() const {
|
2012-08-27 13:19:07 +02:00
|
|
|
return "<name>";
|
2012-08-25 22:26:05 +02:00
|
|
|
}
|
|
|
|
virtual std::string optionSummary() const {
|
|
|
|
return "!TBD";
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
|
|
|
|
config.name = cmd[0];
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class AbortOptionParser : public OptionParser {
|
|
|
|
public:
|
2012-08-27 22:42:55 +02:00
|
|
|
AbortOptionParser() : OptionParser( 0, 1 ) {
|
2012-08-25 22:26:05 +02:00
|
|
|
m_optionNames.push_back( "-a" );
|
|
|
|
m_optionNames.push_back( "--abort" );
|
|
|
|
}
|
|
|
|
virtual std::string argsSynopsis() const {
|
2012-08-27 13:19:07 +02:00
|
|
|
return "[#]";
|
2012-08-25 22:26:05 +02:00
|
|
|
}
|
|
|
|
virtual std::string optionSummary() const {
|
|
|
|
return "!TBD";
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
|
|
|
|
int threshold = 1;
|
|
|
|
if( cmd.argsCount() == 1 ) {
|
|
|
|
std::stringstream ss;
|
|
|
|
ss << cmd[0];
|
|
|
|
ss >> threshold;
|
|
|
|
if( ss.fail() || threshold <= 0 )
|
|
|
|
cmd.raiseError( "threshold must be a number greater than zero" );
|
|
|
|
}
|
|
|
|
config.cutoff = threshold;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class NoThrowOptionParser : public OptionParser {
|
|
|
|
public:
|
|
|
|
NoThrowOptionParser() {
|
|
|
|
m_optionNames.push_back( "-nt" );
|
|
|
|
m_optionNames.push_back( "--nothrow" );
|
|
|
|
}
|
|
|
|
virtual std::string argsSynopsis() const {
|
2012-08-27 13:19:07 +02:00
|
|
|
return "";
|
2012-08-25 22:26:05 +02:00
|
|
|
}
|
|
|
|
virtual std::string optionSummary() const {
|
|
|
|
return "!TBD";
|
|
|
|
}
|
|
|
|
|
2012-08-27 22:48:15 +02:00
|
|
|
virtual void parseIntoConfig( const Command&, ConfigData& config ) {
|
2012-08-25 22:26:05 +02:00
|
|
|
config.allowThrows = false;
|
|
|
|
}
|
|
|
|
};
|
2012-08-28 09:20:18 +02:00
|
|
|
|
|
|
|
class WarningsOptionParser : public OptionParser {
|
|
|
|
public:
|
|
|
|
WarningsOptionParser() : OptionParser( 1, -1 ) {
|
|
|
|
m_optionNames.push_back( "-w" );
|
|
|
|
m_optionNames.push_back( "--warnings" );
|
|
|
|
}
|
|
|
|
virtual std::string argsSynopsis() const {
|
|
|
|
return "<warning>";
|
|
|
|
}
|
|
|
|
virtual std::string optionSummary() const {
|
|
|
|
return "!TBD";
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) {
|
|
|
|
for( std::size_t i = 0; i < cmd.argsCount(); ++i ) {
|
|
|
|
if( cmd[i] == "NoAssertions" )
|
|
|
|
config.warnings = (ConfigData::WarnAbout::What)( config.warnings | ConfigData::WarnAbout::NoAssertions );
|
|
|
|
else
|
|
|
|
cmd.raiseError( "Unrecognised warning: " + cmd[i] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2012-08-25 22:26:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class AllOptions
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef std::vector<Ptr<OptionParser> > Parsers;
|
|
|
|
typedef Parsers::const_iterator const_iterator;
|
|
|
|
typedef Parsers::const_iterator iterator;
|
|
|
|
|
2012-08-28 09:20:18 +02:00
|
|
|
AllOptions() {
|
|
|
|
add<Options::TestCaseOptionParser>(); // Keep this one first
|
|
|
|
|
2012-08-25 22:26:05 +02:00
|
|
|
add<Options::ListOptionParser>();
|
|
|
|
add<Options::ReporterOptionParser>();
|
2012-08-27 13:19:07 +02:00
|
|
|
add<Options::OutputOptionParser>();
|
2012-08-25 22:26:05 +02:00
|
|
|
add<Options::SuccesssOptionParser>();
|
2012-08-27 13:19:07 +02:00
|
|
|
add<Options::DebugBreakOptionParser>();
|
|
|
|
add<Options::NameOptionParser>();
|
|
|
|
add<Options::AbortOptionParser>();
|
|
|
|
add<Options::NoThrowOptionParser>();
|
2012-08-28 09:20:18 +02:00
|
|
|
add<Options::WarningsOptionParser>();
|
|
|
|
|
|
|
|
add<Options::HelpOptionParser>(); // Keep this one last
|
2012-06-08 09:22:56 +02:00
|
|
|
}
|
2012-06-05 21:50:47 +02:00
|
|
|
|
2012-08-25 22:26:05 +02:00
|
|
|
void parseIntoConfig( const CommandParser& parser, ConfigData& config ) {
|
|
|
|
for( const_iterator it = m_parsers.begin(); it != m_parsers.end(); ++it )
|
|
|
|
(*it)->parseIntoConfig( parser, config );
|
2012-06-08 09:22:56 +02:00
|
|
|
}
|
2012-07-28 21:22:40 +02:00
|
|
|
|
2012-08-25 22:26:05 +02:00
|
|
|
const_iterator begin() const {
|
|
|
|
return m_parsers.begin();
|
2012-06-08 09:22:56 +02:00
|
|
|
}
|
2012-08-25 22:26:05 +02:00
|
|
|
const_iterator end() const {
|
|
|
|
return m_parsers.end();
|
|
|
|
}
|
|
|
|
private:
|
2012-06-05 21:50:47 +02:00
|
|
|
|
2012-08-25 22:26:05 +02:00
|
|
|
template<typename T>
|
|
|
|
void add() {
|
2012-08-27 13:19:07 +02:00
|
|
|
m_parsers.push_back( new T() );
|
2012-05-31 20:40:26 +02:00
|
|
|
}
|
2012-08-25 22:26:05 +02:00
|
|
|
Parsers m_parsers;
|
2012-06-08 09:22:56 +02:00
|
|
|
|
2012-08-25 22:26:05 +02:00
|
|
|
};
|
2012-06-08 09:22:56 +02:00
|
|
|
|
2010-11-10 00:24:00 +01:00
|
|
|
} // end namespace Catch
|
|
|
|
|
2010-12-28 15:42:46 +01:00
|
|
|
#endif // TWOBLUECUBES_CATCH_COMMANDLINE_HPP_INCLUDED
|