From feaf355489d80fbc786354d113a296d9f76b8b55 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Fri, 11 Aug 2017 19:55:55 +0100 Subject: [PATCH] Implemented libidentify support - see https://github.com/janwilmans/LibIdentify --- include/catch_session.hpp | 12 +++++++++++- include/internal/catch_commandline.hpp | 8 ++++++++ include/internal/catch_config.hpp | 2 ++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/catch_session.hpp b/include/catch_session.hpp index 002f67a2..1b2d956a 100644 --- a/include/catch_session.hpp +++ b/include/catch_session.hpp @@ -134,6 +134,14 @@ namespace Catch { m_cli.usage( Catch::cout(), processName ); Catch::cout() << "For more detail usage please see the project docs\n" << std::endl; } + void libIdentify( std::string const& processName ) { + Catch::cout() + << std::left << std::setw(16) << "description: " << "A Catch test executable\n" + << std::left << std::setw(16) << "category: " << "testframework\n" + << std::left << std::setw(16) << "framework: " << "Catch Test\n" + << std::left << std::setw(16) << "version: " << libraryVersion() << std::endl; + } + int applyCommandLine( int argc, char const* const* const argv, OnUnusedOptions::DoWhat unusedOptionBehaviour = OnUnusedOptions::Fail ) { try { @@ -141,6 +149,8 @@ namespace Catch { m_unusedTokens = m_cli.parseInto( Clara::argsToVector( argc, argv ), m_configData ); if( m_configData.showHelp ) showHelp( m_configData.processName ); + if( m_configData.libIdentify ) + libIdentify( m_configData.processName ); m_config.reset(); } catch( std::exception& ex ) { @@ -197,7 +207,7 @@ namespace Catch { #endif int run() { - if( m_configData.showHelp ) + if( m_configData.showHelp || m_configData.libIdentify ) return 0; try diff --git a/include/internal/catch_commandline.hpp b/include/internal/catch_commandline.hpp index 3ece92f8..2ea41a00 100644 --- a/include/internal/catch_commandline.hpp +++ b/include/internal/catch_commandline.hpp @@ -211,6 +211,14 @@ namespace Catch { .describe( "should output be colourised" ) .bind( &setUseColour, "yes|no" ); + cli["--use-colour"] + .describe( "should output be colourised" ) + .bind( &setUseColour, "yes|no" ); + + cli["--libidentify"] + .describe( "report name and version according to libidentify standard" ) + .bind( &ConfigData::libIdentify ); + return cli; } diff --git a/include/internal/catch_config.hpp b/include/internal/catch_config.hpp index b006d512..b1275e08 100644 --- a/include/internal/catch_config.hpp +++ b/include/internal/catch_config.hpp @@ -38,6 +38,7 @@ namespace Catch { showHelp( false ), showInvisibles( false ), filenamesAsTags( false ), + libIdentify( false ), abortAfter( -1 ), rngSeed( 0 ), verbosity( Verbosity::Normal ), @@ -59,6 +60,7 @@ namespace Catch { bool showHelp; bool showInvisibles; bool filenamesAsTags; + bool libIdentify; int abortAfter; unsigned int rngSeed;