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

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2
diff options
context:
space:
mode:
authorMartin Hořeňovský2021-09-15 21:17:28 +0200
committerMartin Hořeňovský2021-09-15 21:17:39 +0200
commit785436cd74ac629fea3bcb98343b9ff18f52598b (patch)
treeb065831b3101eedf84c96de6b887e30154c4b2ba /src/catch2
parentf314fa1f8c9576f1879fb0a8a9b038f1108599c2 (diff)
downloadcatch3-785436cd74ac629fea3bcb98343b9ff18f52598b.tar.gz
Make benchmark* and fatalError reporter events pure virtual
Diffstat (limited to 'src/catch2')
-rw-r--r--src/catch2/interfaces/catch_interfaces_reporter.cpp2
-rw-r--r--src/catch2/interfaces/catch_interfaces_reporter.hpp13
-rw-r--r--src/catch2/reporters/catch_reporter_combined_tu.cpp8
-rw-r--r--src/catch2/reporters/catch_reporter_cumulative_base.hpp5
-rw-r--r--src/catch2/reporters/catch_reporter_event_listener.hpp8
-rw-r--r--src/catch2/reporters/catch_reporter_listening.cpp7
-rw-r--r--src/catch2/reporters/catch_reporter_listening.hpp2
-rw-r--r--src/catch2/reporters/catch_reporter_streaming_base.hpp6
8 files changed, 41 insertions, 10 deletions
diff --git a/src/catch2/interfaces/catch_interfaces_reporter.cpp b/src/catch2/interfaces/catch_interfaces_reporter.cpp
index 22994309..89a86f59 100644
--- a/src/catch2/interfaces/catch_interfaces_reporter.cpp
+++ b/src/catch2/interfaces/catch_interfaces_reporter.cpp
@@ -81,6 +81,6 @@ namespace Catch {
aborting( _aborting )
{}
- void IStreamingReporter::fatalErrorEncountered( StringRef ) {}
+ IStreamingReporter::~IStreamingReporter() = default;
} // end namespace Catch
diff --git a/src/catch2/interfaces/catch_interfaces_reporter.hpp b/src/catch2/interfaces/catch_interfaces_reporter.hpp
index 75eadee7..681c8e4d 100644
--- a/src/catch2/interfaces/catch_interfaces_reporter.hpp
+++ b/src/catch2/interfaces/catch_interfaces_reporter.hpp
@@ -162,7 +162,7 @@ namespace Catch {
public:
IStreamingReporter( IConfig const* config ): m_config( config ) {}
- virtual ~IStreamingReporter() = default;
+ virtual ~IStreamingReporter(); // = default;
// Implementing class must also provide the following static methods:
// static std::string getDescription();
@@ -182,10 +182,10 @@ namespace Catch {
virtual void testCasePartialStarting( TestCaseInfo const& testInfo, uint64_t partNumber ) = 0;
virtual void sectionStarting( SectionInfo const& sectionInfo ) = 0;
- virtual void benchmarkPreparing( StringRef ) {}
- virtual void benchmarkStarting( BenchmarkInfo const& ) {}
- virtual void benchmarkEnded( BenchmarkStats<> const& ) {}
- virtual void benchmarkFailed( StringRef ) {}
+ virtual void benchmarkPreparing( StringRef benchmarkName ) = 0;
+ virtual void benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) = 0;
+ virtual void benchmarkEnded( BenchmarkStats<> const& benchmarkStats ) = 0;
+ virtual void benchmarkFailed( StringRef benchmarkName ) = 0;
virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0;
@@ -200,8 +200,7 @@ namespace Catch {
virtual void skipTest( TestCaseInfo const& testInfo ) = 0;
- // Default empty implementation provided
- virtual void fatalErrorEncountered( StringRef name );
+ virtual void fatalErrorEncountered( StringRef error ) = 0;
//! Writes out information about provided reporters using reporter-specific format
virtual void listReporters(std::vector<ReporterDescription> const& descriptions) = 0;
diff --git a/src/catch2/reporters/catch_reporter_combined_tu.cpp b/src/catch2/reporters/catch_reporter_combined_tu.cpp
index bca6ac25..2ca76c93 100644
--- a/src/catch2/reporters/catch_reporter_combined_tu.cpp
+++ b/src/catch2/reporters/catch_reporter_combined_tu.cpp
@@ -220,6 +220,14 @@ namespace Catch {
#include <catch2/reporters/catch_reporter_event_listener.hpp>
namespace Catch {
+
+ void EventListenerBase::fatalErrorEncountered( StringRef ) {}
+
+ void EventListenerBase::benchmarkPreparing( StringRef ) {}
+ void EventListenerBase::benchmarkStarting( BenchmarkInfo const& ) {}
+ void EventListenerBase::benchmarkEnded( BenchmarkStats<> const& ) {}
+ void EventListenerBase::benchmarkFailed( StringRef ) {}
+
void EventListenerBase::assertionStarting( AssertionInfo const& ) {}
void EventListenerBase::assertionEnded( AssertionStats const& ) {}
diff --git a/src/catch2/reporters/catch_reporter_cumulative_base.hpp b/src/catch2/reporters/catch_reporter_cumulative_base.hpp
index a1896e4f..a6acc54f 100644
--- a/src/catch2/reporters/catch_reporter_cumulative_base.hpp
+++ b/src/catch2/reporters/catch_reporter_cumulative_base.hpp
@@ -49,9 +49,14 @@ namespace Catch {
stream( _config.stream() ) {}
~CumulativeReporterBase() override;
+ void benchmarkPreparing( StringRef ) override {}
+ void benchmarkStarting( BenchmarkInfo const& ) override {}
+ void benchmarkEnded( BenchmarkStats<> const& ) override {}
+ void benchmarkFailed( StringRef ) override {}
void noMatchingTestCases( StringRef ) override {}
void reportInvalidArguments( StringRef ) override {}
+ void fatalErrorEncountered( StringRef /*error*/ ) override {}
void testRunStarting( TestRunInfo const& ) override {}
diff --git a/src/catch2/reporters/catch_reporter_event_listener.hpp b/src/catch2/reporters/catch_reporter_event_listener.hpp
index 333f1dfa..d2cccb6b 100644
--- a/src/catch2/reporters/catch_reporter_event_listener.hpp
+++ b/src/catch2/reporters/catch_reporter_event_listener.hpp
@@ -15,7 +15,7 @@ namespace Catch {
/**
* Base class identifying listeners.
*
- * Provides default implementation for all IStreamingReporter member
+ * Provides empty default implementation for all IStreamingReporter member
* functions, so that listeners implementations can pick which
* member functions it actually cares about.
*/
@@ -25,6 +25,12 @@ namespace Catch {
IStreamingReporter( config.fullConfig() ) {}
void reportInvalidArguments( StringRef unmatchedSpec ) override;
+ void fatalErrorEncountered( StringRef error ) override;
+
+ void benchmarkPreparing( StringRef name ) override;
+ void benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) override;
+ void benchmarkEnded( BenchmarkStats<> const& benchmarkStats ) override;
+ void benchmarkFailed( StringRef error ) override;
void assertionStarting( AssertionInfo const& assertionInfo ) override;
void assertionEnded( AssertionStats const& assertionStats ) override;
diff --git a/src/catch2/reporters/catch_reporter_listening.cpp b/src/catch2/reporters/catch_reporter_listening.cpp
index a397997f..f233b0a2 100644
--- a/src/catch2/reporters/catch_reporter_listening.cpp
+++ b/src/catch2/reporters/catch_reporter_listening.cpp
@@ -29,6 +29,13 @@ namespace Catch {
m_reporter->noMatchingTestCases( unmatchedSpec );
}
+ void ListeningReporter::fatalErrorEncountered( StringRef error ) {
+ for ( auto& listener : m_listeners ) {
+ listener->fatalErrorEncountered( error );
+ }
+ m_reporter->fatalErrorEncountered( error );
+ }
+
void ListeningReporter::reportInvalidArguments( StringRef arg ) {
for ( auto& listener : m_listeners ) {
listener->reportInvalidArguments( arg );
diff --git a/src/catch2/reporters/catch_reporter_listening.hpp b/src/catch2/reporters/catch_reporter_listening.hpp
index 3813c085..caa5c1a8 100644
--- a/src/catch2/reporters/catch_reporter_listening.hpp
+++ b/src/catch2/reporters/catch_reporter_listening.hpp
@@ -31,7 +31,7 @@ namespace Catch {
public: // IStreamingReporter
void noMatchingTestCases( StringRef unmatchedSpec ) override;
-
+ void fatalErrorEncountered( StringRef error ) override;
void reportInvalidArguments( StringRef arg ) override;
void benchmarkPreparing( StringRef name ) override;
diff --git a/src/catch2/reporters/catch_reporter_streaming_base.hpp b/src/catch2/reporters/catch_reporter_streaming_base.hpp
index 0cd8a46f..e7b6e5b3 100644
--- a/src/catch2/reporters/catch_reporter_streaming_base.hpp
+++ b/src/catch2/reporters/catch_reporter_streaming_base.hpp
@@ -42,6 +42,12 @@ namespace Catch {
~StreamingReporterBase() override;
+ void benchmarkPreparing( StringRef ) override {}
+ void benchmarkStarting( BenchmarkInfo const& ) override {}
+ void benchmarkEnded( BenchmarkStats<> const& ) override {}
+ void benchmarkFailed( StringRef ) override {}
+
+ void fatalErrorEncountered( StringRef /*error*/ ) override {}
void noMatchingTestCases( StringRef /*unmatchedSpec*/ ) override {}
void reportInvalidArguments( StringRef /*invalidArgument*/ ) override {}