mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-03 22:05:39 +02:00
--list-* flags write to target specified by the -o flag
Also added tests for the default implementations of list* reporter helpers. Closes #2061
This commit is contained in:
@@ -108,20 +108,4 @@ namespace Catch {
|
||||
|
||||
void IStreamingReporter::fatalErrorEncountered( StringRef ) {}
|
||||
|
||||
void IStreamingReporter::listReporters(std::vector<ReporterDescription> const& descriptions) {
|
||||
defaultListReporters(
|
||||
Catch::cout(), descriptions, m_config->verbosity() );
|
||||
}
|
||||
|
||||
void IStreamingReporter::listTests(std::vector<TestCaseHandle> const& tests) {
|
||||
defaultListTests( Catch::cout(),
|
||||
tests,
|
||||
m_config->hasTestFilters(),
|
||||
m_config->verbosity() );
|
||||
}
|
||||
|
||||
void IStreamingReporter::listTags(std::vector<TagInfo> const& tags) {
|
||||
defaultListTags( Catch::cout(), tags, m_config->hasTestFilters() );
|
||||
}
|
||||
|
||||
} // end namespace Catch
|
||||
|
@@ -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);
|
||||
virtual void listReporters(std::vector<ReporterDescription> const& descriptions) = 0;
|
||||
//! Writes out information about provided tests using reporter-specific format
|
||||
virtual void listTests(std::vector<TestCaseHandle> const& tests);
|
||||
virtual void listTests(std::vector<TestCaseHandle> const& tests) = 0;
|
||||
//! Writes out information about the provided tags using reporter-specific format
|
||||
virtual void listTags(std::vector<TagInfo> const& tags);
|
||||
virtual void listTags(std::vector<TagInfo> const& tags) = 0;
|
||||
|
||||
};
|
||||
using IStreamingReporterPtr = Detail::unique_ptr<IStreamingReporter>;
|
||||
|
@@ -6,6 +6,7 @@
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
#include <catch2/reporters/catch_reporter_cumulative_base.hpp>
|
||||
#include <catch2/reporters/catch_reporter_helpers.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
@@ -110,4 +111,19 @@ namespace Catch {
|
||||
testRunEndedCumulative();
|
||||
}
|
||||
|
||||
void CumulativeReporterBase::listReporters(std::vector<ReporterDescription> const& descriptions) {
|
||||
defaultListReporters(stream, descriptions, m_config->verbosity());
|
||||
}
|
||||
|
||||
void CumulativeReporterBase::listTests(std::vector<TestCaseHandle> const& tests) {
|
||||
defaultListTests(stream,
|
||||
tests,
|
||||
m_config->hasTestFilters(),
|
||||
m_config->verbosity());
|
||||
}
|
||||
|
||||
void CumulativeReporterBase::listTags(std::vector<TagInfo> const& tags) {
|
||||
defaultListTags( stream, tags, m_config->hasTestFilters() );
|
||||
}
|
||||
|
||||
} // end namespace Catch
|
||||
|
@@ -69,6 +69,11 @@ namespace Catch {
|
||||
|
||||
void skipTest(TestCaseInfo const&) 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;
|
||||
|
||||
|
||||
std::ostream& stream;
|
||||
// Note: We rely on pointer identity being stable, which is why
|
||||
// which is why we store around pointers rather than values.
|
||||
|
@@ -6,6 +6,7 @@
|
||||
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
#include <catch2/reporters/catch_reporter_streaming_base.hpp>
|
||||
#include <catch2/reporters/catch_reporter_helpers.hpp>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
@@ -31,4 +32,19 @@ namespace Catch {
|
||||
currentTestRunInfo.reset();
|
||||
}
|
||||
|
||||
void StreamingReporterBase::listReporters(std::vector<ReporterDescription> const& descriptions) {
|
||||
defaultListReporters( stream, descriptions, m_config->verbosity() );
|
||||
}
|
||||
|
||||
void StreamingReporterBase::listTests(std::vector<TestCaseHandle> const& tests) {
|
||||
defaultListTests(stream,
|
||||
tests,
|
||||
m_config->hasTestFilters(),
|
||||
m_config->verbosity());
|
||||
}
|
||||
|
||||
void StreamingReporterBase::listTags(std::vector<TagInfo> const& tags) {
|
||||
defaultListTags( stream, tags, m_config->hasTestFilters() );
|
||||
}
|
||||
|
||||
} // end namespace Catch
|
||||
|
@@ -71,6 +71,10 @@ namespace Catch {
|
||||
// It can optionally be overridden in the derived class.
|
||||
}
|
||||
|
||||
void listReporters( std::vector<ReporterDescription> const& descriptions ) override;
|
||||
void listTests( std::vector<TestCaseHandle> const& tests ) override;
|
||||
void listTags( std::vector<TagInfo> const& tags ) override;
|
||||
|
||||
std::ostream& stream;
|
||||
|
||||
LazyStat<TestRunInfo> currentTestRunInfo;
|
||||
|
Reference in New Issue
Block a user