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

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMartin Hořeňovský2023-02-20 14:48:36 +0100
committerMartin Hořeňovský2023-02-20 14:48:39 +0100
commit00f259aeb2fa292ccf5e4a9c3e15d6b4416a06b2 (patch)
treef34b60f24ccf14193a554e3d6adff1507a382d18
parentfed143624660419a55b114138e51f86f717f21dd (diff)
downloadcatch3-00f259aeb2fa292ccf5e4a9c3e15d6b4416a06b2.tar.gz
Move captured output into TestCaseStats when sending testCaseEnded
-rw-r--r--src/catch2/interfaces/catch_interfaces_reporter.cpp8
-rw-r--r--src/catch2/interfaces/catch_interfaces_reporter.hpp4
-rw-r--r--src/catch2/internal/catch_run_context.cpp13
3 files changed, 11 insertions, 14 deletions
diff --git a/src/catch2/interfaces/catch_interfaces_reporter.cpp b/src/catch2/interfaces/catch_interfaces_reporter.cpp
index e9aff69c..67c5c80e 100644
--- a/src/catch2/interfaces/catch_interfaces_reporter.cpp
+++ b/src/catch2/interfaces/catch_interfaces_reporter.cpp
@@ -79,13 +79,13 @@ namespace Catch {
TestCaseStats::TestCaseStats( TestCaseInfo const& _testInfo,
Totals const& _totals,
- std::string const& _stdOut,
- std::string const& _stdErr,
+ std::string&& _stdOut,
+ std::string&& _stdErr,
bool _aborting )
: testInfo( &_testInfo ),
totals( _totals ),
- stdOut( _stdOut ),
- stdErr( _stdErr ),
+ stdOut( CATCH_MOVE(_stdOut) ),
+ stdErr( CATCH_MOVE(_stdErr) ),
aborting( _aborting )
{}
diff --git a/src/catch2/interfaces/catch_interfaces_reporter.hpp b/src/catch2/interfaces/catch_interfaces_reporter.hpp
index 8c122ced..cf414f10 100644
--- a/src/catch2/interfaces/catch_interfaces_reporter.hpp
+++ b/src/catch2/interfaces/catch_interfaces_reporter.hpp
@@ -92,8 +92,8 @@ namespace Catch {
struct TestCaseStats {
TestCaseStats( TestCaseInfo const& _testInfo,
Totals const& _totals,
- std::string const& _stdOut,
- std::string const& _stdErr,
+ std::string&& _stdOut,
+ std::string&& _stdErr,
bool _aborting );
TestCaseInfo const * testInfo;
diff --git a/src/catch2/internal/catch_run_context.cpp b/src/catch2/internal/catch_run_context.cpp
index cac6de5c..92d6d988 100644
--- a/src/catch2/internal/catch_run_context.cpp
+++ b/src/catch2/internal/catch_run_context.cpp
@@ -176,13 +176,8 @@ namespace Catch {
Totals RunContext::runTest(TestCaseHandle const& testCase) {
const Totals prevTotals = m_totals;
- std::string redirectedCout;
- std::string redirectedCerr;
-
auto const& testInfo = testCase.getTestCaseInfo();
-
m_reporter->testCaseStarting(testInfo);
-
m_activeTestCase = &testCase;
@@ -224,6 +219,8 @@ namespace Catch {
seedRng( *m_config );
uint64_t testRuns = 0;
+ std::string redirectedCout;
+ std::string redirectedCerr;
do {
m_trackerContext.startCycle();
m_testCaseTracker = &SectionTracker::acquire(m_trackerContext, TestCaseTracking::NameAndLocationRef(testInfo.name, testInfo.lineInfo));
@@ -237,7 +234,7 @@ namespace Catch {
redirectedCerr += oneRunCerr;
const auto singleRunTotals = m_totals.delta(beforeRunTotals);
- auto statsForOneRun = TestCaseStats(testInfo, singleRunTotals, oneRunCout, oneRunCerr, aborting());
+ auto statsForOneRun = TestCaseStats(testInfo, singleRunTotals, CATCH_MOVE(oneRunCout), CATCH_MOVE(oneRunCerr), aborting());
m_reporter->testCasePartialEnded(statsForOneRun, testRuns);
++testRuns;
@@ -252,8 +249,8 @@ namespace Catch {
m_totals.testCases += deltaTotals.testCases;
m_reporter->testCaseEnded(TestCaseStats(testInfo,
deltaTotals,
- redirectedCout,
- redirectedCerr,
+ CATCH_MOVE(redirectedCout),
+ CATCH_MOVE(redirectedCerr),
aborting()));
m_activeTestCase = nullptr;