mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 21:05:39 +02:00
Event listeners no longer take reporter config in constructor
This also required splitting out Listener factory from the reporter factory hierarchy. In return, the listener factories only need to take in `IConfig const*`, which opens up further refactorings down the road in the colour selection and implementation.
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
namespace {
|
||||
class NonCapturingListener : public Catch::EventListenerBase {
|
||||
public:
|
||||
NonCapturingListener( Catch::ReporterConfig const& config ):
|
||||
NonCapturingListener( Catch::IConfig const* config ):
|
||||
EventListenerBase( config ) {
|
||||
m_preferences.shouldRedirectStdOut = false;
|
||||
std::cerr << "X24 - NonCapturingListener initialized.\n";
|
||||
|
@@ -25,7 +25,7 @@
|
||||
namespace {
|
||||
class CapturingListener : public Catch::EventListenerBase {
|
||||
public:
|
||||
CapturingListener( Catch::ReporterConfig const& config ):
|
||||
CapturingListener( Catch::IConfig const* config ):
|
||||
EventListenerBase( config ) {
|
||||
m_preferences.shouldRedirectStdOut = true;
|
||||
std::cerr << "CapturingListener initialized\n";
|
||||
|
@@ -30,7 +30,7 @@ namespace {
|
||||
|
||||
class TestListener : public Catch::EventListenerBase {
|
||||
public:
|
||||
TestListener( Catch::ReporterConfig const& config ):
|
||||
TestListener( Catch::IConfig const* config ):
|
||||
EventListenerBase( config ) {
|
||||
std::cout << "X28 - TestListener constructed.\n";
|
||||
}
|
||||
|
@@ -143,7 +143,7 @@ namespace {
|
||||
public:
|
||||
MockListener( std::string witness,
|
||||
std::vector<std::string>& recorder,
|
||||
Catch::ReporterConfig const& config ):
|
||||
Catch::IConfig const* config ):
|
||||
EventListenerBase( config ),
|
||||
m_witness( witness ),
|
||||
m_recorder( recorder )
|
||||
@@ -187,10 +187,10 @@ TEST_CASE("Multireporter calls reporters and listeners in correct order",
|
||||
std::vector<std::string> records;
|
||||
multiReporter.addReporter( Catch::Detail::make_unique<MockReporter>(
|
||||
"Goodbye", records, rep_config ) );
|
||||
multiReporter.addListener( Catch::Detail::make_unique<MockListener>(
|
||||
"Hello", records, rep_config ) );
|
||||
multiReporter.addListener( Catch::Detail::make_unique<MockListener>(
|
||||
"world", records, rep_config ) );
|
||||
multiReporter.addListener(
|
||||
Catch::Detail::make_unique<MockListener>( "Hello", records, &config ) );
|
||||
multiReporter.addListener(
|
||||
Catch::Detail::make_unique<MockListener>( "world", records, &config ) );
|
||||
multiReporter.addReporter( Catch::Detail::make_unique<MockReporter>(
|
||||
"world", records, rep_config ) );
|
||||
multiReporter.testRunStarting( { "" } );
|
||||
@@ -206,7 +206,7 @@ namespace {
|
||||
public:
|
||||
PreferenceListener( bool redirectStdout,
|
||||
bool reportAllAssertions,
|
||||
Catch::ReporterConfig const& config ):
|
||||
Catch::IConfig const* config ):
|
||||
EventListenerBase( config ) {
|
||||
m_preferences.shouldRedirectStdOut = redirectStdout;
|
||||
m_preferences.shouldReportAllAssertions = reportAllAssertions;
|
||||
@@ -242,19 +242,19 @@ TEST_CASE("Multireporter updates ReporterPreferences properly",
|
||||
SECTION( "Adding listeners" ) {
|
||||
multiReporter.addListener(
|
||||
Catch::Detail::make_unique<PreferenceListener>(
|
||||
true, false, rep_config ) );
|
||||
true, false, &config ) );
|
||||
REQUIRE( multiReporter.getPreferences().shouldRedirectStdOut == true );
|
||||
REQUIRE( multiReporter.getPreferences().shouldReportAllAssertions == false );
|
||||
|
||||
multiReporter.addListener(
|
||||
Catch::Detail::make_unique<PreferenceListener>(
|
||||
false, true, rep_config ) );
|
||||
false, true, &config ) );
|
||||
REQUIRE( multiReporter.getPreferences().shouldRedirectStdOut == true );
|
||||
REQUIRE( multiReporter.getPreferences().shouldReportAllAssertions == true);
|
||||
|
||||
multiReporter.addListener(
|
||||
Catch::Detail::make_unique<PreferenceListener>(
|
||||
false, false, rep_config ) );
|
||||
false, false, &config ) );
|
||||
REQUIRE( multiReporter.getPreferences().shouldRedirectStdOut == true );
|
||||
REQUIRE( multiReporter.getPreferences().shouldReportAllAssertions == true );
|
||||
}
|
||||
|
@@ -48,7 +48,7 @@ class ValidatingTestListener : public Catch::EventListenerBase {
|
||||
};
|
||||
|
||||
public:
|
||||
ValidatingTestListener(Catch::ReporterConfig const& config) :
|
||||
ValidatingTestListener(Catch::IConfig const* config) :
|
||||
EventListenerBase(config) {
|
||||
m_preferences.shouldReportAllAssertions = true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user