Refactor colour handling to prepare for per-reporter colour modes

This includes always compiling the ANSI and None colour
implementations, as they don't need to touch any platform
specific APIs, and removing their respective compile-time
configuration options.

Because the Win32 colour implementation requires Win32-specific
APIs, it is still hidden behind a compile-time toggle,
`CATCH_CONFIG_COLOUR_WIN32` (renamed from `..._COLOUR_WINDOWS`).

The commandline options for colours were also changed. The
option now uses different name, and allows to select between
different implementations, rather than changing whether
the compiled-in colour implementation is used through
"yes/no/default" options.
This commit is contained in:
Martin Hořeňovský
2022-03-27 23:35:41 +02:00
parent a4e4e82474
commit 1a8a793178
27 changed files with 292 additions and 203 deletions

View File

@@ -9967,7 +9967,7 @@ with expansion:
{?}
CmdLine.tests.cpp:<line number>: PASSED:
REQUIRE( config.useColour == UseColour::Auto )
REQUIRE( config.colourMode == ColourMode::PlatformDefault )
with expansion:
0 == 0
@@ -9980,12 +9980,12 @@ CmdLine.tests.cpp:<line number>
...............................................................................
CmdLine.tests.cpp:<line number>: PASSED:
CHECK( cli.parse({"test", "--use-colour", "auto"}) )
CHECK( cli.parse( { "test", "--colour-mode", "default" } ) )
with expansion:
{?}
CmdLine.tests.cpp:<line number>: PASSED:
REQUIRE( config.useColour == UseColour::Auto )
REQUIRE( config.colourMode == ColourMode::PlatformDefault )
with expansion:
0 == 0
@@ -9998,12 +9998,12 @@ CmdLine.tests.cpp:<line number>
...............................................................................
CmdLine.tests.cpp:<line number>: PASSED:
CHECK( cli.parse({"test", "--use-colour", "yes"}) )
CHECK( cli.parse({"test", "--colour-mode", "ansi"}) )
with expansion:
{?}
CmdLine.tests.cpp:<line number>: PASSED:
REQUIRE( config.useColour == UseColour::Yes )
REQUIRE( config.colourMode == ColourMode::ANSI )
with expansion:
1 == 1
@@ -10016,14 +10016,14 @@ CmdLine.tests.cpp:<line number>
...............................................................................
CmdLine.tests.cpp:<line number>: PASSED:
CHECK( cli.parse({"test", "--use-colour", "no"}) )
CHECK( cli.parse({"test", "--colour-mode", "none"}) )
with expansion:
{?}
CmdLine.tests.cpp:<line number>: PASSED:
REQUIRE( config.useColour == UseColour::No )
REQUIRE( config.colourMode == ColourMode::None )
with expansion:
2 == 2
3 == 3
-------------------------------------------------------------------------------
Process can be configured on command line
@@ -10041,8 +10041,8 @@ with expansion:
CmdLine.tests.cpp:<line number>: PASSED:
CHECK_THAT( result.errorMessage(), ContainsSubstring( "colour mode must be one of" ) )
with expansion:
"colour mode must be one of: auto, yes or no. 'wrong' not recognised"
contains: "colour mode must be one of"
"colour mode must be one of: default, ansi, win32, or none. 'wrong' not
recognised" contains: "colour mode must be one of"
-------------------------------------------------------------------------------
Process can be configured on command line