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

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2/interfaces
diff options
context:
space:
mode:
authorMartin Hořeňovský2022-04-04 21:07:04 +0200
committerMartin Hořeňovský2022-04-07 12:50:08 +0200
commit423e1d2ebbd75bb92cb486f83f2c5800b4b9689e (patch)
tree3cfff7f75517b1771ab43c7439ba195a77dcec31 /src/catch2/interfaces
parent3c06bcb374aaebf91ad1d63aba655dee66cf7b91 (diff)
downloadcatch3-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/interfaces')
-rw-r--r--src/catch2/interfaces/catch_interfaces_reporter.cpp18
-rw-r--r--src/catch2/interfaces/catch_interfaces_reporter.hpp11
2 files changed, 26 insertions, 3 deletions
diff --git a/src/catch2/interfaces/catch_interfaces_reporter.cpp b/src/catch2/interfaces/catch_interfaces_reporter.cpp
index 5f5d274a..585d4365 100644
--- a/src/catch2/interfaces/catch_interfaces_reporter.cpp
+++ b/src/catch2/interfaces/catch_interfaces_reporter.cpp
@@ -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,
diff --git a/src/catch2/interfaces/catch_interfaces_reporter.hpp b/src/catch2/interfaces/catch_interfaces_reporter.hpp
index 53d5ae60..9c367fe9 100644
--- a/src/catch2/interfaces/catch_interfaces_reporter.hpp
+++ b/src/catch2/interfaces/catch_interfaces_reporter.hpp
@@ -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 {