mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-25 23:06:10 +01:00
parent
5bf6e47381
commit
7d2451f119
@ -49,6 +49,15 @@ namespace Catch {
|
|||||||
{}
|
{}
|
||||||
auto RedirectedStdErr::str() const -> std::string { return m_rss.str(); }
|
auto RedirectedStdErr::str() const -> std::string { return m_rss.str(); }
|
||||||
|
|
||||||
|
RedirectedStreams::RedirectedStreams(std::string& redirectedCout, std::string& redirectedCerr)
|
||||||
|
: m_redirectedCout(redirectedCout),
|
||||||
|
m_redirectedCerr(redirectedCerr)
|
||||||
|
{}
|
||||||
|
|
||||||
|
RedirectedStreams::~RedirectedStreams() {
|
||||||
|
m_redirectedCout += m_redirectedStdOut.str();
|
||||||
|
m_redirectedCerr += m_redirectedStdErr.str();
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(CATCH_CONFIG_NEW_CAPTURE)
|
#if defined(CATCH_CONFIG_NEW_CAPTURE)
|
||||||
|
|
||||||
|
@ -46,6 +46,21 @@ namespace Catch {
|
|||||||
auto str() const -> std::string;
|
auto str() const -> std::string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class RedirectedStreams {
|
||||||
|
public:
|
||||||
|
RedirectedStreams(RedirectedStreams const&) = delete;
|
||||||
|
RedirectedStreams& operator=(RedirectedStreams const&) = delete;
|
||||||
|
RedirectedStreams(RedirectedStreams&&) = delete;
|
||||||
|
RedirectedStreams& operator=(RedirectedStreams&&) = delete;
|
||||||
|
|
||||||
|
RedirectedStreams(std::string& redirectedCout, std::string& redirectedCerr);
|
||||||
|
~RedirectedStreams();
|
||||||
|
private:
|
||||||
|
std::string& m_redirectedCout;
|
||||||
|
std::string& m_redirectedCerr;
|
||||||
|
RedirectedStdOut m_redirectedStdOut;
|
||||||
|
RedirectedStdErr m_redirectedStdErr;
|
||||||
|
};
|
||||||
|
|
||||||
#if defined(CATCH_CONFIG_NEW_CAPTURE)
|
#if defined(CATCH_CONFIG_NEW_CAPTURE)
|
||||||
|
|
||||||
|
@ -67,7 +67,6 @@ namespace Catch {
|
|||||||
GeneratorTracker::~GeneratorTracker() {}
|
GeneratorTracker::~GeneratorTracker() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RunContext::RunContext(IConfigPtr const& _config, IStreamingReporterPtr&& reporter)
|
RunContext::RunContext(IConfigPtr const& _config, IStreamingReporterPtr&& reporter)
|
||||||
: m_runInfo(_config->name()),
|
: m_runInfo(_config->name()),
|
||||||
m_context(getCurrentMutableContext()),
|
m_context(getCurrentMutableContext()),
|
||||||
@ -323,13 +322,10 @@ namespace Catch {
|
|||||||
CATCH_TRY {
|
CATCH_TRY {
|
||||||
if (m_reporter->getPreferences().shouldRedirectStdOut) {
|
if (m_reporter->getPreferences().shouldRedirectStdOut) {
|
||||||
#if !defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT)
|
#if !defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT)
|
||||||
RedirectedStdOut redirectedStdOut;
|
RedirectedStreams redirectedStreams(redirectedCout, redirectedCerr);
|
||||||
RedirectedStdErr redirectedStdErr;
|
|
||||||
|
|
||||||
timer.start();
|
timer.start();
|
||||||
invokeActiveTestCase();
|
invokeActiveTestCase();
|
||||||
redirectedCout += redirectedStdOut.str();
|
|
||||||
redirectedCerr += redirectedStdErr.str();
|
|
||||||
#else
|
#else
|
||||||
OutputRedirect r(redirectedCout, redirectedCerr);
|
OutputRedirect r(redirectedCout, redirectedCerr);
|
||||||
timer.start();
|
timer.start();
|
||||||
|
Loading…
Reference in New Issue
Block a user