diff options
| author | Martin Hořeňovský | 2020-08-24 22:52:59 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2020-08-29 19:09:54 +0200 |
| commit | 33ad1ee2ac7beaae8d6bfa661213d13cecbce196 (patch) | |
| tree | 38241cca7d27b67f4eccc6dc5284e1388cd24a91 /src/catch2 | |
| parent | f9fdc96cbfbd79397af202d9afdd3f8eb906b73b (diff) | |
| download | catch3-33ad1ee2ac7beaae8d6bfa661213d13cecbce196.tar.gz | |
Split EventListener base from streaming_base.hpp
The base was also renamed from `TestEventListenerBase` to
`EventListenerBase`, and modified to derive directly from the
reporter interface, rather than deriving from `StreamingReporterBase`.
Diffstat (limited to 'src/catch2')
5 files changed, 77 insertions, 22 deletions
diff --git a/src/catch2/reporters/catch_reporter_combined_tu.cpp b/src/catch2/reporters/catch_reporter_combined_tu.cpp index b0e1f10f..b0f8f7a0 100644 --- a/src/catch2/reporters/catch_reporter_combined_tu.cpp +++ b/src/catch2/reporters/catch_reporter_combined_tu.cpp @@ -81,4 +81,33 @@ namespace Catch { } return out; } + +} // namespace Catch + + +#include <catch2/reporters/catch_reporter_event_listener.hpp> + +namespace Catch { + void EventListenerBase::assertionStarting( AssertionInfo const& ) {} + + bool EventListenerBase::assertionEnded( AssertionStats const& ) { + return false; + } + void + EventListenerBase::listReporters( std::vector<ReporterDescription> const&, + IConfig const& ) {} + void EventListenerBase::listTests( std::vector<TestCaseHandle> const&, + IConfig const& ) {} + void EventListenerBase::listTags( std::vector<TagInfo> const&, + IConfig const& ) {} + void EventListenerBase::noMatchingTestCases( std::string const& ) {} + void EventListenerBase::testRunStarting( TestRunInfo const& ) {} + void EventListenerBase::testGroupStarting( GroupInfo const& ) {} + void EventListenerBase::testCaseStarting( TestCaseInfo const& ) {} + void EventListenerBase::sectionStarting( SectionInfo const& ) {} + void EventListenerBase::sectionEnded( SectionStats const& ) {} + void EventListenerBase::testCaseEnded( TestCaseStats const& ) {} + void EventListenerBase::testGroupEnded( TestGroupStats const& ) {} + void EventListenerBase::testRunEnded( TestRunStats const& ) {} + void EventListenerBase::skipTest( TestCaseInfo const& ) {} } // namespace Catch diff --git a/src/catch2/reporters/catch_reporter_event_listener.hpp b/src/catch2/reporters/catch_reporter_event_listener.hpp new file mode 100644 index 00000000..358b9954 --- /dev/null +++ b/src/catch2/reporters/catch_reporter_event_listener.hpp @@ -0,0 +1,47 @@ +#ifndef CATCH_REPORTER_EVENT_LISTENER_HPP_INCLUDED +#define CATCH_REPORTER_EVENT_LISTENER_HPP_INCLUDED + +#include <catch2/interfaces/catch_interfaces_reporter.hpp> + +namespace Catch { + + /** + * Base class identifying listeners. + * + * Provides default implementation for all IStreamingReporter member + * functions, so that listeners implementations can pick which + * member functions it actually cares about. + */ + class EventListenerBase : public IStreamingReporter { + IConfig const* m_config; + + public: + EventListenerBase( ReporterConfig const& config ): + m_config( config.fullConfig() ) {} + + void assertionStarting( AssertionInfo const& assertionInfo ) override; + bool assertionEnded( AssertionStats const& assertionStats ) override; + + void + listReporters( std::vector<ReporterDescription> const& descriptions, + IConfig const& config ) override; + void listTests( std::vector<TestCaseHandle> const& tests, + IConfig const& config ) override; + void listTags( std::vector<TagInfo> const& tagInfos, + IConfig const& config ) override; + + void noMatchingTestCases( std::string const& spec ) override; + void testRunStarting( TestRunInfo const& testRunInfo ) override; + void testGroupStarting( GroupInfo const& groupInfo ) override; + void testCaseStarting( TestCaseInfo const& testInfo ) override; + void sectionStarting( SectionInfo const& sectionInfo ) override; + void sectionEnded( SectionStats const& sectionStats ) override; + void testCaseEnded( TestCaseStats const& testCaseStats ) override; + void testGroupEnded( TestGroupStats const& testGroupStats ) override; + void testRunEnded( TestRunStats const& testRunStats ) override; + void skipTest( TestCaseInfo const& testInfo ) override; + }; + +} // end namespace Catch + +#endif // CATCH_REPORTER_EVENT_LISTENER_HPP_INCLUDED diff --git a/src/catch2/reporters/catch_reporter_streaming_base.cpp b/src/catch2/reporters/catch_reporter_streaming_base.cpp index 73c63746..b37820ec 100644 --- a/src/catch2/reporters/catch_reporter_streaming_base.cpp +++ b/src/catch2/reporters/catch_reporter_streaming_base.cpp @@ -2,16 +2,6 @@ namespace Catch { - TestEventListenerBase::TestEventListenerBase( - ReporterConfig const& _config ): - StreamingReporterBase( _config ) {} - - void TestEventListenerBase::assertionStarting( AssertionInfo const& ) {} - - bool TestEventListenerBase::assertionEnded( AssertionStats const& ) { - return false; - } - StreamingReporterBase::~StreamingReporterBase() = default; void diff --git a/src/catch2/reporters/catch_reporter_streaming_base.hpp b/src/catch2/reporters/catch_reporter_streaming_base.hpp index c31290cc..36e77aa6 100644 --- a/src/catch2/reporters/catch_reporter_streaming_base.hpp +++ b/src/catch2/reporters/catch_reporter_streaming_base.hpp @@ -74,18 +74,6 @@ namespace Catch { std::vector<SectionInfo> m_sectionStack; }; - struct TestEventListenerBase : StreamingReporterBase { - TestEventListenerBase( ReporterConfig const& _config ); - - void assertionStarting(AssertionInfo const&) override; - bool assertionEnded(AssertionStats const&) override; - - // Event listeners should not use the default listing impl - void listReporters(std::vector<ReporterDescription> const&, IConfig const&) override {} - void listTests(std::vector<TestCaseHandle> const&, IConfig const&) override {} - void listTags(std::vector<TagInfo> const&, IConfig const&) override {} - }; - } // end namespace Catch #endif // CATCH_REPORTER_STREAMING_BASE_HPP_INCLUDED diff --git a/src/catch2/reporters/catch_reporters_all.hpp b/src/catch2/reporters/catch_reporters_all.hpp index 5531427b..6181697f 100644 --- a/src/catch2/reporters/catch_reporters_all.hpp +++ b/src/catch2/reporters/catch_reporters_all.hpp @@ -18,6 +18,7 @@ #include <catch2/reporters/catch_reporter_compact.hpp> #include <catch2/reporters/catch_reporter_console.hpp> #include <catch2/reporters/catch_reporter_cumulative_base.hpp> +#include <catch2/reporters/catch_reporter_event_listener.hpp> #include <catch2/reporters/catch_reporter_helpers.hpp> #include <catch2/reporters/catch_reporter_junit.hpp> #include <catch2/reporters/catch_reporter_listening.hpp> |