Files
Catch2/src/catch2/catch_config.hpp
T

128 lines
4.4 KiB
C++
Raw Normal View History

// Copyright Catch2 Authors
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
// SPDX-License-Identifier: BSL-1.0
#ifndef CATCH_CONFIG_HPP_INCLUDED
#define CATCH_CONFIG_HPP_INCLUDED
2010-11-12 19:55:53 +00:00
2020-03-30 10:34:21 +02:00
#include <catch2/catch_test_spec.hpp>
#include <catch2/catch_user_config.hpp>
2020-03-30 10:34:21 +02:00
#include <catch2/interfaces/catch_interfaces_config.hpp>
#include <catch2/internal/catch_unique_ptr.hpp>
#include <catch2/internal/catch_optional.hpp>
#include <catch2/internal/catch_random_seed_generation.hpp>
#include <catch2/internal/catch_reporter_spec_parser.hpp>
2010-11-12 19:55:53 +00:00
2021-02-06 20:12:07 +01:00
#include <iosfwd>
2010-11-12 19:55:53 +00:00
#include <vector>
#include <string>
2012-05-15 23:58:23 +01:00
namespace Catch {
2013-07-03 19:14:59 +01:00
class IStream;
2017-08-29 16:44:02 +02:00
2012-06-08 08:22:56 +01:00
struct ConfigData {
2021-02-06 20:12:07 +01:00
bool listTests = false;
bool listTags = false;
bool listReporters = false;
2012-08-28 08:20:18 +01:00
bool showSuccessfulTests = false;
bool shouldDebugBreak = false;
bool noThrow = false;
bool showHelp = false;
bool showInvisibles = false;
bool filenamesAsTags = false;
bool libIdentify = false;
bool allowZeroTests = false;
2013-07-03 19:14:59 +01:00
int abortAfter = -1;
uint32_t rngSeed = generateRandomSeed(GenerateFrom::Default);
2019-04-23 23:41:13 +02:00
unsigned int shardCount = 1;
unsigned int shardIndex = 0;
2019-04-23 23:41:13 +02:00
bool benchmarkNoAnalysis = false;
unsigned int benchmarkSamples = 100;
double benchmarkConfidenceInterval = 0.95;
unsigned int benchmarkResamples = 100000;
2020-01-27 15:43:27 +01:00
std::chrono::milliseconds::rep benchmarkWarmupTime = 100;
Verbosity verbosity = Verbosity::Normal;
WarnAbout::What warnings = WarnAbout::Nothing;
2020-08-11 15:03:37 +02:00
ShowDurations showDurations = ShowDurations::DefaultForReporter;
2020-04-13 08:34:27 -04:00
double minDuration = -1;
2020-08-11 15:46:03 +02:00
TestRunOrder runOrder = TestRunOrder::Declared;
ColourMode colourMode = ColourMode::PlatformDefault;
WaitForKeypress::When waitForKeypress = WaitForKeypress::Never;
2021-02-06 20:12:07 +01:00
std::string defaultOutputFilename;
2012-06-08 08:22:56 +01:00
std::string name;
std::string processName;
std::vector<ReporterSpec> reporterSpecifications;
2018-04-07 12:05:29 +02:00
std::vector<std::string> testsOrTags;
std::vector<std::string> sectionsToRun;
2012-06-08 08:22:56 +01:00
};
2013-07-03 19:14:59 +01:00
class Config : public IConfig {
public:
2017-07-19 10:13:47 +02:00
Config() = default;
Config( ConfigData const& data );
~Config() override; // = default in the cpp file
2013-07-03 19:14:59 +01:00
2017-07-19 10:13:47 +02:00
bool listTests() const;
bool listTags() const;
bool listReporters() const;
2013-07-03 19:14:59 +01:00
std::vector<ReporterSpec> const& getReporterSpecs() const;
IStream const* getReporterOutputStream(std::size_t reporterIdx) const;
std::vector<std::string> const& getTestsOrTags() const override;
2017-07-19 10:13:47 +02:00
std::vector<std::string> const& getSectionsToRun() const override;
2013-07-03 19:14:59 +01:00
2018-07-12 14:27:06 +02:00
TestSpec const& testSpec() const override;
bool hasTestFilters() const override;
2017-07-19 10:13:47 +02:00
bool showHelp() const;
2013-05-28 18:39:32 +01:00
// IConfig interface
bool allowThrows() const override;
StringRef name() const override;
bool includeSuccessfulResults() const override;
bool warnAboutMissingAssertions() const override;
2021-12-18 19:59:23 +01:00
bool warnAboutUnmatchedTestSpecs() const override;
bool zeroTestsCountAsSuccess() const override;
2020-08-11 15:03:37 +02:00
ShowDurations showDurations() const override;
2020-04-13 08:34:27 -04:00
double minDuration() const override;
2020-08-11 15:46:03 +02:00
TestRunOrder runOrder() const override;
uint32_t rngSeed() const override;
unsigned int shardCount() const override;
unsigned int shardIndex() const override;
ColourMode colourMode() const override;
bool shouldDebugBreak() const override;
int abortAfter() const override;
bool showInvisibles() const override;
Verbosity verbosity() const override;
2019-04-23 23:41:13 +02:00
bool benchmarkNoAnalysis() const override;
2021-11-20 23:40:32 +01:00
unsigned int benchmarkSamples() const override;
2019-04-23 23:41:13 +02:00
double benchmarkConfidenceInterval() const override;
unsigned int benchmarkResamples() const override;
2020-01-27 15:43:27 +01:00
std::chrono::milliseconds benchmarkWarmupTime() const override;
2013-05-28 18:39:32 +01:00
2011-01-18 19:49:00 +00:00
private:
2021-02-06 20:12:07 +01:00
Detail::unique_ptr<IStream const> openStream(std::string const& outputFileName);
2012-06-08 08:22:56 +01:00
ConfigData m_data;
2013-07-03 19:14:59 +01:00
2021-02-06 20:12:07 +01:00
std::vector<Detail::unique_ptr<IStream const>> m_reporterStreams;
2014-05-16 18:24:07 +01:00
TestSpec m_testSpec;
bool m_hasTestFilters = false;
2010-11-12 19:55:53 +00:00
};
} // end namespace Catch
#endif // CATCH_CONFIG_HPP_INCLUDED