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

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2
diff options
context:
space:
mode:
authorMartin Hořeňovský2022-03-18 00:14:09 +0100
committerMartin Hořeňovský2022-03-18 00:41:47 +0100
commit06092f727d271d2128b026db99dc0d5736434481 (patch)
treea368988665b4bfe7c58d5b1c98b9b695eb1ec09d /src/catch2
parent4acc520f763f7a104d11d57afb8d3bab0bfa6ebc (diff)
downloadcatch3-06092f727d271d2128b026db99dc0d5736434481.tar.gz
Remove special handling of default stream for reporters
This fixes an issue where reporter with default-output to stdout would think that it was given a stream _not_ backed by console, thus not using colour.
Diffstat (limited to 'src/catch2')
-rw-r--r--src/catch2/catch_config.cpp16
-rw-r--r--src/catch2/catch_config.hpp2
-rw-r--r--src/catch2/interfaces/catch_interfaces_config.hpp1
3 files changed, 10 insertions, 9 deletions
diff --git a/src/catch2/catch_config.cpp b/src/catch2/catch_config.cpp
index 6d6e0831..8541d223 100644
--- a/src/catch2/catch_config.cpp
+++ b/src/catch2/catch_config.cpp
@@ -45,8 +45,7 @@ namespace Catch {
}
Config::Config( ConfigData const& data ):
- m_data( data ),
- m_defaultStream( openStream( data.defaultOutputFilename ) ) {
+ m_data( data ) {
// We need to trim filter specs to avoid trouble with superfluous
// whitespace (esp. important for bdd macros, as those are manually
// aligned with whitespace).
@@ -81,13 +80,19 @@ namespace Catch {
} );
}
+ bool defaultOutputUsed = false;
m_reporterStreams.reserve( m_data.reporterSpecifications.size() );
for ( auto const& reporterAndFile : m_data.reporterSpecifications ) {
if ( reporterAndFile.outputFileName.none() ) {
- m_reporterStreams.emplace_back( new Detail::RDBufStream(
- m_defaultStream->stream().rdbuf() ) );
+ CATCH_ENFORCE( !defaultOutputUsed,
+ "Internal error: cannot use default output for "
+ "multiple reporters" );
+ defaultOutputUsed = true;
+
+ m_reporterStreams.push_back(
+ openStream( data.defaultOutputFilename ) );
} else {
- m_reporterStreams.emplace_back(
+ m_reporterStreams.push_back(
openStream( *reporterAndFile.outputFileName ) );
}
}
@@ -118,7 +123,6 @@ namespace Catch {
// IConfig interface
bool Config::allowThrows() const { return !m_data.noThrow; }
- IStream const* Config::defaultStream() const { return m_defaultStream.get(); }
StringRef Config::name() const { return m_data.name.empty() ? m_data.processName : m_data.name; }
bool Config::includeSuccessfulResults() const { return m_data.showSuccessfulTests; }
bool Config::warnAboutMissingAssertions() const {
diff --git a/src/catch2/catch_config.hpp b/src/catch2/catch_config.hpp
index 7b33fa71..2a71537d 100644
--- a/src/catch2/catch_config.hpp
+++ b/src/catch2/catch_config.hpp
@@ -103,7 +103,6 @@ namespace Catch {
// IConfig interface
bool allowThrows() const override;
- IStream const* defaultStream() const override;
StringRef name() const override;
bool includeSuccessfulResults() const override;
bool warnAboutMissingAssertions() const override;
@@ -130,7 +129,6 @@ namespace Catch {
Detail::unique_ptr<IStream const> openStream(std::string const& outputFileName);
ConfigData m_data;
- Detail::unique_ptr<IStream const> m_defaultStream;
std::vector<Detail::unique_ptr<IStream const>> m_reporterStreams;
TestSpec m_testSpec;
bool m_hasTestFilters = false;
diff --git a/src/catch2/interfaces/catch_interfaces_config.hpp b/src/catch2/interfaces/catch_interfaces_config.hpp
index 6c17081a..d98f7b44 100644
--- a/src/catch2/interfaces/catch_interfaces_config.hpp
+++ b/src/catch2/interfaces/catch_interfaces_config.hpp
@@ -62,7 +62,6 @@ namespace Catch {
virtual ~IConfig();
virtual bool allowThrows() const = 0;
- virtual IStream const* defaultStream() const = 0;
virtual StringRef name() const = 0;
virtual bool includeSuccessfulResults() const = 0;
virtual bool shouldDebugBreak() const = 0;