This commit is contained in:
Phil Nash 2013-11-26 20:57:45 +00:00
parent 782c2b5891
commit 5ecb72b9bb
3 changed files with 69 additions and 18 deletions

View File

@ -1,6 +1,6 @@
![catch logo](catch-logo-small.png) ![catch logo](catch-logo-small.png)
*v1.0 build 13 (master branch)* *v1.0 build 14 (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)

View File

@ -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, 13, "master" ); Version libraryVersion( 1, 0, 14, "master" );
} }
#endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED #endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED

View File

@ -1,6 +1,6 @@
/* /*
* CATCH v1.0 build 13 (master branch) * CATCH v1.0 build 14 (master branch)
* Generated: 2013-11-13 08:10:05.836093 * Generated: 2013-11-26 20:54:38.067005
* ---------------------------------------------------------- * ----------------------------------------------------------
* 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.
@ -2125,6 +2125,7 @@ namespace Catch {
: listTests( false ), : listTests( false ),
listTags( false ), listTags( false ),
listReporters( false ), listReporters( false ),
listTestNamesOnly( false ),
showSuccessfulTests( false ), showSuccessfulTests( false ),
shouldDebugBreak( false ), shouldDebugBreak( false ),
noThrow( false ), noThrow( false ),
@ -2138,6 +2139,7 @@ namespace Catch {
bool listTests; bool listTests;
bool listTags; bool listTags;
bool listReporters; bool listReporters;
bool listTestNamesOnly;
bool showSuccessfulTests; bool showSuccessfulTests;
bool shouldDebugBreak; bool shouldDebugBreak;
@ -2206,6 +2208,7 @@ namespace Catch {
} }
bool listTests() const { return m_data.listTests; } bool listTests() const { return m_data.listTests; }
bool listTestNamesOnly() const { return m_data.listTestNamesOnly; }
bool listTags() const { return m_data.listTags; } bool listTags() const { return m_data.listTags; }
bool listReporters() const { return m_data.listReporters; } bool listReporters() const { return m_data.listReporters; }
@ -4128,6 +4131,13 @@ namespace Clara {
int position; int position;
}; };
// NOTE: std::auto_ptr is deprecated in c++11/c++0x
#if defined(__cplusplus) && __cplusplus > 199711L
typedef std::unique_ptr<Arg> ArgAutoPtr;
#else
typedef std::auto_ptr<Arg> ArgAutoPtr;
#endif
class ArgBinder { class ArgBinder {
public: public:
template<typename F> template<typename F>
@ -4152,7 +4162,7 @@ namespace Clara {
else if( m_arg.isAnyPositional() ) { else if( m_arg.isAnyPositional() ) {
if( m_cl->m_arg.get() ) if( m_cl->m_arg.get() )
throw std::logic_error( "Only one unpositional argument can be added" ); throw std::logic_error( "Only one unpositional argument can be added" );
m_cl->m_arg = std::auto_ptr<Arg>( new Arg( m_arg ) ); m_cl->m_arg = ArgAutoPtr( new Arg( m_arg ) );
} }
else else
m_cl->m_options.push_back( m_arg ); m_cl->m_options.push_back( m_arg );
@ -4196,7 +4206,7 @@ namespace Clara {
m_highestSpecifiedArgPosition( other.m_highestSpecifiedArgPosition ) m_highestSpecifiedArgPosition( other.m_highestSpecifiedArgPosition )
{ {
if( other.m_arg.get() ) if( other.m_arg.get() )
m_arg = std::auto_ptr<Arg>( new Arg( *other.m_arg ) ); m_arg = ArgAutoPtr( new Arg( *other.m_arg ) );
} }
template<typename F> template<typename F>
@ -4366,12 +4376,14 @@ namespace Clara {
Detail::BoundArgFunction<ConfigT> m_boundProcessName; Detail::BoundArgFunction<ConfigT> m_boundProcessName;
std::vector<Arg> m_options; std::vector<Arg> m_options;
std::map<int, Arg> m_positionalArgs; std::map<int, Arg> m_positionalArgs;
std::auto_ptr<Arg> m_arg; ArgAutoPtr m_arg;
int m_highestSpecifiedArgPosition; int m_highestSpecifiedArgPosition;
}; };
} // end namespace Clara } // end namespace Clara
#include <fstream>
namespace Catch { namespace Catch {
inline void abortAfterFirst( ConfigData& config ) { config.abortAfter = 1; } inline void abortAfterFirst( ConfigData& config ) { config.abortAfter = 1; }
@ -4398,6 +4410,18 @@ namespace Catch {
? ShowDurations::Always ? ShowDurations::Always
: ShowDurations::Never; : ShowDurations::Never;
} }
inline void loadTestNamesFromFile( ConfigData& config, std::string const& _filename ) {
std::ifstream f( _filename.c_str() );
if( !f.is_open() )
throw std::domain_error( "Unable to load input file: " + _filename );
std::string line;
while( std::getline( f, line ) ) {
line = trim(line);
if( !line.empty() && !startsWith( line, "#" ) )
addTestOrTags( config, line );
}
}
inline Clara::CommandLine<ConfigData> makeCommandLineParser() { inline Clara::CommandLine<ConfigData> makeCommandLineParser() {
@ -4412,19 +4436,15 @@ namespace Catch {
.longOpt( "help" ); .longOpt( "help" );
cli.bind( &ConfigData::listTests ) cli.bind( &ConfigData::listTests )
.describe( "list all (or matching) test cases" ) .describe( "list all/matching test cases" )
.shortOpt( "l") .shortOpt( "l")
.longOpt( "list-tests" ); .longOpt( "list-tests" );
cli.bind( &ConfigData::listTags ) cli.bind( &ConfigData::listTags )
.describe( "list all (or matching) tags" ) .describe( "list all/matching tags" )
.shortOpt( "t") .shortOpt( "t")
.longOpt( "list-tags" ); .longOpt( "list-tags" );
cli.bind( &ConfigData::listReporters )
.describe( "list all reporters" )
.longOpt( "list-reporters" );
cli.bind( &ConfigData::showSuccessfulTests ) cli.bind( &ConfigData::showSuccessfulTests )
.describe( "include successful tests in output" ) .describe( "include successful tests in output" )
.shortOpt( "s") .shortOpt( "s")
@ -4447,7 +4467,7 @@ namespace Catch {
.hint( "filename" ); .hint( "filename" );
cli.bind( &ConfigData::reporterName ) cli.bind( &ConfigData::reporterName )
.describe( "reporter to use - defaults to console" ) .describe( "reporter to use (defaults to console)" )
.shortOpt( "r") .shortOpt( "r")
.longOpt( "reporter" ) .longOpt( "reporter" )
// .hint( "name[:filename]" ); // .hint( "name[:filename]" );
@ -4492,6 +4512,21 @@ namespace Catch {
.longOpt( "durations" ) .longOpt( "durations" )
.hint( "yes/no" ); .hint( "yes/no" );
cli.bind( &loadTestNamesFromFile )
.describe( "load test names to run from a file" )
.shortOpt( "f")
.longOpt( "input-file" )
.hint( "filename" );
// Less common commands which don't have a short form
cli.bind( &ConfigData::listTestNamesOnly )
.describe( "list all/matching test cases names only" )
.longOpt( "list-test-names-only" );
cli.bind( &ConfigData::listReporters )
.describe( "list all reporters" )
.longOpt( "list-reporters" );
return cli; return cli;
} }
@ -4604,6 +4639,20 @@ namespace Catch {
return matchedTests; return matchedTests;
} }
inline std::size_t listTestsNamesOnly( Config const& config ) {
std::size_t matchedTests = 0;
std::vector<TestCase> const& allTests = getRegistryHub().getTestCaseRegistry().getAllTests();
for( std::vector<TestCase>::const_iterator it = allTests.begin(), itEnd = allTests.end();
it != itEnd;
++it )
if( matchesFilters( config.filters(), *it ) ) {
matchedTests++;
TestCaseInfo const& testCaseInfo = it->getTestCaseInfo();
std::cout << testCaseInfo.name << std::endl;
}
return matchedTests;
}
inline std::size_t listTags( Config const& config ) { inline std::size_t listTags( Config const& config ) {
if( config.filters().empty() ) if( config.filters().empty() )
std::cout << "All available tags:\n"; std::cout << "All available tags:\n";
@ -4675,6 +4724,8 @@ namespace Catch {
Option<std::size_t> listedCount; Option<std::size_t> listedCount;
if( config.listTests() ) if( config.listTests() )
listedCount = listedCount.valueOr(0) + listTests( config ); listedCount = listedCount.valueOr(0) + listTests( config );
if( config.listTestNamesOnly() )
listedCount = listedCount.valueOr(0) + listTestsNamesOnly( config );
if( config.listTags() ) if( config.listTags() )
listedCount = listedCount.valueOr(0) + listTags( config ); listedCount = listedCount.valueOr(0) + listTags( config );
if( config.listReporters() ) if( config.listReporters() )
@ -5423,8 +5474,8 @@ namespace Catch {
else { else {
TestCase const& prev = *m_functions.find( testCase ); TestCase const& prev = *m_functions.find( testCase );
std::cerr << "error: TEST_CASE( \"" << name << "\" ) already defined.\n" std::cerr << "error: TEST_CASE( \"" << name << "\" ) already defined.\n"
<< "\tFirst seen at " << SourceLineInfo( prev.getTestCaseInfo().lineInfo ) << "\n" << "\tFirst seen at " << prev.getTestCaseInfo().lineInfo << "\n"
<< "\tRedefined at " << SourceLineInfo( testCase.getTestCaseInfo().lineInfo ) << std::endl; << "\tRedefined at " << testCase.getTestCaseInfo().lineInfo << std::endl;
exit(1); exit(1);
} }
} }
@ -6209,7 +6260,7 @@ namespace Catch {
SourceLineInfo const& _lineInfo ) SourceLineInfo const& _lineInfo )
{ {
std::string desc = _descOrTags; std::string desc = _descOrTags;
bool isHidden( startsWith( _name, "./" ) ); bool isHidden( startsWith( _name, "./" ) ); // Legacy support
std::set<std::string> tags; std::set<std::string> tags;
TagExtracter( tags ).parse( desc ); TagExtracter( tags ).parse( desc );
if( tags.find( "hide" ) != tags.end() || tags.find( "." ) != tags.end() ) if( tags.find( "hide" ) != tags.end() || tags.find( "." ) != tags.end() )
@ -6317,7 +6368,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, 13, "master" ); Version libraryVersion( 1, 0, 14, "master" );
} }
// #included from: catch_text.hpp // #included from: catch_text.hpp