From b435e0d7c79f9b6cc263dfd978bf0e4478f0e8f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Thu, 10 Aug 2017 16:45:38 +0200 Subject: [PATCH] Make default reporter configurable at compile time Closes #978 --- docs/configuration.md | 6 ++++++ include/catch_session.hpp | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/configuration.md b/docs/configuration.md index 51c05ff7..6ac12c91 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -51,6 +51,12 @@ Catch does not use ```std::cout```, ```std::cerr``` and ```std::clog``` directly This can be useful on certain platforms that do not provide the standard iostreams, such as certain embedded systems. +# Default reporter + + CATCH_CONFIG_DEFAULT_REPORTER + +The default reporter (reporter used when no reporters are explicitly specified) can be overriden during compilation time by using the above macro. Note that desired value of the macro is a C string and quotes have to be escaped during compilation: `clang++ test.cpp -DCATCH_CONFIG_DEFAULT_REPORTER=\"xml\"`. + # C++ conformance toggles CATCH_CONFIG_CPP11_NULLPTR // nullptr is supported? diff --git a/include/catch_session.hpp b/include/catch_session.hpp index a24c0c2c..002f67a2 100644 --- a/include/catch_session.hpp +++ b/include/catch_session.hpp @@ -31,10 +31,14 @@ namespace Catch { return reporter; } +#if !defined(CATCH_CONFIG_DEFAULT_REPORTER) +#define CATCH_CONFIG_DEFAULT_REPORTER "console" +#endif + Ptr makeReporter( Ptr const& config ) { std::vector reporters = config->getReporterNames(); if( reporters.empty() ) - reporters.push_back( "console" ); + reporters.push_back( CATCH_CONFIG_DEFAULT_REPORTER ); Ptr reporter; for( std::vector::const_iterator it = reporters.begin(), itEnd = reporters.end();