diff options
| author | Martin Hořeňovský | 2022-03-27 23:35:41 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2022-03-28 13:10:13 +0200 |
| commit | 1a8a793178d50b74b0f9a0adb3eec937b61039a9 (patch) | |
| tree | 2a8cadf3fa4478f1a11548485a4a0389d4920d2d /tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp | |
| parent | a4e4e82474f894d56cbe86e13a2d23bb1b46744d (diff) | |
| download | catch3-1a8a793178d50b74b0f9a0adb3eec937b61039a9.tar.gz | |
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.
Diffstat (limited to 'tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp')
| -rw-r--r-- | tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp b/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp index 253b72e0..25d5fbd6 100644 --- a/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp @@ -15,6 +15,8 @@ #include <catch2/catch_test_case_info.hpp> #include <catch2/internal/catch_commandline.hpp> #include <catch2/generators/catch_generators.hpp> +#include <catch2/internal/catch_compiler_capabilities.hpp> + namespace { auto fakeTestCase(const char* name, const char* desc = "") { return Catch::makeTestCaseInfo("", { name, desc }, CATCH_INTERNAL_LINEINFO); } @@ -556,34 +558,34 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]" SECTION( "use-colour") { - using Catch::UseColour; + using Catch::ColourMode; SECTION( "without option" ) { CHECK(cli.parse({"test"})); - REQUIRE( config.useColour == UseColour::Auto ); + REQUIRE( config.colourMode == ColourMode::PlatformDefault ); } SECTION( "auto" ) { - CHECK(cli.parse({"test", "--use-colour", "auto"})); + CHECK( cli.parse( { "test", "--colour-mode", "default" } ) ); - REQUIRE( config.useColour == UseColour::Auto ); + REQUIRE( config.colourMode == ColourMode::PlatformDefault ); } SECTION( "yes" ) { - CHECK(cli.parse({"test", "--use-colour", "yes"})); + CHECK(cli.parse({"test", "--colour-mode", "ansi"})); - REQUIRE( config.useColour == UseColour::Yes ); + REQUIRE( config.colourMode == ColourMode::ANSI ); } SECTION( "no" ) { - CHECK(cli.parse({"test", "--use-colour", "no"})); + CHECK(cli.parse({"test", "--colour-mode", "none"})); - REQUIRE( config.useColour == UseColour::No ); + REQUIRE( config.colourMode == ColourMode::None ); } SECTION( "error" ) { - auto result = cli.parse({"test", "--use-colour", "wrong"}); + auto result = cli.parse({"test", "--colour-mode", "wrong"}); CHECK( !result ); CHECK_THAT( result.errorMessage(), ContainsSubstring( "colour mode must be one of" ) ); } @@ -712,3 +714,17 @@ TEST_CASE("Various suspicious reporter specs are rejected", auto result = cli.parse( { "test", "--reporter", spec } ); REQUIRE_FALSE( result ); } + +TEST_CASE("Win32 colour implementation is compile-time optional", + "[approvals][cli][colours]") { + Catch::ConfigData config; + auto cli = Catch::makeCommandLineParser( config ); + + auto result = cli.parse( { "test", "--colour-mode", "win32" } ); + +#if defined( CATCH_CONFIG_COLOUR_WIN32 ) + REQUIRE( result ); +#else + REQUIRE_FALSE( result ); +#endif +} |