diff options
| author | Martin Hořeňovský | 2021-09-15 16:03:35 +0200 |
|---|---|---|
| committer | Martin Hořeňovský | 2021-09-15 18:08:31 +0200 |
| commit | 013edc208bb7c9f448ab122a81ce01a3ef640543 (patch) | |
| tree | 0486ba5d8cd92b912d060cef1339d1e6fe135010 /src/catch2 | |
| parent | 10fb93cce8cb878fdfe8faa118b531258db96a26 (diff) | |
| download | catch3-013edc208bb7c9f448ab122a81ce01a3ef640543.tar.gz | |
Refactor noMatchingTestCases and skipTests reporter methods
They now take `StringRef` as the argument, and are virtual only
in the basic interface.
Also cleaned out the various reporters and their overrides
of these members which were often empty or delegating up.
Diffstat (limited to 'src/catch2')
20 files changed, 34 insertions, 51 deletions
diff --git a/src/catch2/interfaces/catch_interfaces_reporter.hpp b/src/catch2/interfaces/catch_interfaces_reporter.hpp index 0056c8ad..25ad540f 100644 --- a/src/catch2/interfaces/catch_interfaces_reporter.hpp +++ b/src/catch2/interfaces/catch_interfaces_reporter.hpp @@ -171,9 +171,8 @@ namespace Catch { return m_preferences; } - virtual void noMatchingTestCases( std::string const& spec ) = 0; - - virtual void reportInvalidArguments(std::string const&) {} + virtual void noMatchingTestCases( StringRef unmatchedSpec ) = 0; + virtual void reportInvalidArguments( StringRef invalidArgument ) = 0; virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0; diff --git a/src/catch2/reporters/catch_reporter_combined_tu.cpp b/src/catch2/reporters/catch_reporter_combined_tu.cpp index dc5dc427..e5dc7e28 100644 --- a/src/catch2/reporters/catch_reporter_combined_tu.cpp +++ b/src/catch2/reporters/catch_reporter_combined_tu.cpp @@ -229,7 +229,8 @@ namespace Catch { std::vector<ReporterDescription> const& ) {} void EventListenerBase::listTests( std::vector<TestCaseHandle> const& ) {} void EventListenerBase::listTags( std::vector<TagInfo> const& ) {} - void EventListenerBase::noMatchingTestCases( std::string const& ) {} + void EventListenerBase::noMatchingTestCases( StringRef ) {} + void EventListenerBase::reportInvalidArguments( StringRef ) {} void EventListenerBase::testRunStarting( TestRunInfo const& ) {} void EventListenerBase::testCaseStarting( TestCaseInfo const& ) {} void EventListenerBase::testCasePartialStarting(TestCaseInfo const&, uint64_t) {} diff --git a/src/catch2/reporters/catch_reporter_compact.cpp b/src/catch2/reporters/catch_reporter_compact.cpp index 7a0991c9..75ec7926 100644 --- a/src/catch2/reporters/catch_reporter_compact.cpp +++ b/src/catch2/reporters/catch_reporter_compact.cpp @@ -258,8 +258,8 @@ private: return "Reports test results on a single line, suitable for IDEs"; } - void CompactReporter::noMatchingTestCases( std::string const& spec ) { - stream << "No test cases matched '" << spec << "'\n"; + void CompactReporter::noMatchingTestCases( StringRef unmatchedSpec ) { + stream << "No test cases matched '" << unmatchedSpec << "'\n"; } void CompactReporter::assertionStarting( AssertionInfo const& ) {} diff --git a/src/catch2/reporters/catch_reporter_compact.hpp b/src/catch2/reporters/catch_reporter_compact.hpp index 15f95317..d7d0a733 100644 --- a/src/catch2/reporters/catch_reporter_compact.hpp +++ b/src/catch2/reporters/catch_reporter_compact.hpp @@ -22,7 +22,7 @@ namespace Catch { static std::string getDescription(); - void noMatchingTestCases(std::string const& spec) override; + void noMatchingTestCases( StringRef unmatchedSpec ) override; void assertionStarting(AssertionInfo const&) override; diff --git a/src/catch2/reporters/catch_reporter_console.cpp b/src/catch2/reporters/catch_reporter_console.cpp index 29aedb90..ab9b6086 100644 --- a/src/catch2/reporters/catch_reporter_console.cpp +++ b/src/catch2/reporters/catch_reporter_console.cpp @@ -381,11 +381,11 @@ std::string ConsoleReporter::getDescription() { return "Reports test results as plain lines of text"; } -void ConsoleReporter::noMatchingTestCases(std::string const& spec) { - stream << "No test cases matched '" << spec << "'\n"; +void ConsoleReporter::noMatchingTestCases( StringRef unmatchedSpec ) { + stream << "No test cases matched '" << unmatchedSpec << "'\n"; } -void ConsoleReporter::reportInvalidArguments(std::string const& arg) { +void ConsoleReporter::reportInvalidArguments( StringRef arg ) { stream << "Invalid Filter: " << arg << '\n'; } diff --git a/src/catch2/reporters/catch_reporter_console.hpp b/src/catch2/reporters/catch_reporter_console.hpp index 2da939e7..ba2db495 100644 --- a/src/catch2/reporters/catch_reporter_console.hpp +++ b/src/catch2/reporters/catch_reporter_console.hpp @@ -23,9 +23,8 @@ namespace Catch { ~ConsoleReporter() override; static std::string getDescription(); - void noMatchingTestCases(std::string const& spec) override; - - void reportInvalidArguments(std::string const&arg) override; + void noMatchingTestCases( StringRef unmatchedSpec ) override; + void reportInvalidArguments( StringRef arg ) override; void assertionStarting(AssertionInfo const&) override; diff --git a/src/catch2/reporters/catch_reporter_cumulative_base.hpp b/src/catch2/reporters/catch_reporter_cumulative_base.hpp index 0c7f7def..3bbd1967 100644 --- a/src/catch2/reporters/catch_reporter_cumulative_base.hpp +++ b/src/catch2/reporters/catch_reporter_cumulative_base.hpp @@ -49,6 +49,11 @@ namespace Catch { stream( _config.stream() ) {} ~CumulativeReporterBase() override; + + void noMatchingTestCases( StringRef ) override {} + void reportInvalidArguments( StringRef ) override {} + + void testRunStarting( TestRunInfo const& ) override {} void testCaseStarting( TestCaseInfo const& ) override {} diff --git a/src/catch2/reporters/catch_reporter_event_listener.hpp b/src/catch2/reporters/catch_reporter_event_listener.hpp index 855acc43..38d94126 100644 --- a/src/catch2/reporters/catch_reporter_event_listener.hpp +++ b/src/catch2/reporters/catch_reporter_event_listener.hpp @@ -24,6 +24,8 @@ namespace Catch { EventListenerBase( ReporterConfig const& config ): IStreamingReporter( config.fullConfig() ) {} + void reportInvalidArguments( StringRef unmatchedSpec ) override; + void assertionStarting( AssertionInfo const& assertionInfo ) override; bool assertionEnded( AssertionStats const& assertionStats ) override; @@ -32,7 +34,7 @@ namespace Catch { void listTests( std::vector<TestCaseHandle> const& tests ) override; void listTags( std::vector<TagInfo> const& tagInfos ) override; - void noMatchingTestCases( std::string const& spec ) override; + void noMatchingTestCases( StringRef unmatchedSpec ) override; void testRunStarting( TestRunInfo const& testRunInfo ) override; void testCaseStarting( TestCaseInfo const& testInfo ) override; void testCasePartialStarting( TestCaseInfo const& testInfo, diff --git a/src/catch2/reporters/catch_reporter_junit.cpp b/src/catch2/reporters/catch_reporter_junit.cpp index e13d374d..4b902750 100644 --- a/src/catch2/reporters/catch_reporter_junit.cpp +++ b/src/catch2/reporters/catch_reporter_junit.cpp @@ -64,14 +64,10 @@ namespace Catch { m_preferences.shouldReportAllAssertions = true; } - JunitReporter::~JunitReporter() {} - std::string JunitReporter::getDescription() { return "Reports test results in an XML format that looks like Ant's junitreport target"; } - void JunitReporter::noMatchingTestCases( std::string const& /*spec*/ ) {} - void JunitReporter::testRunStarting( TestRunInfo const& runInfo ) { CumulativeReporterBase::testRunStarting( runInfo ); xml.startElement( "testsuites" ); diff --git a/src/catch2/reporters/catch_reporter_junit.hpp b/src/catch2/reporters/catch_reporter_junit.hpp index 752ec274..ea573d9b 100644 --- a/src/catch2/reporters/catch_reporter_junit.hpp +++ b/src/catch2/reporters/catch_reporter_junit.hpp @@ -19,12 +19,10 @@ namespace Catch { public: JunitReporter(ReporterConfig const& _config); - ~JunitReporter() override; + ~JunitReporter() override = default; static std::string getDescription(); - void noMatchingTestCases(std::string const& /*spec*/) override; - void testRunStarting(TestRunInfo const& runInfo) override; void testCaseStarting(TestCaseInfo const& testCaseInfo) override; diff --git a/src/catch2/reporters/catch_reporter_listening.cpp b/src/catch2/reporters/catch_reporter_listening.cpp index 62f6af55..82bc2086 100644 --- a/src/catch2/reporters/catch_reporter_listening.cpp +++ b/src/catch2/reporters/catch_reporter_listening.cpp @@ -22,14 +22,14 @@ namespace Catch { m_preferences.shouldRedirectStdOut = m_reporter->getPreferences().shouldRedirectStdOut; } - void ListeningReporter::noMatchingTestCases( std::string const& spec ) { + void ListeningReporter::noMatchingTestCases( StringRef unmatchedSpec ) { for ( auto& listener : m_listeners ) { - listener->noMatchingTestCases( spec ); + listener->noMatchingTestCases( unmatchedSpec ); } - m_reporter->noMatchingTestCases( spec ); + m_reporter->noMatchingTestCases( unmatchedSpec ); } - void ListeningReporter::reportInvalidArguments(std::string const&arg){ + void ListeningReporter::reportInvalidArguments( StringRef arg ) { for ( auto& listener : m_listeners ) { listener->reportInvalidArguments( arg ); } diff --git a/src/catch2/reporters/catch_reporter_listening.hpp b/src/catch2/reporters/catch_reporter_listening.hpp index 0e317653..87cb01f4 100644 --- a/src/catch2/reporters/catch_reporter_listening.hpp +++ b/src/catch2/reporters/catch_reporter_listening.hpp @@ -30,9 +30,9 @@ namespace Catch { public: // IStreamingReporter - void noMatchingTestCases( std::string const& spec ) override; + void noMatchingTestCases( StringRef unmatchedSpec ) override; - void reportInvalidArguments(std::string const&arg) override; + void reportInvalidArguments( StringRef arg ) override; void benchmarkPreparing( StringRef name ) override; void benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) override; diff --git a/src/catch2/reporters/catch_reporter_sonarqube.cpp b/src/catch2/reporters/catch_reporter_sonarqube.cpp index 25f6964c..e09b5109 100644 --- a/src/catch2/reporters/catch_reporter_sonarqube.cpp +++ b/src/catch2/reporters/catch_reporter_sonarqube.cpp @@ -14,8 +14,6 @@ namespace Catch { - SonarQubeReporter::~SonarQubeReporter() {} - void SonarQubeReporter::testRunStarting(TestRunInfo const& testRunInfo) { CumulativeReporterBase::testRunStarting(testRunInfo); xml.startElement("testExecutions"); diff --git a/src/catch2/reporters/catch_reporter_sonarqube.hpp b/src/catch2/reporters/catch_reporter_sonarqube.hpp index 81544388..a4f60ea6 100644 --- a/src/catch2/reporters/catch_reporter_sonarqube.hpp +++ b/src/catch2/reporters/catch_reporter_sonarqube.hpp @@ -23,15 +23,13 @@ namespace Catch { m_preferences.shouldReportAllAssertions = true; } - ~SonarQubeReporter() override; + ~SonarQubeReporter() override = default; static std::string getDescription() { using namespace std::string_literals; return "Reports test results in the Generic Test Data SonarQube XML format"s; } - void noMatchingTestCases(std::string const& /*spec*/) override {} - void testRunStarting( TestRunInfo const& testRunInfo ) override; void testRunEndedCumulative() override { diff --git a/src/catch2/reporters/catch_reporter_streaming_base.hpp b/src/catch2/reporters/catch_reporter_streaming_base.hpp index 3051294e..e1aa0798 100644 --- a/src/catch2/reporters/catch_reporter_streaming_base.hpp +++ b/src/catch2/reporters/catch_reporter_streaming_base.hpp @@ -42,9 +42,8 @@ namespace Catch { ~StreamingReporterBase() override; - void noMatchingTestCases(std::string const&) override {} - - void reportInvalidArguments(std::string const&) override {} + void noMatchingTestCases( StringRef /*unmatchedSpec*/ ) override {} + void reportInvalidArguments( StringRef /*invalidArgument*/ ) override {} void testRunStarting( TestRunInfo const& _testRunInfo ) override; diff --git a/src/catch2/reporters/catch_reporter_tap.cpp b/src/catch2/reporters/catch_reporter_tap.cpp index c5f83b30..4ab2394d 100644 --- a/src/catch2/reporters/catch_reporter_tap.cpp +++ b/src/catch2/reporters/catch_reporter_tap.cpp @@ -194,10 +194,8 @@ namespace Catch { } // End anonymous namespace - TAPReporter::~TAPReporter() {} - - void TAPReporter::noMatchingTestCases(std::string const& spec) { - stream << "# No test cases matched '" << spec << "'\n"; + void TAPReporter::noMatchingTestCases( StringRef unmatchedSpec ) { + stream << "# No test cases matched '" << unmatchedSpec << "'\n"; } bool TAPReporter::assertionEnded(AssertionStats const& _assertionStats) { diff --git a/src/catch2/reporters/catch_reporter_tap.hpp b/src/catch2/reporters/catch_reporter_tap.hpp index d8d3e9a4..62749869 100644 --- a/src/catch2/reporters/catch_reporter_tap.hpp +++ b/src/catch2/reporters/catch_reporter_tap.hpp @@ -18,14 +18,14 @@ namespace Catch { StreamingReporterBase( config ) { m_preferences.shouldReportAllAssertions = true; } - ~TAPReporter() override; + ~TAPReporter() override = default; static std::string getDescription() { using namespace std::string_literals; return "Reports test results in TAP format, suitable for test harnesses"s; } - void noMatchingTestCases(std::string const& spec) override; + void noMatchingTestCases( StringRef unmatchedSpec ) override; void assertionStarting( AssertionInfo const& ) override {} diff --git a/src/catch2/reporters/catch_reporter_teamcity.hpp b/src/catch2/reporters/catch_reporter_teamcity.hpp index 57297eed..ec85a671 100644 --- a/src/catch2/reporters/catch_reporter_teamcity.hpp +++ b/src/catch2/reporters/catch_reporter_teamcity.hpp @@ -34,10 +34,6 @@ namespace Catch { return "Reports test results as TeamCity service messages"s; } - void skipTest( TestCaseInfo const& /* testInfo */ ) override {} - - void noMatchingTestCases( std::string const& /* spec */ ) override {} - void testRunStarting( TestRunInfo const& groupInfo ) override; void testRunEnded( TestRunStats const& testGroupStats ) override; diff --git a/src/catch2/reporters/catch_reporter_xml.cpp b/src/catch2/reporters/catch_reporter_xml.cpp index d67c024f..f72bd867 100644 --- a/src/catch2/reporters/catch_reporter_xml.cpp +++ b/src/catch2/reporters/catch_reporter_xml.cpp @@ -46,10 +46,6 @@ namespace Catch { .writeAttribute( "line"_sr, sourceInfo.line ); } - void XmlReporter::noMatchingTestCases( std::string const& s ) { - StreamingReporterBase::noMatchingTestCases( s ); - } - void XmlReporter::testRunStarting( TestRunInfo const& testInfo ) { StreamingReporterBase::testRunStarting( testInfo ); std::string stylesheetRef = getStylesheetRef(); diff --git a/src/catch2/reporters/catch_reporter_xml.hpp b/src/catch2/reporters/catch_reporter_xml.hpp index da403536..ffe682ea 100644 --- a/src/catch2/reporters/catch_reporter_xml.hpp +++ b/src/catch2/reporters/catch_reporter_xml.hpp @@ -29,8 +29,6 @@ namespace Catch { public: // StreamingReporterBase - void noMatchingTestCases(std::string const& s) override; - void testRunStarting(TestRunInfo const& testInfo) override; void testCaseStarting(TestCaseInfo const& testInfo) override; |