Add quiet verbosity variant to the default listener and tag listing

This commit is contained in:
Martin Hořeňovský committed 2026-02-16 22:52:39 +01:00
1 parent 29c9844f68
commit a404f37cec
5 files changed
+32 -12

No files matched your search

@@ -26,12 +26,12 @@ namespace Catch {
void ReporterBase::listReporters(
std::vector<ReporterDescription> const& descriptions ) {
defaultListReporters(m_stream, descriptions, m_config->verbosity());
defaultListReporters( m_stream, descriptions, m_config->verbosity() );
}
void ReporterBase::listListeners(
std::vector<ListenerDescription> const& descriptions ) {
defaultListListeners( m_stream, descriptions );
defaultListListeners( m_stream, descriptions, m_config->verbosity() );
}
void ReporterBase::listTests(std::vector<TestCaseHandle> const& tests) {
@@ -43,7 +43,7 @@ namespace Catch {
}
void ReporterBase::listTags(std::vector<TagInfo> const& tags) {
defaultListTags( m_stream, tags, m_config->hasTestFilters() );
defaultListTags( m_stream, tags, m_config->hasTestFilters(), m_config->verbosity() );
}
} // namespace Catch
@@ -143,7 +143,15 @@ namespace Catch {
}
void defaultListListeners( std::ostream& out,
std::vector<ListenerDescription> const& descriptions ) {
std::vector<ListenerDescription> const& descriptions,
Verbosity verbosity ) {
if ( verbosity == Verbosity::Quiet ) {
for ( auto const& desc : descriptions ) {
out << desc.name << '\n';
}
return;
}
out << "Registered listeners:\n";
if(descriptions.empty()) {
@@ -176,7 +184,14 @@ namespace Catch {
void defaultListTags( std::ostream& out,
std::vector<TagInfo> const& tags,
bool isFiltered ) {
bool isFiltered,
Verbosity verbosity ) {
if (verbosity == Verbosity::Quiet) {
for (auto const& tagCount : tags) {
out << tagCount.all() << '\n';
}
return;
}
if ( isFiltered ) {
out << "Tags for matching test cases:\n";
} else {
@@ -195,7 +210,7 @@ namespace Catch {
return lhs.count < rhs.count;
} )
->count;
// more padding necessary for 3+ digits
if (maxTagCount >= 100) {
auto numDigits = 1 + std::floor( std::log10( maxTagCount ) );
@@ -55,7 +55,8 @@ namespace Catch {
* format
*/
void defaultListListeners( std::ostream& out,
std::vector<ListenerDescription> const& descriptions );
std::vector<ListenerDescription> const& descriptions,
Verbosity verbosity );
/**
* Lists tag information to the provided stream in user-friendly format
@@ -64,7 +65,10 @@ namespace Catch {
* bases. The output should be backwards compatible with the output of
* Catch2 v2 binaries.
*/
void defaultListTags( std::ostream& out, std::vector<TagInfo> const& tags, bool isFiltered );
void defaultListTags( std::ostream& out,
std::vector<TagInfo> const& tags,
bool isFiltered,
Verbosity verbosity );
/**
* Lists test case information to the provided stream in user-friendly