Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2
diff options
context:
space:
mode:
authorMartin Hořeňovský2020-05-19 17:20:11 +0200
committerMartin Hořeňovský2020-05-20 20:25:45 +0200
commitfa160cf3f251ae6d1672b58fb19eb1af8adb81c6 (patch)
tree94827f24bead7bec44231d9ce52ff827729ef37a /src/catch2
parenta17b9f754a6ad20f42d6714ed5471624c0de4f1a (diff)
downloadcatch3-fa160cf3f251ae6d1672b58fb19eb1af8adb81c6.tar.gz
Keep reporter pointer around in TestGroup
Diffstat (limited to 'src/catch2')
-rw-r--r--src/catch2/catch_session.cpp16
-rw-r--r--src/catch2/internal/catch_run_context.cpp3
-rw-r--r--src/catch2/internal/catch_run_context.hpp2
3 files changed, 9 insertions, 12 deletions
diff --git a/src/catch2/catch_session.cpp b/src/catch2/catch_session.cpp
index e85e0672..66dd7186 100644
--- a/src/catch2/catch_session.cpp
+++ b/src/catch2/catch_session.cpp
@@ -61,10 +61,11 @@ namespace Catch {
class TestGroup {
public:
- explicit TestGroup(IStreamingReporterPtr&& reporter, std::shared_ptr<Config> const& config)
- : m_config{config}
- , m_context{config, std::move(reporter)}
- {
+ explicit TestGroup(IStreamingReporterPtr&& reporter, std::shared_ptr<Config> const& config):
+ m_reporter(reporter.get()),
+ m_config{config},
+ m_context{config, std::move(reporter)} {
+
auto const& allTestCases = getAllTestCasesSorted(*m_config);
m_matches = m_config->testSpec().matchesByFilter(allTestCases, *m_config);
auto const& invalidArgs = m_config->testSpec().getInvalidArgs();
@@ -87,19 +88,19 @@ namespace Catch {
if (!m_context.aborting())
totals += m_context.runTest(*testCase);
else
- m_context.reporter().skipTest(testCase->getTestCaseInfo());
+ m_reporter->skipTest(testCase->getTestCaseInfo());
}
for (auto const& match : m_matches) {
if (match.tests.empty()) {
- m_context.reporter().noMatchingTestCases(match.name);
+ m_reporter->noMatchingTestCases(match.name);
totals.error = -1;
}
}
if (!invalidArgs.empty()) {
for (auto const& invalidArg: invalidArgs)
- m_context.reporter().reportInvalidArguments(invalidArg);
+ m_reporter->reportInvalidArguments(invalidArg);
}
m_context.testGroupEnded(m_config->name(), totals, 1, 1);
@@ -109,6 +110,7 @@ namespace Catch {
private:
using Tests = std::set<TestCaseHandle const*>;
+ IStreamingReporter* m_reporter;
std::shared_ptr<Config> m_config;
RunContext m_context;
Tests m_tests;
diff --git a/src/catch2/internal/catch_run_context.cpp b/src/catch2/internal/catch_run_context.cpp
index c97621d2..379eddcc 100644
--- a/src/catch2/internal/catch_run_context.cpp
+++ b/src/catch2/internal/catch_run_context.cpp
@@ -136,9 +136,6 @@ namespace Catch {
return deltaTotals;
}
- IStreamingReporter& RunContext::reporter() const {
- return *m_reporter;
- }
void RunContext::assertionEnded(AssertionResult const & result) {
if (result.getResultType() == ResultWas::Ok) {
diff --git a/src/catch2/internal/catch_run_context.hpp b/src/catch2/internal/catch_run_context.hpp
index cb2322d6..622a083b 100644
--- a/src/catch2/internal/catch_run_context.hpp
+++ b/src/catch2/internal/catch_run_context.hpp
@@ -45,8 +45,6 @@ namespace Catch {
Totals runTest(TestCaseHandle const& testCase);
- IStreamingReporter& reporter() const;
-
public: // IResultCapture
// Assertion handlers