line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
// Copyright Catch2 Authors |
3
|
|
|
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. |
4
|
|
|
|
|
|
|
// (See accompanying file LICENSE_1_0.txt or copy at |
5
|
|
|
|
|
|
|
// https://www.boost.org/LICENSE_1_0.txt) |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
// SPDX-License-Identifier: BSL-1.0 |
8
|
|
|
|
|
|
|
#ifndef CATCH_INTERFACES_REPORTER_HPP_INCLUDED |
9
|
|
|
|
|
|
|
#define CATCH_INTERFACES_REPORTER_HPP_INCLUDED |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
#include |
12
|
|
|
|
|
|
|
#include |
13
|
|
|
|
|
|
|
#include |
14
|
|
|
|
|
|
|
#include |
15
|
|
|
|
|
|
|
#include |
16
|
|
|
|
|
|
|
#include |
17
|
|
|
|
|
|
|
#include |
18
|
|
|
|
|
|
|
#include |
19
|
|
|
|
|
|
|
#include |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#include |
23
|
|
|
|
|
|
|
#include |
24
|
|
|
|
|
|
|
#include |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
namespace Catch { |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
struct ReporterDescription; |
29
|
|
|
|
|
|
|
struct TagInfo; |
30
|
|
|
|
|
|
|
struct TestCaseInfo; |
31
|
|
|
|
|
|
|
class TestCaseHandle; |
32
|
|
|
|
|
|
|
struct IConfig; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
struct ReporterConfig { |
35
|
|
|
|
|
|
|
explicit ReporterConfig( IConfig const* _fullConfig ); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
ReporterConfig( IConfig const* _fullConfig, std::ostream& _stream ); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
std::ostream& stream() const; |
40
|
|
|
|
|
|
|
IConfig const* fullConfig() const; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
private: |
43
|
|
|
|
|
|
|
std::ostream* m_stream; |
44
|
|
|
|
|
|
|
IConfig const* m_fullConfig; |
45
|
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
struct TestRunInfo { |
48
|
|
|
|
|
|
|
constexpr TestRunInfo(StringRef _name) : name(_name) {} |
49
|
|
|
|
|
|
|
StringRef name; |
50
|
|
|
|
|
|
|
}; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
struct AssertionStats { |
53
|
|
|
|
|
|
|
AssertionStats( AssertionResult const& _assertionResult, |
54
|
|
|
|
|
|
|
std::vector const& _infoMessages, |
55
|
|
|
|
|
|
|
Totals const& _totals ); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
AssertionStats( AssertionStats const& ) = default; |
58
|
|
|
|
|
|
|
AssertionStats( AssertionStats && ) = default; |
59
|
|
|
|
|
|
|
AssertionStats& operator = ( AssertionStats const& ) = delete; |
60
|
|
|
|
|
|
|
AssertionStats& operator = ( AssertionStats && ) = delete; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
AssertionResult assertionResult; |
63
|
|
|
|
|
|
|
std::vector infoMessages; |
64
|
|
|
|
|
|
|
Totals totals; |
65
|
|
|
|
|
|
|
}; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
struct SectionStats { |
68
|
|
|
|
|
|
|
SectionStats( SectionInfo const& _sectionInfo, |
69
|
|
|
|
|
|
|
Counts const& _assertions, |
70
|
|
|
|
|
|
|
double _durationInSeconds, |
71
|
|
|
|
|
|
|
bool _missingAssertions ); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
SectionInfo sectionInfo; |
74
|
|
|
|
|
|
|
Counts assertions; |
75
|
|
|
|
|
|
|
double durationInSeconds; |
76
|
|
|
|
|
|
|
bool missingAssertions; |
77
|
|
|
|
|
|
|
}; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
struct TestCaseStats { |
80
|
|
|
|
|
|
|
TestCaseStats( TestCaseInfo const& _testInfo, |
81
|
|
|
|
|
|
|
Totals const& _totals, |
82
|
|
|
|
|
|
|
std::string const& _stdOut, |
83
|
|
|
|
|
|
|
std::string const& _stdErr, |
84
|
|
|
|
|
|
|
bool _aborting ); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
TestCaseInfo const * testInfo; |
87
|
|
|
|
|
|
|
Totals totals; |
88
|
|
|
|
|
|
|
std::string stdOut; |
89
|
|
|
|
|
|
|
std::string stdErr; |
90
|
|
|
|
|
|
|
bool aborting; |
91
|
|
|
|
|
|
|
}; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
struct TestRunStats { |
94
|
|
|
|
|
|
|
TestRunStats( TestRunInfo const& _runInfo, |
95
|
|
|
|
|
|
|
Totals const& _totals, |
96
|
|
|
|
|
|
|
bool _aborting ); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
TestRunInfo runInfo; |
99
|
|
|
|
|
|
|
Totals totals; |
100
|
|
|
|
|
|
|
bool aborting; |
101
|
|
|
|
|
|
|
}; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
struct BenchmarkInfo { |
105
|
|
|
|
|
|
|
std::string name; |
106
|
|
|
|
|
|
|
double estimatedDuration; |
107
|
|
|
|
|
|
|
int iterations; |
108
|
|
|
|
|
|
|
int samples; |
109
|
|
|
|
|
|
|
unsigned int resamples; |
110
|
|
|
|
|
|
|
double clockResolution; |
111
|
|
|
|
|
|
|
double clockCost; |
112
|
|
|
|
|
|
|
}; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
template |
115
|
0
|
|
|
|
|
|
struct BenchmarkStats { |
116
|
|
|
|
|
|
|
BenchmarkInfo info; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
std::vector samples; |
119
|
|
|
|
|
|
|
Benchmark::Estimate mean; |
120
|
|
|
|
|
|
|
Benchmark::Estimate standardDeviation; |
121
|
|
|
|
|
|
|
Benchmark::OutlierClassification outliers; |
122
|
|
|
|
|
|
|
double outlierVariance; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
template |
125
|
|
|
|
|
|
|
operator BenchmarkStats() const { |
126
|
|
|
|
|
|
|
std::vector samples2; |
127
|
|
|
|
|
|
|
samples2.reserve(samples.size()); |
128
|
|
|
|
|
|
|
for (auto const& sample : samples) { |
129
|
|
|
|
|
|
|
samples2.push_back(Duration2(sample)); |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
return { |
132
|
|
|
|
|
|
|
info, |
133
|
|
|
|
|
|
|
CATCH_MOVE(samples2), |
134
|
|
|
|
|
|
|
mean, |
135
|
|
|
|
|
|
|
standardDeviation, |
136
|
|
|
|
|
|
|
outliers, |
137
|
|
|
|
|
|
|
outlierVariance, |
138
|
|
|
|
|
|
|
}; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
}; |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
//! By setting up its preferences, a reporter can modify Catch2's behaviour |
143
|
|
|
|
|
|
|
//! in some regards, e.g. it can request Catch2 to capture writes to |
144
|
|
|
|
|
|
|
//! stdout/stderr during test execution, and pass them to the reporter. |
145
|
|
|
|
|
|
|
struct ReporterPreferences { |
146
|
|
|
|
|
|
|
//! Catch2 should redirect writes to stdout and pass them to the |
147
|
|
|
|
|
|
|
//! reporter |
148
|
|
|
|
|
|
|
bool shouldRedirectStdOut = false; |
149
|
|
|
|
|
|
|
//! Catch2 should call `Reporter::assertionEnded` even for passing |
150
|
|
|
|
|
|
|
//! assertions |
151
|
|
|
|
|
|
|
bool shouldReportAllAssertions = false; |
152
|
|
|
|
|
|
|
}; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
//! The common base for all reporters and event listeners |
155
|
|
|
|
|
|
|
struct IStreamingReporter { |
156
|
|
|
|
|
|
|
protected: |
157
|
|
|
|
|
|
|
//! Derived classes can set up their preferences here |
158
|
|
|
|
|
|
|
ReporterPreferences m_preferences; |
159
|
|
|
|
|
|
|
//! The test run's config as filled in from CLI and defaults |
160
|
|
|
|
|
|
|
IConfig const* m_config; |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
public: |
163
|
|
|
|
|
|
|
IStreamingReporter( IConfig const* config ): m_config( config ) {} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
virtual ~IStreamingReporter(); // = default; |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
// Implementing class must also provide the following static methods: |
168
|
|
|
|
|
|
|
// static std::string getDescription(); |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
ReporterPreferences const& getPreferences() const { |
171
|
|
|
|
|
|
|
return m_preferences; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
//! Called when no test cases match provided test spec |
175
|
|
|
|
|
|
|
virtual void noMatchingTestCases( StringRef unmatchedSpec ) = 0; |
176
|
|
|
|
|
|
|
//! Called for all invalid arguments from the cli |
177
|
|
|
|
|
|
|
virtual void reportInvalidArguments( StringRef invalidArgument ) = 0; |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
/** |
180
|
|
|
|
|
|
|
* Called once in a testing run before tests are started |
181
|
|
|
|
|
|
|
* |
182
|
|
|
|
|
|
|
* Not called if tests won't be run (e.g. only listing will happen) |
183
|
|
|
|
|
|
|
*/ |
184
|
|
|
|
|
|
|
virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0; |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
//! Called _once_ for each TEST_CASE, no matter how many times it is entered |
187
|
|
|
|
|
|
|
virtual void testCaseStarting( TestCaseInfo const& testInfo ) = 0; |
188
|
|
|
|
|
|
|
//! Called _every time_ a TEST_CASE is entered, including repeats (due to sections) |
189
|
|
|
|
|
|
|
virtual void testCasePartialStarting( TestCaseInfo const& testInfo, uint64_t partNumber ) = 0; |
190
|
|
|
|
|
|
|
//! Called when a `SECTION` is being entered. Not called for skipped sections |
191
|
|
|
|
|
|
|
virtual void sectionStarting( SectionInfo const& sectionInfo ) = 0; |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
//! Called when user-code is being probed before the actual benchmark runs |
194
|
|
|
|
|
|
|
virtual void benchmarkPreparing( StringRef benchmarkName ) = 0; |
195
|
|
|
|
|
|
|
//! Called after probe but before the user-code is being benchmarked |
196
|
|
|
|
|
|
|
virtual void benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) = 0; |
197
|
|
|
|
|
|
|
//! Called with the benchmark results if benchmark successfully finishes |
198
|
|
|
|
|
|
|
virtual void benchmarkEnded( BenchmarkStats<> const& benchmarkStats ) = 0; |
199
|
|
|
|
|
|
|
//! Called if running the benchmarks fails for any reason |
200
|
|
|
|
|
|
|
virtual void benchmarkFailed( StringRef benchmarkName ) = 0; |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
//! Called before assertion success/failure is evaluated |
203
|
|
|
|
|
|
|
virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0; |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
//! Called after assertion was fully evaluated |
206
|
|
|
|
|
|
|
virtual void assertionEnded( AssertionStats const& assertionStats ) = 0; |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
//! Called after a `SECTION` has finished running |
209
|
|
|
|
|
|
|
virtual void sectionEnded( SectionStats const& sectionStats ) = 0; |
210
|
|
|
|
|
|
|
//! Called _every time_ a TEST_CASE is entered, including repeats (due to sections) |
211
|
|
|
|
|
|
|
virtual void testCasePartialEnded(TestCaseStats const& testCaseStats, uint64_t partNumber ) = 0; |
212
|
|
|
|
|
|
|
//! Called _once_ for each TEST_CASE, no matter how many times it is entered |
213
|
|
|
|
|
|
|
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0; |
214
|
|
|
|
|
|
|
/** |
215
|
|
|
|
|
|
|
* Called once after all tests in a testing run are finished |
216
|
|
|
|
|
|
|
* |
217
|
|
|
|
|
|
|
* Not called if tests weren't run (e.g. only listings happened) |
218
|
|
|
|
|
|
|
*/ |
219
|
|
|
|
|
|
|
virtual void testRunEnded( TestRunStats const& testRunStats ) = 0; |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
//! Called with test cases that are skipped due to the test run aborting |
222
|
|
|
|
|
|
|
virtual void skipTest( TestCaseInfo const& testInfo ) = 0; |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
//! Called if a fatal error (signal/structured exception) occured |
225
|
|
|
|
|
|
|
virtual void fatalErrorEncountered( StringRef error ) = 0; |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
//! Writes out information about provided reporters using reporter-specific format |
228
|
|
|
|
|
|
|
virtual void listReporters(std::vector const& descriptions) = 0; |
229
|
|
|
|
|
|
|
//! Writes out information about provided tests using reporter-specific format |
230
|
|
|
|
|
|
|
virtual void listTests(std::vector const& tests) = 0; |
231
|
|
|
|
|
|
|
//! Writes out information about the provided tags using reporter-specific format |
232
|
|
|
|
|
|
|
virtual void listTags(std::vector const& tags) = 0; |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
}; |
235
|
|
|
|
|
|
|
using IStreamingReporterPtr = Detail::unique_ptr; |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
} // end namespace Catch |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
#endif // CATCH_INTERFACES_REPORTER_HPP_INCLUDED |