From 6c2464ec39f7a842a699831627c4eb936720b50c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Fri, 31 Dec 2021 16:24:55 +0100 Subject: [PATCH] Move multireporter's stdout/err passthrough to partial test event 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). --- .../reporters/catch_reporter_listening.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/catch2/reporters/catch_reporter_listening.cpp b/src/catch2/reporters/catch_reporter_listening.cpp index a08e5d59df..e89090fbef 100644 --- a/src/catch2/reporters/catch_reporter_listening.cpp +++ b/src/catch2/reporters/catch_reporter_listening.cpp @@ -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 ); }