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

@@ -2601,23 +2601,23 @@ ok {test-number} - config.noThrow == true for: true == true
# Process can be configured on command line
ok {test-number} - cli.parse({"test"}) for: {?}
# Process can be configured on command line
ok {test-number} - config.useColour == UseColour::Auto for: 0 == 0
ok {test-number} - config.colourMode == ColourMode::PlatformDefault for: 0 == 0
# Process can be configured on command line
ok {test-number} - cli.parse({"test", "--use-colour", "auto"}) for: {?}
ok {test-number} - cli.parse( { "test", "--colour-mode", "default" } ) for: {?}
# Process can be configured on command line
ok {test-number} - config.useColour == UseColour::Auto for: 0 == 0
ok {test-number} - config.colourMode == ColourMode::PlatformDefault for: 0 == 0
# Process can be configured on command line
ok {test-number} - cli.parse({"test", "--use-colour", "yes"}) for: {?}
ok {test-number} - cli.parse({"test", "--colour-mode", "ansi"}) for: {?}
# Process can be configured on command line
ok {test-number} - config.useColour == UseColour::Yes for: 1 == 1
ok {test-number} - config.colourMode == ColourMode::ANSI for: 1 == 1
# Process can be configured on command line
ok {test-number} - cli.parse({"test", "--use-colour", "no"}) for: {?}
ok {test-number} - cli.parse({"test", "--colour-mode", "none"}) for: {?}
# Process can be configured on command line
ok {test-number} - config.useColour == UseColour::No for: 2 == 2
ok {test-number} - config.colourMode == ColourMode::None for: 3 == 3
# Process can be configured on command line
ok {test-number} - !result for: true
# Process can be configured on command line
ok {test-number} - result.errorMessage(), ContainsSubstring( "colour mode must be one of" ) for: "colour mode must be one of: auto, yes or no. 'wrong' not recognised" contains: "colour mode must be one of"
ok {test-number} - result.errorMessage(), ContainsSubstring( "colour mode must be one of" ) for: "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
ok {test-number} - cli.parse({ "test", "--benchmark-samples=200" }) for: {?}
# Process can be configured on command line