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.
This commit is contained in:
Martin Hořeňovský
2022-04-07 12:50:08 +02:00
parent 3c06bcb374
commit 423e1d2ebb
29 changed files with 395 additions and 448 deletions
+5 -16
View File
@@ -33,17 +33,6 @@ namespace Catch {
} // unnamed namespace
} // namespace Detail
std::ostream& operator<<( std::ostream& os,
ConfigData::ReporterAndFile const& reporter ) {
os << "{ " << reporter.reporterName << ", ";
if ( reporter.outputFileName ) {
os << *reporter.outputFileName;
} else {
os << "<default-output>";
}
return os << " }";
}
Config::Config( ConfigData const& data ):
m_data( data ) {
// We need to trim filter specs to avoid trouble with superfluous
@@ -76,14 +65,14 @@ namespace Catch {
#else
"console",
#endif
{}
{}, {}, {}
} );
}
bool defaultOutputUsed = false;
m_reporterStreams.reserve( m_data.reporterSpecifications.size() );
for ( auto const& reporterAndFile : m_data.reporterSpecifications ) {
if ( reporterAndFile.outputFileName.none() ) {
for ( auto const& reporterSpec : m_data.reporterSpecifications ) {
if ( reporterSpec.outputFile().none() ) {
CATCH_ENFORCE( !defaultOutputUsed,
"Internal error: cannot use default output for "
"multiple reporters" );
@@ -93,7 +82,7 @@ namespace Catch {
openStream( data.defaultOutputFilename ) );
} else {
m_reporterStreams.push_back(
openStream( *reporterAndFile.outputFileName ) );
openStream( *reporterSpec.outputFile() ) );
}
}
}
@@ -108,7 +97,7 @@ namespace Catch {
std::vector<std::string> const& Config::getTestsOrTags() const { return m_data.testsOrTags; }
std::vector<std::string> const& Config::getSectionsToRun() const { return m_data.sectionsToRun; }
std::vector<ConfigData::ReporterAndFile> const& Config::getReportersAndOutputFiles() const {
std::vector<ReporterSpec> const& Config::getReporterSpecs() const {
return m_data.reporterSpecifications;
}