| 
									
										
										
										
											2010-11-12 19:55:53 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  *  Created by Phil on 08/11/2010. | 
					
						
							|  |  |  |  *  Copyright 2010 Two Blue Cubes Ltd. All rights reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *  Distributed under the Boost Software License, Version 1.0. (See accompanying | 
					
						
							|  |  |  |  *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2012-09-17 01:42:29 -04:00
										 |  |  | #ifndef TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED
 | 
					
						
							|  |  |  | #define TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED
 | 
					
						
							| 
									
										
										
										
											2010-11-12 19:55:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-16 18:24:07 +01:00
										 |  |  | #include "catch_test_spec_parser.hpp"
 | 
					
						
							| 
									
										
										
										
											2012-05-10 07:58:48 +01:00
										 |  |  | #include "catch_context.h"
 | 
					
						
							| 
									
										
										
										
											2012-08-28 08:20:18 +01:00
										 |  |  | #include "catch_interfaces_config.h"
 | 
					
						
							| 
									
										
										
										
											2013-12-03 18:52:41 +00:00
										 |  |  | #include "catch_stream.h"
 | 
					
						
							| 
									
										
										
										
											2010-11-12 19:55:53 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <memory>
 | 
					
						
							|  |  |  | #include <vector>
 | 
					
						
							|  |  |  | #include <string>
 | 
					
						
							| 
									
										
										
										
											2017-02-12 12:17:07 +01:00
										 |  |  | #include <stdexcept>
 | 
					
						
							| 
									
										
										
										
											2010-11-12 19:55:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-26 20:06:55 +00:00
										 |  |  | #ifndef CATCH_CONFIG_CONSOLE_WIDTH
 | 
					
						
							|  |  |  | #define CATCH_CONFIG_CONSOLE_WIDTH 80
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-15 23:58:23 +01:00
										 |  |  | namespace Catch { | 
					
						
							| 
									
										
										
										
											2013-07-03 19:14:59 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-08 08:22:56 +01:00
										 |  |  |     struct ConfigData { | 
					
						
							| 
									
										
										
										
											2012-08-28 08:20:18 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-08 08:22:56 +01:00
										 |  |  |         ConfigData() | 
					
						
							| 
									
										
										
										
											2013-05-29 18:42:46 +01:00
										 |  |  |         :   listTests( false ), | 
					
						
							|  |  |  |             listTags( false ), | 
					
						
							|  |  |  |             listReporters( false ), | 
					
						
							| 
									
										
										
										
											2013-11-26 20:57:34 +00:00
										 |  |  |             listTestNamesOnly( false ), | 
					
						
							| 
									
										
										
										
											2013-05-29 18:34:11 +01:00
										 |  |  |             showSuccessfulTests( false ), | 
					
						
							| 
									
										
										
										
											2013-05-29 08:12:57 +01:00
										 |  |  |             shouldDebugBreak( false ), | 
					
						
							| 
									
										
										
										
											2013-05-29 18:34:11 +01:00
										 |  |  |             noThrow( false ), | 
					
						
							| 
									
										
										
										
											2013-05-29 19:01:06 +01:00
										 |  |  |             showHelp( false ), | 
					
						
							| 
									
										
										
										
											2014-04-22 18:23:42 +01:00
										 |  |  |             showInvisibles( false ), | 
					
						
							| 
									
										
										
										
											2015-07-02 08:20:18 +01:00
										 |  |  |             filenamesAsTags( false ), | 
					
						
							| 
									
										
										
										
											2013-05-31 08:01:56 +01:00
										 |  |  |             abortAfter( -1 ), | 
					
						
							| 
									
										
										
										
											2014-09-15 18:39:31 +01:00
										 |  |  |             rngSeed( 0 ), | 
					
						
							| 
									
										
										
										
											2013-05-29 19:01:06 +01:00
										 |  |  |             verbosity( Verbosity::Normal ), | 
					
						
							| 
									
										
										
										
											2013-08-07 18:56:35 +01:00
										 |  |  |             warnings( WarnAbout::Nothing ), | 
					
						
							| 
									
										
										
										
											2014-09-15 18:39:31 +01:00
										 |  |  |             showDurations( ShowDurations::DefaultForReporter ), | 
					
						
							| 
									
										
										
										
											2016-02-24 18:51:01 +00:00
										 |  |  |             runOrder( RunTests::InDeclarationOrder ), | 
					
						
							|  |  |  |             useColour( UseColour::Auto ) | 
					
						
							| 
									
										
										
										
											2012-06-08 08:22:56 +01:00
										 |  |  |         {} | 
					
						
							| 
									
										
										
										
											2013-07-03 19:14:59 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-29 18:42:46 +01:00
										 |  |  |         bool listTests; | 
					
						
							|  |  |  |         bool listTags; | 
					
						
							|  |  |  |         bool listReporters; | 
					
						
							| 
									
										
										
										
											2013-11-26 20:57:34 +00:00
										 |  |  |         bool listTestNamesOnly; | 
					
						
							| 
									
										
										
										
											2013-05-29 19:01:06 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-29 18:34:11 +01:00
										 |  |  |         bool showSuccessfulTests; | 
					
						
							| 
									
										
										
										
											2012-06-08 08:22:56 +01:00
										 |  |  |         bool shouldDebugBreak; | 
					
						
							| 
									
										
										
										
											2013-05-29 18:34:11 +01:00
										 |  |  |         bool noThrow; | 
					
						
							| 
									
										
										
										
											2013-05-29 19:01:06 +01:00
										 |  |  |         bool showHelp; | 
					
						
							| 
									
										
										
										
											2014-04-22 18:23:42 +01:00
										 |  |  |         bool showInvisibles; | 
					
						
							| 
									
										
										
										
											2015-07-02 08:20:18 +01:00
										 |  |  |         bool filenamesAsTags; | 
					
						
							| 
									
										
										
										
											2013-05-29 08:12:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-31 08:01:56 +01:00
										 |  |  |         int abortAfter; | 
					
						
							| 
									
										
										
										
											2014-09-15 18:39:31 +01:00
										 |  |  |         unsigned int rngSeed; | 
					
						
							| 
									
										
										
										
											2013-05-29 08:12:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-29 19:01:06 +01:00
										 |  |  |         Verbosity::Level verbosity; | 
					
						
							| 
									
										
										
										
											2012-08-28 08:20:18 +01:00
										 |  |  |         WarnAbout::What warnings; | 
					
						
							| 
									
										
										
										
											2013-08-07 18:56:35 +01:00
										 |  |  |         ShowDurations::OrNot showDurations; | 
					
						
							| 
									
										
										
										
											2014-09-15 18:39:31 +01:00
										 |  |  |         RunTests::InWhatOrder runOrder; | 
					
						
							| 
									
										
										
										
											2016-02-24 18:51:01 +00:00
										 |  |  |         UseColour::YesOrNo useColour; | 
					
						
							| 
									
										
										
										
											2013-05-29 08:12:57 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         std::string outputFilename; | 
					
						
							|  |  |  |         std::string name; | 
					
						
							| 
									
										
										
										
											2013-06-04 08:37:28 +01:00
										 |  |  |         std::string processName; | 
					
						
							| 
									
										
										
										
											2013-05-29 08:12:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-05 19:02:17 +01:00
										 |  |  |         std::vector<std::string> reporterNames; | 
					
						
							| 
									
										
										
										
											2013-05-29 18:56:29 +01:00
										 |  |  |         std::vector<std::string> testsOrTags; | 
					
						
							| 
									
										
										
										
											2017-01-12 17:10:38 +00:00
										 |  |  |         std::vector<std::string> sectionsToRun; | 
					
						
							| 
									
										
										
										
											2012-06-08 08:22:56 +01:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2013-07-03 19:14:59 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-28 18:39:32 +01:00
										 |  |  |     class Config : public SharedImpl<IConfig> { | 
					
						
							| 
									
										
										
										
											2010-12-31 22:07:47 +00:00
										 |  |  |     private: | 
					
						
							| 
									
										
										
										
											2013-04-23 18:58:56 +01:00
										 |  |  |         Config( Config const& other ); | 
					
						
							|  |  |  |         Config& operator = ( Config const& other ); | 
					
						
							| 
									
										
										
										
											2012-08-13 07:46:10 +01:00
										 |  |  |         virtual void dummy(); | 
					
						
							| 
									
										
										
										
											2010-12-31 22:07:47 +00:00
										 |  |  |     public: | 
					
						
							| 
									
										
										
										
											2012-08-13 07:46:10 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-01 00:20:14 +00:00
										 |  |  |         Config() | 
					
						
							| 
									
										
										
										
											2012-06-08 08:22:56 +01:00
										 |  |  |         {} | 
					
						
							| 
									
										
										
										
											2013-07-03 19:14:59 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-23 18:58:56 +01:00
										 |  |  |         Config( ConfigData const& data ) | 
					
						
							| 
									
										
										
										
											2012-06-08 08:22:56 +01:00
										 |  |  |         :   m_data( data ), | 
					
						
							| 
									
										
										
										
											2015-09-29 19:21:08 +01:00
										 |  |  |             m_stream( openStream() ) | 
					
						
							| 
									
										
										
										
											2013-05-29 18:56:29 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2013-06-07 19:06:30 +01:00
										 |  |  |             if( !data.testsOrTags.empty() ) { | 
					
						
							| 
									
										
										
										
											2014-06-30 07:33:17 +01:00
										 |  |  |                 TestSpecParser parser( ITagAliasRegistry::get() ); | 
					
						
							| 
									
										
										
										
											2014-05-16 18:24:07 +01:00
										 |  |  |                 for( std::size_t i = 0; i < data.testsOrTags.size(); ++i ) | 
					
						
							|  |  |  |                     parser.parse( data.testsOrTags[i] ); | 
					
						
							|  |  |  |                 m_testSpec = parser.testSpec(); | 
					
						
							| 
									
										
										
										
											2013-05-29 18:56:29 +01:00
										 |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2013-07-03 19:14:59 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-10 22:39:27 +00:00
										 |  |  |         virtual ~Config() {} | 
					
						
							| 
									
										
										
										
											2013-07-03 19:14:59 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-23 18:58:56 +01:00
										 |  |  |         std::string const& getFilename() const { | 
					
						
							| 
									
										
										
										
											2012-06-08 08:22:56 +01:00
										 |  |  |             return m_data.outputFilename ; | 
					
						
							| 
									
										
										
										
											2010-11-12 19:55:53 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2013-07-03 19:14:59 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-29 18:42:46 +01:00
										 |  |  |         bool listTests() const { return m_data.listTests; } | 
					
						
							| 
									
										
										
										
											2013-11-26 20:57:34 +00:00
										 |  |  |         bool listTestNamesOnly() const { return m_data.listTestNamesOnly; } | 
					
						
							| 
									
										
										
										
											2013-05-29 18:42:46 +01:00
										 |  |  |         bool listTags() const { return m_data.listTags; } | 
					
						
							|  |  |  |         bool listReporters() const { return m_data.listReporters; } | 
					
						
							| 
									
										
										
										
											2013-07-03 19:14:59 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-16 18:24:07 +01:00
										 |  |  |         std::string getProcessName() const { return m_data.processName; } | 
					
						
							| 
									
										
										
										
											2013-06-05 08:18:52 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-12 17:10:38 +00:00
										 |  |  |         std::vector<std::string> const& getReporterNames() const { return m_data.reporterNames; } | 
					
						
							|  |  |  |         std::vector<std::string> const& getSectionsToRun() const CATCH_OVERRIDE { return m_data.sectionsToRun; } | 
					
						
							| 
									
										
										
										
											2012-09-07 17:52:15 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-10 22:39:27 +00:00
										 |  |  |         virtual TestSpec const& testSpec() const CATCH_OVERRIDE { return m_testSpec; } | 
					
						
							| 
									
										
										
										
											2013-07-03 19:14:59 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-04 22:49:14 +01:00
										 |  |  |         bool showHelp() const { return m_data.showHelp; } | 
					
						
							| 
									
										
										
										
											2012-08-31 08:10:36 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-28 18:39:32 +01:00
										 |  |  |         // IConfig interface
 | 
					
						
							| 
									
										
										
										
											2017-02-10 22:39:27 +00:00
										 |  |  |         virtual bool allowThrows() const CATCH_OVERRIDE                 { return !m_data.noThrow; } | 
					
						
							|  |  |  |         virtual std::ostream& stream() const CATCH_OVERRIDE             { return m_stream->stream(); } | 
					
						
							|  |  |  |         virtual std::string name() const CATCH_OVERRIDE                 { return m_data.name.empty() ? m_data.processName : m_data.name; } | 
					
						
							|  |  |  |         virtual bool includeSuccessfulResults() const CATCH_OVERRIDE    { return m_data.showSuccessfulTests; } | 
					
						
							|  |  |  |         virtual bool warnAboutMissingAssertions() const CATCH_OVERRIDE  { return m_data.warnings & WarnAbout::NoAssertions; } | 
					
						
							|  |  |  |         virtual ShowDurations::OrNot showDurations() const CATCH_OVERRIDE { return m_data.showDurations; } | 
					
						
							|  |  |  |         virtual RunTests::InWhatOrder runOrder() const CATCH_OVERRIDE   { return m_data.runOrder; } | 
					
						
							|  |  |  |         virtual unsigned int rngSeed() const CATCH_OVERRIDE             { return m_data.rngSeed; } | 
					
						
							|  |  |  |         virtual UseColour::YesOrNo useColour() const CATCH_OVERRIDE     { return m_data.useColour; } | 
					
						
							|  |  |  |         virtual bool shouldDebugBreak() const CATCH_OVERRIDE { return m_data.shouldDebugBreak; } | 
					
						
							|  |  |  |         virtual int abortAfter() const CATCH_OVERRIDE { return m_data.abortAfter; } | 
					
						
							|  |  |  |         virtual bool showInvisibles() const CATCH_OVERRIDE { return m_data.showInvisibles; } | 
					
						
							| 
									
										
										
										
											2013-05-28 18:39:32 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-18 19:49:00 +00:00
										 |  |  |     private: | 
					
						
							| 
									
										
										
										
											2015-11-04 18:01:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-29 19:21:08 +01:00
										 |  |  |         IStream const* openStream() { | 
					
						
							|  |  |  |             if( m_data.outputFilename.empty() ) | 
					
						
							|  |  |  |                 return new CoutStream(); | 
					
						
							|  |  |  |             else if( m_data.outputFilename[0] == '%' ) { | 
					
						
							|  |  |  |                 if( m_data.outputFilename == "%debug" ) | 
					
						
							|  |  |  |                     return new DebugOutStream(); | 
					
						
							|  |  |  |                 else | 
					
						
							|  |  |  |                     throw std::domain_error( "Unrecognised stream: " + m_data.outputFilename ); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             else | 
					
						
							|  |  |  |                 return new FileStream( m_data.outputFilename ); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2012-06-08 08:22:56 +01:00
										 |  |  |         ConfigData m_data; | 
					
						
							| 
									
										
										
										
											2013-07-03 19:14:59 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-08 19:14:54 +01:00
										 |  |  |         CATCH_AUTO_PTR( IStream const ) m_stream; | 
					
						
							| 
									
										
										
										
											2014-05-16 18:24:07 +01:00
										 |  |  |         TestSpec m_testSpec; | 
					
						
							| 
									
										
										
										
											2012-05-31 19:40:26 +01:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2013-07-03 19:14:59 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-11-12 19:55:53 +00:00
										 |  |  | } // end namespace Catch
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-17 01:42:29 -04:00
										 |  |  | #endif // TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED
 |