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

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2/internal
diff options
context:
space:
mode:
authorMartin Hořeňovský2022-05-10 20:00:36 +0200
committerMartin Hořeňovský2022-05-10 20:57:59 +0200
commit5a49285e9cf203dd20b00ac7488a6a3233d60fff (patch)
tree0a232d7ec81e8f34d37d7fbbe7ccc2f212671eb2 /src/catch2/internal
parentae475a3c19e9b770e66ea3a2ce3eaa2debecd4c6 (diff)
downloadcatch3-5a49285e9cf203dd20b00ac7488a6a3233d60fff.tar.gz
Add --list-listeners option
Diffstat (limited to 'src/catch2/internal')
-rw-r--r--src/catch2/internal/catch_commandline.cpp5
-rw-r--r--src/catch2/internal/catch_list.cpp17
-rw-r--r--src/catch2/internal/catch_list.hpp4
3 files changed, 25 insertions, 1 deletions
diff --git a/src/catch2/internal/catch_commandline.cpp b/src/catch2/internal/catch_commandline.cpp
index f2f638bc..fda4b2bd 100644
--- a/src/catch2/internal/catch_commandline.cpp
+++ b/src/catch2/internal/catch_commandline.cpp
@@ -280,7 +280,10 @@ namespace Catch {
( "list all/matching tags" )
| Opt( config.listReporters )
["--list-reporters"]
- ( "list all reporters" )
+ ( "list all available reporters" )
+ | Opt( config.listListeners )
+ ["--list-listeners"]
+ ( "list all listeners" )
| Opt( setTestOrder, "decl|lex|rand" )
["--order"]
( "test case order (defaults to decl)" )
diff --git a/src/catch2/internal/catch_list.cpp b/src/catch2/internal/catch_list.cpp
index 609d459c..2c22745c 100644
--- a/src/catch2/internal/catch_list.cpp
+++ b/src/catch2/internal/catch_list.cpp
@@ -63,6 +63,19 @@ namespace Catch {
reporter.listReporters(descriptions);
}
+ void listListeners(IEventListener& reporter) {
+ std::vector<ListenerDescription> descriptions;
+
+ auto const& factories =
+ getRegistryHub().getReporterRegistry().getListeners();
+ descriptions.reserve( factories.size() );
+ for ( auto const& fac : factories ) {
+ descriptions.push_back( { fac->getName(), fac->getDescription() } );
+ }
+
+ reporter.listListeners( descriptions );
+ }
+
} // end anonymous namespace
void TagInfo::add( StringRef spelling ) {
@@ -100,6 +113,10 @@ namespace Catch {
listed = true;
listReporters(reporter);
}
+ if ( config.listListeners() ) {
+ listed = true;
+ listListeners( reporter );
+ }
return listed;
}
diff --git a/src/catch2/internal/catch_list.hpp b/src/catch2/internal/catch_list.hpp
index 9caf4cf6..6fd759ea 100644
--- a/src/catch2/internal/catch_list.hpp
+++ b/src/catch2/internal/catch_list.hpp
@@ -23,6 +23,10 @@ namespace Catch {
struct ReporterDescription {
std::string name, description;
};
+ struct ListenerDescription {
+ StringRef name;
+ std::string description;
+ };
struct TagInfo {
void add(StringRef spelling);