Exit with non-0 return code if no tests were run

A new flag, `--allow-running-no-tests` was added to override this
behaviour if exit code of 0 was desired.

This change also made `-w NoTests` obsolete, and so it has been
removed.
This commit is contained in:
Martin Hořeňovský
2021-12-18 20:50:00 +01:00
parent 602e484f02
commit 9f2dca5384
11 changed files with 86 additions and 51 deletions
+4 -4
View File
@@ -105,12 +105,10 @@ namespace Catch {
}
private:
using Tests = std::set<TestCaseHandle const*>;
IStreamingReporter* m_reporter;
Config const* m_config;
RunContext m_context;
Tests m_tests;
std::set<TestCaseHandle const*> m_tests;
TestSpec::Matches m_matches;
};
@@ -303,8 +301,10 @@ namespace Catch {
TestGroup tests { CATCH_MOVE(reporter), m_config.get() };
auto const totals = tests.execute();
if( m_config->warnAboutNoTests() && totals.error == -1 )
if ( totals.testCases.total() == 0
&& !m_config->zeroTestsCountAsSuccess() ) {
return 2;
}
// Note that on unices only the lower 8 bits are usually used, clamping
// the return value to 255 prevents false negative when some multiple