Home | History | Annotate | Download | only in internal
      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 
     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 
     30     std::string const& Config::getFilename() const {
     31         return m_data.outputFilename ;
     32     }
     33 
     34     bool Config::listTests() const          { return m_data.listTests; }
     35     bool Config::listTestNamesOnly() const  { return m_data.listTestNamesOnly; }
     36     bool Config::listTags() const           { return m_data.listTags; }
     37     bool Config::listReporters() const      { return m_data.listReporters; }
     38 
     39     std::string Config::getProcessName() const { return m_data.processName; }
     40     std::string const& Config::getReporterName() const { return m_data.reporterName; }
     41 
     42     std::vector<std::string> const& Config::getTestsOrTags() const { return m_data.testsOrTags; }
     43     std::vector<std::string> const& Config::getSectionsToRun() const { return m_data.sectionsToRun; }
     44 
     45     TestSpec const& Config::testSpec() const { return m_testSpec; }
     46     bool Config::hasTestFilters() const { return m_hasTestFilters; }
     47 
     48     bool Config::showHelp() const { return m_data.showHelp; }
     49 
     50     // IConfig interface
     51     bool Config::allowThrows() const                   { return !m_data.noThrow; }
     52     std::ostream& Config::stream() const               { return m_stream->stream(); }
     53     std::string Config::name() const                   { return m_data.name.empty() ? m_data.processName : m_data.name; }
     54     bool Config::includeSuccessfulResults() const      { return m_data.showSuccessfulTests; }
     55     bool Config::warnAboutMissingAssertions() const    { return !!(m_data.warnings & WarnAbout::NoAssertions); }
     56     bool Config::warnAboutNoTests() const              { return !!(m_data.warnings & WarnAbout::NoTests); }
     57     ShowDurations::OrNot Config::showDurations() const { return m_data.showDurations; }
     58     RunTests::InWhatOrder Config::runOrder() const     { return m_data.runOrder; }
     59     unsigned int Config::rngSeed() const               { return m_data.rngSeed; }
     60     int Config::benchmarkResolutionMultiple() const    { return m_data.benchmarkResolutionMultiple; }
     61     UseColour::YesOrNo Config::useColour() const       { return m_data.useColour; }
     62     bool Config::shouldDebugBreak() const              { return m_data.shouldDebugBreak; }
     63     int Config::abortAfter() const                     { return m_data.abortAfter; }
     64     bool Config::showInvisibles() const                { return m_data.showInvisibles; }
     65     Verbosity Config::verbosity() const                { return m_data.verbosity; }
     66 
     67     IStream const* Config::openStream() {
     68         return Catch::makeStream(m_data.outputFilename);
     69     }
     70 
     71 } // end namespace Catch
     72