diff options
| author | Phil Nash | 2012-08-28 08:20:18 +0100 |
|---|---|---|
| committer | Phil Nash | 2012-08-28 08:20:18 +0100 |
| commit | 55764c8d47dfabb1f4530b1880b87c0b134610d0 (patch) | |
| tree | d47eed8f520ce46a0ffe814ce2968e73eb9b28ad /include/internal | |
| parent | 78c92e68aa350f1a971fbcf8cad70f4187d79caf (diff) | |
| download | catch3-55764c8d47dfabb1f4530b1880b87c0b134610d0.tar.gz | |
Added warnings - first one: no assertions
Diffstat (limited to 'include/internal')
| -rw-r--r-- | include/internal/catch_commandline.hpp | 32 | ||||
| -rw-r--r-- | include/internal/catch_config.hpp | 14 | ||||
| -rw-r--r-- | include/internal/catch_context.h | 3 | ||||
| -rw-r--r-- | include/internal/catch_interfaces_reporter.h | 10 | ||||
| -rw-r--r-- | include/internal/catch_interfaces_testcase.h | 2 | ||||
| -rw-r--r-- | include/internal/catch_test_spec.h | 3 |
6 files changed, 53 insertions, 11 deletions
diff --git a/include/internal/catch_commandline.hpp b/include/internal/catch_commandline.hpp index 31ca3748..17a3ea74 100644 --- a/include/internal/catch_commandline.hpp +++ b/include/internal/catch_commandline.hpp @@ -401,6 +401,29 @@ namespace Catch { config.allowThrows = false; } }; + + class WarningsOptionParser : public OptionParser { + public: + WarningsOptionParser() : OptionParser( 1, -1 ) { + m_optionNames.push_back( "-w" ); + m_optionNames.push_back( "--warnings" ); + } + virtual std::string argsSynopsis() const { + return "<warning>"; + } + virtual std::string optionSummary() const { + return "!TBD"; + } + + virtual void parseIntoConfig( const Command& cmd, ConfigData& config ) { + for( std::size_t i = 0; i < cmd.argsCount(); ++i ) { + if( cmd[i] == "NoAssertions" ) + config.warnings = (ConfigData::WarnAbout::What)( config.warnings | ConfigData::WarnAbout::NoAssertions ); + else + cmd.raiseError( "Unrecognised warning: " + cmd[i] ); + } + } + }; } class AllOptions @@ -410,8 +433,9 @@ namespace Catch { typedef Parsers::const_iterator const_iterator; typedef Parsers::const_iterator iterator; - AllOptions() { - add<Options::TestCaseOptionParser>(); + AllOptions() { + add<Options::TestCaseOptionParser>(); // Keep this one first + add<Options::ListOptionParser>(); add<Options::ReporterOptionParser>(); add<Options::OutputOptionParser>(); @@ -420,7 +444,9 @@ namespace Catch { add<Options::NameOptionParser>(); add<Options::AbortOptionParser>(); add<Options::NoThrowOptionParser>(); - add<Options::HelpOptionParser>(); + add<Options::WarningsOptionParser>(); + + add<Options::HelpOptionParser>(); // Keep this one last } void parseIntoConfig( const CommandParser& parser, ConfigData& config ) { diff --git a/include/internal/catch_config.hpp b/include/internal/catch_config.hpp index f859f004..c2b989b0 100644 --- a/include/internal/catch_config.hpp +++ b/include/internal/catch_config.hpp @@ -9,8 +9,8 @@ #define TWOBLUECUBES_CATCH_RUNNERCONFIG_HPP_INCLUDED #include "catch_test_spec.h" -#include "catch_interfaces_reporter.h" #include "catch_context.h" +#include "catch_interfaces_config.h" #include <memory> #include <vector> @@ -36,18 +36,25 @@ namespace Catch { WhatMask = 0xf, AsText = 0x10, - AsXml = 0x11, + AsXml = 0x20, AsMask = 0xf0 }; }; struct ConfigData { + + struct WarnAbout { enum What { + Nothing = 0x00, + NoAssertions = 0x01 + }; }; + ConfigData() : listSpec( List::None ), shouldDebugBreak( false ), includeWhichResults( Include::FailedOnly ), cutoff( -1 ), - allowThrows( true ) + allowThrows( true ), + warnings( WarnAbout::Nothing ) {} std::string reporter; @@ -60,6 +67,7 @@ namespace Catch { std::string name; int cutoff; bool allowThrows; + WarnAbout::What warnings; }; diff --git a/include/internal/catch_context.h b/include/internal/catch_context.h index c3460e3d..7ddd1f53 100644 --- a/include/internal/catch_context.h +++ b/include/internal/catch_context.h @@ -8,8 +8,6 @@ #ifndef TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED #define TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED -#include "catch_interfaces_reporter.h" -#include "catch_interfaces_config.h" #include "catch_interfaces_generators.h" #include <memory> @@ -22,6 +20,7 @@ namespace Catch { struct IResultCapture; struct IRunner; struct IGeneratorsForTest; + struct IConfig; class StreamBufBase : public std::streambuf { public: diff --git a/include/internal/catch_interfaces_reporter.h b/include/internal/catch_interfaces_reporter.h index f6b90872..792d6ff3 100644 --- a/include/internal/catch_interfaces_reporter.h +++ b/include/internal/catch_interfaces_reporter.h @@ -11,6 +11,7 @@ #include "catch_common.h" #include "catch_totals.hpp" #include "catch_ptr.hpp" +#include "catch_config.hpp" #include <string> #include <ostream> @@ -22,16 +23,19 @@ namespace Catch { ReporterConfig( const std::string& _name, std::ostream& _stream, - bool _includeSuccessfulResults = false ) + bool _includeSuccessfulResults, + const ConfigData& _fullConfig ) : name( _name ), stream( _stream ), - includeSuccessfulResults( _includeSuccessfulResults ) + includeSuccessfulResults( _includeSuccessfulResults ), + fullConfig( _fullConfig ) {} std::string name; std::ostream& stream; bool includeSuccessfulResults; - }; + ConfigData fullConfig; + }; class TestCaseInfo; class ResultInfo; diff --git a/include/internal/catch_interfaces_testcase.h b/include/internal/catch_interfaces_testcase.h index 7d5192aa..94ddf6f7 100644 --- a/include/internal/catch_interfaces_testcase.h +++ b/include/internal/catch_interfaces_testcase.h @@ -8,6 +8,8 @@ #ifndef TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED #define TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED +#include "catch_ptr.hpp" + #include <vector> namespace Catch { diff --git a/include/internal/catch_test_spec.h b/include/internal/catch_test_spec.h index 4aa03855..69a76b82 100644 --- a/include/internal/catch_test_spec.h +++ b/include/internal/catch_test_spec.h @@ -8,7 +8,10 @@ #ifndef TWOBLUECUBES_CATCH_TESTSPEC_H_INCLUDED #define TWOBLUECUBES_CATCH_TESTSPEC_H_INCLUDED +#include "catch_test_case_info.h" + #include <string> +#include <vector> namespace Catch { |