Skip to content

Commit

Permalink
Move captured output into TestCaseStats when sending testCaseEnded
Browse files Browse the repository at this point in the history
  • Loading branch information
horenmar committed Feb 20, 2023
1 parent fed1436 commit 00f259a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/catch2/interfaces/catch_interfaces_reporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{}

Expand Down
4 changes: 2 additions & 2 deletions src/catch2/interfaces/catch_interfaces_reporter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 5 additions & 8 deletions src/catch2/internal/catch_run_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down Expand Up @@ -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));
Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 00f259a

Please sign in to comment.