mirror of
https://github.com/catchorg/Catch2.git
synced 2025-05-29 07:59:25 +00:00
First cut of tags support
This commit is contained in:
parent
dea756f699
commit
fc1baac7f5
7 changed files with 168 additions and 13 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Generated: 2012-09-09 11:44:01.394438
|
||||
* Generated: 2012-09-15 17:50:31.695760
|
||||
* ----------------------------------------------------------
|
||||
* This file has been merged from multiple headers. Please don't edit it directly
|
||||
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
|
||||
|
@ -1644,6 +1644,7 @@ using namespace Generators;
|
|||
#define TWOBLUECUBES_CATCH_TESTCASEINFO_H_INCLUDED
|
||||
|
||||
#include <string>
|
||||
#include <set>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
|
@ -1666,6 +1667,8 @@ namespace Catch {
|
|||
const std::string& getDescription() const;
|
||||
const SourceLineInfo& getLineInfo() const;
|
||||
bool isHidden() const;
|
||||
bool hasTag( const std::string& tag ) const;
|
||||
const std::set<std::string>& tags() const;
|
||||
|
||||
void swap( TestCaseInfo& other );
|
||||
bool operator == ( const TestCaseInfo& other ) const;
|
||||
|
@ -1676,7 +1679,9 @@ namespace Catch {
|
|||
Ptr<ITestCase> m_test;
|
||||
std::string m_name;
|
||||
std::string m_description;
|
||||
std::set<std::string> m_tags;
|
||||
SourceLineInfo m_lineInfo;
|
||||
bool m_isHidden;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1793,6 +1798,10 @@ namespace Catch {
|
|||
if( it == itEnd )
|
||||
return false;
|
||||
}
|
||||
else if( m_exclusionFilters.empty() ) {
|
||||
return !testCase.isHidden();
|
||||
}
|
||||
|
||||
std::vector<TestCaseFilter>::const_iterator it = m_exclusionFilters.begin();
|
||||
std::vector<TestCaseFilter>::const_iterator itEnd = m_exclusionFilters.end();
|
||||
for(; it != itEnd; ++it )
|
||||
|
@ -3697,7 +3706,6 @@ namespace Catch {
|
|||
std::vector<TestCaseFilters> filterGroups = m_config.filters;
|
||||
if( filterGroups.empty() ) {
|
||||
TestCaseFilters filterGroup( "" );
|
||||
filterGroup.addFilter( TestCaseFilter( "./*", IfFilterMatches::ExcludeTests ) );
|
||||
filterGroups.push_back( filterGroup );
|
||||
}
|
||||
|
||||
|
@ -4738,6 +4746,36 @@ namespace Catch {
|
|||
|
||||
namespace Catch {
|
||||
|
||||
namespace {
|
||||
void extractTags( std::string& str, std::set<std::string>& tags ) {
|
||||
std::string remainder;
|
||||
std::size_t last = 0;
|
||||
std::size_t begin = str.find_first_of( '[' );
|
||||
while( begin != std::string::npos ) {
|
||||
std::size_t end = str.find_first_of( ']', begin );
|
||||
if( end != std::string::npos ) {
|
||||
std::string tag = str.substr( begin+1, end-begin-1 );
|
||||
tags.insert( tag );
|
||||
if( begin - last > 0 )
|
||||
remainder += str.substr( last, begin-last );
|
||||
last = end+1;
|
||||
}
|
||||
else if( begin != str.size()-1 ) {
|
||||
end = begin+1;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
begin = str.find_first_of( '[', end );
|
||||
}
|
||||
if( !tags.empty() ) {
|
||||
if( last < str.size() )
|
||||
str = remainder + str.substr( last );
|
||||
else
|
||||
str = remainder;
|
||||
}
|
||||
}
|
||||
}
|
||||
TestCaseInfo::TestCaseInfo( ITestCase* testCase,
|
||||
const char* name,
|
||||
const char* description,
|
||||
|
@ -4745,27 +4783,37 @@ namespace Catch {
|
|||
: m_test( testCase ),
|
||||
m_name( name ),
|
||||
m_description( description ),
|
||||
m_lineInfo( lineInfo )
|
||||
{}
|
||||
m_lineInfo( lineInfo ),
|
||||
m_isHidden( startsWith( name, "./" ) )
|
||||
{
|
||||
extractTags( m_description, m_tags );
|
||||
if( hasTag( "hide" ) )
|
||||
m_isHidden = true;
|
||||
}
|
||||
|
||||
TestCaseInfo::TestCaseInfo()
|
||||
: m_test( NULL ),
|
||||
m_name(),
|
||||
m_description()
|
||||
m_description(),
|
||||
m_isHidden( false )
|
||||
{}
|
||||
|
||||
TestCaseInfo::TestCaseInfo( const TestCaseInfo& other, const std::string& name )
|
||||
: m_test( other.m_test ),
|
||||
m_name( name ),
|
||||
m_description( other.m_description ),
|
||||
m_lineInfo( other.m_lineInfo )
|
||||
m_tags( other.m_tags ),
|
||||
m_lineInfo( other.m_lineInfo ),
|
||||
m_isHidden( other.m_isHidden )
|
||||
{}
|
||||
|
||||
TestCaseInfo::TestCaseInfo( const TestCaseInfo& other )
|
||||
: m_test( other.m_test ),
|
||||
m_name( other.m_name ),
|
||||
m_description( other.m_description ),
|
||||
m_lineInfo( other.m_lineInfo )
|
||||
m_tags( other.m_tags ),
|
||||
m_lineInfo( other.m_lineInfo ),
|
||||
m_isHidden( other.m_isHidden )
|
||||
{}
|
||||
|
||||
void TestCaseInfo::invoke() const {
|
||||
|
@ -4785,7 +4833,14 @@ namespace Catch {
|
|||
}
|
||||
|
||||
bool TestCaseInfo::isHidden() const {
|
||||
return m_name.size() >= 2 && m_name[0] == '.' && m_name[1] == '/';
|
||||
return m_isHidden;
|
||||
}
|
||||
|
||||
bool TestCaseInfo::hasTag( const std::string& tag ) const {
|
||||
return m_tags.find( tag ) != m_tags.end();
|
||||
}
|
||||
const std::set<std::string>& TestCaseInfo::tags() const {
|
||||
return m_tags;
|
||||
}
|
||||
|
||||
void TestCaseInfo::swap( TestCaseInfo& other ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue