File indexing completed on 2025-01-18 09:54:08
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef CATCH_CONFIG_HPP_INCLUDED
0009 #define CATCH_CONFIG_HPP_INCLUDED
0010
0011 #include <catch2/catch_test_spec.hpp>
0012 #include <catch2/interfaces/catch_interfaces_config.hpp>
0013 #include <catch2/internal/catch_unique_ptr.hpp>
0014 #include <catch2/internal/catch_optional.hpp>
0015 #include <catch2/internal/catch_stringref.hpp>
0016 #include <catch2/internal/catch_random_seed_generation.hpp>
0017 #include <catch2/internal/catch_reporter_spec_parser.hpp>
0018
0019 #include <chrono>
0020 #include <map>
0021 #include <string>
0022 #include <vector>
0023
0024 namespace Catch {
0025
0026 class IStream;
0027
0028
0029
0030
0031
0032
0033 struct ProcessedReporterSpec {
0034 std::string name;
0035 std::string outputFilename;
0036 ColourMode colourMode;
0037 std::map<std::string, std::string> customOptions;
0038 friend bool operator==( ProcessedReporterSpec const& lhs,
0039 ProcessedReporterSpec const& rhs );
0040 friend bool operator!=( ProcessedReporterSpec const& lhs,
0041 ProcessedReporterSpec const& rhs ) {
0042 return !( lhs == rhs );
0043 }
0044 };
0045
0046 struct ConfigData {
0047
0048 bool listTests = false;
0049 bool listTags = false;
0050 bool listReporters = false;
0051 bool listListeners = false;
0052
0053 bool showSuccessfulTests = false;
0054 bool shouldDebugBreak = false;
0055 bool noThrow = false;
0056 bool showHelp = false;
0057 bool showInvisibles = false;
0058 bool filenamesAsTags = false;
0059 bool libIdentify = false;
0060 bool allowZeroTests = false;
0061
0062 int abortAfter = -1;
0063 uint32_t rngSeed = generateRandomSeed(GenerateFrom::Default);
0064
0065 unsigned int shardCount = 1;
0066 unsigned int shardIndex = 0;
0067
0068 bool skipBenchmarks = false;
0069 bool benchmarkNoAnalysis = false;
0070 unsigned int benchmarkSamples = 100;
0071 double benchmarkConfidenceInterval = 0.95;
0072 unsigned int benchmarkResamples = 100000;
0073 std::chrono::milliseconds::rep benchmarkWarmupTime = 100;
0074
0075 Verbosity verbosity = Verbosity::Normal;
0076 WarnAbout::What warnings = WarnAbout::Nothing;
0077 ShowDurations showDurations = ShowDurations::DefaultForReporter;
0078 double minDuration = -1;
0079 TestRunOrder runOrder = TestRunOrder::Declared;
0080 ColourMode defaultColourMode = ColourMode::PlatformDefault;
0081 WaitForKeypress::When waitForKeypress = WaitForKeypress::Never;
0082
0083 std::string defaultOutputFilename;
0084 std::string name;
0085 std::string processName;
0086 std::vector<ReporterSpec> reporterSpecifications;
0087
0088 std::vector<std::string> testsOrTags;
0089 std::vector<std::string> sectionsToRun;
0090 };
0091
0092
0093 class Config : public IConfig {
0094 public:
0095
0096 Config() = default;
0097 Config( ConfigData const& data );
0098 ~Config() override;
0099
0100 bool listTests() const;
0101 bool listTags() const;
0102 bool listReporters() const;
0103 bool listListeners() const;
0104
0105 std::vector<ReporterSpec> const& getReporterSpecs() const;
0106 std::vector<ProcessedReporterSpec> const&
0107 getProcessedReporterSpecs() const;
0108
0109 std::vector<std::string> const& getTestsOrTags() const override;
0110 std::vector<std::string> const& getSectionsToRun() const override;
0111
0112 TestSpec const& testSpec() const override;
0113 bool hasTestFilters() const override;
0114
0115 bool showHelp() const;
0116
0117
0118 bool allowThrows() const override;
0119 StringRef name() const override;
0120 bool includeSuccessfulResults() const override;
0121 bool warnAboutMissingAssertions() const override;
0122 bool warnAboutUnmatchedTestSpecs() const override;
0123 bool zeroTestsCountAsSuccess() const override;
0124 ShowDurations showDurations() const override;
0125 double minDuration() const override;
0126 TestRunOrder runOrder() const override;
0127 uint32_t rngSeed() const override;
0128 unsigned int shardCount() const override;
0129 unsigned int shardIndex() const override;
0130 ColourMode defaultColourMode() const override;
0131 bool shouldDebugBreak() const override;
0132 int abortAfter() const override;
0133 bool showInvisibles() const override;
0134 Verbosity verbosity() const override;
0135 bool skipBenchmarks() const override;
0136 bool benchmarkNoAnalysis() const override;
0137 unsigned int benchmarkSamples() const override;
0138 double benchmarkConfidenceInterval() const override;
0139 unsigned int benchmarkResamples() const override;
0140 std::chrono::milliseconds benchmarkWarmupTime() const override;
0141
0142 private:
0143
0144 void readBazelEnvVars();
0145
0146 ConfigData m_data;
0147 std::vector<ProcessedReporterSpec> m_processedReporterSpecs;
0148 TestSpec m_testSpec;
0149 bool m_hasTestFilters = false;
0150 };
0151 }
0152
0153 #endif