mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-22 19:33:29 +01:00
ConfigData just keeps strings for test names/ specs/ tags (processed in Config actor)
This commit is contained in:
parent
c2ca80d9fb
commit
20ddb0055f
@ -255,20 +255,8 @@ namespace Catch {
|
||||
}
|
||||
|
||||
virtual void parseIntoConfig( Command const& 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], "[" ) || startsWith( cmd[i], "~[" ) )
|
||||
filters.addTags( cmd[i] );
|
||||
else
|
||||
filters.addFilter( TestCaseFilter( cmd[i] ) );
|
||||
}
|
||||
config.filters.push_back( filters );
|
||||
for( std::size_t i = 0; i < cmd.argsCount(); ++i )
|
||||
config.testsOrTags.push_back( cmd[i] );
|
||||
}
|
||||
};
|
||||
|
||||
@ -301,16 +289,8 @@ namespace Catch {
|
||||
}
|
||||
|
||||
virtual void parseIntoConfig( Command const& 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 )
|
||||
filters.addTags( cmd[i] );
|
||||
config.filters.push_back( filters );
|
||||
config.testsOrTags.push_back( cmd[i] );
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -65,7 +65,7 @@ namespace Catch {
|
||||
std::string outputFilename;
|
||||
std::string name;
|
||||
|
||||
std::vector<TestCaseFilters> filters; // !TBD strings
|
||||
std::vector<std::string> testsOrTags;
|
||||
|
||||
std::string stream;
|
||||
};
|
||||
@ -84,9 +84,24 @@ namespace Catch {
|
||||
|
||||
Config( ConfigData const& data )
|
||||
: m_data( data ),
|
||||
m_os( std::cout.rdbuf() ),
|
||||
m_filters( data.filters )
|
||||
{}
|
||||
m_os( std::cout.rdbuf() )
|
||||
{
|
||||
std::string groupName;
|
||||
for( std::size_t i = 0; i < data.testsOrTags.size(); ++i ) {
|
||||
if( i != 0 )
|
||||
groupName += " ";
|
||||
groupName += data.testsOrTags[i];
|
||||
}
|
||||
TestCaseFilters filters( groupName );
|
||||
for( std::size_t i = 0; i < data.testsOrTags.size(); ++i ) {
|
||||
std::string filter = data.testsOrTags[i];
|
||||
if( startsWith( filter, "[" ) || startsWith( filter, "~[" ) )
|
||||
filters.addTags( filter );
|
||||
else
|
||||
filters.addFilter( TestCaseFilter( filter ) );
|
||||
}
|
||||
m_filterSets.push_back( filters );
|
||||
}
|
||||
|
||||
virtual ~Config() {
|
||||
m_os.rdbuf( std::cout.rdbuf() );
|
||||
@ -131,7 +146,7 @@ namespace Catch {
|
||||
void addTestSpec( std::string const& testSpec ) {
|
||||
TestCaseFilters filters( testSpec );
|
||||
filters.addFilter( TestCaseFilter( testSpec ) );
|
||||
m_data.filters.push_back( filters );
|
||||
m_filterSets.push_back( filters );
|
||||
}
|
||||
|
||||
int abortAfter() const {
|
||||
@ -139,7 +154,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
std::vector<TestCaseFilters> const& filters() const {
|
||||
return m_filters;
|
||||
return m_filterSets;
|
||||
}
|
||||
|
||||
// IConfig interface
|
||||
@ -154,7 +169,7 @@ namespace Catch {
|
||||
|
||||
Stream m_stream;
|
||||
mutable std::ostream m_os;
|
||||
std::vector<TestCaseFilters> m_filters;
|
||||
std::vector<TestCaseFilters> m_filterSets;
|
||||
};
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -108,54 +108,60 @@ TEST_CASE( "selftest/parser/2", "ConfigData" ) {
|
||||
const char* argv[] = { "test", "-t", "test1" };
|
||||
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||
|
||||
REQUIRE( config.filters.size() == 1 );
|
||||
REQUIRE( config.filters[0].shouldInclude( fakeTestCase( "notIncluded" ) ) == false );
|
||||
REQUIRE( config.filters[0].shouldInclude( fakeTestCase( "test1" ) ) );
|
||||
Catch::Config cfg( config );
|
||||
REQUIRE( cfg.filters().size() == 1 );
|
||||
REQUIRE( cfg.filters()[0].shouldInclude( fakeTestCase( "notIncluded" ) ) == false );
|
||||
REQUIRE( cfg.filters()[0].shouldInclude( fakeTestCase( "test1" ) ) );
|
||||
}
|
||||
SECTION( "-t/exclude:1", "Specify one test case exclusion using -t exclude:" ) {
|
||||
const char* argv[] = { "test", "-t", "exclude:test1" };
|
||||
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||
|
||||
REQUIRE( config.filters.size() == 1 );
|
||||
REQUIRE( config.filters[0].shouldInclude( fakeTestCase( "test1" ) ) == false );
|
||||
REQUIRE( config.filters[0].shouldInclude( fakeTestCase( "alwaysIncluded" ) ) );
|
||||
Catch::Config cfg( config );
|
||||
REQUIRE( cfg.filters().size() == 1 );
|
||||
REQUIRE( cfg.filters()[0].shouldInclude( fakeTestCase( "test1" ) ) == false );
|
||||
REQUIRE( cfg.filters()[0].shouldInclude( fakeTestCase( "alwaysIncluded" ) ) );
|
||||
}
|
||||
|
||||
SECTION( "--test/1", "Specify one test case using --test" ) {
|
||||
const char* argv[] = { "test", "--test", "test1" };
|
||||
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||
|
||||
REQUIRE( config.filters.size() == 1 );
|
||||
REQUIRE( config.filters[0].shouldInclude( fakeTestCase( "notIncluded" ) ) == false );
|
||||
REQUIRE( config.filters[0].shouldInclude( fakeTestCase( "test1" ) ) );
|
||||
Catch::Config cfg( config );
|
||||
REQUIRE( cfg.filters().size() == 1 );
|
||||
REQUIRE( cfg.filters()[0].shouldInclude( fakeTestCase( "notIncluded" ) ) == false );
|
||||
REQUIRE( cfg.filters()[0].shouldInclude( fakeTestCase( "test1" ) ) );
|
||||
}
|
||||
|
||||
SECTION( "--test/exclude:1", "Specify one test case exclusion using --test exclude:" ) {
|
||||
const char* argv[] = { "test", "--test", "exclude:test1" };
|
||||
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||
|
||||
REQUIRE( config.filters.size() == 1 );
|
||||
REQUIRE( config.filters[0].shouldInclude( fakeTestCase( "test1" ) ) == false );
|
||||
REQUIRE( config.filters[0].shouldInclude( fakeTestCase( "alwaysIncluded" ) ) );
|
||||
Catch::Config cfg( config );
|
||||
REQUIRE( cfg.filters().size() == 1 );
|
||||
REQUIRE( cfg.filters()[0].shouldInclude( fakeTestCase( "test1" ) ) == false );
|
||||
REQUIRE( cfg.filters()[0].shouldInclude( fakeTestCase( "alwaysIncluded" ) ) );
|
||||
}
|
||||
|
||||
SECTION( "--test/exclude:2", "Specify one test case exclusion using --test ~" ) {
|
||||
const char* argv[] = { "test", "--test", "~test1" };
|
||||
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||
|
||||
REQUIRE( config.filters.size() == 1 );
|
||||
REQUIRE( config.filters[0].shouldInclude( fakeTestCase( "test1" ) ) == false );
|
||||
REQUIRE( config.filters[0].shouldInclude( fakeTestCase( "alwaysIncluded" ) ) );
|
||||
Catch::Config cfg( config );
|
||||
REQUIRE( cfg.filters().size() == 1 );
|
||||
REQUIRE( cfg.filters()[0].shouldInclude( fakeTestCase( "test1" ) ) == false );
|
||||
REQUIRE( cfg.filters()[0].shouldInclude( fakeTestCase( "alwaysIncluded" ) ) );
|
||||
}
|
||||
|
||||
SECTION( "-t/2", "Specify two test cases using -t" ) {
|
||||
const char* argv[] = { "test", "-t", "test1", "test2" };
|
||||
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||
|
||||
REQUIRE( config.filters.size() == 1 );
|
||||
REQUIRE( config.filters[0].shouldInclude( fakeTestCase( "notIncluded" ) ) == false );
|
||||
REQUIRE( config.filters[0].shouldInclude( fakeTestCase( "test1" ) ) );
|
||||
REQUIRE( config.filters[0].shouldInclude( fakeTestCase( "test2" ) ) );
|
||||
Catch::Config cfg( config );
|
||||
REQUIRE( cfg.filters().size() == 1 );
|
||||
REQUIRE( cfg.filters()[0].shouldInclude( fakeTestCase( "notIncluded" ) ) == false );
|
||||
REQUIRE( cfg.filters()[0].shouldInclude( fakeTestCase( "test1" ) ) );
|
||||
REQUIRE( cfg.filters()[0].shouldInclude( fakeTestCase( "test2" ) ) );
|
||||
}
|
||||
|
||||
SECTION( "-t/0", "When no test names are supplied it is an error" ) {
|
||||
@ -351,9 +357,10 @@ TEST_CASE( "selftest/option parsers", "" )
|
||||
|
||||
CHECK_NOTHROW( opt.parseIntoConfig( parser, config ) );
|
||||
|
||||
REQUIRE( config.filters.size() == 1 );
|
||||
REQUIRE( config.filters[0].shouldInclude( fakeTestCase( "notIncluded" ) ) == false );
|
||||
REQUIRE( config.filters[0].shouldInclude( fakeTestCase( "test1" ) ) );
|
||||
Catch::Config cfg( config );
|
||||
REQUIRE( cfg.filters().size() == 1 );
|
||||
REQUIRE( cfg.filters()[0].shouldInclude( fakeTestCase( "notIncluded" ) ) == false );
|
||||
REQUIRE( cfg.filters()[0].shouldInclude( fakeTestCase( "test1" ) ) );
|
||||
}
|
||||
|
||||
TEST_CASE( "selftest/tags", "" ) {
|
||||
|
Loading…
Reference in New Issue
Block a user