Implement warning for unmatched test specs

This commit is contained in:
Martin Hořeňovský
2021-12-18 20:50:03 +01:00
parent 9f2dca5384
commit 840acedf62
8 changed files with 54 additions and 6 deletions
+13 -2
View File
@@ -96,20 +96,26 @@ namespace Catch {
for (auto const& match : m_matches) {
if (match.tests.empty()) {
m_reporter->noMatchingTestCases(match.name);
totals.error = -1;
m_unmatchedTestSpecs = true;
m_reporter->noMatchingTestCases( match.name );
}
}
return totals;
}
bool hadUnmatchedTestSpecs() const {
return m_unmatchedTestSpecs;
}
private:
IStreamingReporter* m_reporter;
Config const* m_config;
RunContext m_context;
std::set<TestCaseHandle const*> m_tests;
TestSpec::Matches m_matches;
bool m_unmatchedTestSpecs = false;
};
void applyFilenamesAsTags() {
@@ -301,6 +307,11 @@ namespace Catch {
TestGroup tests { CATCH_MOVE(reporter), m_config.get() };
auto const totals = tests.execute();
if ( tests.hadUnmatchedTestSpecs()
&& m_config->warnAboutUnmatchedTestSpecs() ) {
return 3;
}
if ( totals.testCases.total() == 0
&& !m_config->zeroTestsCountAsSuccess() ) {
return 2;