mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-29 16:53:30 +01:00
build 22
This commit is contained in:
parent
886d9d397c
commit
91ef5f7d40
@ -1,6 +1,6 @@
|
|||||||
![catch logo](catch-logo-small.png)
|
![catch logo](catch-logo-small.png)
|
||||||
|
|
||||||
*v1.0 build 21 (master branch)*
|
*v1.0 build 22 (master branch)*
|
||||||
|
|
||||||
Build status (on Travis CI) [![Build Status](https://travis-ci.org/philsquared/Catch.png)](https://travis-ci.org/philsquared/Catch)
|
Build status (on Travis CI) [![Build Status](https://travis-ci.org/philsquared/Catch.png)](https://travis-ci.org/philsquared/Catch)
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
// These numbers are maintained by a script
|
// These numbers are maintained by a script
|
||||||
Version libraryVersion( 1, 0, 21, "master" );
|
Version libraryVersion( 1, 0, 22, "master" );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* CATCH v1.0 build 21 (master branch)
|
* CATCH v1.0 build 22 (master branch)
|
||||||
* Generated: 2013-12-19 18:42:03.734896
|
* Generated: 2013-12-20 19:06:10.591489
|
||||||
* ----------------------------------------------------------
|
* ----------------------------------------------------------
|
||||||
* This file has been merged from multiple headers. Please don't edit it directly
|
* This file has been merged from multiple headers. Please don't edit it directly
|
||||||
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
|
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
|
||||||
@ -3389,18 +3389,25 @@ namespace Clara {
|
|||||||
|
|
||||||
CommandLine()
|
CommandLine()
|
||||||
: m_boundProcessName( new Detail::NullBinder<ConfigT>() ),
|
: m_boundProcessName( new Detail::NullBinder<ConfigT>() ),
|
||||||
m_highestSpecifiedArgPosition( 0 )
|
m_highestSpecifiedArgPosition( 0 ),
|
||||||
|
m_throwOnUnrecognisedTokens( false )
|
||||||
{}
|
{}
|
||||||
CommandLine( CommandLine const& other )
|
CommandLine( CommandLine const& other )
|
||||||
: m_boundProcessName( other.m_boundProcessName ),
|
: m_boundProcessName( other.m_boundProcessName ),
|
||||||
m_options ( other.m_options ),
|
m_options ( other.m_options ),
|
||||||
m_positionalArgs( other.m_positionalArgs ),
|
m_positionalArgs( other.m_positionalArgs ),
|
||||||
m_highestSpecifiedArgPosition( other.m_highestSpecifiedArgPosition )
|
m_highestSpecifiedArgPosition( other.m_highestSpecifiedArgPosition ),
|
||||||
|
m_throwOnUnrecognisedTokens( other.m_throwOnUnrecognisedTokens )
|
||||||
{
|
{
|
||||||
if( other.m_arg.get() )
|
if( other.m_arg.get() )
|
||||||
m_arg = ArgAutoPtr( new Arg( *other.m_arg ) );
|
m_arg = ArgAutoPtr( new Arg( *other.m_arg ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CommandLine& setThrowOnUnrecognisedTokens( bool shouldThrow = true ) {
|
||||||
|
m_throwOnUnrecognisedTokens = shouldThrow;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
ArgBinder bind( F f ) {
|
ArgBinder bind( F f ) {
|
||||||
ArgBinder binder( this, f );
|
ArgBinder binder( this, f );
|
||||||
@ -3506,6 +3513,7 @@ namespace Clara {
|
|||||||
|
|
||||||
std::vector<Parser::Token> populateOptions( std::vector<Parser::Token> const& tokens, ConfigT& config ) const {
|
std::vector<Parser::Token> populateOptions( std::vector<Parser::Token> const& tokens, ConfigT& config ) const {
|
||||||
std::vector<Parser::Token> unusedTokens;
|
std::vector<Parser::Token> unusedTokens;
|
||||||
|
std::vector<std::string> errors;
|
||||||
for( std::size_t i = 0; i < tokens.size(); ++i ) {
|
for( std::size_t i = 0; i < tokens.size(); ++i ) {
|
||||||
Parser::Token const& token = tokens[i];
|
Parser::Token const& token = tokens[i];
|
||||||
typename std::vector<Arg>::const_iterator it = m_options.begin(), itEnd = m_options.end();
|
typename std::vector<Arg>::const_iterator it = m_options.begin(), itEnd = m_options.end();
|
||||||
@ -3517,8 +3525,9 @@ namespace Clara {
|
|||||||
( token.type == Parser::Token::LongOpt && arg.hasLongName( token.data ) ) ) {
|
( token.type == Parser::Token::LongOpt && arg.hasLongName( token.data ) ) ) {
|
||||||
if( arg.takesArg() ) {
|
if( arg.takesArg() ) {
|
||||||
if( i == tokens.size()-1 || tokens[i+1].type != Parser::Token::Positional )
|
if( i == tokens.size()-1 || tokens[i+1].type != Parser::Token::Positional )
|
||||||
throw std::domain_error( "Expected argument to option " + token.data );
|
errors.push_back( "Expected argument to option: " + token.data );
|
||||||
arg.boundField.set( config, tokens[++i].data );
|
else
|
||||||
|
arg.boundField.set( config, tokens[++i].data );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
arg.boundField.setFlag( config );
|
arg.boundField.setFlag( config );
|
||||||
@ -3527,11 +3536,26 @@ namespace Clara {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( std::exception& ex ) {
|
catch( std::exception& ex ) {
|
||||||
throw std::runtime_error( std::string( ex.what() ) + "\n- while parsing: (" + arg.commands() + ")" );
|
errors.push_back( std::string( ex.what() ) + "\n- while parsing: (" + arg.commands() + ")" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( it == itEnd )
|
if( it == itEnd ) {
|
||||||
unusedTokens.push_back( token );
|
if( token.type == Parser::Token::Positional || !m_throwOnUnrecognisedTokens )
|
||||||
|
unusedTokens.push_back( token );
|
||||||
|
else if( m_throwOnUnrecognisedTokens )
|
||||||
|
errors.push_back( "unrecognised option: " + token.data );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( !errors.empty() ) {
|
||||||
|
std::ostringstream oss;
|
||||||
|
for( std::vector<std::string>::const_iterator it = errors.begin(), itEnd = errors.end();
|
||||||
|
it != itEnd;
|
||||||
|
++it ) {
|
||||||
|
if( it != errors.begin() )
|
||||||
|
oss << "\n";
|
||||||
|
oss << *it;
|
||||||
|
}
|
||||||
|
throw std::runtime_error( oss.str() );
|
||||||
}
|
}
|
||||||
return unusedTokens;
|
return unusedTokens;
|
||||||
}
|
}
|
||||||
@ -3570,6 +3594,7 @@ namespace Clara {
|
|||||||
std::map<int, Arg> m_positionalArgs;
|
std::map<int, Arg> m_positionalArgs;
|
||||||
ArgAutoPtr m_arg;
|
ArgAutoPtr m_arg;
|
||||||
int m_highestSpecifiedArgPosition;
|
int m_highestSpecifiedArgPosition;
|
||||||
|
bool m_throwOnUnrecognisedTokens;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace Clara
|
} // end namespace Clara
|
||||||
@ -4812,9 +4837,8 @@ namespace Catch {
|
|||||||
|
|
||||||
int applyCommandLine( int argc, char* const argv[], OnUnusedOptions::DoWhat unusedOptionBehaviour = OnUnusedOptions::Fail ) {
|
int applyCommandLine( int argc, char* const argv[], OnUnusedOptions::DoWhat unusedOptionBehaviour = OnUnusedOptions::Fail ) {
|
||||||
try {
|
try {
|
||||||
|
m_cli.setThrowOnUnrecognisedTokens( unusedOptionBehaviour == OnUnusedOptions::Fail );
|
||||||
m_unusedTokens = m_cli.parseInto( argc, argv, m_configData );
|
m_unusedTokens = m_cli.parseInto( argc, argv, m_configData );
|
||||||
if( unusedOptionBehaviour == OnUnusedOptions::Fail )
|
|
||||||
enforceNoUsedTokens();
|
|
||||||
if( m_configData.showHelp )
|
if( m_configData.showHelp )
|
||||||
showHelp( m_configData.processName );
|
showHelp( m_configData.processName );
|
||||||
m_config.reset();
|
m_config.reset();
|
||||||
@ -4822,7 +4846,7 @@ namespace Catch {
|
|||||||
catch( std::exception& ex ) {
|
catch( std::exception& ex ) {
|
||||||
{
|
{
|
||||||
Colour colourGuard( Colour::Red );
|
Colour colourGuard( Colour::Red );
|
||||||
std::cerr << "\nError in input:\n"
|
std::cerr << "\nError(s) in input:\n"
|
||||||
<< Text( ex.what(), TextAttributes().setIndent(2) )
|
<< Text( ex.what(), TextAttributes().setIndent(2) )
|
||||||
<< "\n\n";
|
<< "\n\n";
|
||||||
}
|
}
|
||||||
@ -4837,18 +4861,6 @@ namespace Catch {
|
|||||||
m_config.reset();
|
m_config.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void enforceNoUsedTokens() const {
|
|
||||||
if( !m_unusedTokens.empty() ) {
|
|
||||||
std::vector<Clara::Parser::Token>::const_iterator
|
|
||||||
it = m_unusedTokens.begin(),
|
|
||||||
itEnd = m_unusedTokens.end();
|
|
||||||
std::string msg;
|
|
||||||
for(; it != itEnd; ++it )
|
|
||||||
msg += " unrecognised option: " + it->data + "\n";
|
|
||||||
throw std::runtime_error( msg.substr( 0, msg.size()-1 ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int run( int argc, char* const argv[] ) {
|
int run( int argc, char* const argv[] ) {
|
||||||
|
|
||||||
int returnCode = applyCommandLine( argc, argv );
|
int returnCode = applyCommandLine( argc, argv );
|
||||||
@ -6166,7 +6178,7 @@ namespace Catch {
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
// These numbers are maintained by a script
|
// These numbers are maintained by a script
|
||||||
Version libraryVersion( 1, 0, 21, "master" );
|
Version libraryVersion( 1, 0, 22, "master" );
|
||||||
}
|
}
|
||||||
|
|
||||||
// #included from: catch_text.hpp
|
// #included from: catch_text.hpp
|
||||||
|
Loading…
Reference in New Issue
Block a user