2020-08-30 15:43:45 +02:00
|
|
|
|
|
|
|
|
// 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
|
2020-08-29 20:48:32 +02:00
|
|
|
#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>
|
2022-02-02 15:36:58 +01:00
|
|
|
#include <catch2/catch_user_config.hpp>
|
2020-03-30 10:34:21 +02:00
|
|
|
#include <catch2/interfaces/catch_interfaces_config.hpp>
|
2020-05-25 09:45:24 +02:00
|
|
|
#include <catch2/internal/catch_unique_ptr.hpp>
|
2021-10-06 00:00:46 +02:00
|
|
|
#include <catch2/internal/catch_optional.hpp>
|
2021-10-08 21:32:03 +02:00
|
|
|
#include <catch2/internal/catch_random_seed_generation.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
|
|
|
|
2022-02-23 23:46:45 +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
|
|
|
struct ReporterAndFile {
|
|
|
|
|
std::string reporterName;
|
|
|
|
|
|
|
|
|
|
// If none, the output goes to the default output.
|
|
|
|
|
Optional<std::string> outputFileName;
|
|
|
|
|
|
|
|
|
|
friend bool operator==(ReporterAndFile const& lhs, ReporterAndFile const& rhs) {
|
|
|
|
|
return lhs.reporterName == rhs.reporterName && lhs.outputFileName == rhs.outputFileName;
|
|
|
|
|
}
|
|
|
|
|
friend std::ostream& operator<<(std::ostream &os, ReporterAndFile const& reporter);
|
|
|
|
|
};
|
|
|
|
|
|
2017-04-25 18:56:53 +01:00
|
|
|
bool listTests = false;
|
|
|
|
|
bool listTags = false;
|
|
|
|
|
bool listReporters = false;
|
2012-08-28 08:20:18 +01:00
|
|
|
|
2017-04-25 18:56:53 +01:00
|
|
|
bool showSuccessfulTests = false;
|
|
|
|
|
bool shouldDebugBreak = false;
|
|
|
|
|
bool noThrow = false;
|
|
|
|
|
bool showHelp = false;
|
|
|
|
|
bool showInvisibles = false;
|
|
|
|
|
bool filenamesAsTags = false;
|
2017-08-11 19:55:55 +01:00
|
|
|
bool libIdentify = false;
|
2021-12-13 15:15:23 +01:00
|
|
|
bool allowZeroTests = false;
|
2013-07-03 19:14:59 +01:00
|
|
|
|
2017-04-25 18:56:53 +01:00
|
|
|
int abortAfter = -1;
|
2021-10-08 21:32:03 +02:00
|
|
|
uint32_t rngSeed = generateRandomSeed(GenerateFrom::Default);
|
2019-04-23 23:41:13 +02:00
|
|
|
|
2021-07-11 12:46:05 -07: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;
|
2013-05-29 19:01:06 +01:00
|
|
|
|
2017-06-20 22:14:38 +03:00
|
|
|
Verbosity verbosity = Verbosity::Normal;
|
2017-04-25 18:56:53 +01:00
|
|
|
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;
|
2020-08-11 15:50:51 +02:00
|
|
|
UseColour useColour = UseColour::Auto;
|
2017-08-11 19:55:55 +01:00
|
|
|
WaitForKeypress::When waitForKeypress = WaitForKeypress::Never;
|
2013-05-29 08:12:57 +01:00
|
|
|
|
2021-02-06 20:12:07 +01:00
|
|
|
std::string defaultOutputFilename;
|
2012-06-08 08:22:56 +01:00
|
|
|
std::string name;
|
2013-06-04 08:37:28 +01:00
|
|
|
std::string processName;
|
2022-02-17 20:44:27 +01:00
|
|
|
std::vector<ReporterAndFile> reporterSpecifications;
|
2018-04-07 12:05:29 +02:00
|
|
|
|
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
|
|
|
|
|
|
|
|
|
2017-04-25 20:18:02 +01:00
|
|
|
class Config : public IConfig {
|
2010-12-31 22:07:47 +00:00
|
|
|
public:
|
2012-08-13 07:46:10 +01:00
|
|
|
|
2017-07-19 10:13:47 +02:00
|
|
|
Config() = default;
|
|
|
|
|
Config( ConfigData const& data );
|
2020-02-02 14:43:26 +01:00
|
|
|
~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
|
|
|
|
2021-02-06 20:12:07 +01:00
|
|
|
std::vector<ConfigData::ReporterAndFile> const& getReportersAndOutputFiles() const;
|
2022-02-23 23:46:45 +01:00
|
|
|
IStream const* getReporterOutputStream(std::size_t reporterIdx) const;
|
2017-06-20 22:14:38 +03:00
|
|
|
|
2019-04-01 22:33:57 +03:00
|
|
|
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;
|
2018-02-09 00:18:32 +02:00
|
|
|
bool hasTestFilters() const override;
|
2013-06-05 08:18:52 +01:00
|
|
|
|
2017-07-19 10:13:47 +02:00
|
|
|
bool showHelp() const;
|
2012-08-31 08:10:36 +01:00
|
|
|
|
2013-05-28 18:39:32 +01:00
|
|
|
// IConfig interface
|
2017-07-20 15:57:17 +01:00
|
|
|
bool allowThrows() const override;
|
2021-09-08 00:01:31 +02:00
|
|
|
StringRef name() const override;
|
2017-07-20 15:57:17 +01:00
|
|
|
bool includeSuccessfulResults() const override;
|
|
|
|
|
bool warnAboutMissingAssertions() const override;
|
2021-12-18 19:59:23 +01:00
|
|
|
bool warnAboutUnmatchedTestSpecs() const override;
|
2021-12-13 15:15:23 +01:00
|
|
|
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;
|
2021-10-08 21:32:03 +02:00
|
|
|
uint32_t rngSeed() const override;
|
2021-07-11 12:46:05 -07:00
|
|
|
unsigned int shardCount() const override;
|
|
|
|
|
unsigned int shardIndex() const override;
|
2020-08-11 15:50:51 +02:00
|
|
|
UseColour useColour() const override;
|
2017-07-20 15:57:17 +01:00
|
|
|
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;
|
2018-02-09 00:18:32 +02:00
|
|
|
bool m_hasTestFilters = false;
|
2010-11-12 19:55:53 +00:00
|
|
|
};
|
|
|
|
|
} // end namespace Catch
|
|
|
|
|
|
2020-08-29 20:48:32 +02:00
|
|
|
#endif // CATCH_CONFIG_HPP_INCLUDED
|