mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Default included reporters are now also in .cpp files
The non-default ones remain as header files.
This commit is contained in:
parent
93f84b5b0d
commit
5f3f19de08
@ -224,15 +224,19 @@ CheckFileList(INTERNAL_FILES ${HEADER_DIR}/internal)
|
|||||||
set(REPORTER_HEADERS
|
set(REPORTER_HEADERS
|
||||||
${HEADER_DIR}/reporters/catch_reporter_automake.hpp
|
${HEADER_DIR}/reporters/catch_reporter_automake.hpp
|
||||||
${HEADER_DIR}/reporters/catch_reporter_bases.hpp
|
${HEADER_DIR}/reporters/catch_reporter_bases.hpp
|
||||||
${HEADER_DIR}/reporters/catch_reporter_compact.hpp
|
|
||||||
${HEADER_DIR}/reporters/catch_reporter_console.hpp
|
|
||||||
${HEADER_DIR}/reporters/catch_reporter_junit.hpp
|
|
||||||
${HEADER_DIR}/reporters/catch_reporter_multi.hpp
|
|
||||||
${HEADER_DIR}/reporters/catch_reporter_tap.hpp
|
${HEADER_DIR}/reporters/catch_reporter_tap.hpp
|
||||||
${HEADER_DIR}/reporters/catch_reporter_teamcity.hpp
|
${HEADER_DIR}/reporters/catch_reporter_teamcity.hpp
|
||||||
${HEADER_DIR}/reporters/catch_reporter_xml.hpp
|
|
||||||
)
|
)
|
||||||
CheckFileList(REPORTER_HEADERS ${HEADER_DIR}/reporters)
|
set(REPORTER_SOURCES
|
||||||
|
${HEADER_DIR}/reporters/catch_reporter_bases.cpp
|
||||||
|
${HEADER_DIR}/reporters/catch_reporter_compact.cpp
|
||||||
|
${HEADER_DIR}/reporters/catch_reporter_console.cpp
|
||||||
|
${HEADER_DIR}/reporters/catch_reporter_junit.cpp
|
||||||
|
${HEADER_DIR}/reporters/catch_reporter_multi.cpp
|
||||||
|
${HEADER_DIR}/reporters/catch_reporter_xml.cpp
|
||||||
|
)
|
||||||
|
set(REPORTER_FILES ${REPORTER_HEADERS} ${REPORTER_SOURCES})
|
||||||
|
CheckFileList(REPORTER_FILES ${HEADER_DIR}/reporters)
|
||||||
|
|
||||||
# Specify the headers, too, so CLion recognises them as project files
|
# Specify the headers, too, so CLion recognises them as project files
|
||||||
set(HEADERS
|
set(HEADERS
|
||||||
@ -262,8 +266,8 @@ add_definitions( -DCATCH_CONFIG_FULL_PROJECT )
|
|||||||
# Projects consuming Catch via ExternalProject_Add might want to use install step
|
# Projects consuming Catch via ExternalProject_Add might want to use install step
|
||||||
# without building all of our selftests.
|
# without building all of our selftests.
|
||||||
if (NOT NO_SELFTEST)
|
if (NOT NO_SELFTEST)
|
||||||
add_executable(SelfTest ${TEST_SOURCES} ${IMPL_SOURCES} ${SURROGATE_SOURCES} ${HEADERS})
|
add_executable(SelfTest ${TEST_SOURCES} ${IMPL_SOURCES} ${REPORTER_SOURCES} ${SURROGATE_SOURCES} ${HEADERS})
|
||||||
add_executable(Benchmark ${BENCH_SOURCES} ${IMPL_SOURCES} ${HEADERS})
|
add_executable(Benchmark ${BENCH_SOURCES} ${IMPL_SOURCES} ${REPORTER_SOURCES} ${HEADERS})
|
||||||
|
|
||||||
# Add desired warnings
|
# Add desired warnings
|
||||||
if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang|GNU" )
|
if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang|GNU" )
|
||||||
|
@ -16,6 +16,12 @@
|
|||||||
#pragma clang diagnostic ignored "-Wweak-vtables"
|
#pragma clang diagnostic ignored "-Wweak-vtables"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Temporary hack to fix separately provided reporters
|
||||||
|
#include "../reporters/catch_reporter_bases.hpp"
|
||||||
|
#include "catch_reporter_registrars.hpp"
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
#include "../catch_session.hpp"
|
#include "../catch_session.hpp"
|
||||||
#include "catch_stream.hpp"
|
#include "catch_stream.hpp"
|
||||||
#include "catch_test_spec.hpp"
|
#include "catch_test_spec.hpp"
|
||||||
@ -24,13 +30,6 @@
|
|||||||
// Cpp files will be included in the single-header file here
|
// Cpp files will be included in the single-header file here
|
||||||
// ~*~* CATCH_CPP_STITCH_PLACE *~*~
|
// ~*~* CATCH_CPP_STITCH_PLACE *~*~
|
||||||
|
|
||||||
|
|
||||||
#include "../reporters/catch_reporter_multi.hpp"
|
|
||||||
#include "../reporters/catch_reporter_xml.hpp"
|
|
||||||
#include "../reporters/catch_reporter_junit.hpp"
|
|
||||||
#include "../reporters/catch_reporter_console.hpp"
|
|
||||||
#include "../reporters/catch_reporter_compact.hpp"
|
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
// These are all here to avoid warnings about not having any out of line
|
// These are all here to avoid warnings about not having any out of line
|
||||||
// virtual methods
|
// virtual methods
|
||||||
@ -56,17 +55,10 @@ namespace Catch {
|
|||||||
TestCaseStats::~TestCaseStats() {}
|
TestCaseStats::~TestCaseStats() {}
|
||||||
TestGroupStats::~TestGroupStats() {}
|
TestGroupStats::~TestGroupStats() {}
|
||||||
TestRunStats::~TestRunStats() {}
|
TestRunStats::~TestRunStats() {}
|
||||||
CumulativeReporterBase::SectionNode::~SectionNode() {}
|
|
||||||
CumulativeReporterBase::~CumulativeReporterBase() {}
|
|
||||||
|
|
||||||
StreamingReporterBase::~StreamingReporterBase() {}
|
|
||||||
ConsoleReporter::~ConsoleReporter() {}
|
|
||||||
CompactReporter::~CompactReporter() {}
|
|
||||||
IRunner::~IRunner() {}
|
IRunner::~IRunner() {}
|
||||||
IMutableContext::~IMutableContext() {}
|
IMutableContext::~IMutableContext() {}
|
||||||
IConfig::~IConfig() {}
|
IConfig::~IConfig() {}
|
||||||
XmlReporter::~XmlReporter() {}
|
|
||||||
JunitReporter::~JunitReporter() {}
|
|
||||||
WildcardPattern::~WildcardPattern() {}
|
WildcardPattern::~WildcardPattern() {}
|
||||||
TestSpec::Pattern::~Pattern() {}
|
TestSpec::Pattern::~Pattern() {}
|
||||||
TestSpec::NamePattern::~NamePattern() {}
|
TestSpec::NamePattern::~NamePattern() {}
|
||||||
|
227
include/reporters/catch_reporter_bases.cpp
Normal file
227
include/reporters/catch_reporter_bases.cpp
Normal file
@ -0,0 +1,227 @@
|
|||||||
|
/*
|
||||||
|
* 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 "../internal/catch_interfaces_reporter.h"
|
||||||
|
#include "../internal/catch_errno_guard.h"
|
||||||
|
#include "catch_reporter_bases.hpp"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
#include <cfloat>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
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 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
|
||||||
|
sprintf(buffer, "%.3f", duration);
|
||||||
|
#endif
|
||||||
|
return std::string(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
StreamingReporterBase::StreamingReporterBase(ReporterConfig const& _config)
|
||||||
|
: m_config(_config.fullConfig()),
|
||||||
|
stream(_config.stream())
|
||||||
|
{
|
||||||
|
m_reporterPrefs.shouldRedirectStdOut = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReporterPreferences StreamingReporterBase::getPreferences() const {
|
||||||
|
return m_reporterPrefs;
|
||||||
|
}
|
||||||
|
|
||||||
|
StreamingReporterBase::~StreamingReporterBase() {}
|
||||||
|
|
||||||
|
void StreamingReporterBase::noMatchingTestCases(std::string const &) {}
|
||||||
|
|
||||||
|
void StreamingReporterBase::testRunStarting(TestRunInfo const & _testRunInfo) {
|
||||||
|
currentTestRunInfo = _testRunInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StreamingReporterBase::testGroupStarting(GroupInfo const & _groupInfo) {
|
||||||
|
currentGroupInfo = _groupInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StreamingReporterBase::testCaseStarting(TestCaseInfo const & _testInfo) {
|
||||||
|
currentTestCaseInfo = _testInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StreamingReporterBase::sectionStarting(SectionInfo const & _sectionInfo) {
|
||||||
|
m_sectionStack.push_back(_sectionInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
void StreamingReporterBase::sectionEnded(SectionStats const &) {
|
||||||
|
m_sectionStack.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
|
void StreamingReporterBase::testCaseEnded(TestCaseStats const &) {
|
||||||
|
currentTestCaseInfo.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void StreamingReporterBase::testGroupEnded(TestGroupStats const &) {
|
||||||
|
currentGroupInfo.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void StreamingReporterBase::testRunEnded(TestRunStats const &) {
|
||||||
|
currentTestCaseInfo.reset();
|
||||||
|
currentGroupInfo.reset();
|
||||||
|
currentTestRunInfo.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void StreamingReporterBase::skipTest(TestCaseInfo const &) {
|
||||||
|
// Don't do anything with this by default.
|
||||||
|
// It can optionally be overridden in the derived class.
|
||||||
|
}
|
||||||
|
|
||||||
|
CumulativeReporterBase::CumulativeReporterBase(ReporterConfig const & _config)
|
||||||
|
: m_config(_config.fullConfig()),
|
||||||
|
stream(_config.stream()) {
|
||||||
|
m_reporterPrefs.shouldRedirectStdOut = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CumulativeReporterBase::~CumulativeReporterBase() {}
|
||||||
|
|
||||||
|
ReporterPreferences CumulativeReporterBase::getPreferences() const {
|
||||||
|
return m_reporterPrefs;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CumulativeReporterBase::testRunStarting(TestRunInfo const &) {}
|
||||||
|
|
||||||
|
void CumulativeReporterBase::testGroupStarting(GroupInfo const &) {}
|
||||||
|
|
||||||
|
void CumulativeReporterBase::testCaseStarting(TestCaseInfo const &) {}
|
||||||
|
|
||||||
|
void CumulativeReporterBase::sectionStarting(SectionInfo const & sectionInfo) {
|
||||||
|
SectionStats incompleteStats(sectionInfo, Counts(), 0, false);
|
||||||
|
std::shared_ptr<SectionNode> node;
|
||||||
|
if (m_sectionStack.empty()) {
|
||||||
|
if (!m_rootSection)
|
||||||
|
m_rootSection = std::make_shared<SectionNode>(incompleteStats);
|
||||||
|
node = m_rootSection;
|
||||||
|
} else {
|
||||||
|
SectionNode& parentNode = *m_sectionStack.back();
|
||||||
|
SectionNode::ChildSections::const_iterator it =
|
||||||
|
std::find_if(parentNode.childSections.begin(),
|
||||||
|
parentNode.childSections.end(),
|
||||||
|
BySectionInfo(sectionInfo));
|
||||||
|
if (it == parentNode.childSections.end()) {
|
||||||
|
node = std::make_shared<SectionNode>(incompleteStats);
|
||||||
|
parentNode.childSections.push_back(node);
|
||||||
|
} else
|
||||||
|
node = *it;
|
||||||
|
}
|
||||||
|
m_sectionStack.push_back(node);
|
||||||
|
m_deepestSection = node;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CumulativeReporterBase::assertionStarting(AssertionInfo const &) {}
|
||||||
|
|
||||||
|
bool CumulativeReporterBase::assertionEnded(AssertionStats const & assertionStats) {
|
||||||
|
assert(!m_sectionStack.empty());
|
||||||
|
SectionNode& sectionNode = *m_sectionStack.back();
|
||||||
|
sectionNode.assertions.push_back(assertionStats);
|
||||||
|
// AssertionResult holds a pointer to a temporary DecomposedExpression,
|
||||||
|
// which getExpandedExpression() calls to build the expression string.
|
||||||
|
// Our section stack copy of the assertionResult will likely outlive the
|
||||||
|
// temporary, so it must be expanded or discarded now to avoid calling
|
||||||
|
// a destroyed object later.
|
||||||
|
prepareExpandedExpression(sectionNode.assertions.back().assertionResult);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CumulativeReporterBase::sectionEnded(SectionStats const & sectionStats) {
|
||||||
|
assert(!m_sectionStack.empty());
|
||||||
|
SectionNode& node = *m_sectionStack.back();
|
||||||
|
node.stats = sectionStats;
|
||||||
|
m_sectionStack.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CumulativeReporterBase::testCaseEnded(TestCaseStats const & testCaseStats) {
|
||||||
|
auto node = std::make_shared<TestCaseNode>(testCaseStats);
|
||||||
|
assert(m_sectionStack.size() == 0);
|
||||||
|
node->children.push_back(m_rootSection);
|
||||||
|
m_testCases.push_back(node);
|
||||||
|
m_rootSection.reset();
|
||||||
|
|
||||||
|
assert(m_deepestSection);
|
||||||
|
m_deepestSection->stdOut = testCaseStats.stdOut;
|
||||||
|
m_deepestSection->stdErr = testCaseStats.stdErr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CumulativeReporterBase::testGroupEnded(TestGroupStats const & testGroupStats) {
|
||||||
|
auto node = std::make_shared<TestGroupNode>(testGroupStats);
|
||||||
|
node->children.swap(m_testCases);
|
||||||
|
m_testGroups.push_back(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CumulativeReporterBase::testRunEnded(TestRunStats const & testRunStats) {
|
||||||
|
auto node = std::make_shared<TestRunNode>(testRunStats);
|
||||||
|
node->children.swap(m_testGroups);
|
||||||
|
m_testRuns.push_back(node);
|
||||||
|
testRunEndedCumulative();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CumulativeReporterBase::skipTest(TestCaseInfo const &) {}
|
||||||
|
|
||||||
|
void CumulativeReporterBase::prepareExpandedExpression(AssertionResult & result) const {
|
||||||
|
if (result.isOk())
|
||||||
|
result.discardDecomposedExpression();
|
||||||
|
else
|
||||||
|
result.expandDecomposedExpression();
|
||||||
|
}
|
||||||
|
|
||||||
|
CumulativeReporterBase::SectionNode::SectionNode(SectionStats const& _stats)
|
||||||
|
:stats(_stats) {}
|
||||||
|
CumulativeReporterBase::SectionNode::~SectionNode() {}
|
||||||
|
|
||||||
|
bool CumulativeReporterBase::SectionNode::operator==(SectionNode const & other) const {
|
||||||
|
return stats.sectionInfo.lineInfo == other.stats.sectionInfo.lineInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CumulativeReporterBase::SectionNode::operator==(std::shared_ptr<SectionNode> const& other) const {
|
||||||
|
return operator==(*other);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CumulativeReporterBase::BySectionInfo::BySectionInfo(SectionInfo const& other)
|
||||||
|
:m_other(other) {}
|
||||||
|
|
||||||
|
CumulativeReporterBase::BySectionInfo::BySectionInfo(BySectionInfo const & other)
|
||||||
|
:m_other(other.m_other) {}
|
||||||
|
|
||||||
|
bool CumulativeReporterBase::BySectionInfo::operator()(std::shared_ptr<SectionNode> const & node) const {
|
||||||
|
return node->stats.sectionInfo.lineInfo == m_other.lineInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TestEventListenerBase::TestEventListenerBase(ReporterConfig const & _config)
|
||||||
|
:StreamingReporterBase(_config) {}
|
||||||
|
|
||||||
|
void TestEventListenerBase::assertionStarting(AssertionInfo const &) {}
|
||||||
|
|
||||||
|
bool TestEventListenerBase::assertionEnded(AssertionStats const &) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // end namespace Catch
|
@ -9,7 +9,6 @@
|
|||||||
#define TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED
|
#define TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED
|
||||||
|
|
||||||
#include "../internal/catch_interfaces_reporter.h"
|
#include "../internal/catch_interfaces_reporter.h"
|
||||||
#include "../internal/catch_errno_guard.h"
|
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
@ -19,79 +18,31 @@
|
|||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
namespace {
|
// Returns double formatted as %.3f (format expected on output)
|
||||||
// Because formatting using c++ streams is stateful, drop down to C is required
|
std::string getFormattedDuration( double duration );
|
||||||
// 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 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
|
|
||||||
sprintf(buffer, "%.3f", duration);
|
|
||||||
#endif
|
|
||||||
return std::string(buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct StreamingReporterBase : IStreamingReporter {
|
struct StreamingReporterBase : IStreamingReporter {
|
||||||
|
|
||||||
StreamingReporterBase( ReporterConfig const& _config )
|
StreamingReporterBase(ReporterConfig const& _config);
|
||||||
: m_config( _config.fullConfig() ),
|
|
||||||
stream( _config.stream() )
|
|
||||||
{
|
|
||||||
m_reporterPrefs.shouldRedirectStdOut = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ReporterPreferences getPreferences() const override {
|
virtual ReporterPreferences getPreferences() const override;
|
||||||
return m_reporterPrefs;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~StreamingReporterBase() override;
|
virtual ~StreamingReporterBase() override;
|
||||||
|
|
||||||
virtual void noMatchingTestCases( std::string const& ) override {}
|
virtual void noMatchingTestCases(std::string const&) override;
|
||||||
|
|
||||||
virtual void testRunStarting( TestRunInfo const& _testRunInfo ) override {
|
virtual void testRunStarting(TestRunInfo const& _testRunInfo) override;
|
||||||
currentTestRunInfo = _testRunInfo;
|
virtual void testGroupStarting(GroupInfo const& _groupInfo) override;
|
||||||
}
|
|
||||||
virtual void testGroupStarting( GroupInfo const& _groupInfo ) override {
|
|
||||||
currentGroupInfo = _groupInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void testCaseStarting( TestCaseInfo const& _testInfo ) override {
|
virtual void testCaseStarting(TestCaseInfo const& _testInfo) override;
|
||||||
currentTestCaseInfo = _testInfo;
|
virtual void sectionStarting(SectionInfo const& _sectionInfo) override;
|
||||||
}
|
|
||||||
virtual void sectionStarting( SectionInfo const& _sectionInfo ) override {
|
|
||||||
m_sectionStack.push_back( _sectionInfo );
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void sectionEnded( SectionStats const& /* _sectionStats */ ) override {
|
virtual void sectionEnded(SectionStats const& /* _sectionStats */) override;
|
||||||
m_sectionStack.pop_back();
|
virtual void testCaseEnded(TestCaseStats const& /* _testCaseStats */) override;
|
||||||
}
|
virtual void testGroupEnded(TestGroupStats const& /* _testGroupStats */) override;
|
||||||
virtual void testCaseEnded( TestCaseStats const& /* _testCaseStats */ ) override {
|
virtual void testRunEnded(TestRunStats const& /* _testRunStats */) override;
|
||||||
currentTestCaseInfo.reset();
|
|
||||||
}
|
|
||||||
virtual void testGroupEnded( TestGroupStats const& /* _testGroupStats */ ) override {
|
|
||||||
currentGroupInfo.reset();
|
|
||||||
}
|
|
||||||
virtual void testRunEnded( TestRunStats const& /* _testRunStats */ ) override {
|
|
||||||
currentTestCaseInfo.reset();
|
|
||||||
currentGroupInfo.reset();
|
|
||||||
currentTestRunInfo.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void skipTest( TestCaseInfo const& ) override {
|
virtual void skipTest(TestCaseInfo const&) override;
|
||||||
// Don't do anything with this by default.
|
|
||||||
// It can optionally be overridden in the derived class.
|
|
||||||
}
|
|
||||||
|
|
||||||
IConfigPtr m_config;
|
IConfigPtr m_config;
|
||||||
std::ostream& stream;
|
std::ostream& stream;
|
||||||
@ -115,15 +66,11 @@ namespace Catch {
|
|||||||
ChildNodes children;
|
ChildNodes children;
|
||||||
};
|
};
|
||||||
struct SectionNode {
|
struct SectionNode {
|
||||||
explicit SectionNode( SectionStats const& _stats ) : stats( _stats ) {}
|
explicit SectionNode(SectionStats const& _stats);
|
||||||
virtual ~SectionNode();
|
virtual ~SectionNode();
|
||||||
|
|
||||||
bool operator == ( SectionNode const& other ) const {
|
bool operator == (SectionNode const& other) const;
|
||||||
return stats.sectionInfo.lineInfo == other.stats.sectionInfo.lineInfo;
|
bool operator == (std::shared_ptr<SectionNode> const& other) const;
|
||||||
}
|
|
||||||
bool operator == ( std::shared_ptr<SectionNode> const& other ) const {
|
|
||||||
return operator==( *other );
|
|
||||||
}
|
|
||||||
|
|
||||||
SectionStats stats;
|
SectionStats stats;
|
||||||
using ChildSections = std::vector<std::shared_ptr<SectionNode>>;
|
using ChildSections = std::vector<std::shared_ptr<SectionNode>>;
|
||||||
@ -135,13 +82,12 @@ namespace Catch {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct BySectionInfo {
|
struct BySectionInfo {
|
||||||
BySectionInfo( SectionInfo const& other ) : m_other( other ) {}
|
BySectionInfo(SectionInfo const& other);
|
||||||
BySectionInfo( BySectionInfo const& other ) : m_other( other.m_other ) {}
|
BySectionInfo(BySectionInfo const& other);
|
||||||
bool operator() ( std::shared_ptr<SectionNode> const& node ) const {
|
bool operator() (std::shared_ptr<SectionNode> const& node) const;
|
||||||
return node->stats.sectionInfo.lineInfo == m_other.lineInfo;
|
void operator=(BySectionInfo const&) = delete;
|
||||||
}
|
|
||||||
private:
|
private:
|
||||||
void operator=( BySectionInfo const& );
|
|
||||||
SectionInfo const& m_other;
|
SectionInfo const& m_other;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -150,100 +96,30 @@ namespace Catch {
|
|||||||
using TestGroupNode = Node<TestGroupStats, TestCaseNode>;
|
using TestGroupNode = Node<TestGroupStats, TestCaseNode>;
|
||||||
using TestRunNode = Node<TestRunStats, TestGroupNode>;
|
using TestRunNode = Node<TestRunStats, TestGroupNode>;
|
||||||
|
|
||||||
CumulativeReporterBase( ReporterConfig const& _config )
|
CumulativeReporterBase(ReporterConfig const& _config);
|
||||||
: m_config( _config.fullConfig() ),
|
|
||||||
stream( _config.stream() )
|
|
||||||
{
|
|
||||||
m_reporterPrefs.shouldRedirectStdOut = false;
|
|
||||||
}
|
|
||||||
~CumulativeReporterBase();
|
~CumulativeReporterBase();
|
||||||
|
|
||||||
virtual ReporterPreferences getPreferences() const override {
|
virtual ReporterPreferences getPreferences() const override;
|
||||||
return m_reporterPrefs;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void testRunStarting( TestRunInfo const& ) override {}
|
virtual void testRunStarting(TestRunInfo const&) override;
|
||||||
virtual void testGroupStarting( GroupInfo const& ) override {}
|
virtual void testGroupStarting(GroupInfo const&) override;
|
||||||
|
|
||||||
virtual void testCaseStarting( TestCaseInfo const& ) override {}
|
virtual void testCaseStarting(TestCaseInfo const&) override;
|
||||||
|
|
||||||
virtual void sectionStarting( SectionInfo const& sectionInfo ) override {
|
virtual void sectionStarting(SectionInfo const& sectionInfo) override;
|
||||||
SectionStats incompleteStats( sectionInfo, Counts(), 0, false );
|
|
||||||
std::shared_ptr<SectionNode> node;
|
|
||||||
if( m_sectionStack.empty() ) {
|
|
||||||
if( !m_rootSection )
|
|
||||||
m_rootSection = std::make_shared<SectionNode>( incompleteStats );
|
|
||||||
node = m_rootSection;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
SectionNode& parentNode = *m_sectionStack.back();
|
|
||||||
SectionNode::ChildSections::const_iterator it =
|
|
||||||
std::find_if( parentNode.childSections.begin(),
|
|
||||||
parentNode.childSections.end(),
|
|
||||||
BySectionInfo( sectionInfo ) );
|
|
||||||
if( it == parentNode.childSections.end() ) {
|
|
||||||
node = std::make_shared<SectionNode>( incompleteStats );
|
|
||||||
parentNode.childSections.push_back( node );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
node = *it;
|
|
||||||
}
|
|
||||||
m_sectionStack.push_back( node );
|
|
||||||
m_deepestSection = node;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void assertionStarting( AssertionInfo const& ) override {}
|
virtual void assertionStarting(AssertionInfo const&) override;
|
||||||
|
|
||||||
virtual bool assertionEnded( AssertionStats const& assertionStats ) override {
|
virtual bool assertionEnded(AssertionStats const& assertionStats) override;
|
||||||
assert( !m_sectionStack.empty() );
|
virtual void sectionEnded(SectionStats const& sectionStats) override;
|
||||||
SectionNode& sectionNode = *m_sectionStack.back();
|
virtual void testCaseEnded(TestCaseStats const& testCaseStats) override;
|
||||||
sectionNode.assertions.push_back( assertionStats );
|
virtual void testGroupEnded(TestGroupStats const& testGroupStats) override;
|
||||||
// AssertionResult holds a pointer to a temporary DecomposedExpression,
|
virtual void testRunEnded(TestRunStats const& testRunStats) override;
|
||||||
// which getExpandedExpression() calls to build the expression string.
|
|
||||||
// Our section stack copy of the assertionResult will likely outlive the
|
|
||||||
// temporary, so it must be expanded or discarded now to avoid calling
|
|
||||||
// a destroyed object later.
|
|
||||||
prepareExpandedExpression( sectionNode.assertions.back().assertionResult );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
virtual void sectionEnded( SectionStats const& sectionStats ) override {
|
|
||||||
assert( !m_sectionStack.empty() );
|
|
||||||
SectionNode& node = *m_sectionStack.back();
|
|
||||||
node.stats = sectionStats;
|
|
||||||
m_sectionStack.pop_back();
|
|
||||||
}
|
|
||||||
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) override {
|
|
||||||
auto node = std::make_shared<TestCaseNode>( testCaseStats );
|
|
||||||
assert( m_sectionStack.size() == 0 );
|
|
||||||
node->children.push_back( m_rootSection );
|
|
||||||
m_testCases.push_back( node );
|
|
||||||
m_rootSection.reset();
|
|
||||||
|
|
||||||
assert( m_deepestSection );
|
|
||||||
m_deepestSection->stdOut = testCaseStats.stdOut;
|
|
||||||
m_deepestSection->stdErr = testCaseStats.stdErr;
|
|
||||||
}
|
|
||||||
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) override {
|
|
||||||
auto node = std::make_shared<TestGroupNode>( testGroupStats );
|
|
||||||
node->children.swap( m_testCases );
|
|
||||||
m_testGroups.push_back( node );
|
|
||||||
}
|
|
||||||
virtual void testRunEnded( TestRunStats const& testRunStats ) override {
|
|
||||||
auto node = std::make_shared<TestRunNode>( testRunStats );
|
|
||||||
node->children.swap( m_testGroups );
|
|
||||||
m_testRuns.push_back( node );
|
|
||||||
testRunEndedCumulative();
|
|
||||||
}
|
|
||||||
virtual void testRunEndedCumulative() = 0;
|
virtual void testRunEndedCumulative() = 0;
|
||||||
|
|
||||||
virtual void skipTest( TestCaseInfo const& ) override {}
|
virtual void skipTest(TestCaseInfo const&) override;
|
||||||
|
|
||||||
virtual void prepareExpandedExpression( AssertionResult& result ) const {
|
virtual void prepareExpandedExpression(AssertionResult& result) const;
|
||||||
if( result.isOk() )
|
|
||||||
result.discardDecomposedExpression();
|
|
||||||
else
|
|
||||||
result.expandDecomposedExpression();
|
|
||||||
}
|
|
||||||
|
|
||||||
IConfigPtr m_config;
|
IConfigPtr m_config;
|
||||||
std::ostream& stream;
|
std::ostream& stream;
|
||||||
@ -258,7 +134,6 @@ namespace Catch {
|
|||||||
std::shared_ptr<SectionNode> m_deepestSection;
|
std::shared_ptr<SectionNode> m_deepestSection;
|
||||||
std::vector<std::shared_ptr<SectionNode>> m_sectionStack;
|
std::vector<std::shared_ptr<SectionNode>> m_sectionStack;
|
||||||
ReporterPreferences m_reporterPrefs;
|
ReporterPreferences m_reporterPrefs;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<char C>
|
template<char C>
|
||||||
@ -273,14 +148,10 @@ namespace Catch {
|
|||||||
|
|
||||||
|
|
||||||
struct TestEventListenerBase : StreamingReporterBase {
|
struct TestEventListenerBase : StreamingReporterBase {
|
||||||
TestEventListenerBase( ReporterConfig const& _config )
|
TestEventListenerBase(ReporterConfig const& _config);
|
||||||
: StreamingReporterBase( _config )
|
|
||||||
{}
|
|
||||||
|
|
||||||
virtual void assertionStarting( AssertionInfo const& ) override {}
|
virtual void assertionStarting(AssertionInfo const&) override;
|
||||||
virtual bool assertionEnded( AssertionStats const& ) override {
|
virtual bool assertionEnded(AssertionStats const&) override;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
* 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)
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*/
|
*/
|
||||||
#ifndef TWOBLUECUBES_CATCH_REPORTER_COMPACT_HPP_INCLUDED
|
|
||||||
#define TWOBLUECUBES_CATCH_REPORTER_COMPACT_HPP_INCLUDED
|
|
||||||
|
|
||||||
#include "catch_reporter_bases.hpp"
|
#include "catch_reporter_bases.hpp"
|
||||||
|
|
||||||
@ -297,8 +295,8 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
CompactReporter::~CompactReporter() {}
|
||||||
|
|
||||||
INTERNAL_CATCH_REGISTER_REPORTER( "compact", CompactReporter )
|
INTERNAL_CATCH_REGISTER_REPORTER( "compact", CompactReporter )
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_REPORTER_COMPACT_HPP_INCLUDED
|
|
@ -5,23 +5,26 @@
|
|||||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
* 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)
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*/
|
*/
|
||||||
#ifndef TWOBLUECUBES_CATCH_REPORTER_CONSOLE_HPP_INCLUDED
|
|
||||||
#define TWOBLUECUBES_CATCH_REPORTER_CONSOLE_HPP_INCLUDED
|
|
||||||
|
|
||||||
#include "catch_reporter_bases.hpp"
|
#include "catch_reporter_bases.hpp"
|
||||||
|
|
||||||
#include "../internal/catch_reporter_registrars.hpp"
|
#include "../internal/catch_reporter_registrars.hpp"
|
||||||
#include "../internal/catch_console_colour.hpp"
|
#include "../internal/catch_console_colour.hpp"
|
||||||
|
#include "../internal/catch_version.h"
|
||||||
|
#include "../external/tbc_text_format.h"
|
||||||
|
|
||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
|
using Tbc::Text;
|
||||||
|
using Tbc::TextAttributes;
|
||||||
|
|
||||||
struct ConsoleReporter : StreamingReporterBase {
|
struct ConsoleReporter : StreamingReporterBase {
|
||||||
using StreamingReporterBase::StreamingReporterBase;
|
using StreamingReporterBase::StreamingReporterBase;
|
||||||
|
|
||||||
|
|
||||||
virtual ~ConsoleReporter() override;
|
virtual ~ConsoleReporter() override;
|
||||||
static std::string getDescription() {
|
static std::string getDescription() {
|
||||||
return "Reports test results as plain lines of text";
|
return "Reports test results as plain lines of text";
|
||||||
@ -437,6 +440,6 @@ namespace Catch {
|
|||||||
|
|
||||||
INTERNAL_CATCH_REGISTER_REPORTER( "console", ConsoleReporter )
|
INTERNAL_CATCH_REGISTER_REPORTER( "console", ConsoleReporter )
|
||||||
|
|
||||||
} // end namespace Catch
|
ConsoleReporter::~ConsoleReporter() {}
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_REPORTER_CONSOLE_HPP_INCLUDED
|
} // end namespace Catch
|
@ -5,14 +5,13 @@
|
|||||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
* 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)
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*/
|
*/
|
||||||
#ifndef TWOBLUECUBES_CATCH_REPORTER_JUNIT_HPP_INCLUDED
|
|
||||||
#define TWOBLUECUBES_CATCH_REPORTER_JUNIT_HPP_INCLUDED
|
|
||||||
|
|
||||||
#include "catch_reporter_bases.hpp"
|
#include "catch_reporter_bases.hpp"
|
||||||
|
|
||||||
#include "../internal/catch_tostring.h"
|
#include "../internal/catch_tostring.h"
|
||||||
#include "../internal/catch_reporter_registrars.hpp"
|
#include "../internal/catch_reporter_registrars.hpp"
|
||||||
#include "../internal/catch_xmlwriter.hpp"
|
#include "../internal/catch_xmlwriter.hpp"
|
||||||
|
#include "../internal/catch_timer.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
@ -247,8 +246,7 @@ namespace Catch {
|
|||||||
bool m_okToFail = false;
|
bool m_okToFail = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
JunitReporter::~JunitReporter() {}
|
||||||
INTERNAL_CATCH_REGISTER_REPORTER( "junit", JunitReporter )
|
INTERNAL_CATCH_REGISTER_REPORTER( "junit", JunitReporter )
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_REPORTER_JUNIT_HPP_INCLUDED
|
|
@ -5,8 +5,6 @@
|
|||||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
* 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)
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*/
|
*/
|
||||||
#ifndef TWOBLUECUBES_CATCH_REPORTER_MULTI_HPP_INCLUDED
|
|
||||||
#define TWOBLUECUBES_CATCH_REPORTER_MULTI_HPP_INCLUDED
|
|
||||||
|
|
||||||
#include "../internal/catch_interfaces_reporter.h"
|
#include "../internal/catch_interfaces_reporter.h"
|
||||||
|
|
||||||
@ -124,5 +122,3 @@ void addReporter( IStreamingReporterPtr& existingReporter, IStreamingReporterPtr
|
|||||||
|
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_REPORTER_MULTI_HPP_INCLUDED
|
|
@ -5,8 +5,6 @@
|
|||||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
* 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)
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*/
|
*/
|
||||||
#ifndef TWOBLUECUBES_CATCH_REPORTER_XML_HPP_INCLUDED
|
|
||||||
#define TWOBLUECUBES_CATCH_REPORTER_XML_HPP_INCLUDED
|
|
||||||
|
|
||||||
#include "catch_reporter_bases.hpp"
|
#include "catch_reporter_bases.hpp"
|
||||||
|
|
||||||
@ -221,8 +219,7 @@ namespace Catch {
|
|||||||
int m_sectionDepth = 0;
|
int m_sectionDepth = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
XmlReporter::~XmlReporter() {}
|
||||||
INTERNAL_CATCH_REGISTER_REPORTER( "xml", XmlReporter )
|
INTERNAL_CATCH_REGISTER_REPORTER( "xml", XmlReporter )
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_REPORTER_XML_HPP_INCLUDED
|
|
Loading…
Reference in New Issue
Block a user