mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 05:16:10 +01:00
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`.
This commit is contained in:
parent
f9fdc96cbf
commit
33ad1ee2ac
@ -114,6 +114,9 @@ new design.
|
||||
* You should instead include the appropriate headers as needed.
|
||||
* `CATCH_CONFIG_IMPL` has been removed.
|
||||
* The implementation is now compiled into a static library.
|
||||
* Event Listener interface has changed
|
||||
* `TestEventListenerBase` was renamed to `EventListenerBase`
|
||||
* `EventListenerBase` now directly derives from `IStreamingReporter`, instead of deriving from `StreamingReporterBase`
|
||||
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
// 3. Test cases
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/reporters/catch_reporter_streaming_base.hpp>
|
||||
#include <catch2/reporters/catch_reporter_event_listener.hpp>
|
||||
#include <catch2/catch_reporter_registrars.hpp>
|
||||
#include <catch2/catch_test_case_info.hpp>
|
||||
#include <iostream>
|
||||
@ -303,9 +303,9 @@ char const * dashed_line =
|
||||
"--------------------------------------------------------------------------";
|
||||
|
||||
|
||||
struct MyListener : Catch::TestEventListenerBase {
|
||||
struct MyListener : Catch::EventListenerBase {
|
||||
|
||||
using TestEventListenerBase::TestEventListenerBase; // inherit constructor
|
||||
using EventListenerBase::EventListenerBase; // inherit constructor
|
||||
|
||||
// Get rid of Wweak-tables
|
||||
~MyListener();
|
||||
|
@ -198,6 +198,7 @@ set(REPORTER_HEADERS
|
||||
${SOURCES_DIR}/reporters/catch_reporter_compact.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_console.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_cumulative_base.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_event_listener.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_helpers.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_junit.hpp
|
||||
${SOURCES_DIR}/reporters/catch_reporter_listening.hpp
|
||||
|
@ -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
|
||||
|
47
src/catch2/reporters/catch_reporter_event_listener.hpp
Normal file
47
src/catch2/reporters/catch_reporter_event_listener.hpp
Normal file
@ -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
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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>
|
||||
|
@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
#include <catch2/catch_tag_alias_autoregistrar.hpp>
|
||||
#include <catch2/reporters/catch_reporter_event_listener.hpp>
|
||||
|
||||
// Some example tag aliases
|
||||
CATCH_REGISTER_TAG_ALIAS( "[@nhf]", "[failing]~[.]" )
|
||||
@ -15,10 +16,9 @@ CATCH_REGISTER_TAG_ALIAS( "[@tricky]", "[tricky]~[.]" )
|
||||
# pragma clang diagnostic ignored "-Wc++98-compat"
|
||||
#endif
|
||||
|
||||
#include <catch2/reporters/catch_reporter_streaming_base.hpp>
|
||||
|
||||
struct TestListener : Catch::TestEventListenerBase {
|
||||
using TestEventListenerBase::TestEventListenerBase;
|
||||
struct TestListener : Catch::EventListenerBase {
|
||||
using EventListenerBase::EventListenerBase;
|
||||
};
|
||||
|
||||
#include <catch2/catch_reporter_registrars.hpp>
|
||||
|
Loading…
Reference in New Issue
Block a user