Split catch_reporter_bases.hpp into two separate headers

Each of the two reporter bases now has its own header file, and
cpp file. Even though this adds another TU to the compilation,
the total CPU time taken by compilation is reduced by about 1%
for debug build and ~0.5% for optimized build of the main library.
(The improvement would be roughly doubles without splitting the TUs,
but the maintainability hit is not worth it.)

The code size of the static library build has also somewhat decreased.

Follow up: Introduce combined TU for reporters, and further split
apart the catch_reporter_streaming_base.hpp header into its
constituent parts, as it still contains a whole bunch of other stuff.
This commit is contained in:
Martin Hořeňovský 2020-08-22 23:16:23 +02:00
parent 24559493bf
commit ed7eaf2df3
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
18 changed files with 289 additions and 278 deletions

View File

@ -6,7 +6,7 @@
// 3. Test cases // 3. Test cases
#include <catch2/catch_test_macros.hpp> #include <catch2/catch_test_macros.hpp>
#include <catch2/reporters/catch_reporter_bases.hpp> #include <catch2/reporters/catch_reporter_streaming_base.hpp>
#include <catch2/catch_reporter_registrars.hpp> #include <catch2/catch_reporter_registrars.hpp>
#include <catch2/catch_test_case_info.hpp> #include <catch2/catch_test_case_info.hpp>
#include <iostream> #include <iostream>

View File

@ -193,24 +193,26 @@ set(INTERNAL_FILES ${IMPL_SOURCES} ${INTERNAL_HEADERS})
set(REPORTER_HEADERS set(REPORTER_HEADERS
${SOURCES_DIR}/reporters/catch_reporters_all.hpp ${SOURCES_DIR}/reporters/catch_reporters_all.hpp
${SOURCES_DIR}/reporters/catch_reporter_automake.hpp ${SOURCES_DIR}/reporters/catch_reporter_automake.hpp
${SOURCES_DIR}/reporters/catch_reporter_bases.hpp
${SOURCES_DIR}/reporters/catch_reporter_compact.hpp ${SOURCES_DIR}/reporters/catch_reporter_compact.hpp
${SOURCES_DIR}/reporters/catch_reporter_console.hpp ${SOURCES_DIR}/reporters/catch_reporter_console.hpp
${SOURCES_DIR}/reporters/catch_reporter_cumulative_base.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_listening.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_tap.hpp ${SOURCES_DIR}/reporters/catch_reporter_tap.hpp
${SOURCES_DIR}/reporters/catch_reporter_teamcity.hpp ${SOURCES_DIR}/reporters/catch_reporter_teamcity.hpp
${SOURCES_DIR}/reporters/catch_reporter_xml.hpp ${SOURCES_DIR}/reporters/catch_reporter_xml.hpp
) )
set(REPORTER_SOURCES set(REPORTER_SOURCES
${SOURCES_DIR}/reporters/catch_reporter_automake.cpp ${SOURCES_DIR}/reporters/catch_reporter_automake.cpp
${SOURCES_DIR}/reporters/catch_reporter_bases.cpp
${SOURCES_DIR}/reporters/catch_reporter_compact.cpp ${SOURCES_DIR}/reporters/catch_reporter_compact.cpp
${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_junit.cpp ${SOURCES_DIR}/reporters/catch_reporter_junit.cpp
${SOURCES_DIR}/reporters/catch_reporter_listening.cpp ${SOURCES_DIR}/reporters/catch_reporter_listening.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_tap.cpp ${SOURCES_DIR}/reporters/catch_reporter_tap.cpp
${SOURCES_DIR}/reporters/catch_reporter_teamcity.cpp ${SOURCES_DIR}/reporters/catch_reporter_teamcity.cpp
${SOURCES_DIR}/reporters/catch_reporter_xml.cpp ${SOURCES_DIR}/reporters/catch_reporter_xml.cpp

View File

@ -5,7 +5,7 @@
#ifndef TWOBLUECUBES_CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED #ifndef TWOBLUECUBES_CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED #define TWOBLUECUBES_CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED
#include <catch2/reporters/catch_reporter_bases.hpp> #include <catch2/reporters/catch_reporter_streaming_base.hpp>
namespace Catch { namespace Catch {

View File

@ -1,169 +0,0 @@
/*
* Created by Phil on 27/11/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_REPORTER_BASES_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
#include <iosfwd>
#include <memory>
#include <string>
#include <vector>
namespace Catch {
// Returns double formatted as %.3f (format expected on output)
std::string getFormattedDuration( double duration );
//! Should the reporter show
bool shouldShowDuration( IConfig const& config, double duration );
std::string serializeFilters( std::vector<std::string> const& container );
struct StreamingReporterBase : IStreamingReporter {
StreamingReporterBase( ReporterConfig const& _config ):
m_config( _config.fullConfig() ), stream( _config.stream() ) {
}
~StreamingReporterBase() override;
void noMatchingTestCases(std::string const&) override {}
void reportInvalidArguments(std::string const&) override {}
void testRunStarting(TestRunInfo const& _testRunInfo) override {
currentTestRunInfo = _testRunInfo;
}
void testGroupStarting(GroupInfo const& _groupInfo) override {
currentGroupInfo = _groupInfo;
}
void testCaseStarting(TestCaseInfo const& _testInfo) override {
currentTestCaseInfo = &_testInfo;
}
void sectionStarting(SectionInfo const& _sectionInfo) override {
m_sectionStack.push_back(_sectionInfo);
}
void sectionEnded(SectionStats const& /* _sectionStats */) override {
m_sectionStack.pop_back();
}
void testCaseEnded(TestCaseStats const& /* _testCaseStats */) override {
currentTestCaseInfo = nullptr;
}
void testGroupEnded( TestGroupStats const& ) override;
void testRunEnded( TestRunStats const& /* _testRunStats */ ) override;
void skipTest(TestCaseInfo const&) override {
// Don't do anything with this by default.
// It can optionally be overridden in the derived class.
}
IConfig const* m_config;
std::ostream& stream;
LazyStat<TestRunInfo> currentTestRunInfo;
LazyStat<GroupInfo> currentGroupInfo;
TestCaseInfo const* currentTestCaseInfo = nullptr;
std::vector<SectionInfo> m_sectionStack;
};
struct CumulativeReporterBase : IStreamingReporter {
template<typename T, typename ChildNodeT>
struct Node {
explicit Node( T const& _value ) : value( _value ) {}
virtual ~Node() {}
using ChildNodes = std::vector<std::shared_ptr<ChildNodeT>>;
T value;
ChildNodes children;
};
struct SectionNode {
explicit SectionNode(SectionStats const& _stats) : stats(_stats) {}
bool operator == (SectionNode const& other) const {
return stats.sectionInfo.lineInfo == other.stats.sectionInfo.lineInfo;
}
SectionStats stats;
using ChildSections = std::vector<std::shared_ptr<SectionNode>>;
using Assertions = std::vector<AssertionStats>;
ChildSections childSections;
Assertions assertions;
std::string stdOut;
std::string stdErr;
};
using TestCaseNode = Node<TestCaseStats, SectionNode>;
using TestGroupNode = Node<TestGroupStats, TestCaseNode>;
using TestRunNode = Node<TestRunStats, TestGroupNode>;
CumulativeReporterBase( ReporterConfig const& _config ):
m_config( _config.fullConfig() ), stream( _config.stream() ) {}
~CumulativeReporterBase() override;
void testRunStarting( TestRunInfo const& ) override {}
void testGroupStarting( GroupInfo const& ) override {}
void testCaseStarting( TestCaseInfo const& ) override {}
void sectionStarting( SectionInfo const& sectionInfo ) override;
void assertionStarting( AssertionInfo const& ) override {}
bool assertionEnded( AssertionStats const& assertionStats ) 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;
virtual void testRunEndedCumulative() = 0;
void skipTest(TestCaseInfo const&) override {}
IConfig const* m_config;
std::ostream& stream;
std::vector<AssertionStats> m_assertions;
std::vector<std::vector<std::shared_ptr<SectionNode>>> m_sections;
std::vector<std::shared_ptr<TestCaseNode>> m_testCases;
std::vector<std::shared_ptr<TestGroupNode>> m_testGroups;
std::vector<std::shared_ptr<TestRunNode>> m_testRuns;
std::shared_ptr<SectionNode> m_rootSection;
std::shared_ptr<SectionNode> m_deepestSection;
std::vector<std::shared_ptr<SectionNode>> m_sectionStack;
};
struct lineOfChars {
char c;
constexpr lineOfChars(char c):
c(c)
{}
friend std::ostream& operator<< (std::ostream& out, lineOfChars value);
};
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 // TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED

View File

@ -9,7 +9,7 @@
#define TWOBLUECUBES_CATCH_REPORTER_COMPACT_H_INCLUDED #define TWOBLUECUBES_CATCH_REPORTER_COMPACT_H_INCLUDED
#include <catch2/reporters/catch_reporter_bases.hpp> #include <catch2/reporters/catch_reporter_streaming_base.hpp>
namespace Catch { namespace Catch {

View File

@ -8,7 +8,7 @@
#ifndef TWOBLUECUBES_CATCH_REPORTER_CONSOLE_H_INCLUDED #ifndef TWOBLUECUBES_CATCH_REPORTER_CONSOLE_H_INCLUDED
#define TWOBLUECUBES_CATCH_REPORTER_CONSOLE_H_INCLUDED #define TWOBLUECUBES_CATCH_REPORTER_CONSOLE_H_INCLUDED
#include <catch2/reporters/catch_reporter_bases.hpp> #include <catch2/reporters/catch_reporter_streaming_base.hpp>
#include <catch2/internal/catch_unique_ptr.hpp> #include <catch2/internal/catch_unique_ptr.hpp>
#if defined(_MSC_VER) #if defined(_MSC_VER)

View File

@ -1,23 +1,6 @@
/* #include <catch2/reporters/catch_reporter_cumulative_base.hpp>
* Created by Phil on 27/11/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)
*/
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
#include <catch2/internal/catch_console_width.hpp>
#include <catch2/internal/catch_errno_guard.hpp>
#include <catch2/reporters/catch_reporter_bases.hpp>
#include <catch2/internal/catch_stream.hpp>
#include <catch2/interfaces/catch_interfaces_config.hpp>
#include <algorithm> #include <algorithm>
#include <cstring>
#include <cfloat>
#include <cstdio>
#include <ostream>
#include <cassert> #include <cassert>
namespace Catch { namespace Catch {
@ -44,74 +27,6 @@ namespace Catch {
} }
} // namespace } // namespace
// Because formatting using c++ streams is stateful, drop down to C is required
// Alternatively we could use stringstream, but its performance is... not good.
std::string getFormattedDuration( double duration ) {
// Max exponent + 1 is required to represent the whole part
// + 1 for decimal point
// + 3 for the 3 decimal places
// + 1 for null terminator
const std::size_t maxDoubleSize = DBL_MAX_10_EXP + 1 + 1 + 3 + 1;
char buffer[maxDoubleSize];
// Save previous errno, to prevent sprintf from overwriting it
ErrnoGuard guard;
#ifdef _MSC_VER
sprintf_s(buffer, "%.3f", duration);
#else
std::sprintf(buffer, "%.3f", duration);
#endif
return std::string(buffer);
}
bool shouldShowDuration( IConfig const& config, double duration ) {
if ( config.showDurations() == ShowDurations::Always ) {
return true;
}
if ( config.showDurations() == ShowDurations::Never ) {
return false;
}
const double min = config.minDuration();
return min >= 0 && duration >= min;
}
std::string serializeFilters( std::vector<std::string> const& container ) {
ReusableStringStream oss;
bool first = true;
for (auto&& filter : container)
{
if (!first)
oss << ' ';
else
first = false;
oss << filter;
}
return oss.str();
}
TestEventListenerBase::TestEventListenerBase(ReporterConfig const & _config)
:StreamingReporterBase(_config) {}
void TestEventListenerBase::assertionStarting(AssertionInfo const &) {}
bool TestEventListenerBase::assertionEnded(AssertionStats const &) {
return false;
}
StreamingReporterBase::~StreamingReporterBase() = default;
void StreamingReporterBase::testGroupEnded( TestGroupStats const& ) {
currentGroupInfo.reset();
}
void StreamingReporterBase::testRunEnded( TestRunStats const& ) {
currentTestCaseInfo = nullptr;
currentGroupInfo.reset();
currentTestRunInfo.reset();
}
CumulativeReporterBase::~CumulativeReporterBase() = default; CumulativeReporterBase::~CumulativeReporterBase() = default;
@ -189,12 +104,4 @@ namespace Catch {
testRunEndedCumulative(); testRunEndedCumulative();
} }
std::ostream& operator<<(std::ostream& out, lineOfChars value) {
for (size_t idx = 0; idx < CATCH_CONFIG_CONSOLE_WIDTH - 1; ++idx) {
out.put(value.c);
}
return out;
}
} // end namespace Catch } // end namespace Catch

View File

@ -0,0 +1,82 @@
#ifndef CATCH_REPORTER_CUMULATIVE_BASE_HPP_INCLUDED
#define CATCH_REPORTER_CUMULATIVE_BASE_HPP_INCLUDED
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
#include <iosfwd>
#include <memory>
#include <string>
#include <vector>
namespace Catch {
struct CumulativeReporterBase : IStreamingReporter {
template<typename T, typename ChildNodeT>
struct Node {
explicit Node( T const& _value ) : value( _value ) {}
virtual ~Node() {}
using ChildNodes = std::vector<std::shared_ptr<ChildNodeT>>;
T value;
ChildNodes children;
};
struct SectionNode {
explicit SectionNode(SectionStats const& _stats) : stats(_stats) {}
bool operator == (SectionNode const& other) const {
return stats.sectionInfo.lineInfo == other.stats.sectionInfo.lineInfo;
}
SectionStats stats;
using ChildSections = std::vector<std::shared_ptr<SectionNode>>;
using Assertions = std::vector<AssertionStats>;
ChildSections childSections;
Assertions assertions;
std::string stdOut;
std::string stdErr;
};
using TestCaseNode = Node<TestCaseStats, SectionNode>;
using TestGroupNode = Node<TestGroupStats, TestCaseNode>;
using TestRunNode = Node<TestRunStats, TestGroupNode>;
CumulativeReporterBase( ReporterConfig const& _config ):
m_config( _config.fullConfig() ), stream( _config.stream() ) {}
~CumulativeReporterBase() override;
void testRunStarting( TestRunInfo const& ) override {}
void testGroupStarting( GroupInfo const& ) override {}
void testCaseStarting( TestCaseInfo const& ) override {}
void sectionStarting( SectionInfo const& sectionInfo ) override;
void assertionStarting( AssertionInfo const& ) override {}
bool assertionEnded( AssertionStats const& assertionStats ) 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;
virtual void testRunEndedCumulative() = 0;
void skipTest(TestCaseInfo const&) override {}
IConfig const* m_config;
std::ostream& stream;
std::vector<AssertionStats> m_assertions;
std::vector<std::vector<std::shared_ptr<SectionNode>>> m_sections;
std::vector<std::shared_ptr<TestCaseNode>> m_testCases;
std::vector<std::shared_ptr<TestGroupNode>> m_testGroups;
std::vector<std::shared_ptr<TestRunNode>> m_testRuns;
std::shared_ptr<SectionNode> m_rootSection;
std::shared_ptr<SectionNode> m_deepestSection;
std::vector<std::shared_ptr<SectionNode>> m_sectionStack;
};
} // end namespace Catch
#endif // CATCH_REPORTER_CUMULATIVE_BASE_HPP_INCLUDED

View File

@ -6,10 +6,9 @@
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/ */
#include <catch2/reporters/catch_reporter_bases.hpp>
#include <catch2/reporters/catch_reporter_junit.hpp> #include <catch2/reporters/catch_reporter_junit.hpp>
#include <catch2/reporters/catch_reporter_streaming_base.hpp>
#include <catch2/catch_tostring.hpp> #include <catch2/catch_tostring.hpp>
#include <catch2/internal/catch_string_manip.hpp> #include <catch2/internal/catch_string_manip.hpp>
#include <catch2/internal/catch_textflow.hpp> #include <catch2/internal/catch_textflow.hpp>

View File

@ -8,7 +8,7 @@
#define TWOBLUECUBES_CATCH_REPORTER_JUNIT_H_INCLUDED #define TWOBLUECUBES_CATCH_REPORTER_JUNIT_H_INCLUDED
#include <catch2/reporters/catch_reporter_bases.hpp> #include <catch2/reporters/catch_reporter_cumulative_base.hpp>
#include <catch2/internal/catch_xmlwriter.hpp> #include <catch2/internal/catch_xmlwriter.hpp>
#include <catch2/catch_timer.hpp> #include <catch2/catch_timer.hpp>

View File

@ -5,7 +5,7 @@
#ifndef CATCH_REPORTER_SONARQUBE_HPP_INCLUDED #ifndef CATCH_REPORTER_SONARQUBE_HPP_INCLUDED
#define CATCH_REPORTER_SONARQUBE_HPP_INCLUDED #define CATCH_REPORTER_SONARQUBE_HPP_INCLUDED
#include <catch2/reporters/catch_reporter_bases.hpp> #include <catch2/reporters/catch_reporter_cumulative_base.hpp>
#include <catch2/internal/catch_xmlwriter.hpp> #include <catch2/internal/catch_xmlwriter.hpp>

View File

@ -0,0 +1,99 @@
#include <catch2/reporters/catch_reporter_streaming_base.hpp>
#include <catch2/internal/catch_console_width.hpp>
#include <catch2/internal/catch_errno_guard.hpp>
#include <catch2/internal/catch_stream.hpp>
#include <catch2/interfaces/catch_interfaces_config.hpp>
#include <cfloat>
#include <cstdio>
#include <ostream>
namespace Catch {
// Because formatting using c++ streams is stateful, drop down to C is
// required Alternatively we could use stringstream, but its performance
// is... not good.
std::string getFormattedDuration( double duration ) {
// Max exponent + 1 is required to represent the whole part
// + 1 for decimal point
// + 3 for the 3 decimal places
// + 1 for null terminator
const std::size_t maxDoubleSize = DBL_MAX_10_EXP + 1 + 1 + 3 + 1;
char buffer[maxDoubleSize];
// Save previous errno, to prevent sprintf from overwriting it
ErrnoGuard guard;
#ifdef _MSC_VER
sprintf_s( buffer, "%.3f", duration );
#else
std::sprintf( buffer, "%.3f", duration );
#endif
return std::string( buffer );
}
bool shouldShowDuration( IConfig const& config, double duration ) {
if ( config.showDurations() == ShowDurations::Always ) {
return true;
}
if ( config.showDurations() == ShowDurations::Never ) {
return false;
}
const double min = config.minDuration();
return min >= 0 && duration >= min;
}
std::string serializeFilters( std::vector<std::string> const& container ) {
ReusableStringStream oss;
bool first = true;
for ( auto&& filter : container ) {
if ( !first )
oss << ' ';
else
first = false;
oss << filter;
}
return oss.str();
}
TestEventListenerBase::TestEventListenerBase(
ReporterConfig const& _config ):
StreamingReporterBase( _config ) {}
void TestEventListenerBase::assertionStarting( AssertionInfo const& ) {}
bool TestEventListenerBase::assertionEnded( AssertionStats const& ) {
return false;
}
StreamingReporterBase::~StreamingReporterBase() = default;
void
StreamingReporterBase::testRunStarting( TestRunInfo const& _testRunInfo ) {
currentTestRunInfo = _testRunInfo;
}
void
StreamingReporterBase::testGroupStarting( GroupInfo const& _groupInfo ) {
currentGroupInfo = _groupInfo;
}
void StreamingReporterBase::testGroupEnded( TestGroupStats const& ) {
currentGroupInfo.reset();
}
void StreamingReporterBase::testRunEnded( TestRunStats const& ) {
currentTestCaseInfo = nullptr;
currentGroupInfo.reset();
currentTestRunInfo.reset();
}
std::ostream& operator<<( std::ostream& out, lineOfChars value ) {
for ( size_t idx = 0; idx < CATCH_CONFIG_CONSOLE_WIDTH - 1; ++idx ) {
out.put( value.c );
}
return out;
}
} // end namespace Catch

View File

@ -0,0 +1,90 @@
#ifndef CATCH_REPORTER_STREAMING_BASE_HPP_INCLUDED
#define CATCH_REPORTER_STREAMING_BASE_HPP_INCLUDED
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
#include <iosfwd>
#include <string>
#include <vector>
namespace Catch {
// Returns double formatted as %.3f (format expected on output)
std::string getFormattedDuration( double duration );
//! Should the reporter show
bool shouldShowDuration( IConfig const& config, double duration );
std::string serializeFilters( std::vector<std::string> const& container );
struct StreamingReporterBase : IStreamingReporter {
StreamingReporterBase( ReporterConfig const& _config ):
m_config( _config.fullConfig() ), stream( _config.stream() ) {
}
~StreamingReporterBase() override;
void noMatchingTestCases(std::string const&) override {}
void reportInvalidArguments(std::string const&) override {}
void testRunStarting( TestRunInfo const& _testRunInfo ) override;
void testGroupStarting( GroupInfo const& _groupInfo ) override;
void testCaseStarting(TestCaseInfo const& _testInfo) override {
currentTestCaseInfo = &_testInfo;
}
void sectionStarting(SectionInfo const& _sectionInfo) override {
m_sectionStack.push_back(_sectionInfo);
}
void sectionEnded(SectionStats const& /* _sectionStats */) override {
m_sectionStack.pop_back();
}
void testCaseEnded(TestCaseStats const& /* _testCaseStats */) override {
currentTestCaseInfo = nullptr;
}
void testGroupEnded( TestGroupStats const& ) override;
void testRunEnded( TestRunStats const& /* _testRunStats */ ) override;
void skipTest(TestCaseInfo const&) override {
// Don't do anything with this by default.
// It can optionally be overridden in the derived class.
}
IConfig const* m_config;
std::ostream& stream;
LazyStat<TestRunInfo> currentTestRunInfo;
LazyStat<GroupInfo> currentGroupInfo;
TestCaseInfo const* currentTestCaseInfo = nullptr;
std::vector<SectionInfo> m_sectionStack;
};
struct lineOfChars {
char c;
constexpr lineOfChars(char c):
c(c)
{}
friend std::ostream& operator<< (std::ostream& out, lineOfChars value);
};
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

View File

@ -5,7 +5,7 @@
#ifndef TWOBLUECUBES_CATCH_REPORTER_TAP_HPP_INCLUDED #ifndef TWOBLUECUBES_CATCH_REPORTER_TAP_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_REPORTER_TAP_HPP_INCLUDED #define TWOBLUECUBES_CATCH_REPORTER_TAP_HPP_INCLUDED
#include <catch2/reporters/catch_reporter_bases.hpp> #include <catch2/reporters/catch_reporter_streaming_base.hpp>
namespace Catch { namespace Catch {

View File

@ -5,8 +5,8 @@
#ifndef TWOBLUECUBES_CATCH_REPORTER_TEAMCITY_HPP_INCLUDED #ifndef TWOBLUECUBES_CATCH_REPORTER_TEAMCITY_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_REPORTER_TEAMCITY_HPP_INCLUDED #define TWOBLUECUBES_CATCH_REPORTER_TEAMCITY_HPP_INCLUDED
#include <catch2/reporters/catch_reporter_streaming_base.hpp>
#include <catch2/catch_timer.hpp> #include <catch2/catch_timer.hpp>
#include <catch2/reporters/catch_reporter_bases.hpp>
#include <cstring> #include <cstring>

View File

@ -7,7 +7,7 @@
#ifndef TWOBLUECUBES_CATCH_REPORTER_XML_H_INCLUDED #ifndef TWOBLUECUBES_CATCH_REPORTER_XML_H_INCLUDED
#define TWOBLUECUBES_CATCH_REPORTER_XML_H_INCLUDED #define TWOBLUECUBES_CATCH_REPORTER_XML_H_INCLUDED
#include <catch2/reporters/catch_reporter_bases.hpp> #include <catch2/reporters/catch_reporter_streaming_base.hpp>
#include <catch2/internal/catch_xmlwriter.hpp> #include <catch2/internal/catch_xmlwriter.hpp>
#include <catch2/catch_timer.hpp> #include <catch2/catch_timer.hpp>

View File

@ -15,12 +15,13 @@
#define CATCH_REPORTERS_ALL_HPP_INCLUDED #define CATCH_REPORTERS_ALL_HPP_INCLUDED
#include <catch2/reporters/catch_reporter_automake.hpp> #include <catch2/reporters/catch_reporter_automake.hpp>
#include <catch2/reporters/catch_reporter_bases.hpp>
#include <catch2/reporters/catch_reporter_compact.hpp> #include <catch2/reporters/catch_reporter_compact.hpp>
#include <catch2/reporters/catch_reporter_console.hpp> #include <catch2/reporters/catch_reporter_console.hpp>
#include <catch2/reporters/catch_reporter_cumulative_base.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_listening.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_tap.hpp> #include <catch2/reporters/catch_reporter_tap.hpp>
#include <catch2/reporters/catch_reporter_teamcity.hpp> #include <catch2/reporters/catch_reporter_teamcity.hpp>
#include <catch2/reporters/catch_reporter_xml.hpp> #include <catch2/reporters/catch_reporter_xml.hpp>

View File

@ -15,7 +15,7 @@ CATCH_REGISTER_TAG_ALIAS( "[@tricky]", "[tricky]~[.]" )
# pragma clang diagnostic ignored "-Wc++98-compat" # pragma clang diagnostic ignored "-Wc++98-compat"
#endif #endif
#include <catch2/reporters/catch_reporter_bases.hpp> #include <catch2/reporters/catch_reporter_streaming_base.hpp>
struct TestListener : Catch::TestEventListenerBase { struct TestListener : Catch::TestEventListenerBase {
using TestEventListenerBase::TestEventListenerBase; using TestEventListenerBase::TestEventListenerBase;