Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include/internal/catch_session.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2019-06-21 23:15:08 +0200
committerMartin Hořeňovský2019-10-29 14:07:18 +0100
commit85b129c741d7493df178c4e0644cd221ad434141 (patch)
treeca0427cc57cccd85734d0bb3b17175a77d6cfa09 /include/internal/catch_session.cpp
parent0f39438aaefe70a89aaee65e8ce78c490a6b03b5 (diff)
downloadcatch3-85b129c741d7493df178c4e0644cd221ad434141.tar.gz
Pipe --list* through reporters
This allows us to provide machine-readable listings through the XMLReporter and it will also allow users to define their own listing format that does whatever their own tools need.
Diffstat (limited to 'include/internal/catch_session.cpp')
-rw-r--r--include/internal/catch_session.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/include/internal/catch_session.cpp b/include/internal/catch_session.cpp
index f490c88a..dd3dc241 100644
--- a/include/internal/catch_session.cpp
+++ b/include/internal/catch_session.cpp
@@ -62,14 +62,14 @@ namespace Catch {
class TestGroup {
public:
- explicit TestGroup(std::shared_ptr<Config> const& config)
+ explicit TestGroup(IStreamingReporterPtr&& reporter, std::shared_ptr<Config> const& config)
: m_config{config}
- , m_context{config, makeReporter(config)}
+ , m_context{config, std::move(reporter)}
{
auto const& allTestCases = getAllTestCasesSorted(*m_config);
m_matches = m_config->testSpec().matchesByFilter(allTestCases, *m_config);
auto const& invalidArgs = m_config->testSpec().getInvalidArgs();
-
+
if (m_matches.empty() && invalidArgs.empty()) {
for (auto const& test : allTestCases)
if (!test.isHidden())
@@ -97,12 +97,12 @@ namespace Catch {
totals.error = -1;
}
}
-
+
if (!invalidArgs.empty()) {
- for (auto const& invalidArg: invalidArgs)
+ for (auto const& invalidArg: invalidArgs)
m_context.reporter().reportInvalidArguments(invalidArg);
- }
-
+ }
+
m_context.testGroupEnded(m_config->name(), totals, 1, 1);
return totals;
}
@@ -287,12 +287,15 @@ namespace Catch {
if( m_configData.filenamesAsTags )
applyFilenamesAsTags( *m_config );
+ // Create reporter(s) so we can route listings through them
+ auto reporter = makeReporter(m_config);
+
// Handle list request
- if (list(m_config)) {
+ if (list(*reporter, m_config)) {
return 0;
}
- TestGroup tests { m_config };
+ TestGroup tests { std::move(reporter), m_config };
auto const totals = tests.execute();
if( m_config->warnAboutNoTests() && totals.error == -1 )