mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 12:55:40 +02:00
Config refactoring: split List enum into three bools
This commit is contained in:
@@ -317,7 +317,7 @@ namespace Catch {
|
||||
|
||||
class ListOptionParser : public OptionParser {
|
||||
public:
|
||||
ListOptionParser() : OptionParser( 0, 2 ) {
|
||||
ListOptionParser() : OptionParser( 0, 1 ) {
|
||||
m_optionNames.push_back( "-l" );
|
||||
m_optionNames.push_back( "--list" );
|
||||
}
|
||||
@@ -346,27 +346,21 @@ namespace Catch {
|
||||
}
|
||||
|
||||
virtual void parseIntoConfig( Command const& cmd, ConfigData& config ) {
|
||||
config.listSpec = List::Tests;
|
||||
if( cmd.argsCount() >= 1 ) {
|
||||
if( cmd[0] == "all" )
|
||||
config.listSpec = List::All;
|
||||
if( cmd[0] == "all" ) {
|
||||
config.listTests = true;
|
||||
config.listTags = true;
|
||||
config.listReporters = true;
|
||||
}
|
||||
else if( cmd[0] == "tests" )
|
||||
config.listSpec = List::Tests;
|
||||
config.listTests = true;
|
||||
else if( cmd[0] == "tags" )
|
||||
config.listSpec = List::Tags;
|
||||
config.listTags = true;
|
||||
else if( cmd[0] == "reporters" )
|
||||
config.listSpec = List::Reports;
|
||||
config.listReporters = true;
|
||||
else
|
||||
cmd.raiseError( "Expected tests, reporters or tags" );
|
||||
}
|
||||
if( cmd.argsCount() >= 2 ) {
|
||||
if( cmd[1] == "xml" )
|
||||
config.listSpec = static_cast<List::What>( config.listSpec | List::AsXml );
|
||||
else if( cmd[1] == "text" )
|
||||
config.listSpec = static_cast<List::What>( config.listSpec | List::AsText );
|
||||
else
|
||||
cmd.raiseError( "Expected xml or text" );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -23,27 +23,6 @@
|
||||
#endif
|
||||
|
||||
namespace Catch {
|
||||
|
||||
struct Include { enum WhichResults {
|
||||
FailedOnly,
|
||||
SuccessfulResults
|
||||
}; };
|
||||
|
||||
struct List{ enum What {
|
||||
None = 0,
|
||||
|
||||
Reports = 1,
|
||||
Tests = 2,
|
||||
Tags = 4,
|
||||
All = Reports | Tests | Tags,
|
||||
|
||||
WhatMask = 0xf,
|
||||
|
||||
AsText = 0x10,
|
||||
AsXml = 0x20,
|
||||
|
||||
AsMask = 0xf0
|
||||
}; };
|
||||
|
||||
struct ConfigData {
|
||||
|
||||
@@ -52,13 +31,16 @@ namespace Catch {
|
||||
Quiet,
|
||||
Normal
|
||||
}; };
|
||||
|
||||
struct WarnAbout { enum What {
|
||||
Nothing = 0x00,
|
||||
NoAssertions = 0x01
|
||||
}; };
|
||||
|
||||
ConfigData()
|
||||
: listSpec( List::None ),
|
||||
: listTests( false ),
|
||||
listTags( false ),
|
||||
listReporters( false ),
|
||||
showSuccessfulTests( false ),
|
||||
shouldDebugBreak( false ),
|
||||
noThrow( false ),
|
||||
@@ -66,7 +48,9 @@ namespace Catch {
|
||||
warnings( WarnAbout::Nothing )
|
||||
{}
|
||||
|
||||
List::What listSpec; // !TBD Split into bools
|
||||
bool listTests;
|
||||
bool listTags;
|
||||
bool listReporters;
|
||||
bool showSuccessfulTests;
|
||||
bool shouldDebugBreak;
|
||||
bool noThrow;
|
||||
@@ -117,9 +101,9 @@ namespace Catch {
|
||||
return m_data.outputFilename ;
|
||||
}
|
||||
|
||||
bool listTests() const { return m_data.listSpec & List::Tests; }
|
||||
bool listTags() const { return m_data.listSpec & List::Tags; }
|
||||
bool listReporters() const { return m_data.listSpec & List::Reports; }
|
||||
bool listTests() const { return m_data.listTests; }
|
||||
bool listTags() const { return m_data.listTags; }
|
||||
bool listReporters() const { return m_data.listReporters; }
|
||||
|
||||
std::string getName() const {
|
||||
return m_data.name;
|
||||
|
Reference in New Issue
Block a user