Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Fix colourized output to file

This change should be backwards compatible, but it would be better
to make the console colour API take an argument in the long term.

Fixes #1502
Commit
084b1d5fe67d080d88473a4264589927b2ba5711
Author
Martin Hořeňovský ·
Parents
41098704359f

Files · Download .tar.gz

Changes

 docs/deprecations.md                      | 5 +++++
 include/internal/catch_console_colour.cpp | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/docs/deprecations.md b/docs/deprecations.md
index b8047684..0489e1ff 100644
--- a/docs/deprecations.md
+++ b/docs/deprecations.md
@@ -83,6 +83,11 @@ be changed so that hidden tests are included in a run only if they
 positively match a testspec.
 
 
+### Console Colour API
+
+The API for Catch2's console colour will be changed to take an extra
+argument, the stream to which the colour code should be applied.
+
 ---
 
 [Home](Readme.md#top)
diff --git a/include/internal/catch_console_colour.cpp b/include/internal/catch_console_colour.cpp
index 5fb1d07f..863e0d67 100644
--- a/include/internal/catch_console_colour.cpp
+++ b/include/internal/catch_console_colour.cpp
@@ -160,7 +160,8 @@ namespace {
 
     private:
         void setColour( const char* _escapeCode ) {
-            Catch::cout() << '\033' << _escapeCode;
+            getCurrentContext().getConfig().stream()
+                << '\033' << _escapeCode;
         }
     };