From 7542685a2f53f9cb54013517884755b879759f8c Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Tue, 12 Mar 2013 19:06:40 +0000 Subject: [PATCH] Moved "no test cases matched" message to reporter --- include/catch_runner.hpp | 2 +- include/internal/catch_interfaces_reporter.h | 5 +++++ include/reporters/catch_reporter_console.hpp | 4 ++++ projects/SelfTest/catch_self_test.hpp | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/catch_runner.hpp b/include/catch_runner.hpp index 0b2fad79..edceeccb 100644 --- a/include/catch_runner.hpp +++ b/include/catch_runner.hpp @@ -70,7 +70,7 @@ namespace Catch { } } if( testsRunForGroup == 0 && !filterGroup.getName().empty() ) - std::cerr << "\n[No test cases matched with: " << filterGroup.getName() << "]" << std::endl; + m_reporter->noMatchingTestCases( filterGroup.getName() ); return totals; } diff --git a/include/internal/catch_interfaces_reporter.h b/include/internal/catch_interfaces_reporter.h index 8fa7cf1a..2b3be789 100644 --- a/include/internal/catch_interfaces_reporter.h +++ b/include/internal/catch_interfaces_reporter.h @@ -197,6 +197,8 @@ namespace Catch // static std::string getDescription(); virtual ReporterPreferences getPreferences() const = 0; + + virtual void noMatchingTestCases( std::string const& spec ) = 0; virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0; virtual void testGroupStarting( GroupInfo const& groupInfo ) = 0; @@ -221,6 +223,8 @@ namespace Catch {} virtual ~StreamingReporterBase(); + + virtual void noMatchingTestCases( std::string const& ) {} virtual void testRunStarting( TestRunInfo const& _testRunInfo ) { testRunInfo = _testRunInfo; @@ -390,6 +394,7 @@ namespace Catch return prefs; } + virtual void noMatchingTestCases( std::string const& ) {} virtual void testRunStarting( TestRunInfo const& ) { m_legacyReporter->StartTesting(); } diff --git a/include/reporters/catch_reporter_console.hpp b/include/reporters/catch_reporter_console.hpp index a9b88fbe..3f0c770c 100644 --- a/include/reporters/catch_reporter_console.hpp +++ b/include/reporters/catch_reporter_console.hpp @@ -31,6 +31,10 @@ namespace Catch { return prefs; } + + virtual void noMatchingTestCases( std::string const& spec ) { + stream << "No test cases matched '" << spec << "'" << std::endl; + } virtual void assertionStarting( AssertionInfo const& ) { } diff --git a/projects/SelfTest/catch_self_test.hpp b/projects/SelfTest/catch_self_test.hpp index 44293e0c..a5c7e812 100644 --- a/projects/SelfTest/catch_self_test.hpp +++ b/projects/SelfTest/catch_self_test.hpp @@ -35,6 +35,7 @@ namespace Catch { return ReporterPreferences(); } + virtual void noMatchingTestCases( std::string const& ) {} virtual void testRunStarting( TestRunInfo const& ) {} virtual void testGroupStarting( GroupInfo const& ) {} virtual void testCaseStarting( TestCaseInfo const& ) {}