mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Keep reporter pointer around in TestGroup
This commit is contained in:
parent
a17b9f754a
commit
fa160cf3f2
@ -61,10 +61,11 @@ namespace Catch {
|
|||||||
|
|
||||||
class TestGroup {
|
class TestGroup {
|
||||||
public:
|
public:
|
||||||
explicit TestGroup(IStreamingReporterPtr&& reporter, std::shared_ptr<Config> const& config)
|
explicit TestGroup(IStreamingReporterPtr&& reporter, std::shared_ptr<Config> const& config):
|
||||||
: m_config{config}
|
m_reporter(reporter.get()),
|
||||||
, m_context{config, std::move(reporter)}
|
m_config{config},
|
||||||
{
|
m_context{config, std::move(reporter)} {
|
||||||
|
|
||||||
auto const& allTestCases = getAllTestCasesSorted(*m_config);
|
auto const& allTestCases = getAllTestCasesSorted(*m_config);
|
||||||
m_matches = m_config->testSpec().matchesByFilter(allTestCases, *m_config);
|
m_matches = m_config->testSpec().matchesByFilter(allTestCases, *m_config);
|
||||||
auto const& invalidArgs = m_config->testSpec().getInvalidArgs();
|
auto const& invalidArgs = m_config->testSpec().getInvalidArgs();
|
||||||
@ -87,19 +88,19 @@ namespace Catch {
|
|||||||
if (!m_context.aborting())
|
if (!m_context.aborting())
|
||||||
totals += m_context.runTest(*testCase);
|
totals += m_context.runTest(*testCase);
|
||||||
else
|
else
|
||||||
m_context.reporter().skipTest(testCase->getTestCaseInfo());
|
m_reporter->skipTest(testCase->getTestCaseInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto const& match : m_matches) {
|
for (auto const& match : m_matches) {
|
||||||
if (match.tests.empty()) {
|
if (match.tests.empty()) {
|
||||||
m_context.reporter().noMatchingTestCases(match.name);
|
m_reporter->noMatchingTestCases(match.name);
|
||||||
totals.error = -1;
|
totals.error = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!invalidArgs.empty()) {
|
if (!invalidArgs.empty()) {
|
||||||
for (auto const& invalidArg: invalidArgs)
|
for (auto const& invalidArg: invalidArgs)
|
||||||
m_context.reporter().reportInvalidArguments(invalidArg);
|
m_reporter->reportInvalidArguments(invalidArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_context.testGroupEnded(m_config->name(), totals, 1, 1);
|
m_context.testGroupEnded(m_config->name(), totals, 1, 1);
|
||||||
@ -109,6 +110,7 @@ namespace Catch {
|
|||||||
private:
|
private:
|
||||||
using Tests = std::set<TestCaseHandle const*>;
|
using Tests = std::set<TestCaseHandle const*>;
|
||||||
|
|
||||||
|
IStreamingReporter* m_reporter;
|
||||||
std::shared_ptr<Config> m_config;
|
std::shared_ptr<Config> m_config;
|
||||||
RunContext m_context;
|
RunContext m_context;
|
||||||
Tests m_tests;
|
Tests m_tests;
|
||||||
|
@ -136,9 +136,6 @@ namespace Catch {
|
|||||||
return deltaTotals;
|
return deltaTotals;
|
||||||
}
|
}
|
||||||
|
|
||||||
IStreamingReporter& RunContext::reporter() const {
|
|
||||||
return *m_reporter;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunContext::assertionEnded(AssertionResult const & result) {
|
void RunContext::assertionEnded(AssertionResult const & result) {
|
||||||
if (result.getResultType() == ResultWas::Ok) {
|
if (result.getResultType() == ResultWas::Ok) {
|
||||||
|
@ -45,8 +45,6 @@ namespace Catch {
|
|||||||
|
|
||||||
Totals runTest(TestCaseHandle const& testCase);
|
Totals runTest(TestCaseHandle const& testCase);
|
||||||
|
|
||||||
IStreamingReporter& reporter() const;
|
|
||||||
|
|
||||||
public: // IResultCapture
|
public: // IResultCapture
|
||||||
|
|
||||||
// Assertion handlers
|
// Assertion handlers
|
||||||
|
Loading…
Reference in New Issue
Block a user