IStreamingReporter::list* only uses IConfig instead of full Config

As the full `Config` is not needed, the TUs implementing the `list*`
functions can require the less heavy header `catch_interfaces_config.hpp`
instead of the much heavier `catch_config.hpp`.

This commit also fixes up some other TUs that include `Config`,
while using just `IConfig`, to cleanup the includes further.
This commit is contained in:
Martin Hořeňovský 2020-08-11 09:34:25 +02:00
parent 24b83edf8a
commit 6dc8345261
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
11 changed files with 32 additions and 31 deletions

View File

@ -10,7 +10,7 @@
#ifndef TWOBLUECUBES_CATCH_BENCHMARK_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_BENCHMARK_HPP_INCLUDED
#include <catch2/catch_config.hpp>
#include <catch2/interfaces/catch_interfaces_config.hpp>
#include <catch2/internal/catch_context.hpp>
#include <catch2/interfaces/catch_interfaces_reporter.hpp>

View File

@ -11,7 +11,7 @@
#ifndef TWOBLUECUBES_CATCH_EXECUTION_PLAN_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_EXECUTION_PLAN_HPP_INCLUDED
#include <catch2/catch_config.hpp>
#include <catch2/interfaces/catch_interfaces_config.hpp>
#include <catch2/benchmark/catch_clock.hpp>
#include <catch2/benchmark/catch_environment.hpp>
#include <catch2/benchmark/detail/catch_benchmark_function.hpp>

View File

@ -7,7 +7,6 @@
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
#include <catch2/interfaces/catch_interfaces_config.hpp>
#include <catch2/catch_config.hpp>
#include <catch2/internal/catch_console_colour.hpp>
#include <catch2/internal/catch_console_width.hpp>
#include <catch2/catch_message.hpp>
@ -110,7 +109,7 @@ namespace Catch {
void IStreamingReporter::fatalErrorEncountered( StringRef ) {}
void IStreamingReporter::listReporters(std::vector<ReporterDescription> const& descriptions, Config const& config) {
void IStreamingReporter::listReporters(std::vector<ReporterDescription> const& descriptions, IConfig const& config) {
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(); })
@ -137,10 +136,10 @@ namespace Catch {
Catch::cout() << std::endl;
}
void IStreamingReporter::listTests(std::vector<TestCaseHandle> const& tests, Config const& config) {
if (config.hasTestFilters())
void IStreamingReporter::listTests(std::vector<TestCaseHandle> const& tests, IConfig const& config) {
if (config.hasTestFilters()) {
Catch::cout() << "Matching test cases:\n";
else {
} else {
Catch::cout() << "All available test cases:\n";
}
@ -167,7 +166,7 @@ namespace Catch {
}
}
void IStreamingReporter::listTags(std::vector<TagInfo> const& tags, Config const& config) {
void IStreamingReporter::listTags(std::vector<TagInfo> const& tags, IConfig const& config) {
if (config.hasTestFilters()) {
Catch::cout() << "Tags for matching test cases:\n";
} else {

View File

@ -234,10 +234,12 @@ namespace Catch {
// Default empty implementation provided
virtual void fatalErrorEncountered( StringRef name );
// Listing support
virtual void listReporters(std::vector<ReporterDescription> const& descriptions, Config const& config);
virtual void listTests(std::vector<TestCaseHandle> const& tests, Config const& config);
virtual void listTags(std::vector<TagInfo> const& tags, Config const& config);
//! Writes out information about provided reporters using reporter-specific format
virtual void listReporters(std::vector<ReporterDescription> const& descriptions, IConfig const& config);
//! Writes out information about provided tests using reporter-specific format
virtual void listTests(std::vector<TestCaseHandle> const& tests, IConfig const& config);
//! Writes out information about the provided tags using reporter-specific format
virtual void listTags(std::vector<TagInfo> const& tags, IConfig const& config);
};
using IStreamingReporterPtr = Detail::unique_ptr<IStreamingReporter>;

View File

@ -22,13 +22,13 @@
namespace Catch {
namespace {
void listTests(IStreamingReporter& reporter, Config const& config) {
void listTests(IStreamingReporter& reporter, IConfig const& config) {
auto const& testSpec = config.testSpec();
auto matchedTestCases = filterTests(getAllTestCasesSorted(config), testSpec, config);
reporter.listTests(matchedTestCases, config);
}
void listTags(IStreamingReporter& reporter, Config const& config) {
void listTags(IStreamingReporter& reporter, IConfig const& config) {
auto const& testSpec = config.testSpec();
std::vector<TestCaseHandle> matchedTestCases = filterTests(getAllTestCasesSorted(config), testSpec, config);
@ -50,7 +50,7 @@ namespace Catch {
reporter.listTags(infos, config);
}
void listReporters(IStreamingReporter& reporter, Config const& config) {
void listReporters(IStreamingReporter& reporter, IConfig const& config) {
std::vector<ReporterDescription> descriptions;
IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories();

View File

@ -11,7 +11,7 @@
#include <catch2/internal/catch_errno_guard.hpp>
#include <catch2/reporters/catch_reporter_bases.hpp>
#include <catch2/internal/catch_stream.hpp>
#include <catch2/catch_config.hpp>
#include <catch2/interfaces/catch_interfaces_config.hpp>
#include <algorithm>
#include <cstring>

View File

@ -159,9 +159,9 @@ namespace Catch {
bool assertionEnded(AssertionStats const&) override;
// Event listeners should not use the default listing impl
void listReporters(std::vector<ReporterDescription> const&, Config const&) override {}
void listTests(std::vector<TestCaseHandle> const&, Config const&) override {}
void listTags(std::vector<TagInfo> const&, Config const&) override {}
void listReporters(std::vector<ReporterDescription> const&, IConfig const&) override {}
void listTests(std::vector<TestCaseHandle> const&, IConfig const&) override {}
void listTags(std::vector<TagInfo> const&, IConfig const&) override {}
};
} // end namespace Catch

View File

@ -147,21 +147,21 @@ namespace Catch {
m_reporter->skipTest( testInfo );
}
void ListeningReporter::listReporters(std::vector<ReporterDescription> const& descriptions, Config const& config) {
void ListeningReporter::listReporters(std::vector<ReporterDescription> const& descriptions, IConfig const& config) {
for (auto const& listener : m_listeners) {
listener->listReporters(descriptions, config);
}
m_reporter->listReporters(descriptions, config);
}
void ListeningReporter::listTests(std::vector<TestCaseHandle> const& tests, Config const& config) {
void ListeningReporter::listTests(std::vector<TestCaseHandle> const& tests, IConfig const& config) {
for (auto const& listener : m_listeners) {
listener->listTests(tests, config);
}
m_reporter->listTests(tests, config);
}
void ListeningReporter::listTags(std::vector<TagInfo> const& tags, Config const& config) {
void ListeningReporter::listTags(std::vector<TagInfo> const& tags, IConfig const& config) {
for (auto const& listener : m_listeners) {
listener->listTags(tags, config);
}

View File

@ -48,9 +48,9 @@ namespace Catch {
void skipTest( TestCaseInfo const& testInfo ) override;
void listReporters(std::vector<ReporterDescription> const& descriptions, Config const& config) override;
void listTests(std::vector<TestCaseHandle> const& tests, Config const& config) override;
void listTags(std::vector<TagInfo> const& tags, Config const& config) 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;
};

View File

@ -272,7 +272,7 @@ namespace Catch {
m_xml.endElement();
}
void XmlReporter::listReporters(std::vector<ReporterDescription> const& descriptions, Config const&) {
void XmlReporter::listReporters(std::vector<ReporterDescription> const& descriptions, IConfig const&) {
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, Config const&) {
void XmlReporter::listTests(std::vector<TestCaseHandle> const& tests, IConfig const&) {
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, Config const&) {
void XmlReporter::listTags(std::vector<TagInfo> const& tags, IConfig const&) {
auto outerTag = m_xml.scopedElement("TagsFromMatchingTests");
for (auto const& tag : tags) {
auto innerTag = m_xml.scopedElement("Tag");

View File

@ -55,9 +55,9 @@ namespace Catch {
void benchmarkEnded(BenchmarkStats<> const&) override;
void benchmarkFailed(std::string const&) override;
void listReporters(std::vector<ReporterDescription> const& descriptions, Config const& config) override;
void listTests(std::vector<TestCaseHandle> const& tests, Config const& config) override;
void listTags(std::vector<TagInfo> const& tags, Config const& config) 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;
private:
Timer m_testCaseTimer;