mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-23 05:46:11 +01:00
Removed legacy reporter support
This commit is contained in:
parent
de348b9bdd
commit
602b62f037
@ -142,7 +142,6 @@ LeakDetector leakDetector;
|
|||||||
#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" )
|
#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" )
|
||||||
|
|
||||||
#define CATCH_REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
|
#define CATCH_REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
|
||||||
#define CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType )
|
|
||||||
|
|
||||||
#define CATCH_GENERATE( expr) INTERNAL_CATCH_GENERATE( expr )
|
#define CATCH_GENERATE( expr) INTERNAL_CATCH_GENERATE( expr )
|
||||||
|
|
||||||
@ -209,7 +208,6 @@ LeakDetector leakDetector;
|
|||||||
#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" )
|
#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" )
|
||||||
|
|
||||||
#define REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
|
#define REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
|
||||||
#define REGISTER_LEGACY_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType )
|
|
||||||
|
|
||||||
#define GENERATE( expr) INTERNAL_CATCH_GENERATE( expr )
|
#define GENERATE( expr) INTERNAL_CATCH_GENERATE( expr )
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
#include "catch_test_spec.hpp"
|
#include "catch_test_spec.hpp"
|
||||||
#include "catch_version.hpp"
|
#include "catch_version.hpp"
|
||||||
#include "catch_message.hpp"
|
#include "catch_message.hpp"
|
||||||
#include "catch_legacy_reporter_adapter.hpp"
|
|
||||||
#include "catch_timer.hpp"
|
#include "catch_timer.hpp"
|
||||||
#include "catch_common.hpp"
|
#include "catch_common.hpp"
|
||||||
#include "catch_section.hpp"
|
#include "catch_section.hpp"
|
||||||
@ -62,7 +61,6 @@ namespace Catch {
|
|||||||
IMutableRegistryHub::~IMutableRegistryHub() {}
|
IMutableRegistryHub::~IMutableRegistryHub() {}
|
||||||
IExceptionTranslator::~IExceptionTranslator() {}
|
IExceptionTranslator::~IExceptionTranslator() {}
|
||||||
IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() {}
|
IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() {}
|
||||||
IReporter::~IReporter() {}
|
|
||||||
IReporterFactory::~IReporterFactory() {}
|
IReporterFactory::~IReporterFactory() {}
|
||||||
IReporterRegistry::~IReporterRegistry() {}
|
IReporterRegistry::~IReporterRegistry() {}
|
||||||
IStreamingReporter::~IStreamingReporter() {}
|
IStreamingReporter::~IStreamingReporter() {}
|
||||||
|
@ -1,60 +0,0 @@
|
|||||||
/*
|
|
||||||
* Created by Phil on 6th April 2013.
|
|
||||||
* Copyright 2013 Two Blue Cubes Ltd. All rights reserved.
|
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
*/
|
|
||||||
#ifndef TWOBLUECUBES_CATCH_LEGACY_REPORTER_ADAPTER_H_INCLUDED
|
|
||||||
#define TWOBLUECUBES_CATCH_LEGACY_REPORTER_ADAPTER_H_INCLUDED
|
|
||||||
|
|
||||||
#include "catch_interfaces_reporter.h"
|
|
||||||
|
|
||||||
namespace Catch
|
|
||||||
{
|
|
||||||
// Deprecated
|
|
||||||
struct IReporter : IShared {
|
|
||||||
virtual ~IReporter();
|
|
||||||
|
|
||||||
virtual bool shouldRedirectStdout() const = 0;
|
|
||||||
|
|
||||||
virtual void StartTesting() = 0;
|
|
||||||
virtual void EndTesting( Totals const& totals ) = 0;
|
|
||||||
virtual void StartGroup( std::string const& groupName ) = 0;
|
|
||||||
virtual void EndGroup( std::string const& groupName, Totals const& totals ) = 0;
|
|
||||||
virtual void StartTestCase( TestCaseInfo const& testInfo ) = 0;
|
|
||||||
virtual void EndTestCase( TestCaseInfo const& testInfo, Totals const& totals, std::string const& stdOut, std::string const& stdErr ) = 0;
|
|
||||||
virtual void StartSection( std::string const& sectionName, std::string const& description ) = 0;
|
|
||||||
virtual void EndSection( std::string const& sectionName, Counts const& assertions ) = 0;
|
|
||||||
virtual void NoAssertionsInSection( std::string const& sectionName ) = 0;
|
|
||||||
virtual void NoAssertionsInTestCase( std::string const& testName ) = 0;
|
|
||||||
virtual void Aborted() = 0;
|
|
||||||
virtual void Result( AssertionResult const& result ) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
class LegacyReporterAdapter : public SharedImpl<IStreamingReporter>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
LegacyReporterAdapter( Ptr<IReporter> const& legacyReporter );
|
|
||||||
virtual ~LegacyReporterAdapter();
|
|
||||||
|
|
||||||
virtual ReporterPreferences getPreferences() const;
|
|
||||||
virtual void noMatchingTestCases( std::string const& );
|
|
||||||
virtual void testRunStarting( TestRunInfo const& );
|
|
||||||
virtual void testGroupStarting( GroupInfo const& groupInfo );
|
|
||||||
virtual void testCaseStarting( TestCaseInfo const& testInfo );
|
|
||||||
virtual void sectionStarting( SectionInfo const& sectionInfo );
|
|
||||||
virtual void assertionStarting( AssertionInfo const& );
|
|
||||||
virtual bool assertionEnded( AssertionStats const& assertionStats );
|
|
||||||
virtual void sectionEnded( SectionStats const& sectionStats );
|
|
||||||
virtual void testCaseEnded( TestCaseStats const& testCaseStats );
|
|
||||||
virtual void testGroupEnded( TestGroupStats const& testGroupStats );
|
|
||||||
virtual void testRunEnded( TestRunStats const& testRunStats );
|
|
||||||
virtual void skipTest( TestCaseInfo const& );
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ptr<IReporter> m_legacyReporter;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_LEGACY_REPORTER_ADAPTER_H_INCLUDED
|
|
@ -1,82 +0,0 @@
|
|||||||
/*
|
|
||||||
* Created by Phil on 6th April 2013.
|
|
||||||
* Copyright 2013 Two Blue Cubes Ltd. All rights reserved.
|
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
*/
|
|
||||||
#ifndef TWOBLUECUBES_CATCH_LEGACY_REPORTER_ADAPTER_HPP_INCLUDED
|
|
||||||
#define TWOBLUECUBES_CATCH_LEGACY_REPORTER_ADAPTER_HPP_INCLUDED
|
|
||||||
|
|
||||||
#include "catch_legacy_reporter_adapter.h"
|
|
||||||
|
|
||||||
namespace Catch
|
|
||||||
{
|
|
||||||
LegacyReporterAdapter::LegacyReporterAdapter( Ptr<IReporter> const& legacyReporter )
|
|
||||||
: m_legacyReporter( legacyReporter )
|
|
||||||
{}
|
|
||||||
LegacyReporterAdapter::~LegacyReporterAdapter() {}
|
|
||||||
|
|
||||||
ReporterPreferences LegacyReporterAdapter::getPreferences() const {
|
|
||||||
ReporterPreferences prefs;
|
|
||||||
prefs.shouldRedirectStdOut = m_legacyReporter->shouldRedirectStdout();
|
|
||||||
return prefs;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LegacyReporterAdapter::noMatchingTestCases( std::string const& ) {}
|
|
||||||
void LegacyReporterAdapter::testRunStarting( TestRunInfo const& ) {
|
|
||||||
m_legacyReporter->StartTesting();
|
|
||||||
}
|
|
||||||
void LegacyReporterAdapter::testGroupStarting( GroupInfo const& groupInfo ) {
|
|
||||||
m_legacyReporter->StartGroup( groupInfo.name );
|
|
||||||
}
|
|
||||||
void LegacyReporterAdapter::testCaseStarting( TestCaseInfo const& testInfo ) {
|
|
||||||
m_legacyReporter->StartTestCase( testInfo );
|
|
||||||
}
|
|
||||||
void LegacyReporterAdapter::sectionStarting( SectionInfo const& sectionInfo ) {
|
|
||||||
m_legacyReporter->StartSection( sectionInfo.name, sectionInfo.description );
|
|
||||||
}
|
|
||||||
void LegacyReporterAdapter::assertionStarting( AssertionInfo const& ) {
|
|
||||||
// Not on legacy interface
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LegacyReporterAdapter::assertionEnded( AssertionStats const& assertionStats ) {
|
|
||||||
if( assertionStats.assertionResult.getResultType() != ResultWas::Ok ) {
|
|
||||||
for( auto const& messageInfo : assertionStats.infoMessages ) {
|
|
||||||
if( messageInfo.type == ResultWas::Info ) {
|
|
||||||
ResultBuilder rb( messageInfo.macroName.c_str(), messageInfo.lineInfo, "", ResultDisposition::Normal );
|
|
||||||
rb << messageInfo.message;
|
|
||||||
rb.setResultType( ResultWas::Info );
|
|
||||||
AssertionResult result = rb.build();
|
|
||||||
m_legacyReporter->Result( result );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_legacyReporter->Result( assertionStats.assertionResult );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
void LegacyReporterAdapter::sectionEnded( SectionStats const& sectionStats ) {
|
|
||||||
if( sectionStats.missingAssertions )
|
|
||||||
m_legacyReporter->NoAssertionsInSection( sectionStats.sectionInfo.name );
|
|
||||||
m_legacyReporter->EndSection( sectionStats.sectionInfo.name, sectionStats.assertions );
|
|
||||||
}
|
|
||||||
void LegacyReporterAdapter::testCaseEnded( TestCaseStats const& testCaseStats ) {
|
|
||||||
m_legacyReporter->EndTestCase
|
|
||||||
( testCaseStats.testInfo,
|
|
||||||
testCaseStats.totals,
|
|
||||||
testCaseStats.stdOut,
|
|
||||||
testCaseStats.stdErr );
|
|
||||||
}
|
|
||||||
void LegacyReporterAdapter::testGroupEnded( TestGroupStats const& testGroupStats ) {
|
|
||||||
if( testGroupStats.aborting )
|
|
||||||
m_legacyReporter->Aborted();
|
|
||||||
m_legacyReporter->EndGroup( testGroupStats.groupInfo.name, testGroupStats.totals );
|
|
||||||
}
|
|
||||||
void LegacyReporterAdapter::testRunEnded( TestRunStats const& testRunStats ) {
|
|
||||||
m_legacyReporter->EndTesting( testRunStats.totals );
|
|
||||||
}
|
|
||||||
void LegacyReporterAdapter::skipTest( TestCaseInfo const& ) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_LEGACY_REPORTER_ADAPTER_H_INCLUDED
|
|
@ -9,46 +9,14 @@
|
|||||||
#define TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
|
#define TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
|
||||||
|
|
||||||
#include "catch_interfaces_registry_hub.h"
|
#include "catch_interfaces_registry_hub.h"
|
||||||
#include "catch_legacy_reporter_adapter.h"
|
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
class LegacyReporterRegistrar {
|
|
||||||
|
|
||||||
class ReporterFactory : public IReporterFactory {
|
|
||||||
virtual IStreamingReporter* create( ReporterConfig const& config ) const {
|
|
||||||
return new LegacyReporterAdapter( new T( config ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual std::string getDescription() const {
|
|
||||||
return T::getDescription();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
LegacyReporterRegistrar( std::string const& name ) {
|
|
||||||
getMutableRegistryHub().registerReporter( name, new ReporterFactory() );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class ReporterRegistrar {
|
class ReporterRegistrar {
|
||||||
|
|
||||||
class ReporterFactory : public SharedImpl<IReporterFactory> {
|
class ReporterFactory : public SharedImpl<IReporterFactory> {
|
||||||
|
|
||||||
// *** Please Note ***:
|
|
||||||
// - If you end up here looking at a compiler error because it's trying to register
|
|
||||||
// your custom reporter class be aware that the native reporter interface has changed
|
|
||||||
// to IStreamingReporter. The "legacy" interface, IReporter, is still supported via
|
|
||||||
// an adapter. Just use REGISTER_LEGACY_REPORTER to take advantage of the adapter.
|
|
||||||
// However please consider updating to the new interface as the old one is now
|
|
||||||
// deprecated and will probably be removed quite soon!
|
|
||||||
// Please contact me via github if you have any questions at all about this.
|
|
||||||
// In fact, ideally, please contact me anyway to let me know you've hit this - as I have
|
|
||||||
// no idea who is actually using custom reporters at all (possibly no-one!).
|
|
||||||
// The new interface is designed to minimise exposure to interface changes in the future.
|
|
||||||
virtual IStreamingReporter* create( ReporterConfig const& config ) const {
|
virtual IStreamingReporter* create( ReporterConfig const& config ) const {
|
||||||
return new T( config );
|
return new T( config );
|
||||||
}
|
}
|
||||||
@ -86,9 +54,6 @@ namespace Catch {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#define INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) \
|
|
||||||
namespace{ Catch::LegacyReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name ); }
|
|
||||||
|
|
||||||
#define INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) \
|
#define INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) \
|
||||||
namespace{ Catch::ReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name ); }
|
namespace{ Catch::ReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name ); }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user