2017-07-19 10:13:47 +02:00
|
|
|
/*
|
|
|
|
* Created by Martin on 19/07/2017.
|
|
|
|
*
|
|
|
|
* 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)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "catch_config.hpp"
|
2017-08-01 18:46:33 +02:00
|
|
|
#include "catch_enforce.h"
|
2017-11-07 16:55:09 +01:00
|
|
|
#include "catch_stringref.h"
|
2017-07-19 10:13:47 +02:00
|
|
|
|
|
|
|
namespace Catch {
|
|
|
|
|
|
|
|
Config::Config( ConfigData const& data )
|
|
|
|
: m_data( data ),
|
|
|
|
m_stream( openStream() )
|
|
|
|
{
|
2019-09-09 11:30:45 +02:00
|
|
|
// We need to trim filter specs to avoid trouble with superfluous
|
|
|
|
// whitespace (esp. important for bdd macros, as those are manually
|
|
|
|
// aligned with whitespace).
|
|
|
|
|
|
|
|
for (auto& elem : m_data.testsOrTags) {
|
|
|
|
elem = trim(elem);
|
|
|
|
}
|
|
|
|
for (auto& elem : m_data.sectionsToRun) {
|
|
|
|
elem = trim(elem);
|
|
|
|
}
|
|
|
|
|
2018-02-08 23:18:32 +01:00
|
|
|
TestSpecParser parser(ITagAliasRegistry::get());
|
2019-09-09 11:30:45 +02:00
|
|
|
if (!m_data.testsOrTags.empty()) {
|
2018-02-08 23:18:32 +01:00
|
|
|
m_hasTestFilters = true;
|
2019-09-09 11:30:45 +02:00
|
|
|
for (auto const& testOrTags : m_data.testsOrTags) {
|
|
|
|
parser.parse(testOrTags);
|
|
|
|
}
|
2017-07-19 10:13:47 +02:00
|
|
|
}
|
2018-02-08 23:18:32 +01:00
|
|
|
m_testSpec = parser.testSpec();
|
2017-07-19 10:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string const& Config::getFilename() const {
|
|
|
|
return m_data.outputFilename ;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Config::listTests() const { return m_data.listTests; }
|
|
|
|
bool Config::listTags() const { return m_data.listTags; }
|
|
|
|
bool Config::listReporters() const { return m_data.listReporters; }
|
2019-09-09 11:30:45 +02:00
|
|
|
|
2017-07-19 10:13:47 +02:00
|
|
|
std::string Config::getProcessName() const { return m_data.processName; }
|
2018-04-07 12:05:29 +02:00
|
|
|
std::string const& Config::getReporterName() const { return m_data.reporterName; }
|
2017-07-19 10:13:47 +02:00
|
|
|
|
2018-02-09 00:31:19 +01:00
|
|
|
std::vector<std::string> const& Config::getTestsOrTags() const { return m_data.testsOrTags; }
|
2017-07-19 10:13:47 +02:00
|
|
|
std::vector<std::string> const& Config::getSectionsToRun() const { return m_data.sectionsToRun; }
|
|
|
|
|
|
|
|
TestSpec const& Config::testSpec() const { return m_testSpec; }
|
2018-02-08 23:18:32 +01:00
|
|
|
bool Config::hasTestFilters() const { return m_hasTestFilters; }
|
2017-07-19 10:13:47 +02:00
|
|
|
|
|
|
|
bool Config::showHelp() const { return m_data.showHelp; }
|
|
|
|
|
|
|
|
// IConfig interface
|
|
|
|
bool Config::allowThrows() const { return !m_data.noThrow; }
|
|
|
|
std::ostream& Config::stream() const { return m_stream->stream(); }
|
|
|
|
std::string Config::name() const { return m_data.name.empty() ? m_data.processName : m_data.name; }
|
|
|
|
bool Config::includeSuccessfulResults() const { return m_data.showSuccessfulTests; }
|
2018-02-09 00:31:19 +01:00
|
|
|
bool Config::warnAboutMissingAssertions() const { return !!(m_data.warnings & WarnAbout::NoAssertions); }
|
|
|
|
bool Config::warnAboutNoTests() const { return !!(m_data.warnings & WarnAbout::NoTests); }
|
2017-07-19 10:13:47 +02:00
|
|
|
ShowDurations::OrNot Config::showDurations() const { return m_data.showDurations; }
|
|
|
|
RunTests::InWhatOrder Config::runOrder() const { return m_data.runOrder; }
|
|
|
|
unsigned int Config::rngSeed() const { return m_data.rngSeed; }
|
|
|
|
UseColour::YesOrNo Config::useColour() const { return m_data.useColour; }
|
|
|
|
bool Config::shouldDebugBreak() const { return m_data.shouldDebugBreak; }
|
|
|
|
int Config::abortAfter() const { return m_data.abortAfter; }
|
|
|
|
bool Config::showInvisibles() const { return m_data.showInvisibles; }
|
2017-07-19 23:15:54 +02:00
|
|
|
Verbosity Config::verbosity() const { return m_data.verbosity; }
|
2017-07-19 10:13:47 +02:00
|
|
|
|
2019-04-23 23:41:13 +02:00
|
|
|
bool Config::benchmarkNoAnalysis() const { return m_data.benchmarkNoAnalysis; }
|
|
|
|
int Config::benchmarkSamples() const { return m_data.benchmarkSamples; }
|
|
|
|
double Config::benchmarkConfidenceInterval() const { return m_data.benchmarkConfidenceInterval; }
|
|
|
|
unsigned int Config::benchmarkResamples() const { return m_data.benchmarkResamples; }
|
|
|
|
|
2017-07-19 10:13:47 +02:00
|
|
|
IStream const* Config::openStream() {
|
2017-11-07 16:55:09 +01:00
|
|
|
return Catch::makeStream(m_data.outputFilename);
|
2017-07-19 10:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // end namespace Catch
|