Rename listening reporter to multi reporter

This commit is contained in:
Martin Hořeňovský 2022-01-04 21:48:20 +01:00
parent 244680d512
commit 103cb16696
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
6 changed files with 38 additions and 38 deletions

View File

@ -217,7 +217,7 @@ set(REPORTER_HEADERS
${SOURCES_DIR}/reporters/catch_reporter_event_listener.hpp ${SOURCES_DIR}/reporters/catch_reporter_event_listener.hpp
${SOURCES_DIR}/reporters/catch_reporter_helpers.hpp ${SOURCES_DIR}/reporters/catch_reporter_helpers.hpp
${SOURCES_DIR}/reporters/catch_reporter_junit.hpp ${SOURCES_DIR}/reporters/catch_reporter_junit.hpp
${SOURCES_DIR}/reporters/catch_reporter_listening.hpp ${SOURCES_DIR}/reporters/catch_reporter_multi.hpp
${SOURCES_DIR}/reporters/catch_reporter_sonarqube.hpp ${SOURCES_DIR}/reporters/catch_reporter_sonarqube.hpp
${SOURCES_DIR}/reporters/catch_reporter_streaming_base.hpp ${SOURCES_DIR}/reporters/catch_reporter_streaming_base.hpp
${SOURCES_DIR}/reporters/catch_reporter_tap.hpp ${SOURCES_DIR}/reporters/catch_reporter_tap.hpp
@ -231,7 +231,7 @@ set(REPORTER_SOURCES
${SOURCES_DIR}/reporters/catch_reporter_console.cpp ${SOURCES_DIR}/reporters/catch_reporter_console.cpp
${SOURCES_DIR}/reporters/catch_reporter_cumulative_base.cpp ${SOURCES_DIR}/reporters/catch_reporter_cumulative_base.cpp
${SOURCES_DIR}/reporters/catch_reporter_junit.cpp ${SOURCES_DIR}/reporters/catch_reporter_junit.cpp
${SOURCES_DIR}/reporters/catch_reporter_listening.cpp ${SOURCES_DIR}/reporters/catch_reporter_multi.cpp
${SOURCES_DIR}/reporters/catch_reporter_sonarqube.cpp ${SOURCES_DIR}/reporters/catch_reporter_sonarqube.cpp
${SOURCES_DIR}/reporters/catch_reporter_streaming_base.cpp ${SOURCES_DIR}/reporters/catch_reporter_streaming_base.cpp
${SOURCES_DIR}/reporters/catch_reporter_tap.cpp ${SOURCES_DIR}/reporters/catch_reporter_tap.cpp

View File

@ -19,7 +19,7 @@
#include <catch2/internal/catch_sharding.hpp> #include <catch2/internal/catch_sharding.hpp>
#include <catch2/internal/catch_textflow.hpp> #include <catch2/internal/catch_textflow.hpp>
#include <catch2/internal/catch_windows_h_proxy.hpp> #include <catch2/internal/catch_windows_h_proxy.hpp>
#include <catch2/reporters/catch_reporter_listening.hpp> #include <catch2/reporters/catch_reporter_multi.hpp>
#include <catch2/interfaces/catch_interfaces_reporter_registry.hpp> #include <catch2/interfaces/catch_interfaces_reporter_registry.hpp>
#include <catch2/interfaces/catch_interfaces_reporter_factory.hpp> #include <catch2/interfaces/catch_interfaces_reporter_factory.hpp>
#include <catch2/internal/catch_move_and_forward.hpp> #include <catch2/internal/catch_move_and_forward.hpp>
@ -48,7 +48,7 @@ namespace Catch {
return createReporter(config->getReportersAndOutputFiles()[0].reporterName, ReporterConfig(config, stream)); return createReporter(config->getReportersAndOutputFiles()[0].reporterName, ReporterConfig(config, stream));
} }
auto multi = Detail::make_unique<ListeningReporter>(config); auto multi = Detail::make_unique<MultiReporter>(config);
auto const& listeners = Catch::getRegistryHub().getReporterRegistry().getListeners(); auto const& listeners = Catch::getRegistryHub().getReporterRegistry().getListeners();
for (auto const& listener : listeners) { for (auto const& listener : listeners) {

View File

@ -5,7 +5,7 @@
// https://www.boost.org/LICENSE_1_0.txt) // https://www.boost.org/LICENSE_1_0.txt)
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
#include <catch2/reporters/catch_reporter_listening.hpp> #include <catch2/reporters/catch_reporter_multi.hpp>
#include <catch2/catch_config.hpp> #include <catch2/catch_config.hpp>
#include <catch2/internal/catch_move_and_forward.hpp> #include <catch2/internal/catch_move_and_forward.hpp>
@ -14,20 +14,20 @@
#include <cassert> #include <cassert>
namespace Catch { namespace Catch {
void ListeningReporter::updatePreferences(IStreamingReporter const& reporterish) { void MultiReporter::updatePreferences(IStreamingReporter const& reporterish) {
m_preferences.shouldRedirectStdOut |= m_preferences.shouldRedirectStdOut |=
reporterish.getPreferences().shouldRedirectStdOut; reporterish.getPreferences().shouldRedirectStdOut;
m_preferences.shouldReportAllAssertions |= m_preferences.shouldReportAllAssertions |=
reporterish.getPreferences().shouldReportAllAssertions; reporterish.getPreferences().shouldReportAllAssertions;
} }
void ListeningReporter::addListener( IStreamingReporterPtr&& listener ) { void MultiReporter::addListener( IStreamingReporterPtr&& listener ) {
updatePreferences(*listener); updatePreferences(*listener);
m_reporterLikes.insert(m_reporterLikes.begin() + m_insertedListeners, CATCH_MOVE(listener) ); m_reporterLikes.insert(m_reporterLikes.begin() + m_insertedListeners, CATCH_MOVE(listener) );
++m_insertedListeners; ++m_insertedListeners;
} }
void ListeningReporter::addReporter( IStreamingReporterPtr&& reporter ) { void MultiReporter::addReporter( IStreamingReporterPtr&& reporter ) {
updatePreferences(*reporter); updatePreferences(*reporter);
// We will need to output the captured stdout if there are reporters // We will need to output the captured stdout if there are reporters
@ -42,80 +42,80 @@ namespace Catch {
m_reporterLikes.push_back( CATCH_MOVE( reporter ) ); m_reporterLikes.push_back( CATCH_MOVE( reporter ) );
} }
void ListeningReporter::noMatchingTestCases( StringRef unmatchedSpec ) { void MultiReporter::noMatchingTestCases( StringRef unmatchedSpec ) {
for ( auto& reporterish : m_reporterLikes ) { for ( auto& reporterish : m_reporterLikes ) {
reporterish->noMatchingTestCases( unmatchedSpec ); reporterish->noMatchingTestCases( unmatchedSpec );
} }
} }
void ListeningReporter::fatalErrorEncountered( StringRef error ) { void MultiReporter::fatalErrorEncountered( StringRef error ) {
for ( auto& reporterish : m_reporterLikes ) { for ( auto& reporterish : m_reporterLikes ) {
reporterish->fatalErrorEncountered( error ); reporterish->fatalErrorEncountered( error );
} }
} }
void ListeningReporter::reportInvalidTestSpec( StringRef arg ) { void MultiReporter::reportInvalidTestSpec( StringRef arg ) {
for ( auto& reporterish : m_reporterLikes ) { for ( auto& reporterish : m_reporterLikes ) {
reporterish->reportInvalidTestSpec( arg ); reporterish->reportInvalidTestSpec( arg );
} }
} }
void ListeningReporter::benchmarkPreparing( StringRef name ) { void MultiReporter::benchmarkPreparing( StringRef name ) {
for (auto& reporterish : m_reporterLikes) { for (auto& reporterish : m_reporterLikes) {
reporterish->benchmarkPreparing(name); reporterish->benchmarkPreparing(name);
} }
} }
void ListeningReporter::benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) { void MultiReporter::benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) {
for ( auto& reporterish : m_reporterLikes ) { for ( auto& reporterish : m_reporterLikes ) {
reporterish->benchmarkStarting( benchmarkInfo ); reporterish->benchmarkStarting( benchmarkInfo );
} }
} }
void ListeningReporter::benchmarkEnded( BenchmarkStats<> const& benchmarkStats ) { void MultiReporter::benchmarkEnded( BenchmarkStats<> const& benchmarkStats ) {
for ( auto& reporterish : m_reporterLikes ) { for ( auto& reporterish : m_reporterLikes ) {
reporterish->benchmarkEnded( benchmarkStats ); reporterish->benchmarkEnded( benchmarkStats );
} }
} }
void ListeningReporter::benchmarkFailed( StringRef error ) { void MultiReporter::benchmarkFailed( StringRef error ) {
for (auto& reporterish : m_reporterLikes) { for (auto& reporterish : m_reporterLikes) {
reporterish->benchmarkFailed(error); reporterish->benchmarkFailed(error);
} }
} }
void ListeningReporter::testRunStarting( TestRunInfo const& testRunInfo ) { void MultiReporter::testRunStarting( TestRunInfo const& testRunInfo ) {
for ( auto& reporterish : m_reporterLikes ) { for ( auto& reporterish : m_reporterLikes ) {
reporterish->testRunStarting( testRunInfo ); reporterish->testRunStarting( testRunInfo );
} }
} }
void ListeningReporter::testCaseStarting( TestCaseInfo const& testInfo ) { void MultiReporter::testCaseStarting( TestCaseInfo const& testInfo ) {
for ( auto& reporterish : m_reporterLikes ) { for ( auto& reporterish : m_reporterLikes ) {
reporterish->testCaseStarting( testInfo ); reporterish->testCaseStarting( testInfo );
} }
} }
void void
ListeningReporter::testCasePartialStarting( TestCaseInfo const& testInfo, MultiReporter::testCasePartialStarting( TestCaseInfo const& testInfo,
uint64_t partNumber ) { uint64_t partNumber ) {
for ( auto& reporterish : m_reporterLikes ) { for ( auto& reporterish : m_reporterLikes ) {
reporterish->testCasePartialStarting( testInfo, partNumber ); reporterish->testCasePartialStarting( testInfo, partNumber );
} }
} }
void ListeningReporter::sectionStarting( SectionInfo const& sectionInfo ) { void MultiReporter::sectionStarting( SectionInfo const& sectionInfo ) {
for ( auto& reporterish : m_reporterLikes ) { for ( auto& reporterish : m_reporterLikes ) {
reporterish->sectionStarting( sectionInfo ); reporterish->sectionStarting( sectionInfo );
} }
} }
void ListeningReporter::assertionStarting( AssertionInfo const& assertionInfo ) { void MultiReporter::assertionStarting( AssertionInfo const& assertionInfo ) {
for ( auto& reporterish : m_reporterLikes ) { for ( auto& reporterish : m_reporterLikes ) {
reporterish->assertionStarting( assertionInfo ); reporterish->assertionStarting( assertionInfo );
} }
} }
// The return value indicates if the messages buffer should be cleared: // The return value indicates if the messages buffer should be cleared:
void ListeningReporter::assertionEnded( AssertionStats const& assertionStats ) { void MultiReporter::assertionEnded( AssertionStats const& assertionStats ) {
const bool reportByDefault = const bool reportByDefault =
assertionStats.assertionResult.getResultType() != ResultWas::Ok || assertionStats.assertionResult.getResultType() != ResultWas::Ok ||
m_config->includeSuccessfulResults(); m_config->includeSuccessfulResults();
@ -128,13 +128,13 @@ namespace Catch {
} }
} }
void ListeningReporter::sectionEnded( SectionStats const& sectionStats ) { void MultiReporter::sectionEnded( SectionStats const& sectionStats ) {
for ( auto& reporterish : m_reporterLikes ) { for ( auto& reporterish : m_reporterLikes ) {
reporterish->sectionEnded( sectionStats ); reporterish->sectionEnded( sectionStats );
} }
} }
void ListeningReporter::testCasePartialEnded( TestCaseStats const& testStats, void MultiReporter::testCasePartialEnded( TestCaseStats const& testStats,
uint64_t partNumber ) { uint64_t partNumber ) {
if ( m_preferences.shouldRedirectStdOut && if ( m_preferences.shouldRedirectStdOut &&
m_haveNoncapturingReporters ) { m_haveNoncapturingReporters ) {
@ -151,38 +151,38 @@ namespace Catch {
} }
} }
void ListeningReporter::testCaseEnded( TestCaseStats const& testCaseStats ) { void MultiReporter::testCaseEnded( TestCaseStats const& testCaseStats ) {
for ( auto& reporterish : m_reporterLikes ) { for ( auto& reporterish : m_reporterLikes ) {
reporterish->testCaseEnded( testCaseStats ); reporterish->testCaseEnded( testCaseStats );
} }
} }
void ListeningReporter::testRunEnded( TestRunStats const& testRunStats ) { void MultiReporter::testRunEnded( TestRunStats const& testRunStats ) {
for ( auto& reporterish : m_reporterLikes ) { for ( auto& reporterish : m_reporterLikes ) {
reporterish->testRunEnded( testRunStats ); reporterish->testRunEnded( testRunStats );
} }
} }
void ListeningReporter::skipTest( TestCaseInfo const& testInfo ) { void MultiReporter::skipTest( TestCaseInfo const& testInfo ) {
for ( auto& reporterish : m_reporterLikes ) { for ( auto& reporterish : m_reporterLikes ) {
reporterish->skipTest( testInfo ); reporterish->skipTest( testInfo );
} }
} }
void ListeningReporter::listReporters(std::vector<ReporterDescription> const& descriptions) { void MultiReporter::listReporters(std::vector<ReporterDescription> const& descriptions) {
for (auto& reporterish : m_reporterLikes) { for (auto& reporterish : m_reporterLikes) {
reporterish->listReporters(descriptions); reporterish->listReporters(descriptions);
} }
} }
void ListeningReporter::listTests(std::vector<TestCaseHandle> const& tests) { void MultiReporter::listTests(std::vector<TestCaseHandle> const& tests) {
for (auto& reporterish : m_reporterLikes) { for (auto& reporterish : m_reporterLikes) {
reporterish->listTests(tests); reporterish->listTests(tests);
} }
} }
void ListeningReporter::listTags(std::vector<TagInfo> const& tags) { void MultiReporter::listTags(std::vector<TagInfo> const& tags) {
for (auto& reporterish : m_reporterLikes) { for (auto& reporterish : m_reporterLikes) {
reporterish->listTags(tags); reporterish->listTags(tags);
} }

View File

@ -5,14 +5,14 @@
// https://www.boost.org/LICENSE_1_0.txt) // https://www.boost.org/LICENSE_1_0.txt)
// SPDX-License-Identifier: BSL-1.0 // SPDX-License-Identifier: BSL-1.0
#ifndef CATCH_REPORTER_LISTENING_HPP_INCLUDED #ifndef CATCH_REPORTER_MULTI_HPP_INCLUDED
#define CATCH_REPORTER_LISTENING_HPP_INCLUDED #define CATCH_REPORTER_MULTI_HPP_INCLUDED
#include <catch2/interfaces/catch_interfaces_reporter.hpp> #include <catch2/interfaces/catch_interfaces_reporter.hpp>
namespace Catch { namespace Catch {
class ListeningReporter final : public IStreamingReporter { class MultiReporter final : public IStreamingReporter {
/* /*
* Stores all added reporters and listeners * Stores all added reporters and listeners
* *
@ -29,7 +29,7 @@ namespace Catch {
void updatePreferences(IStreamingReporter const& reporterish); void updatePreferences(IStreamingReporter const& reporterish);
public: public:
ListeningReporter( IConfig const* config ): MultiReporter( IConfig const* config ):
IStreamingReporter( config ) IStreamingReporter( config )
{} {}
@ -70,4 +70,4 @@ namespace Catch {
} // end namespace Catch } // end namespace Catch
#endif // CATCH_REPORTER_LISTENING_HPP_INCLUDED #endif // CATCH_REPORTER_MULTI_HPP_INCLUDED

View File

@ -28,7 +28,7 @@
#include <catch2/reporters/catch_reporter_event_listener.hpp> #include <catch2/reporters/catch_reporter_event_listener.hpp>
#include <catch2/reporters/catch_reporter_helpers.hpp> #include <catch2/reporters/catch_reporter_helpers.hpp>
#include <catch2/reporters/catch_reporter_junit.hpp> #include <catch2/reporters/catch_reporter_junit.hpp>
#include <catch2/reporters/catch_reporter_listening.hpp> #include <catch2/reporters/catch_reporter_multi.hpp>
#include <catch2/reporters/catch_reporter_registrars.hpp> #include <catch2/reporters/catch_reporter_registrars.hpp>
#include <catch2/reporters/catch_reporter_sonarqube.hpp> #include <catch2/reporters/catch_reporter_sonarqube.hpp>
#include <catch2/reporters/catch_reporter_streaming_base.hpp> #include <catch2/reporters/catch_reporter_streaming_base.hpp>

View File

@ -18,7 +18,7 @@
#include <catch2/reporters/catch_reporter_helpers.hpp> #include <catch2/reporters/catch_reporter_helpers.hpp>
#include <catch2/reporters/catch_reporter_event_listener.hpp> #include <catch2/reporters/catch_reporter_event_listener.hpp>
#include <catch2/reporters/catch_reporter_streaming_base.hpp> #include <catch2/reporters/catch_reporter_streaming_base.hpp>
#include <catch2/reporters/catch_reporter_listening.hpp> #include <catch2/reporters/catch_reporter_multi.hpp>
#include <sstream> #include <sstream>
@ -165,7 +165,7 @@ TEST_CASE("Multireporter calls reporters and listeners in correct order",
// We add reporters before listeners, to check that internally they // We add reporters before listeners, to check that internally they
// get sorted properly, and listeners are called first anyway. // get sorted properly, and listeners are called first anyway.
Catch::ListeningReporter multiReporter( &config ); Catch::MultiReporter multiReporter( &config );
std::vector<std::string> records; std::vector<std::string> records;
multiReporter.addReporter( Catch::Detail::make_unique<MockReporter>( multiReporter.addReporter( Catch::Detail::make_unique<MockReporter>(
"Goodbye", records, rep_config ) ); "Goodbye", records, rep_config ) );
@ -215,7 +215,7 @@ TEST_CASE("Multireporter updates ReporterPreferences properly",
Catch::Config config( config_data ); Catch::Config config( config_data );
std::stringstream sstream; std::stringstream sstream;
Catch::ReporterConfig rep_config( &config, sstream ); Catch::ReporterConfig rep_config( &config, sstream );
Catch::ListeningReporter multiReporter( &config ); Catch::MultiReporter multiReporter( &config );
// Post init defaults // Post init defaults
REQUIRE( multiReporter.getPreferences().shouldRedirectStdOut == false ); REQUIRE( multiReporter.getPreferences().shouldRedirectStdOut == false );