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
@@ -14,17 +14,31 @@
#include <catch2/internal/catch_string_manip.hpp>
#include <catch2/catch_test_case_info.hpp>
#include <catch2/reporters/catch_reporter_helpers.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <algorithm>
#include <iomanip>
namespace Catch {
ReporterConfig::ReporterConfig( IConfig const* _fullConfig, IStream const* _stream )
: m_stream( _stream ), m_fullConfig( _fullConfig ) {}
ReporterConfig::ReporterConfig(
IConfig const* _fullConfig,
IStream const* _stream,
ColourMode colourMode,
std::map<std::string, std::string> customOptions ):
m_stream( _stream ),
m_fullConfig( _fullConfig ),
m_colourMode( colourMode ),
m_customOptions( CATCH_MOVE( customOptions ) ) {}
IStream const* ReporterConfig::stream() const { return m_stream; }
IConfig const * ReporterConfig::fullConfig() const { return m_fullConfig; }
ColourMode ReporterConfig::colourMode() const { return m_colourMode; }
std::map<std::string, std::string> const&
ReporterConfig::customOptions() const {
return m_customOptions;
}
AssertionStats::AssertionStats( AssertionResult const& _assertionResult,
std::vector<MessageInfo> const& _infoMessages,
@@ -19,6 +19,7 @@
#include <catch2/benchmark/catch_outlier_classification.hpp>
#include <map>
#include <string>
#include <vector>
#include <iosfwd>
@@ -31,16 +32,24 @@ namespace Catch {
class TestCaseHandle;
struct IConfig;
class IStream;
enum class ColourMode : std::uint8_t;
struct ReporterConfig {
ReporterConfig( IConfig const* _fullConfig, IStream const* _stream );
ReporterConfig( IConfig const* _fullConfig,
IStream const* _stream,
ColourMode colourMode,
std::map<std::string, std::string> customOptions );
IStream const* stream() const;
IConfig const* fullConfig() const;
ColourMode colourMode() const;
std::map<std::string, std::string> const& customOptions() const;
private:
IStream const* m_stream;
IConfig const* m_fullConfig;
ColourMode m_colourMode;
std::map<std::string, std::string> m_customOptions;
};
struct TestRunInfo {