diff options
| author | Martin Hořeňovský | 2021-12-18 19:59:23 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2021-12-18 20:50:03 +0100 |
| commit | 840acedf62b2dabb98bf4ab372a7582131d6b530 (patch) | |
| tree | 2246182676b827884962a1a62ed216a14de0d992 /src/catch2/catch_session.cpp | |
| parent | 9f2dca5384a6a8f9f37a7dc2d998cac616545592 (diff) | |
| download | catch3-840acedf62b2dabb98bf4ab372a7582131d6b530.tar.gz | |
Implement warning for unmatched test specs
Diffstat (limited to 'src/catch2/catch_session.cpp')
| -rw-r--r-- | src/catch2/catch_session.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/catch2/catch_session.cpp b/src/catch2/catch_session.cpp index 647dcfa3..38111fe8 100644 --- a/src/catch2/catch_session.cpp +++ b/src/catch2/catch_session.cpp @@ -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; |