mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 13:26:10 +01:00
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:
parent
24b83edf8a
commit
6dc8345261
@ -10,7 +10,7 @@
|
|||||||
#ifndef TWOBLUECUBES_CATCH_BENCHMARK_HPP_INCLUDED
|
#ifndef TWOBLUECUBES_CATCH_BENCHMARK_HPP_INCLUDED
|
||||||
#define 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/internal/catch_context.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
|
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#ifndef TWOBLUECUBES_CATCH_EXECUTION_PLAN_HPP_INCLUDED
|
#ifndef TWOBLUECUBES_CATCH_EXECUTION_PLAN_HPP_INCLUDED
|
||||||
#define 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_clock.hpp>
|
||||||
#include <catch2/benchmark/catch_environment.hpp>
|
#include <catch2/benchmark/catch_environment.hpp>
|
||||||
#include <catch2/benchmark/detail/catch_benchmark_function.hpp>
|
#include <catch2/benchmark/detail/catch_benchmark_function.hpp>
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
|
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_config.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_colour.hpp>
|
||||||
#include <catch2/internal/catch_console_width.hpp>
|
#include <catch2/internal/catch_console_width.hpp>
|
||||||
#include <catch2/catch_message.hpp>
|
#include <catch2/catch_message.hpp>
|
||||||
@ -110,7 +109,7 @@ namespace Catch {
|
|||||||
|
|
||||||
void IStreamingReporter::fatalErrorEncountered( StringRef ) {}
|
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";
|
Catch::cout() << "Available reporters:\n";
|
||||||
const auto maxNameLen = std::max_element(descriptions.begin(), descriptions.end(),
|
const auto maxNameLen = std::max_element(descriptions.begin(), descriptions.end(),
|
||||||
[](ReporterDescription const& lhs, ReporterDescription const& rhs) { return lhs.name.size() < rhs.name.size(); })
|
[](ReporterDescription const& lhs, ReporterDescription const& rhs) { return lhs.name.size() < rhs.name.size(); })
|
||||||
@ -137,10 +136,10 @@ namespace Catch {
|
|||||||
Catch::cout() << std::endl;
|
Catch::cout() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IStreamingReporter::listTests(std::vector<TestCaseHandle> const& tests, Config const& config) {
|
void IStreamingReporter::listTests(std::vector<TestCaseHandle> const& tests, IConfig const& config) {
|
||||||
if (config.hasTestFilters())
|
if (config.hasTestFilters()) {
|
||||||
Catch::cout() << "Matching test cases:\n";
|
Catch::cout() << "Matching test cases:\n";
|
||||||
else {
|
} else {
|
||||||
Catch::cout() << "All available test cases:\n";
|
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()) {
|
if (config.hasTestFilters()) {
|
||||||
Catch::cout() << "Tags for matching test cases:\n";
|
Catch::cout() << "Tags for matching test cases:\n";
|
||||||
} else {
|
} else {
|
||||||
|
@ -234,10 +234,12 @@ namespace Catch {
|
|||||||
// Default empty implementation provided
|
// Default empty implementation provided
|
||||||
virtual void fatalErrorEncountered( StringRef name );
|
virtual void fatalErrorEncountered( StringRef name );
|
||||||
|
|
||||||
// Listing support
|
//! Writes out information about provided reporters using reporter-specific format
|
||||||
virtual void listReporters(std::vector<ReporterDescription> const& descriptions, Config const& config);
|
virtual void listReporters(std::vector<ReporterDescription> const& descriptions, IConfig const& config);
|
||||||
virtual void listTests(std::vector<TestCaseHandle> const& tests, Config const& config);
|
//! Writes out information about provided tests using reporter-specific format
|
||||||
virtual void listTags(std::vector<TagInfo> const& tags, Config const& config);
|
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>;
|
using IStreamingReporterPtr = Detail::unique_ptr<IStreamingReporter>;
|
||||||
|
@ -22,13 +22,13 @@
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void listTests(IStreamingReporter& reporter, Config const& config) {
|
void listTests(IStreamingReporter& reporter, IConfig const& config) {
|
||||||
auto const& testSpec = config.testSpec();
|
auto const& testSpec = config.testSpec();
|
||||||
auto matchedTestCases = filterTests(getAllTestCasesSorted(config), testSpec, config);
|
auto matchedTestCases = filterTests(getAllTestCasesSorted(config), testSpec, config);
|
||||||
reporter.listTests(matchedTestCases, config);
|
reporter.listTests(matchedTestCases, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
void listTags(IStreamingReporter& reporter, Config const& config) {
|
void listTags(IStreamingReporter& reporter, IConfig const& config) {
|
||||||
auto const& testSpec = config.testSpec();
|
auto const& testSpec = config.testSpec();
|
||||||
std::vector<TestCaseHandle> matchedTestCases = filterTests(getAllTestCasesSorted(config), testSpec, config);
|
std::vector<TestCaseHandle> matchedTestCases = filterTests(getAllTestCasesSorted(config), testSpec, config);
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ namespace Catch {
|
|||||||
reporter.listTags(infos, config);
|
reporter.listTags(infos, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
void listReporters(IStreamingReporter& reporter, Config const& config) {
|
void listReporters(IStreamingReporter& reporter, IConfig const& config) {
|
||||||
std::vector<ReporterDescription> descriptions;
|
std::vector<ReporterDescription> descriptions;
|
||||||
|
|
||||||
IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories();
|
IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories();
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include <catch2/internal/catch_errno_guard.hpp>
|
#include <catch2/internal/catch_errno_guard.hpp>
|
||||||
#include <catch2/reporters/catch_reporter_bases.hpp>
|
#include <catch2/reporters/catch_reporter_bases.hpp>
|
||||||
#include <catch2/internal/catch_stream.hpp>
|
#include <catch2/internal/catch_stream.hpp>
|
||||||
#include <catch2/catch_config.hpp>
|
#include <catch2/interfaces/catch_interfaces_config.hpp>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
@ -159,9 +159,9 @@ namespace Catch {
|
|||||||
bool assertionEnded(AssertionStats const&) override;
|
bool assertionEnded(AssertionStats const&) override;
|
||||||
|
|
||||||
// Event listeners should not use the default listing impl
|
// Event listeners should not use the default listing impl
|
||||||
void listReporters(std::vector<ReporterDescription> const&, Config const&) override {}
|
void listReporters(std::vector<ReporterDescription> const&, IConfig const&) override {}
|
||||||
void listTests(std::vector<TestCaseHandle> const&, Config const&) override {}
|
void listTests(std::vector<TestCaseHandle> const&, IConfig const&) override {}
|
||||||
void listTags(std::vector<TagInfo> const&, Config const&) override {}
|
void listTags(std::vector<TagInfo> const&, IConfig const&) override {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
@ -147,21 +147,21 @@ namespace Catch {
|
|||||||
m_reporter->skipTest( testInfo );
|
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) {
|
for (auto const& listener : m_listeners) {
|
||||||
listener->listReporters(descriptions, config);
|
listener->listReporters(descriptions, config);
|
||||||
}
|
}
|
||||||
m_reporter->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) {
|
for (auto const& listener : m_listeners) {
|
||||||
listener->listTests(tests, config);
|
listener->listTests(tests, config);
|
||||||
}
|
}
|
||||||
m_reporter->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) {
|
for (auto const& listener : m_listeners) {
|
||||||
listener->listTags(tags, config);
|
listener->listTags(tags, config);
|
||||||
}
|
}
|
||||||
|
@ -48,9 +48,9 @@ namespace Catch {
|
|||||||
|
|
||||||
void skipTest( TestCaseInfo const& testInfo ) override;
|
void skipTest( TestCaseInfo const& testInfo ) override;
|
||||||
|
|
||||||
void listReporters(std::vector<ReporterDescription> const& descriptions, Config const& config) override;
|
void listReporters(std::vector<ReporterDescription> const& descriptions, IConfig const& config) override;
|
||||||
void listTests(std::vector<TestCaseHandle> const& tests, Config const& config) override;
|
void listTests(std::vector<TestCaseHandle> const& tests, IConfig const& config) override;
|
||||||
void listTags(std::vector<TagInfo> const& tags, Config const& config) override;
|
void listTags(std::vector<TagInfo> const& tags, IConfig const& config) override;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -272,7 +272,7 @@ namespace Catch {
|
|||||||
m_xml.endElement();
|
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");
|
auto outerTag = m_xml.scopedElement("AvailableReporters");
|
||||||
for (auto const& reporter : descriptions) {
|
for (auto const& reporter : descriptions) {
|
||||||
auto inner = m_xml.scopedElement("Reporter");
|
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");
|
auto outerTag = m_xml.scopedElement("MatchingTests");
|
||||||
for (auto const& test : tests) {
|
for (auto const& test : tests) {
|
||||||
auto innerTag = m_xml.scopedElement("TestCase");
|
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");
|
auto outerTag = m_xml.scopedElement("TagsFromMatchingTests");
|
||||||
for (auto const& tag : tags) {
|
for (auto const& tag : tags) {
|
||||||
auto innerTag = m_xml.scopedElement("Tag");
|
auto innerTag = m_xml.scopedElement("Tag");
|
||||||
|
@ -55,9 +55,9 @@ namespace Catch {
|
|||||||
void benchmarkEnded(BenchmarkStats<> const&) override;
|
void benchmarkEnded(BenchmarkStats<> const&) override;
|
||||||
void benchmarkFailed(std::string const&) override;
|
void benchmarkFailed(std::string const&) override;
|
||||||
|
|
||||||
void listReporters(std::vector<ReporterDescription> const& descriptions, Config const& config) override;
|
void listReporters(std::vector<ReporterDescription> const& descriptions, IConfig const& config) override;
|
||||||
void listTests(std::vector<TestCaseHandle> const& tests, Config const& config) override;
|
void listTests(std::vector<TestCaseHandle> const& tests, IConfig const& config) override;
|
||||||
void listTags(std::vector<TagInfo> const& tags, Config const& config) override;
|
void listTags(std::vector<TagInfo> const& tags, IConfig const& config) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Timer m_testCaseTimer;
|
Timer m_testCaseTimer;
|
||||||
|
Loading…
Reference in New Issue
Block a user