File indexing completed on 2025-01-30 10:02:48
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef CATCH_INTERFACES_REPORTER_HPP_INCLUDED
0009 #define CATCH_INTERFACES_REPORTER_HPP_INCLUDED
0010
0011 #include <catch2/catch_section_info.hpp>
0012 #include <catch2/catch_totals.hpp>
0013 #include <catch2/catch_assertion_result.hpp>
0014 #include <catch2/internal/catch_message_info.hpp>
0015 #include <catch2/internal/catch_stringref.hpp>
0016 #include <catch2/internal/catch_test_run_info.hpp>
0017 #include <catch2/internal/catch_unique_ptr.hpp>
0018 #include <catch2/internal/catch_move_and_forward.hpp>
0019 #include <catch2/benchmark/detail/catch_benchmark_stats.hpp>
0020
0021 #include <map>
0022 #include <string>
0023 #include <vector>
0024 #include <iosfwd>
0025
0026 namespace Catch {
0027
0028 struct ReporterDescription;
0029 struct ListenerDescription;
0030 struct TagInfo;
0031 struct TestCaseInfo;
0032 class TestCaseHandle;
0033 class IConfig;
0034 class IStream;
0035 enum class ColourMode : std::uint8_t;
0036
0037 struct ReporterConfig {
0038 ReporterConfig( IConfig const* _fullConfig,
0039 Detail::unique_ptr<IStream> _stream,
0040 ColourMode colourMode,
0041 std::map<std::string, std::string> customOptions );
0042
0043 ReporterConfig( ReporterConfig&& ) = default;
0044 ReporterConfig& operator=( ReporterConfig&& ) = default;
0045 ~ReporterConfig();
0046
0047 Detail::unique_ptr<IStream> takeStream() &&;
0048 IConfig const* fullConfig() const;
0049 ColourMode colourMode() const;
0050 std::map<std::string, std::string> const& customOptions() const;
0051
0052 private:
0053 Detail::unique_ptr<IStream> m_stream;
0054 IConfig const* m_fullConfig;
0055 ColourMode m_colourMode;
0056 std::map<std::string, std::string> m_customOptions;
0057 };
0058
0059 struct AssertionStats {
0060 AssertionStats( AssertionResult const& _assertionResult,
0061 std::vector<MessageInfo> const& _infoMessages,
0062 Totals const& _totals );
0063
0064 AssertionStats( AssertionStats const& ) = default;
0065 AssertionStats( AssertionStats && ) = default;
0066 AssertionStats& operator = ( AssertionStats const& ) = delete;
0067 AssertionStats& operator = ( AssertionStats && ) = delete;
0068
0069 AssertionResult assertionResult;
0070 std::vector<MessageInfo> infoMessages;
0071 Totals totals;
0072 };
0073
0074 struct SectionStats {
0075 SectionStats( SectionInfo&& _sectionInfo,
0076 Counts const& _assertions,
0077 double _durationInSeconds,
0078 bool _missingAssertions );
0079
0080 SectionInfo sectionInfo;
0081 Counts assertions;
0082 double durationInSeconds;
0083 bool missingAssertions;
0084 };
0085
0086 struct TestCaseStats {
0087 TestCaseStats( TestCaseInfo const& _testInfo,
0088 Totals const& _totals,
0089 std::string&& _stdOut,
0090 std::string&& _stdErr,
0091 bool _aborting );
0092
0093 TestCaseInfo const * testInfo;
0094 Totals totals;
0095 std::string stdOut;
0096 std::string stdErr;
0097 bool aborting;
0098 };
0099
0100 struct TestRunStats {
0101 TestRunStats( TestRunInfo const& _runInfo,
0102 Totals const& _totals,
0103 bool _aborting );
0104
0105 TestRunInfo runInfo;
0106 Totals totals;
0107 bool aborting;
0108 };
0109
0110
0111
0112
0113 struct ReporterPreferences {
0114
0115
0116 bool shouldRedirectStdOut = false;
0117
0118
0119 bool shouldReportAllAssertions = false;
0120 };
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134 class IEventListener {
0135 protected:
0136
0137 ReporterPreferences m_preferences;
0138
0139 IConfig const* m_config;
0140
0141 public:
0142 IEventListener( IConfig const* config ): m_config( config ) {}
0143
0144 virtual ~IEventListener();
0145
0146
0147
0148
0149 ReporterPreferences const& getPreferences() const {
0150 return m_preferences;
0151 }
0152
0153
0154 virtual void noMatchingTestCases( StringRef unmatchedSpec ) = 0;
0155
0156 virtual void reportInvalidTestSpec( StringRef invalidArgument ) = 0;
0157
0158
0159
0160
0161
0162
0163 virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0;
0164
0165
0166 virtual void testCaseStarting( TestCaseInfo const& testInfo ) = 0;
0167
0168 virtual void testCasePartialStarting( TestCaseInfo const& testInfo, uint64_t partNumber ) = 0;
0169
0170 virtual void sectionStarting( SectionInfo const& sectionInfo ) = 0;
0171
0172
0173 virtual void benchmarkPreparing( StringRef benchmarkName ) = 0;
0174
0175 virtual void benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) = 0;
0176
0177 virtual void benchmarkEnded( BenchmarkStats<> const& benchmarkStats ) = 0;
0178
0179 virtual void benchmarkFailed( StringRef benchmarkName ) = 0;
0180
0181
0182 virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0;
0183
0184
0185 virtual void assertionEnded( AssertionStats const& assertionStats ) = 0;
0186
0187
0188 virtual void sectionEnded( SectionStats const& sectionStats ) = 0;
0189
0190 virtual void testCasePartialEnded(TestCaseStats const& testCaseStats, uint64_t partNumber ) = 0;
0191
0192 virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0;
0193
0194
0195
0196
0197
0198 virtual void testRunEnded( TestRunStats const& testRunStats ) = 0;
0199
0200
0201
0202
0203
0204
0205
0206 virtual void skipTest( TestCaseInfo const& testInfo ) = 0;
0207
0208
0209 virtual void fatalErrorEncountered( StringRef error ) = 0;
0210
0211
0212 virtual void listReporters(std::vector<ReporterDescription> const& descriptions) = 0;
0213
0214 virtual void listListeners(std::vector<ListenerDescription> const& descriptions) = 0;
0215
0216 virtual void listTests(std::vector<TestCaseHandle> const& tests) = 0;
0217
0218 virtual void listTags(std::vector<TagInfo> const& tags) = 0;
0219 };
0220 using IEventListenerPtr = Detail::unique_ptr<IEventListener>;
0221
0222 }
0223
0224 #endif