Allow only 1 reporter at a time

This commit is contained in:
Martin Hořeňovský
2018-04-07 12:05:29 +02:00
parent d2d8455b57
commit 414dcae34a
10 changed files with 67 additions and 121 deletions

View File

@@ -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" )

View File

@@ -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<std::string> const& Config::getReporterNames() const { return m_data.reporterNames; }
std::vector<std::string> const& Config::getTestsOrTags() const { return m_data.testsOrTags; }
std::vector<std::string> const& Config::getSectionsToRun() const { return m_data.sectionsToRun; }

View File

@@ -55,7 +55,13 @@ namespace Catch {
std::string name;
std::string processName;
std::vector<std::string> 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<std::string> testsOrTags;
std::vector<std::string> sectionsToRun;
};
@@ -76,8 +82,8 @@ namespace Catch {
bool listReporters() const;
std::string getProcessName() const;
std::string const& getReporterName() const;
std::vector<std::string> const& getReporterNames() const;
std::vector<std::string> const& getTestsOrTags() const;
std::vector<std::string> const& getSectionsToRun() const override;

View File

@@ -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<Config> 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();