mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Previous implementation didn't work
It relied on calling a virtual method from a base constructer
This commit is contained in:
parent
f749347523
commit
058b21e604
@ -77,10 +77,12 @@ namespace Catch {
|
||||
TestCaseStats::~TestCaseStats() {}
|
||||
TestGroupStats::~TestGroupStats() {}
|
||||
TestRunStats::~TestRunStats() {}
|
||||
CumulativeReporterBase::SectionNode::~SectionNode() {}
|
||||
CumulativeReporterBase::~CumulativeReporterBase() {}
|
||||
|
||||
StreamingReporterBase::~StreamingReporterBase() {}
|
||||
template<typename DerivedT>
|
||||
CumulativeReporterBase<DerivedT>::SectionNode::~SectionNode() {}
|
||||
template<typename DerivedT>
|
||||
CumulativeReporterBase<DerivedT>::~CumulativeReporterBase() {}
|
||||
template<typename DerivedT>
|
||||
StreamingReporterBase<DerivedT>::~StreamingReporterBase() {}
|
||||
ConsoleReporter::~ConsoleReporter() {}
|
||||
CompactReporter::~CompactReporter() {}
|
||||
IRunner::~IRunner() {}
|
||||
|
@ -208,13 +208,12 @@ namespace Catch
|
||||
struct IStreamingReporter {
|
||||
virtual ~IStreamingReporter();
|
||||
|
||||
// Implementing class must also provide the following static method:
|
||||
// Implementing class must also provide the following static methods:
|
||||
// static std::string getDescription();
|
||||
// static std::set<Verbosity> getSupportedVerbosities()
|
||||
|
||||
virtual ReporterPreferences getPreferences() const = 0;
|
||||
|
||||
virtual std::set<Verbosity> const& getSupportedVerbosities() const = 0;
|
||||
|
||||
virtual void noMatchingTestCases( std::string const& spec ) = 0;
|
||||
|
||||
virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0;
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
namespace Catch {
|
||||
|
||||
struct AutomakeReporter : StreamingReporterBase {
|
||||
struct AutomakeReporter : StreamingReporterBase<AutomakeReporter> {
|
||||
AutomakeReporter( ReporterConfig const& _config )
|
||||
: StreamingReporterBase( _config )
|
||||
{}
|
||||
|
@ -41,7 +41,7 @@ namespace Catch {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<typename DerivedT>
|
||||
struct StreamingReporterBase : IStreamingReporter {
|
||||
|
||||
StreamingReporterBase( ReporterConfig const& _config )
|
||||
@ -49,16 +49,15 @@ namespace Catch {
|
||||
stream( _config.stream() )
|
||||
{
|
||||
m_reporterPrefs.shouldRedirectStdOut = false;
|
||||
CATCH_ENFORCE( getSupportedVerbosities().count( m_config->verbosity() ), "Verbosity level not supported by this reporter" );
|
||||
CATCH_ENFORCE( DerivedT::getSupportedVerbosities().count( m_config->verbosity() ), "Verbosity level not supported by this reporter" );
|
||||
}
|
||||
|
||||
virtual ReporterPreferences getPreferences() const override {
|
||||
return m_reporterPrefs;
|
||||
}
|
||||
|
||||
virtual std::set<Verbosity> const& getSupportedVerbosities() const override {
|
||||
static std::set<Verbosity> supported{ Verbosity::Normal };
|
||||
return supported;
|
||||
static std::set<Verbosity> getSupportedVerbosities() {
|
||||
return { Verbosity::Normal };
|
||||
}
|
||||
|
||||
virtual ~StreamingReporterBase() override;
|
||||
@ -110,6 +109,7 @@ namespace Catch {
|
||||
ReporterPreferences m_reporterPrefs;
|
||||
};
|
||||
|
||||
template<typename DerivedT>
|
||||
struct CumulativeReporterBase : IStreamingReporter {
|
||||
template<typename T, typename ChildNodeT>
|
||||
struct Node {
|
||||
@ -161,7 +161,7 @@ namespace Catch {
|
||||
stream( _config.stream() )
|
||||
{
|
||||
m_reporterPrefs.shouldRedirectStdOut = false;
|
||||
CATCH_ENFORCE( getSupportedVerbosities().count( m_config->verbosity() ), "Verbosity level not supported by this reporter" );
|
||||
CATCH_ENFORCE( DerivedT::getSupportedVerbosities().count( m_config->verbosity() ), "Verbosity level not supported by this reporter" );
|
||||
}
|
||||
~CumulativeReporterBase();
|
||||
|
||||
@ -169,9 +169,8 @@ namespace Catch {
|
||||
return m_reporterPrefs;
|
||||
}
|
||||
|
||||
virtual std::set<Verbosity> const& getSupportedVerbosities() const override {
|
||||
static std::set<Verbosity> supported{ Verbosity::Normal };
|
||||
return supported;
|
||||
static std::set<Verbosity> getSupportedVerbosities() {
|
||||
return { Verbosity::Normal };
|
||||
}
|
||||
|
||||
virtual void testRunStarting( TestRunInfo const& ) override {}
|
||||
@ -189,7 +188,7 @@ namespace Catch {
|
||||
}
|
||||
else {
|
||||
SectionNode& parentNode = *m_sectionStack.back();
|
||||
SectionNode::ChildSections::const_iterator it =
|
||||
typename SectionNode::ChildSections::const_iterator it =
|
||||
std::find_if( parentNode.childSections.begin(),
|
||||
parentNode.childSections.end(),
|
||||
BySectionInfo( sectionInfo ) );
|
||||
@ -284,7 +283,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
|
||||
struct TestEventListenerBase : StreamingReporterBase {
|
||||
struct TestEventListenerBase : StreamingReporterBase<TestEventListenerBase> {
|
||||
TestEventListenerBase( ReporterConfig const& _config )
|
||||
: StreamingReporterBase( _config )
|
||||
{}
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
namespace Catch {
|
||||
|
||||
struct CompactReporter : StreamingReporterBase {
|
||||
struct CompactReporter : StreamingReporterBase<CompactReporter> {
|
||||
|
||||
using StreamingReporterBase::StreamingReporterBase;
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
namespace Catch {
|
||||
|
||||
|
||||
struct ConsoleReporter : StreamingReporterBase {
|
||||
struct ConsoleReporter : StreamingReporterBase<ConsoleReporter> {
|
||||
using StreamingReporterBase::StreamingReporterBase;
|
||||
|
||||
virtual ~ConsoleReporter() override;
|
||||
|
@ -47,7 +47,7 @@ namespace Catch {
|
||||
|
||||
}
|
||||
|
||||
class JunitReporter : public CumulativeReporterBase {
|
||||
class JunitReporter : public CumulativeReporterBase<JunitReporter> {
|
||||
public:
|
||||
JunitReporter( ReporterConfig const& _config )
|
||||
: CumulativeReporterBase( _config ),
|
||||
|
@ -15,23 +15,9 @@ namespace Catch {
|
||||
class MultipleReporters : public IStreamingReporter {
|
||||
typedef std::vector<IStreamingReporterPtr> Reporters;
|
||||
Reporters m_reporters;
|
||||
std::set<Verbosity> m_verbosities;
|
||||
|
||||
public:
|
||||
void add( IStreamingReporterPtr&& reporter ) {
|
||||
if( m_reporters.empty() ) {
|
||||
m_verbosities = reporter->getSupportedVerbosities();
|
||||
}
|
||||
else {
|
||||
for( auto it = m_verbosities.cbegin(); it != m_verbosities.cend(); ) {
|
||||
if( reporter->getSupportedVerbosities().count( *it ) == 0 ) {
|
||||
it = m_verbosities.erase(it);
|
||||
}
|
||||
else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_reporters.push_back( std::move( reporter ) );
|
||||
}
|
||||
|
||||
@ -41,8 +27,8 @@ public: // IStreamingReporter
|
||||
return m_reporters[0]->getPreferences();
|
||||
}
|
||||
|
||||
virtual std::set<Verbosity> const& getSupportedVerbosities() const override {
|
||||
return m_verbosities;
|
||||
static std::set<Verbosity> getSupportedVerbosities() {
|
||||
return { };
|
||||
}
|
||||
|
||||
virtual void noMatchingTestCases( std::string const& spec ) override {
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
namespace Catch {
|
||||
|
||||
struct TAPReporter : StreamingReporterBase {
|
||||
struct TAPReporter : StreamingReporterBase<TAPReporter> {
|
||||
|
||||
using StreamingReporterBase::StreamingReporterBase;
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
namespace Catch {
|
||||
|
||||
struct TeamCityReporter : StreamingReporterBase {
|
||||
struct TeamCityReporter : StreamingReporterBase<TeamCityReporter> {
|
||||
TeamCityReporter( ReporterConfig const& _config )
|
||||
: StreamingReporterBase( _config )
|
||||
{
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "../internal/catch_timer.h"
|
||||
|
||||
namespace Catch {
|
||||
class XmlReporter : public StreamingReporterBase {
|
||||
class XmlReporter : public StreamingReporterBase<XmlReporter> {
|
||||
public:
|
||||
XmlReporter( ReporterConfig const& _config )
|
||||
: StreamingReporterBase( _config ),
|
||||
|
Loading…
Reference in New Issue
Block a user