diff --git a/include/internal/catch_commandline.cpp b/include/internal/catch_commandline.cpp index 85af1085..c57b7ed7 100644 --- a/include/internal/catch_commandline.cpp +++ b/include/internal/catch_commandline.cpp @@ -130,7 +130,7 @@ namespace Catch { | Opt( config.outputFilename, "filename" ) ["-o"]["--out"] ( "output filename" ) - | Opt( config.reporterNames, "name" ) + | Opt( config.reporterName, "name" ) ["-r"]["--reporter"] ( "reporter to use (defaults to console)" ) | Opt( config.name, "name" ) diff --git a/include/internal/catch_config.cpp b/include/internal/catch_config.cpp index 1db94119..e8ad2a81 100644 --- a/include/internal/catch_config.cpp +++ b/include/internal/catch_config.cpp @@ -37,8 +37,8 @@ namespace Catch { bool Config::listReporters() const { return m_data.listReporters; } std::string Config::getProcessName() const { return m_data.processName; } + std::string const& Config::getReporterName() const { return m_data.reporterName; } - std::vector const& Config::getReporterNames() const { return m_data.reporterNames; } std::vector const& Config::getTestsOrTags() const { return m_data.testsOrTags; } std::vector const& Config::getSectionsToRun() const { return m_data.sectionsToRun; } diff --git a/include/internal/catch_config.hpp b/include/internal/catch_config.hpp index 3afdff5e..9d5e772e 100644 --- a/include/internal/catch_config.hpp +++ b/include/internal/catch_config.hpp @@ -55,7 +55,13 @@ namespace Catch { std::string name; std::string processName; - std::vector reporterNames; +#ifndef CATCH_CONFIG_DEFAULT_REPORTER +#define CATCH_CONFIG_DEFAULT_REPORTER "console" +#endif + std::string reporterName = CATCH_CONFIG_DEFAULT_REPORTER; +#undef CATCH_CONFIG_DEFAULT_REPORTER + + std::vector testsOrTags; std::vector sectionsToRun; }; @@ -76,8 +82,8 @@ namespace Catch { bool listReporters() const; std::string getProcessName() const; + std::string const& getReporterName() const; - std::vector const& getReporterNames() const; std::vector const& getTestsOrTags() const; std::vector const& getSectionsToRun() const override; diff --git a/include/internal/catch_session.cpp b/include/internal/catch_session.cpp index a5f8946e..a7ae19db 100644 --- a/include/internal/catch_session.cpp +++ b/include/internal/catch_session.cpp @@ -36,22 +36,11 @@ namespace Catch { return reporter; } -#ifndef CATCH_CONFIG_DEFAULT_REPORTER -#define CATCH_CONFIG_DEFAULT_REPORTER "console" -#endif IStreamingReporterPtr makeReporter(std::shared_ptr const& config) { - auto const& reporterNames = config->getReporterNames(); - if (reporterNames.empty()) - return createReporter(CATCH_CONFIG_DEFAULT_REPORTER, config); - - IStreamingReporterPtr reporter; - for (auto const& name : reporterNames) - addReporter(reporter, createReporter(name, config)); - return reporter; + return createReporter(config->getReporterName(), config); } -#undef CATCH_CONFIG_DEFAULT_REPORTER void addListeners(IStreamingReporterPtr& reporters, IConfigPtr const& config) { auto const& listeners = Catch::getRegistryHub().getReporterRegistry().getListeners(); diff --git a/projects/SelfTest/Baselines/compact.sw.approved.txt b/projects/SelfTest/Baselines/compact.sw.approved.txt index dbf34fd4..12b4f730 100644 --- a/projects/SelfTest/Baselines/compact.sw.approved.txt +++ b/projects/SelfTest/Baselines/compact.sw.approved.txt @@ -528,7 +528,7 @@ CmdLine.tests.cpp:: passed: config.processName == "test" for: "test CmdLine.tests.cpp:: passed: config.shouldDebugBreak == false for: false == false CmdLine.tests.cpp:: passed: config.abortAfter == -1 for: -1 == -1 CmdLine.tests.cpp:: passed: config.noThrow == false for: false == false -CmdLine.tests.cpp:: passed: config.reporterNames.empty() for: true +CmdLine.tests.cpp:: passed: config.reporterName == "console" for: "console" == "console" CmdLine.tests.cpp:: passed: !(cfg.hasTestFilters()) for: !false CmdLine.tests.cpp:: passed: result for: {?} CmdLine.tests.cpp:: passed: cfg.hasTestFilters() for: true @@ -543,15 +543,12 @@ CmdLine.tests.cpp:: passed: cfg.hasTestFilters() for: true CmdLine.tests.cpp:: passed: cfg.testSpec().matches(fakeTestCase("test1")) == false for: false == false CmdLine.tests.cpp:: passed: cfg.testSpec().matches(fakeTestCase("alwaysIncluded")) for: true CmdLine.tests.cpp:: passed: cli.parse({"test", "-r", "console"}) for: {?} -CmdLine.tests.cpp:: passed: config.reporterNames[0] == "console" for: "console" == "console" +CmdLine.tests.cpp:: passed: config.reporterName == "console" for: "console" == "console" CmdLine.tests.cpp:: passed: cli.parse({"test", "-r", "xml"}) for: {?} -CmdLine.tests.cpp:: passed: config.reporterNames[0] == "xml" for: "xml" == "xml" -CmdLine.tests.cpp:: passed: cli.parse({"test", "-r", "xml", "-r", "junit"}) for: {?} -CmdLine.tests.cpp:: passed: config.reporterNames.size() == 2 for: 2 == 2 -CmdLine.tests.cpp:: passed: config.reporterNames[0] == "xml" for: "xml" == "xml" -CmdLine.tests.cpp:: passed: config.reporterNames[1] == "junit" for: "junit" == "junit" +CmdLine.tests.cpp:: passed: config.reporterName == "xml" for: "xml" == "xml" CmdLine.tests.cpp:: passed: cli.parse({"test", "--reporter", "junit"}) for: {?} -CmdLine.tests.cpp:: passed: config.reporterNames[0] == "junit" for: "junit" == "junit" +CmdLine.tests.cpp:: passed: config.reporterName == "junit" for: "junit" == "junit" +CmdLine.tests.cpp:: passed: !(cli.parse({ "test", "-r", "xml", "-r", "junit" })) for: !{?} CmdLine.tests.cpp:: passed: cli.parse({"test", "-b"}) for: {?} CmdLine.tests.cpp:: passed: config.shouldDebugBreak == true for: true == true CmdLine.tests.cpp:: passed: cli.parse({"test", "--break"}) for: {?} diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index 8bef5356..b4dd6129 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -1085,5 +1085,5 @@ due to unexpected exception with message: =============================================================================== test cases: 205 | 152 passed | 49 failed | 4 failed as expected -assertions: 1063 | 935 passed | 107 failed | 21 failed as expected +assertions: 1060 | 932 passed | 107 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index 1e67fd94..085b2ea8 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -4080,9 +4080,9 @@ with expansion: CmdLine.tests.cpp:: PASSED: - CHECK( config.reporterNames.empty() ) + CHECK( config.reporterName == "console" ) with expansion: - true + "console" == "console" CmdLine.tests.cpp:: PASSED: @@ -4202,7 +4202,7 @@ with expansion: CmdLine.tests.cpp:: PASSED: - REQUIRE( config.reporterNames[0] == "console" ) + REQUIRE( config.reporterName == "console" ) with expansion: "console" == "console" @@ -4222,42 +4222,10 @@ with expansion: CmdLine.tests.cpp:: PASSED: - REQUIRE( config.reporterNames[0] == "xml" ) + REQUIRE( config.reporterName == "xml" ) with expansion: "xml" == "xml" -------------------------------------------------------------------------------- -Process can be configured on command line - reporter - -r xml and junit -------------------------------------------------------------------------------- -CmdLine.tests.cpp: -............................................................................... - -CmdLine.tests.cpp:: -PASSED: - CHECK( cli.parse({"test", "-r", "xml", "-r", "junit"}) ) -with expansion: - {?} - -CmdLine.tests.cpp:: -PASSED: - REQUIRE( config.reporterNames.size() == 2 ) -with expansion: - 2 == 2 - -CmdLine.tests.cpp:: -PASSED: - REQUIRE( config.reporterNames[0] == "xml" ) -with expansion: - "xml" == "xml" - -CmdLine.tests.cpp:: -PASSED: - REQUIRE( config.reporterNames[1] == "junit" ) -with expansion: - "junit" == "junit" - ------------------------------------------------------------------------------- Process can be configured on command line reporter @@ -4274,10 +4242,24 @@ with expansion: CmdLine.tests.cpp:: PASSED: - REQUIRE( config.reporterNames[0] == "junit" ) + REQUIRE( config.reporterName == "junit" ) with expansion: "junit" == "junit" +------------------------------------------------------------------------------- +Process can be configured on command line + reporter + Only one reporter is accepted +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + REQUIRE_FALSE( cli.parse({ "test", "-r", "xml", "-r", "junit" }) ) +with expansion: + !{?} + ------------------------------------------------------------------------------- Process can be configured on command line debugger @@ -8960,5 +8942,5 @@ PASSED: =============================================================================== test cases: 205 | 139 passed | 62 failed | 4 failed as expected -assertions: 1077 | 935 passed | 121 failed | 21 failed as expected +assertions: 1074 | 932 passed | 121 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index 63424efe..2691a27e 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -1,7 +1,7 @@ - + @@ -474,8 +474,8 @@ Message.tests.cpp: - + diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index e2fdb2a4..0c5747ac 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -4757,10 +4757,10 @@ - config.reporterNames.empty() + config.reporterName == "console" - true + "console" == "console" @@ -4899,7 +4899,7 @@ - config.reporterNames[0] == "console" + config.reporterName == "console" "console" == "console" @@ -4921,7 +4921,7 @@ - config.reporterNames[0] == "xml" + config.reporterName == "xml" "xml" == "xml" @@ -4931,44 +4931,6 @@ -
-
- - - cli.parse({"test", "-r", "xml", "-r", "junit"}) - - - {?} - - - - - config.reporterNames.size() == 2 - - - 2 == 2 - - - - - config.reporterNames[0] == "xml" - - - "xml" == "xml" - - - - - config.reporterNames[1] == "junit" - - - "junit" == "junit" - - - -
- -
@@ -4981,7 +4943,7 @@ - config.reporterNames[0] == "junit" + config.reporterName == "junit" "junit" == "junit" @@ -4991,6 +4953,20 @@
+
+
+ + + !(cli.parse({ "test", "-r", "xml", "-r", "junit" })) + + + !{?} + + + +
+ +
@@ -9913,7 +9889,7 @@ loose text artifact
- + - + diff --git a/projects/SelfTest/IntrospectiveTests/CmdLine.tests.cpp b/projects/SelfTest/IntrospectiveTests/CmdLine.tests.cpp index 7bc4a367..1da3fa08 100644 --- a/projects/SelfTest/IntrospectiveTests/CmdLine.tests.cpp +++ b/projects/SelfTest/IntrospectiveTests/CmdLine.tests.cpp @@ -288,7 +288,7 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]" CHECK(config.shouldDebugBreak == false); CHECK(config.abortAfter == -1); CHECK(config.noThrow == false); - CHECK(config.reporterNames.empty()); + CHECK(config.reporterName == "console"); Catch::Config cfg(config); CHECK_FALSE(cfg.hasTestFilters()); @@ -330,24 +330,20 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]" SECTION("-r/console") { CHECK(cli.parse({"test", "-r", "console"})); - REQUIRE(config.reporterNames[0] == "console"); + REQUIRE(config.reporterName == "console"); } SECTION("-r/xml") { CHECK(cli.parse({"test", "-r", "xml"})); - REQUIRE(config.reporterNames[0] == "xml"); - } - SECTION("-r xml and junit") { - CHECK(cli.parse({"test", "-r", "xml", "-r", "junit"})); - - REQUIRE(config.reporterNames.size() == 2); - REQUIRE(config.reporterNames[0] == "xml"); - REQUIRE(config.reporterNames[1] == "junit"); + REQUIRE(config.reporterName == "xml"); } SECTION("--reporter/junit") { CHECK(cli.parse({"test", "--reporter", "junit"})); - REQUIRE(config.reporterNames[0] == "junit"); + REQUIRE(config.reporterName == "junit"); + } + SECTION("Only one reporter is accepted") { + REQUIRE_FALSE(cli.parse({ "test", "-r", "xml", "-r", "junit" })); } }