diff options
| author | Martin Hořeňovský | 2022-04-13 14:55:05 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2022-04-13 15:02:25 +0200 |
| commit | a243cbae52d5599ccce07b36cfe8b2e3308d4108 (patch) | |
| tree | 9d18094f4bbfa4eef34bac5d4ea1bbce8a2a4936 /src/catch2/catch_config.cpp | |
| parent | 79d1e8238135427a6780a6db2cdb8b9be0b7f086 (diff) | |
| download | catch3-a243cbae52d5599ccce07b36cfe8b2e3308d4108.tar.gz | |
Introduce type to handle reporter specs with defaults filled-in
Diffstat (limited to 'src/catch2/catch_config.cpp')
| -rw-r--r-- | src/catch2/catch_config.cpp | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/src/catch2/catch_config.cpp b/src/catch2/catch_config.cpp index 32d40410..79ec33f8 100644 --- a/src/catch2/catch_config.cpp +++ b/src/catch2/catch_config.cpp @@ -18,6 +18,14 @@ namespace Catch { + bool operator==( ProcessedReporterSpec const& lhs, + ProcessedReporterSpec const& rhs ) { + return lhs.name == rhs.name && + lhs.outputFilename == rhs.outputFilename && + lhs.colourMode == rhs.colourMode && + lhs.customOptions == rhs.customOptions; + } + Config::Config( ConfigData const& data ): m_data( data ) { // We need to trim filter specs to avoid trouble with superfluous @@ -80,25 +88,23 @@ namespace Catch { // We now fixup the reporter specs to handle default output spec, // default colour spec, etc bool defaultOutputUsed = false; - for ( auto& reporterSpec : m_data.reporterSpecifications ) { + for ( auto const& reporterSpec : m_data.reporterSpecifications ) { + // We do the default-output check separately, while always + // using the default output below to make the code simpler + // and avoid superfluous copies. if ( reporterSpec.outputFile().none() ) { CATCH_ENFORCE( !defaultOutputUsed, "Internal error: cannot use default output for " "multiple reporters" ); defaultOutputUsed = true; - - reporterSpec = ReporterSpec{ reporterSpec.name(), - data.defaultOutputFilename, - reporterSpec.colourMode(), - reporterSpec.customOptions() }; } - if ( reporterSpec.colourMode().none() ) { - reporterSpec = ReporterSpec{ reporterSpec.name(), - reporterSpec.outputFile(), - data.defaultColourMode, - reporterSpec.customOptions() }; - } + m_processedReporterSpecs.push_back( ProcessedReporterSpec{ + reporterSpec.name(), + reporterSpec.outputFile() ? *reporterSpec.outputFile() + : data.defaultOutputFilename, + reporterSpec.colourMode().valueOr( data.defaultColourMode ), + reporterSpec.customOptions() } ); } } @@ -116,6 +122,11 @@ namespace Catch { return m_data.reporterSpecifications; } + std::vector<ProcessedReporterSpec> const& + Config::getProcessedReporterSpecs() const { + return m_processedReporterSpecs; + } + TestSpec const& Config::testSpec() const { return m_testSpec; } bool Config::hasTestFilters() const { return m_hasTestFilters; } |