Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2
diff options
context:
space:
mode:
authorMartin Hořeňovský2022-02-17 20:44:27 +0100
committerMartin Hořeňovský2022-02-17 23:02:30 +0100
commitfc5552d27b57628f8faf6064ca6b305e2d3bf458 (patch)
treee1ffae9f5e92ad3eb31ad544c06b0e1e639c4d98 /src/catch2
parent7cf2f88e50f0d1de324489c31db0314188423b6d (diff)
downloadcatch3-fc5552d27b57628f8faf6064ca6b305e2d3bf458.tar.gz
Push down handling of default reporter to Config's constructor
This simplifies the handling of default reporter in console parsing, at the cost of making `Config`'s constructor responsible for more things.
Diffstat (limited to 'src/catch2')
-rw-r--r--src/catch2/catch_config.cpp15
-rw-r--r--src/catch2/catch_config.hpp10
-rw-r--r--src/catch2/internal/catch_commandline.cpp11
3 files changed, 18 insertions, 18 deletions
diff --git a/src/catch2/catch_config.cpp b/src/catch2/catch_config.cpp
index c507b1b6..e6a5b2ed 100644
--- a/src/catch2/catch_config.cpp
+++ b/src/catch2/catch_config.cpp
@@ -6,6 +6,7 @@
// SPDX-License-Identifier: BSL-1.0
#include <catch2/catch_config.hpp>
+#include <catch2/catch_user_config.hpp>
#include <catch2/internal/catch_enforce.hpp>
#include <catch2/internal/catch_stream.hpp>
#include <catch2/internal/catch_stringref.hpp>
@@ -57,6 +58,7 @@ namespace Catch {
elem = trim(elem);
}
+
TestSpecParser parser(ITagAliasRegistry::get());
if (!m_data.testsOrTags.empty()) {
m_hasTestFilters = true;
@@ -66,6 +68,19 @@ namespace Catch {
}
m_testSpec = parser.testSpec();
+
+ // Insert the default reporter if user hasn't asked for a specfic one
+ if ( m_data.reporterSpecifications.empty() ) {
+ m_data.reporterSpecifications.push_back( {
+#if defined( CATCH_CONFIG_DEFAULT_REPORTER )
+ CATCH_CONFIG_DEFAULT_REPORTER,
+#else
+ "console",
+#endif
+ {}
+ } );
+ }
+
m_reporterStreams.reserve( m_data.reporterSpecifications.size() );
for ( auto const& reporterAndFile : m_data.reporterSpecifications ) {
if ( reporterAndFile.outputFileName.none() ) {
diff --git a/src/catch2/catch_config.hpp b/src/catch2/catch_config.hpp
index 1aaa9828..a8cdc48a 100644
--- a/src/catch2/catch_config.hpp
+++ b/src/catch2/catch_config.hpp
@@ -71,15 +71,7 @@ namespace Catch {
std::string defaultOutputFilename;
std::string name;
std::string processName;
-#ifndef CATCH_CONFIG_DEFAULT_REPORTER
-#define CATCH_CONFIG_DEFAULT_REPORTER "console"
-#endif
- std::vector<ReporterAndFile> reporterSpecifications = {
- {CATCH_CONFIG_DEFAULT_REPORTER, {}}
- };
- // Internal: used as parser state
- bool _nonDefaultReporterSpecifications = false;
-#undef CATCH_CONFIG_DEFAULT_REPORTER
+ std::vector<ReporterAndFile> reporterSpecifications;
std::vector<std::string> testsOrTags;
std::vector<std::string> sectionsToRun;
diff --git a/src/catch2/internal/catch_commandline.cpp b/src/catch2/internal/catch_commandline.cpp
index dd7b9f6c..ca1af626 100644
--- a/src/catch2/internal/catch_commandline.cpp
+++ b/src/catch2/internal/catch_commandline.cpp
@@ -139,15 +139,6 @@ namespace Catch {
return ParserResult::runtimeError( "Received empty reporter spec." );
}
- IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories();
-
- // clear the default reporter
- if (!config._nonDefaultReporterSpecifications) {
- config.reporterSpecifications.clear();
- config._nonDefaultReporterSpecifications = true;
- }
-
-
// Exactly one of the reporters may be specified without an output
// file, in which case it defaults to the output specified by "-o"
// (or standard output).
@@ -176,6 +167,8 @@ namespace Catch {
fileNameSeparatorPos + separatorSize, reporterSpec.size() );
}
+ IReporterRegistry::FactoryMap const& factories =
+ getRegistryHub().getReporterRegistry().getFactories();
auto result = factories.find( reporterName );
if( result == factories.end() )