mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Remove superfluous IConfig argument from IStreamingReporter::list*
The previous commit made it so that the `IConfig` is stored in `IStreamingReporter` and thus always available.
This commit is contained in:
parent
74f2f4ba5e
commit
5509ceff60
@ -127,14 +127,14 @@ namespace Catch {
|
||||
|
||||
void IStreamingReporter::fatalErrorEncountered( StringRef ) {}
|
||||
|
||||
void IStreamingReporter::listReporters(std::vector<ReporterDescription> const& descriptions, IConfig const& config) {
|
||||
void IStreamingReporter::listReporters(std::vector<ReporterDescription> const& descriptions) {
|
||||
Catch::cout() << "Available reporters:\n";
|
||||
const auto maxNameLen = std::max_element(descriptions.begin(), descriptions.end(),
|
||||
[](ReporterDescription const& lhs, ReporterDescription const& rhs) { return lhs.name.size() < rhs.name.size(); })
|
||||
->name.size();
|
||||
|
||||
for (auto const& desc : descriptions) {
|
||||
if (config.verbosity() == Verbosity::Quiet) {
|
||||
if (m_config->verbosity() == Verbosity::Quiet) {
|
||||
Catch::cout()
|
||||
<< TextFlow::Column(desc.name)
|
||||
.indent(2)
|
||||
@ -154,16 +154,16 @@ namespace Catch {
|
||||
Catch::cout() << std::endl;
|
||||
}
|
||||
|
||||
void IStreamingReporter::listTests(std::vector<TestCaseHandle> const& tests, IConfig const& config) {
|
||||
void IStreamingReporter::listTests(std::vector<TestCaseHandle> const& tests) {
|
||||
// We special case this to provide the equivalent of old
|
||||
// `--list-test-names-only`, which could then be used by the
|
||||
// `--input-file` option.
|
||||
if (config.verbosity() == Verbosity::Quiet) {
|
||||
if (m_config->verbosity() == Verbosity::Quiet) {
|
||||
listTestNamesOnly(tests);
|
||||
return;
|
||||
}
|
||||
|
||||
if (config.hasTestFilters()) {
|
||||
if (m_config->hasTestFilters()) {
|
||||
Catch::cout() << "Matching test cases:\n";
|
||||
} else {
|
||||
Catch::cout() << "All available test cases:\n";
|
||||
@ -177,23 +177,24 @@ namespace Catch {
|
||||
Colour colourGuard(colour);
|
||||
|
||||
Catch::cout() << TextFlow::Column(testCaseInfo.name).initialIndent(2).indent(4) << '\n';
|
||||
if (config.verbosity() >= Verbosity::High) {
|
||||
if (m_config->verbosity() >= Verbosity::High) {
|
||||
Catch::cout() << TextFlow::Column(Catch::Detail::stringify(testCaseInfo.lineInfo)).indent(4) << std::endl;
|
||||
}
|
||||
if (!testCaseInfo.tags.empty() && config.verbosity() > Verbosity::Quiet) {
|
||||
if ( !testCaseInfo.tags.empty() &&
|
||||
m_config->verbosity() > Verbosity::Quiet ) {
|
||||
Catch::cout() << TextFlow::Column(testCaseInfo.tagsAsString()).indent(6) << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
if (!config.hasTestFilters()) {
|
||||
if (!m_config->hasTestFilters()) {
|
||||
Catch::cout() << pluralise(tests.size(), "test case") << '\n' << std::endl;
|
||||
} else {
|
||||
Catch::cout() << pluralise(tests.size(), "matching test case") << '\n' << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void IStreamingReporter::listTags(std::vector<TagInfo> const& tags, IConfig const& config) {
|
||||
if (config.hasTestFilters()) {
|
||||
void IStreamingReporter::listTags(std::vector<TagInfo> const& tags) {
|
||||
if (m_config->hasTestFilters()) {
|
||||
Catch::cout() << "Tags for matching test cases:\n";
|
||||
} else {
|
||||
Catch::cout() << "All available tags:\n";
|
||||
|
@ -222,11 +222,11 @@ namespace Catch {
|
||||
virtual void fatalErrorEncountered( StringRef name );
|
||||
|
||||
//! Writes out information about provided reporters using reporter-specific format
|
||||
virtual void listReporters(std::vector<ReporterDescription> const& descriptions, IConfig const& config);
|
||||
virtual void listReporters(std::vector<ReporterDescription> const& descriptions);
|
||||
//! Writes out information about provided tests using reporter-specific format
|
||||
virtual void listTests(std::vector<TestCaseHandle> const& tests, IConfig const& config);
|
||||
virtual void listTests(std::vector<TestCaseHandle> const& tests);
|
||||
//! Writes out information about the provided tags using reporter-specific format
|
||||
virtual void listTags(std::vector<TagInfo> const& tags, IConfig const& config);
|
||||
virtual void listTags(std::vector<TagInfo> const& tags);
|
||||
|
||||
};
|
||||
using IStreamingReporterPtr = Detail::unique_ptr<IStreamingReporter>;
|
||||
|
@ -24,7 +24,7 @@ namespace Catch {
|
||||
void listTests(IStreamingReporter& reporter, IConfig const& config) {
|
||||
auto const& testSpec = config.testSpec();
|
||||
auto matchedTestCases = filterTests(getAllTestCasesSorted(config), testSpec, config);
|
||||
reporter.listTests(matchedTestCases, config);
|
||||
reporter.listTests(matchedTestCases);
|
||||
}
|
||||
|
||||
void listTags(IStreamingReporter& reporter, IConfig const& config) {
|
||||
@ -46,10 +46,10 @@ namespace Catch {
|
||||
infos.push_back(std::move(tagc.second));
|
||||
}
|
||||
|
||||
reporter.listTags(infos, config);
|
||||
reporter.listTags(infos);
|
||||
}
|
||||
|
||||
void listReporters(IStreamingReporter& reporter, IConfig const& config) {
|
||||
void listReporters(IStreamingReporter& reporter) {
|
||||
std::vector<ReporterDescription> descriptions;
|
||||
|
||||
IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories();
|
||||
@ -58,7 +58,7 @@ namespace Catch {
|
||||
descriptions.push_back({ fac.first, fac.second->getDescription() });
|
||||
}
|
||||
|
||||
reporter.listReporters(descriptions, config);
|
||||
reporter.listReporters(descriptions);
|
||||
}
|
||||
|
||||
} // end anonymous namespace
|
||||
@ -96,7 +96,7 @@ namespace Catch {
|
||||
}
|
||||
if (config.listReporters()) {
|
||||
listed = true;
|
||||
listReporters(reporter, config);
|
||||
listReporters(reporter);
|
||||
}
|
||||
return listed;
|
||||
}
|
||||
|
@ -100,13 +100,10 @@ namespace Catch {
|
||||
bool EventListenerBase::assertionEnded( AssertionStats const& ) {
|
||||
return false;
|
||||
}
|
||||
void
|
||||
EventListenerBase::listReporters( std::vector<ReporterDescription> const&,
|
||||
IConfig const& ) {}
|
||||
void EventListenerBase::listTests( std::vector<TestCaseHandle> const&,
|
||||
IConfig const& ) {}
|
||||
void EventListenerBase::listTags( std::vector<TagInfo> const&,
|
||||
IConfig const& ) {}
|
||||
void EventListenerBase::listReporters(
|
||||
std::vector<ReporterDescription> const& ) {}
|
||||
void EventListenerBase::listTests( std::vector<TestCaseHandle> const& ) {}
|
||||
void EventListenerBase::listTags( std::vector<TagInfo> const& ) {}
|
||||
void EventListenerBase::noMatchingTestCases( std::string const& ) {}
|
||||
void EventListenerBase::testRunStarting( TestRunInfo const& ) {}
|
||||
void EventListenerBase::testGroupStarting( GroupInfo const& ) {}
|
||||
|
@ -27,13 +27,10 @@ namespace Catch {
|
||||
void assertionStarting( AssertionInfo const& assertionInfo ) override;
|
||||
bool assertionEnded( AssertionStats const& assertionStats ) override;
|
||||
|
||||
void
|
||||
listReporters( std::vector<ReporterDescription> const& descriptions,
|
||||
IConfig const& config ) override;
|
||||
void listTests( std::vector<TestCaseHandle> const& tests,
|
||||
IConfig const& config ) override;
|
||||
void listTags( std::vector<TagInfo> const& tagInfos,
|
||||
IConfig const& config ) override;
|
||||
void listReporters(
|
||||
std::vector<ReporterDescription> const& descriptions ) override;
|
||||
void listTests( std::vector<TestCaseHandle> const& tests ) override;
|
||||
void listTags( std::vector<TagInfo> const& tagInfos ) override;
|
||||
|
||||
void noMatchingTestCases( std::string const& spec ) override;
|
||||
void testRunStarting( TestRunInfo const& testRunInfo ) override;
|
||||
|
@ -141,25 +141,25 @@ namespace Catch {
|
||||
m_reporter->skipTest( testInfo );
|
||||
}
|
||||
|
||||
void ListeningReporter::listReporters(std::vector<ReporterDescription> const& descriptions, IConfig const& config) {
|
||||
void ListeningReporter::listReporters(std::vector<ReporterDescription> const& descriptions) {
|
||||
for (auto const& listener : m_listeners) {
|
||||
listener->listReporters(descriptions, config);
|
||||
listener->listReporters(descriptions);
|
||||
}
|
||||
m_reporter->listReporters(descriptions, config);
|
||||
m_reporter->listReporters(descriptions);
|
||||
}
|
||||
|
||||
void ListeningReporter::listTests(std::vector<TestCaseHandle> const& tests, IConfig const& config) {
|
||||
void ListeningReporter::listTests(std::vector<TestCaseHandle> const& tests) {
|
||||
for (auto const& listener : m_listeners) {
|
||||
listener->listTests(tests, config);
|
||||
listener->listTests(tests);
|
||||
}
|
||||
m_reporter->listTests(tests, config);
|
||||
m_reporter->listTests(tests);
|
||||
}
|
||||
|
||||
void ListeningReporter::listTags(std::vector<TagInfo> const& tags, IConfig const& config) {
|
||||
void ListeningReporter::listTags(std::vector<TagInfo> const& tags) {
|
||||
for (auto const& listener : m_listeners) {
|
||||
listener->listTags(tags, config);
|
||||
listener->listTags(tags);
|
||||
}
|
||||
m_reporter->listTags(tags, config);
|
||||
m_reporter->listTags(tags);
|
||||
}
|
||||
|
||||
} // end namespace Catch
|
||||
|
@ -54,9 +54,9 @@ namespace Catch {
|
||||
|
||||
void skipTest( TestCaseInfo const& testInfo ) override;
|
||||
|
||||
void listReporters(std::vector<ReporterDescription> const& descriptions, IConfig const& config) override;
|
||||
void listTests(std::vector<TestCaseHandle> const& tests, IConfig const& config) override;
|
||||
void listTags(std::vector<TagInfo> const& tags, IConfig const& config) override;
|
||||
void listReporters(std::vector<ReporterDescription> const& descriptions) override;
|
||||
void listTests(std::vector<TestCaseHandle> const& tests) override;
|
||||
void listTags(std::vector<TagInfo> const& tags) override;
|
||||
|
||||
|
||||
};
|
||||
|
@ -272,7 +272,7 @@ namespace Catch {
|
||||
m_xml.endElement();
|
||||
}
|
||||
|
||||
void XmlReporter::listReporters(std::vector<ReporterDescription> const& descriptions, IConfig const&) {
|
||||
void XmlReporter::listReporters(std::vector<ReporterDescription> const& descriptions) {
|
||||
auto outerTag = m_xml.scopedElement("AvailableReporters");
|
||||
for (auto const& reporter : descriptions) {
|
||||
auto inner = m_xml.scopedElement("Reporter");
|
||||
@ -285,7 +285,7 @@ namespace Catch {
|
||||
}
|
||||
}
|
||||
|
||||
void XmlReporter::listTests(std::vector<TestCaseHandle> const& tests, IConfig const&) {
|
||||
void XmlReporter::listTests(std::vector<TestCaseHandle> const& tests) {
|
||||
auto outerTag = m_xml.scopedElement("MatchingTests");
|
||||
for (auto const& test : tests) {
|
||||
auto innerTag = m_xml.scopedElement("TestCase");
|
||||
@ -310,7 +310,7 @@ namespace Catch {
|
||||
}
|
||||
}
|
||||
|
||||
void XmlReporter::listTags(std::vector<TagInfo> const& tags, IConfig const&) {
|
||||
void XmlReporter::listTags(std::vector<TagInfo> const& tags) {
|
||||
auto outerTag = m_xml.scopedElement("TagsFromMatchingTests");
|
||||
for (auto const& tag : tags) {
|
||||
auto innerTag = m_xml.scopedElement("Tag");
|
||||
|
@ -56,9 +56,9 @@ namespace Catch {
|
||||
void benchmarkEnded(BenchmarkStats<> const&) override;
|
||||
void benchmarkFailed(std::string const&) override;
|
||||
|
||||
void listReporters(std::vector<ReporterDescription> const& descriptions, IConfig const& config) override;
|
||||
void listTests(std::vector<TestCaseHandle> const& tests, IConfig const& config) override;
|
||||
void listTags(std::vector<TagInfo> const& tags, IConfig const& config) override;
|
||||
void listReporters(std::vector<ReporterDescription> const& descriptions) override;
|
||||
void listTests(std::vector<TestCaseHandle> const& tests) override;
|
||||
void listTags(std::vector<TagInfo> const& tags) override;
|
||||
|
||||
private:
|
||||
Timer m_testCaseTimer;
|
||||
|
Loading…
Reference in New Issue
Block a user