diff --git a/include/catch_runner.hpp b/include/catch_runner.hpp index 5402cd05..e431e50f 100644 --- a/include/catch_runner.hpp +++ b/include/catch_runner.hpp @@ -21,10 +21,10 @@ namespace Catch { - class Runner2 { // This will become Runner when Runner becomes Context + class Runner { public: - Runner2( Ptr const& config ) + Runner( Ptr const& config ) : m_config( config ) { openStream(); @@ -39,7 +39,8 @@ namespace Catch { filterGroups.push_back( filterGroup ); } - Runner context( m_config.get(), m_reporter ); // This Runner will be renamed Context + RunContext context( m_config.get(), m_reporter ); + Totals totals; for( std::size_t i=0; i < filterGroups.size() && !context.aborting(); ++i ) { @@ -50,7 +51,7 @@ namespace Catch { return totals; } - Totals runTestsForGroup( Runner& context, const TestCaseFilters& filterGroup ) { + Totals runTestsForGroup( RunContext& context, const TestCaseFilters& filterGroup ) { Totals totals; std::vector::const_iterator it = getRegistryHub().getTestCaseRegistry().getAllTests().begin(); std::vector::const_iterator itEnd = getRegistryHub().getTestCaseRegistry().getAllTests().end(); @@ -111,7 +112,7 @@ namespace Catch { int result = 0; try { - Runner2 runner( config ); + Runner runner( config ); // Handle list request if( list( config ) ) { @@ -144,7 +145,7 @@ namespace Catch { cli.usage( std::cout, processName ); std::cout << "\nFor more detail usage please see: https://github.com/philsquared/Catch/wiki/Command-line\n" << std::endl; } - inline Ptr processConfig( int argc, char* const argv[], ConfigData configData = ConfigData() ) { + inline Ptr processConfig( int argc, char* const argv[], ConfigData& configData ) { Clara::CommandLine cli = makeCommandLineParser(); std::vector unused = cli.parseInto( argc, argv, configData ); if( !unused.empty() ) { @@ -159,6 +160,10 @@ namespace Catch { Ptr config = new Config( configData ); return config; } + inline Ptr processConfig( int argc, char* const argv[] ) { + ConfigData configData; + return processConfig( argc, argv, configData ); + } inline int Main( int argc, char* const argv[], ConfigData configData = ConfigData() ) { @@ -167,7 +172,7 @@ namespace Catch { try { config = processConfig( argc, argv, configData ); if( config->showHelp() ) { - showHelp( argv[0] ); + showHelp( config->getProcessName() ); Catch::cleanUp(); return 0; } @@ -175,7 +180,7 @@ namespace Catch { catch( std::exception& ex ) { std::cerr << "\nError in input:\n" << " " << ex.what() << "\n\n"; - makeCommandLineParser().usage( std::cout, argv[0] ); + makeCommandLineParser().usage( std::cout, configData.processName ); Catch::cleanUp(); return (std::numeric_limits::max)(); } diff --git a/include/internal/catch_config.hpp b/include/internal/catch_config.hpp index 74089135..87e4d552 100644 --- a/include/internal/catch_config.hpp +++ b/include/internal/catch_config.hpp @@ -122,10 +122,10 @@ namespace Catch { bool listTags() const { return m_data.listTags; } bool listReporters() const { return m_data.listReporters; } - std::string getName() const { - return m_data.name; + std::string getProcessName() const { + return m_data.processName; } - + bool shouldDebugBreak() const { return m_data.shouldDebugBreak; } @@ -162,7 +162,7 @@ namespace Catch { // IConfig interface virtual bool allowThrows() const { return !m_data.noThrow; } virtual std::ostream& stream() const { return m_os; } - virtual std::string name() const { return m_data.name; } + virtual std::string name() const { return m_data.name.empty() ? m_data.processName : m_data.name; } virtual bool includeSuccessfulResults() const { return m_data.showSuccessfulTests; } virtual bool warnAboutMissingAssertions() const { return m_data.warnings & ConfigData::WarnAbout::NoAssertions; } diff --git a/include/internal/catch_runner_impl.hpp b/include/internal/catch_runner_impl.hpp index 66a57923..7058d827 100644 --- a/include/internal/catch_runner_impl.hpp +++ b/include/internal/catch_runner_impl.hpp @@ -49,14 +49,14 @@ namespace Catch { /////////////////////////////////////////////////////////////////////////// - class Runner : public IResultCapture, public IRunner { + class RunContext : public IResultCapture, public IRunner { - Runner( Runner const& ); - void operator =( Runner const& ); + RunContext( RunContext const& ); + void operator =( RunContext const& ); public: - explicit Runner( Ptr const& config, Ptr const& reporter ) + explicit RunContext( Ptr const& config, Ptr const& reporter ) : m_runInfo( config->name() ), m_context( getCurrentMutableContext() ), m_runningTest( NULL ), @@ -72,7 +72,7 @@ namespace Catch { m_reporter->testRunStarting( m_runInfo ); } - virtual ~Runner() { + virtual ~RunContext() { m_reporter->testRunEnded( TestRunStats( m_runInfo, m_totals, aborting() ) ); m_context.setRunner( m_prevRunner ); m_context.setConfig( NULL ); diff --git a/include/internal/clara.h b/include/internal/clara.h index ada6d6ce..c89c6e51 100644 --- a/include/internal/clara.h +++ b/include/internal/clara.h @@ -458,7 +458,11 @@ namespace Clara { } std::vector parseInto( int argc, char const * const * argv, ConfigT& config ) const { - m_boundProcessName.set( config, argv[0] ); + std::string processName = argv[0]; + std::size_t lastSlash = processName.find_last_of( "/\\" ); + if( lastSlash != std::string::npos ) + processName = processName.substr( lastSlash+1 ); + m_boundProcessName.set( config, processName ); std::vector tokens; Parser parser; parser.parseIntoTokens( argc, argv, tokens ); diff --git a/include/reporters/catch_reporter_console.hpp b/include/reporters/catch_reporter_console.hpp index 12640a2a..cd5cd7be 100644 --- a/include/reporters/catch_reporter_console.hpp +++ b/include/reporters/catch_reporter_console.hpp @@ -243,7 +243,7 @@ namespace Catch { stream << "\n" << getTildes() << "\n"; Colour colour( Colour::SecondaryText ); stream << testRunInfo->name - << " is a CATCH v" << libraryVersion.majorVersion << "." + << " is a Catch v" << libraryVersion.majorVersion << "." << libraryVersion.minorVersion << " b" << libraryVersion.buildNumber; if( libraryVersion.branchName != "master" ) diff --git a/projects/SelfTest/catch_self_test.cpp b/projects/SelfTest/catch_self_test.cpp index 089f8e1d..c5153d68 100644 --- a/projects/SelfTest/catch_self_test.cpp +++ b/projects/SelfTest/catch_self_test.cpp @@ -20,9 +20,9 @@ namespace Catch{ Totals totals; - // Scoped because Runner doesn't report EndTesting until its destructor + // Scoped because RunContext doesn't report EndTesting until its destructor { - Runner runner( config.get(), m_reporter.get() ); + RunContext runner( config.get(), m_reporter.get() ); totals = runner.runMatching( rawTestSpec, groupIndex, groupsCount ); } return totals;