1 /* 2 * Created by Martin on 19/07/2017. 3 * 4 * Distributed under the Boost Software License, Version 1.0. (See accompanying 5 * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 */ 7 8 #include "catch_config.hpp" 9 #include "catch_enforce.h" 10 #include "catch_stringref.h" 11 12 namespace Catch { 13 Config(ConfigData const & data)14 Config::Config( ConfigData const& data ) 15 : m_data( data ), 16 m_stream( openStream() ) 17 { 18 TestSpecParser parser(ITagAliasRegistry::get()); 19 if (data.testsOrTags.empty()) { 20 parser.parse("~[.]"); // All not hidden tests 21 } 22 else { 23 m_hasTestFilters = true; 24 for( auto const& testOrTags : data.testsOrTags ) 25 parser.parse( testOrTags ); 26 } 27 m_testSpec = parser.testSpec(); 28 } 29 getFilename() const30 std::string const& Config::getFilename() const { 31 return m_data.outputFilename ; 32 } 33 listTests() const34 bool Config::listTests() const { return m_data.listTests; } listTestNamesOnly() const35 bool Config::listTestNamesOnly() const { return m_data.listTestNamesOnly; } listTags() const36 bool Config::listTags() const { return m_data.listTags; } listReporters() const37 bool Config::listReporters() const { return m_data.listReporters; } 38 getProcessName() const39 std::string Config::getProcessName() const { return m_data.processName; } getReporterName() const40 std::string const& Config::getReporterName() const { return m_data.reporterName; } 41 getTestsOrTags() const42 std::vector<std::string> const& Config::getTestsOrTags() const { return m_data.testsOrTags; } getSectionsToRun() const43 std::vector<std::string> const& Config::getSectionsToRun() const { return m_data.sectionsToRun; } 44 testSpec() const45 TestSpec const& Config::testSpec() const { return m_testSpec; } hasTestFilters() const46 bool Config::hasTestFilters() const { return m_hasTestFilters; } 47 showHelp() const48 bool Config::showHelp() const { return m_data.showHelp; } 49 50 // IConfig interface allowThrows() const51 bool Config::allowThrows() const { return !m_data.noThrow; } stream() const52 std::ostream& Config::stream() const { return m_stream->stream(); } name() const53 std::string Config::name() const { return m_data.name.empty() ? m_data.processName : m_data.name; } includeSuccessfulResults() const54 bool Config::includeSuccessfulResults() const { return m_data.showSuccessfulTests; } warnAboutMissingAssertions() const55 bool Config::warnAboutMissingAssertions() const { return !!(m_data.warnings & WarnAbout::NoAssertions); } warnAboutNoTests() const56 bool Config::warnAboutNoTests() const { return !!(m_data.warnings & WarnAbout::NoTests); } showDurations() const57 ShowDurations::OrNot Config::showDurations() const { return m_data.showDurations; } runOrder() const58 RunTests::InWhatOrder Config::runOrder() const { return m_data.runOrder; } rngSeed() const59 unsigned int Config::rngSeed() const { return m_data.rngSeed; } benchmarkResolutionMultiple() const60 int Config::benchmarkResolutionMultiple() const { return m_data.benchmarkResolutionMultiple; } useColour() const61 UseColour::YesOrNo Config::useColour() const { return m_data.useColour; } shouldDebugBreak() const62 bool Config::shouldDebugBreak() const { return m_data.shouldDebugBreak; } abortAfter() const63 int Config::abortAfter() const { return m_data.abortAfter; } showInvisibles() const64 bool Config::showInvisibles() const { return m_data.showInvisibles; } verbosity() const65 Verbosity Config::verbosity() const { return m_data.verbosity; } 66 openStream()67 IStream const* Config::openStream() { 68 return Catch::makeStream(m_data.outputFilename); 69 } 70 71 } // end namespace Catch 72