diff options
| author | Martin Hořeňovský | 2022-04-04 21:07:04 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2022-04-07 12:50:08 +0200 |
| commit | 423e1d2ebbd75bb92cb486f83f2c5800b4b9689e (patch) | |
| tree | 3cfff7f75517b1771ab43c7439ba195a77dcec31 /src/catch2/catch_session.cpp | |
| parent | 3c06bcb374aaebf91ad1d63aba655dee66cf7b91 (diff) | |
| download | catch3-423e1d2ebbd75bb92cb486f83f2c5800b4b9689e.tar.gz | |
Integrate the new reporter specs into Catch2
This means that the CLI interface now uses the new key-value oriented
reporter spec, the common reporter base creates the colour implementation
based on the reporter-specific configuration, and it also stores the
custom configuration options for each reporter instance.
Closes #339 as it allows per-reporter forcing of ansi colour codes.
Diffstat (limited to 'src/catch2/catch_session.cpp')
| -rw-r--r-- | src/catch2/catch_session.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/catch2/catch_session.cpp b/src/catch2/catch_session.cpp index 6af52685..74731cd0 100644 --- a/src/catch2/catch_session.cpp +++ b/src/catch2/catch_session.cpp @@ -41,11 +41,18 @@ namespace Catch { return reporter; } - IStreamingReporterPtr makeReporter(Config const* config) { + IStreamingReporterPtr prepareReporters(Config const* config) { if (Catch::getRegistryHub().getReporterRegistry().getListeners().empty() - && config->getReportersAndOutputFiles().size() == 1) { + && config->getReporterSpecs().size() == 1) { + auto const& spec = config->getReporterSpecs()[0]; auto stream = config->getReporterOutputStream(0); - return createReporter(config->getReportersAndOutputFiles()[0].reporterName, ReporterConfig(config, stream)); + return createReporter( + config->getReporterSpecs()[0].name(), + ReporterConfig( + config, + stream, + spec.colourMode().valueOr( config->colourMode() ), + spec.customOptions() ) ); } auto multi = Detail::make_unique<MultiReporter>(config); @@ -56,9 +63,15 @@ namespace Catch { } std::size_t reporterIdx = 0; - for (auto const& reporterAndFile : config->getReportersAndOutputFiles()) { + for (auto const& reporterSpec : config->getReporterSpecs()) { auto stream = config->getReporterOutputStream(reporterIdx); - multi->addReporter(createReporter(reporterAndFile.reporterName, ReporterConfig(config, stream))); + multi->addReporter( createReporter( + reporterSpec.name(), + ReporterConfig( config, + stream, + reporterSpec.colourMode().valueOr( + config->colourMode() ), + reporterSpec.customOptions() ) ) ); reporterIdx++; } @@ -304,7 +317,7 @@ namespace Catch { getCurrentMutableContext().setConfig(m_config.get()); // Create reporter(s) so we can route listings through them - auto reporter = makeReporter(m_config.get()); + auto reporter = prepareReporters(m_config.get()); auto const& invalidSpecs = m_config->testSpec().getInvalidSpecs(); if ( !invalidSpecs.empty() ) { |