mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-02 13:25:41 +02:00
Unit tests build and run (todo: projects, includes, extras)
This commit is contained in:
@@ -222,6 +222,6 @@ add_library(Catch2 STATIC
|
||||
|
||||
target_include_directories(Catch2
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${SOURCES_DIR}>
|
||||
$<BUILD_INTERFACE:${SOURCES_DIR}/..>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
)
|
||||
|
@@ -13,24 +13,24 @@
|
||||
|
||||
namespace Catch {
|
||||
|
||||
template <typename T>
|
||||
class ReporterFactory : public IReporterFactory {
|
||||
|
||||
IStreamingReporterPtr create( ReporterConfig const& config ) const override {
|
||||
return std::unique_ptr<T>( new T( config ) );
|
||||
}
|
||||
|
||||
std::string getDescription() const override {
|
||||
return T::getDescription();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename T>
|
||||
class ReporterRegistrar {
|
||||
|
||||
class ReporterFactory : public IReporterFactory {
|
||||
|
||||
IStreamingReporterPtr create( ReporterConfig const& config ) const override {
|
||||
return std::unique_ptr<T>( new T( config ) );
|
||||
}
|
||||
|
||||
std::string getDescription() const override {
|
||||
return T::getDescription();
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
explicit ReporterRegistrar( std::string const& name ) {
|
||||
getMutableRegistryHub().registerReporter( name, std::make_shared<ReporterFactory>() );
|
||||
getMutableRegistryHub().registerReporter( name, std::make_shared<ReporterFactory<T>>() );
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -6,9 +6,21 @@
|
||||
*/
|
||||
#include "catch_reporter_registry.h"
|
||||
|
||||
#include <catch2/catch_reporter_registrars.hpp>
|
||||
#include <catch2/reporters/catch_reporter_compact.h>
|
||||
#include <catch2/reporters/catch_reporter_console.h>
|
||||
#include <catch2/reporters/catch_reporter_junit.h>
|
||||
#include <catch2/reporters/catch_reporter_xml.h>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
ReporterRegistry::~ReporterRegistry() = default;
|
||||
ReporterRegistry::ReporterRegistry():
|
||||
m_factories({
|
||||
{"compact", std::make_shared<ReporterFactory<CompactReporter>>() },
|
||||
{"console", std::make_shared<ReporterFactory<ConsoleReporter>>() },
|
||||
{"junit", std::make_shared<ReporterFactory<JunitReporter>>() },
|
||||
{"xml", std::make_shared<ReporterFactory<XmlReporter>>() },
|
||||
}) {}
|
||||
|
||||
IStreamingReporterPtr ReporterRegistry::create( std::string const& name, IConfigPtr const& config ) const {
|
||||
auto it = m_factories.find( name );
|
||||
|
@@ -15,10 +15,10 @@
|
||||
namespace Catch {
|
||||
|
||||
class ReporterRegistry : public IReporterRegistry {
|
||||
|
||||
public:
|
||||
|
||||
~ReporterRegistry() override;
|
||||
ReporterRegistry();
|
||||
~ReporterRegistry() override = default;
|
||||
|
||||
IStreamingReporterPtr create( std::string const& name, IConfigPtr const& config ) const override;
|
||||
|
||||
|
@@ -7,7 +7,6 @@
|
||||
|
||||
#include "catch_reporter_compact.h"
|
||||
|
||||
#include "../catch_reporter_registrars.hpp"
|
||||
#include "../catch_console_colour.h"
|
||||
|
||||
namespace {
|
||||
@@ -288,6 +287,4 @@ private:
|
||||
|
||||
CompactReporter::~CompactReporter() {}
|
||||
|
||||
CATCH_REGISTER_REPORTER( "compact", CompactReporter )
|
||||
|
||||
} // end namespace Catch
|
||||
|
@@ -688,8 +688,6 @@ void ConsoleReporter::printTestFilters() {
|
||||
stream << Colour(Colour::BrightYellow) << "Filters: " << serializeFilters( m_config->getTestsOrTags() ) << '\n';
|
||||
}
|
||||
|
||||
CATCH_REGISTER_REPORTER("console", ConsoleReporter)
|
||||
|
||||
} // end namespace Catch
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
|
@@ -280,6 +280,4 @@ namespace Catch {
|
||||
}
|
||||
}
|
||||
|
||||
CATCH_REGISTER_REPORTER( "junit", JunitReporter )
|
||||
|
||||
} // end namespace Catch
|
||||
|
@@ -318,9 +318,6 @@ namespace Catch {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CATCH_REGISTER_REPORTER( "xml", XmlReporter )
|
||||
|
||||
} // end namespace Catch
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
|
Reference in New Issue
Block a user