• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Created by Phil on 08/11/2010.
3  *  Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
4  *
5  *  Distributed under the Boost Software License, Version 1.0. (See accompanying
6  *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7  */
8 #ifndef TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED
9 #define TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED
10 
11 #include "catch_test_spec_parser.h"
12 #include "catch_interfaces_config.h"
13 
14 // Libstdc++ doesn't like incomplete classes for unique_ptr
15 #include "catch_stream.h"
16 
17 #include <memory>
18 #include <vector>
19 #include <string>
20 
21 #ifndef CATCH_CONFIG_CONSOLE_WIDTH
22 #define CATCH_CONFIG_CONSOLE_WIDTH 80
23 #endif
24 
25 namespace Catch {
26 
27     struct IStream;
28 
29     struct ConfigData {
30         bool listTests = false;
31         bool listTags = false;
32         bool listReporters = false;
33         bool listTestNamesOnly = false;
34 
35         bool showSuccessfulTests = false;
36         bool shouldDebugBreak = false;
37         bool noThrow = false;
38         bool showHelp = false;
39         bool showInvisibles = false;
40         bool filenamesAsTags = false;
41         bool libIdentify = false;
42 
43         int abortAfter = -1;
44         unsigned int rngSeed = 0;
45 
46         bool benchmarkNoAnalysis = false;
47         unsigned int benchmarkSamples = 100;
48         double benchmarkConfidenceInterval = 0.95;
49         unsigned int benchmarkResamples = 100000;
50         std::chrono::milliseconds::rep benchmarkWarmupTime = 100;
51 
52         Verbosity verbosity = Verbosity::Normal;
53         WarnAbout::What warnings = WarnAbout::Nothing;
54         ShowDurations::OrNot showDurations = ShowDurations::DefaultForReporter;
55         RunTests::InWhatOrder runOrder = RunTests::InDeclarationOrder;
56         UseColour::YesOrNo useColour = UseColour::Auto;
57         WaitForKeypress::When waitForKeypress = WaitForKeypress::Never;
58 
59         std::string outputFilename;
60         std::string name;
61         std::string processName;
62 #ifndef CATCH_CONFIG_DEFAULT_REPORTER
63 #define CATCH_CONFIG_DEFAULT_REPORTER "console"
64 #endif
65         std::string reporterName = CATCH_CONFIG_DEFAULT_REPORTER;
66 #undef CATCH_CONFIG_DEFAULT_REPORTER
67 
68         std::vector<std::string> testsOrTags;
69         std::vector<std::string> sectionsToRun;
70     };
71 
72 
73     class Config : public IConfig {
74     public:
75 
76         Config() = default;
77         Config( ConfigData const& data );
78         virtual ~Config() = default;
79 
80         std::string const& getFilename() const;
81 
82         bool listTests() const;
83         bool listTestNamesOnly() const;
84         bool listTags() const;
85         bool listReporters() const;
86 
87         std::string getProcessName() const;
88         std::string const& getReporterName() const;
89 
90         std::vector<std::string> const& getTestsOrTags() const override;
91         std::vector<std::string> const& getSectionsToRun() const override;
92 
93         TestSpec const& testSpec() const override;
94         bool hasTestFilters() const override;
95 
96         bool showHelp() const;
97 
98         // IConfig interface
99         bool allowThrows() const override;
100         std::ostream& stream() const override;
101         std::string name() const override;
102         bool includeSuccessfulResults() const override;
103         bool warnAboutMissingAssertions() const override;
104         bool warnAboutNoTests() const override;
105         ShowDurations::OrNot showDurations() const override;
106         RunTests::InWhatOrder runOrder() const override;
107         unsigned int rngSeed() const override;
108         UseColour::YesOrNo useColour() const override;
109         bool shouldDebugBreak() const override;
110         int abortAfter() const override;
111         bool showInvisibles() const override;
112         Verbosity verbosity() const override;
113         bool benchmarkNoAnalysis() const override;
114         int benchmarkSamples() const override;
115         double benchmarkConfidenceInterval() const override;
116         unsigned int benchmarkResamples() const override;
117         std::chrono::milliseconds benchmarkWarmupTime() const override;
118 
119     private:
120 
121         IStream const* openStream();
122         ConfigData m_data;
123 
124         std::unique_ptr<IStream const> m_stream;
125         TestSpec m_testSpec;
126         bool m_hasTestFilters = false;
127     };
128 
129 } // end namespace Catch
130 
131 #endif // TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED
132