From c2ca80d9fb4d06e2893942bd061613115ade6bae Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Wed, 29 May 2013 18:42:46 +0100 Subject: [PATCH] Config refactoring: split List enum into three bools --- include/internal/catch_commandline.hpp | 24 ++- include/internal/catch_config.hpp | 36 ++--- .../SelfTest/Baselines/approvedResults.txt | 140 +++++++++--------- projects/SelfTest/CmdLineTests.cpp | 1 + 4 files changed, 90 insertions(+), 111 deletions(-) diff --git a/include/internal/catch_commandline.hpp b/include/internal/catch_commandline.hpp index 2eda8912..e0cccd70 100644 --- a/include/internal/catch_commandline.hpp +++ b/include/internal/catch_commandline.hpp @@ -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( config.listSpec | List::AsXml ); - else if( cmd[1] == "text" ) - config.listSpec = static_cast( config.listSpec | List::AsText ); - else - cmd.raiseError( "Expected xml or text" ); - } } }; diff --git a/include/internal/catch_config.hpp b/include/internal/catch_config.hpp index 141ac437..9472a422 100644 --- a/include/internal/catch_config.hpp +++ b/include/internal/catch_config.hpp @@ -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; diff --git a/projects/SelfTest/Baselines/approvedResults.txt b/projects/SelfTest/Baselines/approvedResults.txt index d599d648..08eda83f 100644 --- a/projects/SelfTest/Baselines/approvedResults.txt +++ b/projects/SelfTest/Baselines/approvedResults.txt @@ -5762,7 +5762,7 @@ Scenario: New Catch commandline interface When: We ask for usage strings Then: It prints the usage strings ------------------------------------------------------------------------------- -CmdLineTests.cpp:323 +CmdLineTests.cpp:324 ............................................................................... @@ -5773,22 +5773,22 @@ Scenario: New Catch commandline interface Given: A built cli parser for Catch When: Multiple flags are combined ------------------------------------------------------------------------------- -CmdLineTests.cpp:328 +CmdLineTests.cpp:329 ............................................................................... -CmdLineTests.cpp:330: +CmdLineTests.cpp:331: PASSED: CHECK_FALSE( config.showSuccessfulTests ) with expansion: !false -CmdLineTests.cpp:331: +CmdLineTests.cpp:332: PASSED: CHECK_FALSE( config.noThrow ) with expansion: !false -CmdLineTests.cpp:332: +CmdLineTests.cpp:333: PASSED: CHECK_FALSE( config.breakIntoDebugger ) with expansion: @@ -5800,22 +5800,22 @@ Scenario: New Catch commandline interface When: Multiple flags are combined Then: All the flags are set ------------------------------------------------------------------------------- -CmdLineTests.cpp:337 +CmdLineTests.cpp:338 ............................................................................... -CmdLineTests.cpp:338: +CmdLineTests.cpp:339: PASSED: CHECK( config.showSuccessfulTests ) with expansion: true -CmdLineTests.cpp:339: +CmdLineTests.cpp:340: PASSED: CHECK( config.noThrow ) with expansion: true -CmdLineTests.cpp:340: +CmdLineTests.cpp:341: PASSED: CHECK( config.breakIntoDebugger ) with expansion: @@ -5826,22 +5826,22 @@ Scenario: New Catch commandline interface Given: A built cli parser for Catch When: Multiple flags are combined ------------------------------------------------------------------------------- -CmdLineTests.cpp:328 +CmdLineTests.cpp:329 ............................................................................... -CmdLineTests.cpp:330: +CmdLineTests.cpp:331: PASSED: CHECK_FALSE( config.showSuccessfulTests ) with expansion: !false -CmdLineTests.cpp:331: +CmdLineTests.cpp:332: PASSED: CHECK_FALSE( config.noThrow ) with expansion: !false -CmdLineTests.cpp:332: +CmdLineTests.cpp:333: PASSED: CHECK_FALSE( config.breakIntoDebugger ) with expansion: @@ -5852,10 +5852,10 @@ Scenario: New Catch commandline interface Given: A built cli parser for Catch When: A flag is set via a nullary method ------------------------------------------------------------------------------- -CmdLineTests.cpp:343 +CmdLineTests.cpp:344 ............................................................................... -CmdLineTests.cpp:344: +CmdLineTests.cpp:345: PASSED: CHECK( config.abortAfter == 0 ) with expansion: @@ -5867,10 +5867,10 @@ Scenario: New Catch commandline interface When: A flag is set via a nullary method Then: The flag is set ------------------------------------------------------------------------------- -CmdLineTests.cpp:349 +CmdLineTests.cpp:350 ............................................................................... -CmdLineTests.cpp:350: +CmdLineTests.cpp:351: PASSED: REQUIRE( config.abortAfter == 1 ) with expansion: @@ -5881,10 +5881,10 @@ Scenario: New Catch commandline interface Given: A built cli parser for Catch When: A flag is set via a nullary method ------------------------------------------------------------------------------- -CmdLineTests.cpp:343 +CmdLineTests.cpp:344 ............................................................................... -CmdLineTests.cpp:344: +CmdLineTests.cpp:345: PASSED: CHECK( config.abortAfter == 0 ) with expansion: @@ -5895,10 +5895,10 @@ Scenario: New Catch commandline interface Given: A built cli parser for Catch When: A flag is set via a unary method ------------------------------------------------------------------------------- -CmdLineTests.cpp:352 +CmdLineTests.cpp:353 ............................................................................... -CmdLineTests.cpp:353: +CmdLineTests.cpp:354: PASSED: CHECK( config.abortAfter == 0 ) with expansion: @@ -5910,10 +5910,10 @@ Scenario: New Catch commandline interface When: A flag is set via a unary method Then: The flag is set ------------------------------------------------------------------------------- -CmdLineTests.cpp:358 +CmdLineTests.cpp:359 ............................................................................... -CmdLineTests.cpp:359: +CmdLineTests.cpp:360: PASSED: REQUIRE( config.abortAfter == 2 ) with expansion: @@ -5924,10 +5924,10 @@ Scenario: New Catch commandline interface Given: A built cli parser for Catch When: A flag is set via a unary method ------------------------------------------------------------------------------- -CmdLineTests.cpp:352 +CmdLineTests.cpp:353 ............................................................................... -CmdLineTests.cpp:353: +CmdLineTests.cpp:354: PASSED: CHECK( config.abortAfter == 0 ) with expansion: @@ -5939,16 +5939,16 @@ Scenario: New Catch commandline interface When: A positional argument is supplied Then: The argument is in the testOrTags collection ------------------------------------------------------------------------------- -CmdLineTests.cpp:366 +CmdLineTests.cpp:367 ............................................................................... -CmdLineTests.cpp:367: +CmdLineTests.cpp:368: PASSED: REQUIRE( config.testsOrTags.size() == 1 ) with expansion: 1 == 1 -CmdLineTests.cpp:368: +CmdLineTests.cpp:369: PASSED: REQUIRE( config.testsOrTags[0] == "[hello]" ) with expansion: @@ -5959,10 +5959,10 @@ Scenario: New Catch commandline interface Given: A built cli parser for Catch When: And enum opt is set by numeric value ------------------------------------------------------------------------------- -CmdLineTests.cpp:371 +CmdLineTests.cpp:372 ............................................................................... -CmdLineTests.cpp:372: +CmdLineTests.cpp:373: PASSED: CHECK( config.verbosity == Config::Verbosity::Normal ) with expansion: @@ -5974,10 +5974,10 @@ Scenario: New Catch commandline interface When: And enum opt is set by numeric value Then: The member is set to the enum value ------------------------------------------------------------------------------- -CmdLineTests.cpp:377 +CmdLineTests.cpp:378 ............................................................................... -CmdLineTests.cpp:378: +CmdLineTests.cpp:379: PASSED: REQUIRE( config.verbosity == Config::Verbosity::NoOutput ) with expansion: @@ -13012,7 +13012,7 @@ CmdLineTests.cpp" line="179">
-CmdLineTests.cpp" line="330"> +CmdLineTests.cpp" line="331"> !config.showSuccessfulTests @@ -13020,7 +13020,7 @@ CmdLineTests.cpp" line="330"> !false -CmdLineTests.cpp" line="331"> +CmdLineTests.cpp" line="332"> !config.noThrow @@ -13028,7 +13028,7 @@ CmdLineTests.cpp" line="331"> !false -CmdLineTests.cpp" line="332"> +CmdLineTests.cpp" line="333"> !config.breakIntoDebugger @@ -13037,7 +13037,7 @@ CmdLineTests.cpp" line="332">
-CmdLineTests.cpp" line="338"> +CmdLineTests.cpp" line="339"> config.showSuccessfulTests @@ -13045,7 +13045,7 @@ CmdLineTests.cpp" line="338"> true -CmdLineTests.cpp" line="339"> +CmdLineTests.cpp" line="340"> config.noThrow @@ -13053,7 +13053,7 @@ CmdLineTests.cpp" line="339"> true -CmdLineTests.cpp" line="340"> +CmdLineTests.cpp" line="341"> config.breakIntoDebugger @@ -13069,7 +13069,7 @@ CmdLineTests.cpp" line="340">
-CmdLineTests.cpp" line="330"> +CmdLineTests.cpp" line="331"> !config.showSuccessfulTests @@ -13077,7 +13077,7 @@ CmdLineTests.cpp" line="330"> !false -CmdLineTests.cpp" line="331"> +CmdLineTests.cpp" line="332"> !config.noThrow @@ -13085,7 +13085,7 @@ CmdLineTests.cpp" line="331"> !false -CmdLineTests.cpp" line="332"> +CmdLineTests.cpp" line="333"> !config.breakIntoDebugger @@ -13099,7 +13099,7 @@ CmdLineTests.cpp" line="332">
-CmdLineTests.cpp" line="344"> +CmdLineTests.cpp" line="345"> config.abortAfter == 0 @@ -13108,7 +13108,7 @@ CmdLineTests.cpp" line="344">
-CmdLineTests.cpp" line="350"> +CmdLineTests.cpp" line="351"> config.abortAfter == 1 @@ -13124,7 +13124,7 @@ CmdLineTests.cpp" line="350">
-CmdLineTests.cpp" line="344"> +CmdLineTests.cpp" line="345"> config.abortAfter == 0 @@ -13138,7 +13138,7 @@ CmdLineTests.cpp" line="344">
-CmdLineTests.cpp" line="353"> +CmdLineTests.cpp" line="354"> config.abortAfter == 0 @@ -13147,7 +13147,7 @@ CmdLineTests.cpp" line="353">
-CmdLineTests.cpp" line="359"> +CmdLineTests.cpp" line="360"> config.abortAfter == 2 @@ -13163,7 +13163,7 @@ CmdLineTests.cpp" line="359">
-CmdLineTests.cpp" line="353"> +CmdLineTests.cpp" line="354"> config.abortAfter == 0 @@ -13178,7 +13178,7 @@ CmdLineTests.cpp" line="353">
-CmdLineTests.cpp" line="367"> +CmdLineTests.cpp" line="368"> config.testsOrTags.size() == 1 @@ -13186,7 +13186,7 @@ CmdLineTests.cpp" line="367"> 1 == 1 -CmdLineTests.cpp" line="368"> +CmdLineTests.cpp" line="369"> config.testsOrTags[0] == "[hello]" @@ -13208,7 +13208,7 @@ CmdLineTests.cpp" line="368">
-CmdLineTests.cpp" line="372"> +CmdLineTests.cpp" line="373"> config.verbosity == Config::Verbosity::Normal @@ -13217,7 +13217,7 @@ CmdLineTests.cpp" line="372">
-CmdLineTests.cpp" line="378"> +CmdLineTests.cpp" line="379"> config.verbosity == Config::Verbosity::NoOutput @@ -15192,13 +15192,13 @@ No assertions in section, ' Then: It prints the usage strings' [Started section: ' Given: A built cli parser for Catch'] [Started section: ' When: Multiple flags are combined'] -CmdLineTests.cpp:330: !config.showSuccessfulTests succeeded for: !false -CmdLineTests.cpp:331: !config.noThrow succeeded for: !false -CmdLineTests.cpp:332: !config.breakIntoDebugger succeeded for: !false +CmdLineTests.cpp:331: !config.showSuccessfulTests succeeded for: !false +CmdLineTests.cpp:332: !config.noThrow succeeded for: !false +CmdLineTests.cpp:333: !config.breakIntoDebugger succeeded for: !false [Started section: ' Then: All the flags are set'] -CmdLineTests.cpp:338: config.showSuccessfulTests succeeded for: true -CmdLineTests.cpp:339: config.noThrow succeeded for: true -CmdLineTests.cpp:340: config.breakIntoDebugger succeeded for: true +CmdLineTests.cpp:339: config.showSuccessfulTests succeeded for: true +CmdLineTests.cpp:340: config.noThrow succeeded for: true +CmdLineTests.cpp:341: config.breakIntoDebugger succeeded for: true [End of section: ' Then: All the flags are set' All 3 assertions passed] [End of section: ' When: Multiple flags are combined' All 6 assertions passed] @@ -15207,18 +15207,18 @@ CmdLineTests.cpp:340: config.breakIntoDebugger succeeded for: true [Started section: ' Given: A built cli parser for Catch'] [Started section: ' When: Multiple flags are combined'] -CmdLineTests.cpp:330: !config.showSuccessfulTests succeeded for: !false -CmdLineTests.cpp:331: !config.noThrow succeeded for: !false -CmdLineTests.cpp:332: !config.breakIntoDebugger succeeded for: !false +CmdLineTests.cpp:331: !config.showSuccessfulTests succeeded for: !false +CmdLineTests.cpp:332: !config.noThrow succeeded for: !false +CmdLineTests.cpp:333: !config.breakIntoDebugger succeeded for: !false [End of section: ' When: Multiple flags are combined' All 3 assertions passed] [End of section: ' Given: A built cli parser for Catch' All 3 assertions passed] [Started section: ' Given: A built cli parser for Catch'] [Started section: ' When: A flag is set via a nullary method'] -CmdLineTests.cpp:344: config.abortAfter == 0 succeeded for: 0 == 0 +CmdLineTests.cpp:345: config.abortAfter == 0 succeeded for: 0 == 0 [Started section: ' Then: The flag is set'] -CmdLineTests.cpp:350: config.abortAfter == 1 succeeded for: 1 == 1 +CmdLineTests.cpp:351: config.abortAfter == 1 succeeded for: 1 == 1 [End of section: ' Then: The flag is set' 1 assertion passed] [End of section: ' When: A flag is set via a nullary method' All 2 assertions passed] @@ -15227,16 +15227,16 @@ CmdLineTests.cpp:350: config.abortAfter == 1 succeeded for: 1 == 1 [Started section: ' Given: A built cli parser for Catch'] [Started section: ' When: A flag is set via a nullary method'] -CmdLineTests.cpp:344: config.abortAfter == 0 succeeded for: 0 == 0 +CmdLineTests.cpp:345: config.abortAfter == 0 succeeded for: 0 == 0 [End of section: ' When: A flag is set via a nullary method' 1 assertion passed] [End of section: ' Given: A built cli parser for Catch' 1 assertion passed] [Started section: ' Given: A built cli parser for Catch'] [Started section: ' When: A flag is set via a unary method'] -CmdLineTests.cpp:353: config.abortAfter == 0 succeeded for: 0 == 0 +CmdLineTests.cpp:354: config.abortAfter == 0 succeeded for: 0 == 0 [Started section: ' Then: The flag is set'] -CmdLineTests.cpp:359: config.abortAfter == 2 succeeded for: 2 == 2 +CmdLineTests.cpp:360: config.abortAfter == 2 succeeded for: 2 == 2 [End of section: ' Then: The flag is set' 1 assertion passed] [End of section: ' When: A flag is set via a unary method' All 2 assertions passed] @@ -15245,7 +15245,7 @@ CmdLineTests.cpp:359: config.abortAfter == 2 succeeded for: 2 == 2 [Started section: ' Given: A built cli parser for Catch'] [Started section: ' When: A flag is set via a unary method'] -CmdLineTests.cpp:353: config.abortAfter == 0 succeeded for: 0 == 0 +CmdLineTests.cpp:354: config.abortAfter == 0 succeeded for: 0 == 0 [End of section: ' When: A flag is set via a unary method' 1 assertion passed] [End of section: ' Given: A built cli parser for Catch' 1 assertion passed] @@ -15253,8 +15253,8 @@ CmdLineTests.cpp:353: config.abortAfter == 0 succeeded for: 0 == 0 [Started section: ' Given: A built cli parser for Catch'] [Started section: ' When: A positional argument is supplied'] [Started section: ' Then: The argument is in the testOrTags collection'] -CmdLineTests.cpp:367: config.testsOrTags.size() == 1 succeeded for: 1 == 1 -CmdLineTests.cpp:368: config.testsOrTags[0] == "[hello]" succeeded for: "[hello]" == "[hello]" +CmdLineTests.cpp:368: config.testsOrTags.size() == 1 succeeded for: 1 == 1 +CmdLineTests.cpp:369: config.testsOrTags[0] == "[hello]" succeeded for: "[hello]" == "[hello]" [End of section: ' Then: The argument is in the testOrTags collection' All 2 assertions passed] [End of section: ' When: A positional argument is supplied' All 2 assertions passed] @@ -15263,9 +15263,9 @@ CmdLineTests.cpp:368: config.testsOrTags[0] == "[hello]" succeeded for: "[hello] [Started section: ' Given: A built cli parser for Catch'] [Started section: ' When: And enum opt is set by numeric value'] -CmdLineTests.cpp:372: config.verbosity == Config::Verbosity::Normal succeeded for: 2 == 2 +CmdLineTests.cpp:373: config.verbosity == Config::Verbosity::Normal succeeded for: 2 == 2 [Started section: ' Then: The member is set to the enum value'] -CmdLineTests.cpp:378: config.verbosity == Config::Verbosity::NoOutput succeeded for: 0 == 0 +CmdLineTests.cpp:379: config.verbosity == Config::Verbosity::NoOutput succeeded for: 0 == 0 [End of section: ' Then: The member is set to the enum value' 1 assertion passed] [End of section: ' When: And enum opt is set by numeric value' All 2 assertions passed] diff --git a/projects/SelfTest/CmdLineTests.cpp b/projects/SelfTest/CmdLineTests.cpp index 1e9b3116..3626c61c 100644 --- a/projects/SelfTest/CmdLineTests.cpp +++ b/projects/SelfTest/CmdLineTests.cpp @@ -188,6 +188,7 @@ struct Config { Config() : listTests( false ), listTags( false ), + listReporters( false ), showSuccessfulTests( false ), breakIntoDebugger( false ), noThrow( false ),