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-13 15:15:23 +01:00
parent 602e484f02
commit 9f2dca5384
No known key found for this signature in database
GPG key ID: DE48307B8B0D381A
11 changed files with 86 additions and 51 deletions

View file

@ -24,21 +24,14 @@ namespace Catch {
using namespace Clara;
auto const setWarning = [&]( std::string const& warning ) {
auto warningSet = [&]() {
if( warning == "NoAssertions" )
return WarnAbout::NoAssertions;
if ( warning == "NoTests" )
return WarnAbout::NoTests;
return WarnAbout::Nothing;
}();
if (warningSet == WarnAbout::Nothing)
return ParserResult::runtimeError( "Unrecognised warning: '" + warning + '\'' );
config.warnings = static_cast<WarnAbout::What>( config.warnings | warningSet );
if ( warning == "NoAssertions" ) {
config.warnings = WarnAbout::NoAssertions;
return ParserResult::ok( ParseResultType::Matched );
};
}
return ParserResult ::runtimeError(
"Unrecognised warning option: '" + warning + '\'' );
};
auto const loadTestNamesFromFile = [&]( std::string const& filename ) {
std::ifstream f( filename.c_str() );
if( !f.is_open() )
@ -280,7 +273,10 @@ namespace Catch {
( "split the tests to execute into this many groups" )
| Opt( setShardIndex, "shard index" )
["--shard-index"]
( "index of the group of tests to execute (see --shard-count)" )
( "index of the group of tests to execute (see --shard-count)" ) |
Opt( config.allowZeroTests )
["--allow-running-no-tests"]
( "Treat 'No tests run' as a success" )
| Arg( config.testsOrTags, "test name|pattern|tags" )
( "which test or tests to use" );