@@ -18,7 +18,9 @@ struct Output {
1818 }
1919};
2020
21- struct Reporter {
21+ struct Reporter : _impl::Factory<Reporter> {
22+ explicit Reporter (Key) {}
23+
2224 virtual ~Reporter () = default ;
2325 virtual void before_run (TestNamespace const & tests) {}
2426 virtual void after_run (std::span<TestResult> results) {}
@@ -36,31 +38,4 @@ struct Reporter {
3638
3739 virtual void finalize (Output& output) {}
3840};
39-
40- namespace _reporter_impl {
41- consteval std::string_view get_name (std::meta::info R) {
42- auto annotations = annotations_of (R, ^^annotations::Rename);
43- if (annotations.size () == 1 ) {
44- auto opt = extract<annotations::Rename>(constant_of (annotations[0 ]));
45- return opt.value ;
46- }
47- return identifier_of (R);
48- }
49- } // namespace _reporter_impl
50-
51- using ReporterDef = std::unique_ptr<Reporter> (*)();
52- std::unordered_map<std::string_view, ReporterDef>& reporter_registry ();
53-
54- template <typename T>
55- bool register_reporter () {
56- reporter_registry ()[_reporter_impl::get_name (^^T)] =
57- +[] -> std::unique_ptr<Reporter> { return std::make_unique<T>(); };
58- return true ;
59- }
60- } // namespace rsl::testing
61-
62- #define REGISTER_REPORTER (classname ) \
63- namespace { \
64- [[maybe_unused]] static bool const _reporter_registered = \
65- rsl::testing::register_reporter<classname>(); \
66- }
41+ } // namespace rsl::testing
0 commit comments