diff options
| author | Martin Hořeňovský | 2021-01-26 17:53:59 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2021-01-26 18:36:54 +0100 |
| commit | 971b1fc32a857caa10eb166f39442cee5237267b (patch) | |
| tree | a4bb48202c96d1dd4b7efe83f98c2919d890d1c9 /src/catch2 | |
| parent | 6798c139a65f97ce5ed0105a2a8adb28262ef7f7 (diff) | |
| download | catch3-971b1fc32a857caa10eb166f39442cee5237267b.tar.gz | |
--list-* flags write to target specified by the -o flag
Also added tests for the default implementations of list* reporter
helpers.
Closes #2061
Diffstat (limited to 'src/catch2')
6 files changed, 44 insertions, 19 deletions
diff --git a/src/catch2/interfaces/catch_interfaces_reporter.cpp b/src/catch2/interfaces/catch_interfaces_reporter.cpp index 29fafecf..19416130 100644 --- a/src/catch2/interfaces/catch_interfaces_reporter.cpp +++ b/src/catch2/interfaces/catch_interfaces_reporter.cpp @@ -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 diff --git a/src/catch2/interfaces/catch_interfaces_reporter.hpp b/src/catch2/interfaces/catch_interfaces_reporter.hpp index 5449cc22..5a4c31a8 100644 --- a/src/catch2/interfaces/catch_interfaces_reporter.hpp +++ b/src/catch2/interfaces/catch_interfaces_reporter.hpp @@ -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>; diff --git a/src/catch2/reporters/catch_reporter_cumulative_base.cpp b/src/catch2/reporters/catch_reporter_cumulative_base.cpp index bba6f67d..a83a9ad0 100644 --- a/src/catch2/reporters/catch_reporter_cumulative_base.cpp +++ b/src/catch2/reporters/catch_reporter_cumulative_base.cpp @@ -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 diff --git a/src/catch2/reporters/catch_reporter_cumulative_base.hpp b/src/catch2/reporters/catch_reporter_cumulative_base.hpp index 0729567c..2820e9f6 100644 --- a/src/catch2/reporters/catch_reporter_cumulative_base.hpp +++ b/src/catch2/reporters/catch_reporter_cumulative_base.hpp @@ -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. diff --git a/src/catch2/reporters/catch_reporter_streaming_base.cpp b/src/catch2/reporters/catch_reporter_streaming_base.cpp index e4bbb261..d0b8ae94 100644 --- a/src/catch2/reporters/catch_reporter_streaming_base.cpp +++ b/src/catch2/reporters/catch_reporter_streaming_base.cpp @@ -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 diff --git a/src/catch2/reporters/catch_reporter_streaming_base.hpp b/src/catch2/reporters/catch_reporter_streaming_base.hpp index ebf06385..b0f1dd49 100644 --- a/src/catch2/reporters/catch_reporter_streaming_base.hpp +++ b/src/catch2/reporters/catch_reporter_streaming_base.hpp @@ -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; |