mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 07:16:10 +01:00
Can specify tests without -t. ex: is shorthand for exclude:
This commit is contained in:
parent
4c97fc5619
commit
e571e6f4a0
@ -36,7 +36,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
operator SafeBool::type() const {
|
operator SafeBool::type() const {
|
||||||
return SafeBool::makeSafe( !m_name.empty() );
|
return SafeBool::makeSafe( !m_name.empty() || !m_args.empty() );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string name() const { return m_name; }
|
std::string name() const { return m_name; }
|
||||||
@ -72,16 +72,19 @@ namespace Catch {
|
|||||||
return find( shortArg ) + find( longArg );
|
return find( shortArg ) + find( longArg );
|
||||||
}
|
}
|
||||||
Command find( const std::string& arg ) const {
|
Command find( const std::string& arg ) const {
|
||||||
for( std::size_t i = 0; i < m_argc; ++i )
|
for( std::size_t i = 1; i < m_argc; ++i )
|
||||||
if( m_argv[i] == arg )
|
if( m_argv[i] == arg )
|
||||||
return getArgs( i );
|
return getArgs( m_argv[i], i+1 );
|
||||||
return Command();
|
return Command();
|
||||||
}
|
}
|
||||||
|
Command getDefaultArgs() const {
|
||||||
|
return getArgs( "", 1 );
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Command getArgs( std::size_t from ) const {
|
Command getArgs( const std::string& cmdName, std::size_t from ) const {
|
||||||
Command command( m_argv[from] );
|
Command command( cmdName );
|
||||||
for( std::size_t i = from+1; i < m_argc && m_argv[i][0] != '-'; ++i )
|
for( std::size_t i = from; i < m_argc && m_argv[i][0] != '-'; ++i )
|
||||||
command += m_argv[i];
|
command += m_argv[i];
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
@ -117,7 +120,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( Command cmd = parser.find( "-t", "--test" ) ) {
|
if( Command cmd = parser.find( "-t", "--test" ) + parser.getDefaultArgs() ) {
|
||||||
if( cmd.argsCount() == 0 )
|
if( cmd.argsCount() == 0 )
|
||||||
cmd.raiseError( "Expected at least one argument" );
|
cmd.raiseError( "Expected at least one argument" );
|
||||||
std::string groupName;
|
std::string groupName;
|
||||||
@ -128,8 +131,11 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
TestCaseFilters filters( groupName );
|
TestCaseFilters filters( groupName );
|
||||||
for( std::size_t i = 0; i < cmd.argsCount(); ++i ) {
|
for( std::size_t i = 0; i < cmd.argsCount(); ++i ) {
|
||||||
|
std::cout << "[" << cmd[i] << "]" << std::endl;
|
||||||
if( startsWith( cmd[i], "exclude:" ) )
|
if( startsWith( cmd[i], "exclude:" ) )
|
||||||
filters.addFilter( TestCaseFilter( cmd[i].substr( 8 ), IfFilterMatches::ExcludeTests ) );
|
filters.addFilter( TestCaseFilter( cmd[i].substr( 8 ), IfFilterMatches::ExcludeTests ) );
|
||||||
|
else if( startsWith( cmd[i], "ex:" ) )
|
||||||
|
filters.addFilter( TestCaseFilter( cmd[i].substr( 3 ), IfFilterMatches::ExcludeTests ) );
|
||||||
else
|
else
|
||||||
filters.addFilter( TestCaseFilter( cmd[i] ) );
|
filters.addFilter( TestCaseFilter( cmd[i] ) );
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Generated: 2012-08-24 08:23:10.017875
|
* Generated: 2012-08-24 18:54:08.754777
|
||||||
* ----------------------------------------------------------
|
* ----------------------------------------------------------
|
||||||
* 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.
|
||||||
@ -2499,7 +2499,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
operator SafeBool::type() const {
|
operator SafeBool::type() const {
|
||||||
return SafeBool::makeSafe( !m_name.empty() );
|
return SafeBool::makeSafe( !m_name.empty() || !m_args.empty() );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string name() const { return m_name; }
|
std::string name() const { return m_name; }
|
||||||
@ -2535,16 +2535,19 @@ namespace Catch {
|
|||||||
return find( shortArg ) + find( longArg );
|
return find( shortArg ) + find( longArg );
|
||||||
}
|
}
|
||||||
Command find( const std::string& arg ) const {
|
Command find( const std::string& arg ) const {
|
||||||
for( std::size_t i = 0; i < m_argc; ++i )
|
for( std::size_t i = 1; i < m_argc; ++i )
|
||||||
if( m_argv[i] == arg )
|
if( m_argv[i] == arg )
|
||||||
return getArgs( i );
|
return getArgs( m_argv[i], i+1 );
|
||||||
return Command();
|
return Command();
|
||||||
}
|
}
|
||||||
|
Command getDefaultArgs() const {
|
||||||
|
return getArgs( "", 1 );
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Command getArgs( std::size_t from ) const {
|
Command getArgs( const std::string& cmdName, std::size_t from ) const {
|
||||||
Command command( m_argv[from] );
|
Command command( cmdName );
|
||||||
for( std::size_t i = from+1; i < m_argc && m_argv[i][0] != '-'; ++i )
|
for( std::size_t i = from; i < m_argc && m_argv[i][0] != '-'; ++i )
|
||||||
command += m_argv[i];
|
command += m_argv[i];
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
@ -2580,7 +2583,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( Command cmd = parser.find( "-t", "--test" ) ) {
|
if( Command cmd = parser.find( "-t", "--test" ) + parser.getDefaultArgs() ) {
|
||||||
if( cmd.argsCount() == 0 )
|
if( cmd.argsCount() == 0 )
|
||||||
cmd.raiseError( "Expected at least one argument" );
|
cmd.raiseError( "Expected at least one argument" );
|
||||||
std::string groupName;
|
std::string groupName;
|
||||||
@ -2591,8 +2594,11 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
TestCaseFilters filters( groupName );
|
TestCaseFilters filters( groupName );
|
||||||
for( std::size_t i = 0; i < cmd.argsCount(); ++i ) {
|
for( std::size_t i = 0; i < cmd.argsCount(); ++i ) {
|
||||||
|
std::cout << "[" << cmd[i] << "]" << std::endl;
|
||||||
if( startsWith( cmd[i], "exclude:" ) )
|
if( startsWith( cmd[i], "exclude:" ) )
|
||||||
filters.addFilter( TestCaseFilter( cmd[i].substr( 8 ), IfFilterMatches::ExcludeTests ) );
|
filters.addFilter( TestCaseFilter( cmd[i].substr( 8 ), IfFilterMatches::ExcludeTests ) );
|
||||||
|
else if( startsWith( cmd[i], "ex:" ) )
|
||||||
|
filters.addFilter( TestCaseFilter( cmd[i].substr( 3 ), IfFilterMatches::ExcludeTests ) );
|
||||||
else
|
else
|
||||||
filters.addFilter( TestCaseFilter( cmd[i] ) );
|
filters.addFilter( TestCaseFilter( cmd[i] ) );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user