Skip to content

Commit

Permalink
Passthrough stdout/err in multireporter's partial test end
Browse files Browse the repository at this point in the history
This should provide the same overall stdout/err, but the new
output should feel "faster" for test cases that are entered
and exited multiple times (e.g. due to generators).
  • Loading branch information
horenmar committed Jan 1, 2022
1 parent 93882f7 commit b5547f2
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/catch2/reporters/catch_reporter_listening.cpp
Expand Up @@ -136,21 +136,22 @@ namespace Catch {

void ListeningReporter::testCasePartialEnded( TestCaseStats const& testStats,
uint64_t partNumber ) {
// TODO: Fix handling of stderr/stdout?
if ( m_preferences.shouldRedirectStdOut &&
m_haveNoncapturingReporters ) {
if ( !testStats.stdOut.empty() ) {
Catch::cout() << testStats.stdOut << std::flush;
}
if ( !testStats.stdErr.empty() ) {
Catch::cerr() << testStats.stdErr << std::flush;
}
}

for ( auto& reporterish : m_reporterLikes ) {
reporterish->testCasePartialEnded( testStats, partNumber );
}
}

void ListeningReporter::testCaseEnded( TestCaseStats const& testCaseStats ) {
if ( m_preferences.shouldRedirectStdOut && m_haveNoncapturingReporters ) {
if ( !testCaseStats.stdOut.empty() ) {
Catch::cout() << testCaseStats.stdOut << std::flush;
}
if ( !testCaseStats.stdErr.empty() ) {
Catch::cerr() << testCaseStats.stdErr << std::flush;
}
}
for ( auto& reporterish : m_reporterLikes ) {
reporterish->testCaseEnded( testCaseStats );
}
Expand Down

0 comments on commit b5547f2

Please sign in to comment.