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

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2
diff options
context:
space:
mode:
authorMartin Hořeňovský2026-02-16 22:51:27 +0100
committerMartin Hořeňovský2026-02-16 22:52:39 +0100
commita404f37cec56e6ff161db9b26cfb1e77de3bc1e0 (patch)
treef7ac16c38b4ee532cc022d47a46d3eb69408147a /src/catch2
parent29c9844f688acb27c87338c39cd186ebfe41aa19 (diff)
downloadcatch3-a404f37cec56e6ff161db9b26cfb1e77de3bc1e0.tar.gz
Add quiet verbosity variant to the default listener and tag listing
Diffstat (limited to 'src/catch2')
-rw-r--r--src/catch2/reporters/catch_reporter_common_base.cpp6
-rw-r--r--src/catch2/reporters/catch_reporter_helpers.cpp21
-rw-r--r--src/catch2/reporters/catch_reporter_helpers.hpp8
3 files changed, 27 insertions, 8 deletions
diff --git a/src/catch2/reporters/catch_reporter_common_base.cpp b/src/catch2/reporters/catch_reporter_common_base.cpp
index a1ca76a0..0a3671e1 100644
--- a/src/catch2/reporters/catch_reporter_common_base.cpp
+++ b/src/catch2/reporters/catch_reporter_common_base.cpp
@@ -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
diff --git a/src/catch2/reporters/catch_reporter_helpers.cpp b/src/catch2/reporters/catch_reporter_helpers.cpp
index c710ac43..6fa68a3c 100644
--- a/src/catch2/reporters/catch_reporter_helpers.cpp
+++ b/src/catch2/reporters/catch_reporter_helpers.cpp
@@ -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 ) );
diff --git a/src/catch2/reporters/catch_reporter_helpers.hpp b/src/catch2/reporters/catch_reporter_helpers.hpp
index 316cb404..46988888 100644
--- a/src/catch2/reporters/catch_reporter_helpers.hpp
+++ b/src/catch2/reporters/catch_reporter_helpers.hpp
@@ -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