Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
catch_run_context.h
Go to the documentation of this file.
1 /*
2 * Created by Phil on 22/10/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_RUNNER_IMPL_HPP_INCLUDED
9#define TWOBLUECUBES_CATCH_RUNNER_IMPL_HPP_INCLUDED
10
15#include "catch_config.hpp"
16#include "catch_test_registry.h"
18#include "catch_capture.hpp"
19#include "catch_totals.h"
20#include "catch_test_spec.h"
22#include "catch_timer.h"
25
26#include <string>
27
28namespace Catch {
29
30 struct IMutableContext;
31
33
34 class RunContext : public IResultCapture, public IRunner {
35
36 public:
37 RunContext( RunContext const& ) = delete;
38 RunContext& operator =( RunContext const& ) = delete;
39
40 explicit RunContext( IConfigPtr const& _config, IStreamingReporterPtr&& reporter );
41
42 ~RunContext() override;
43
44 void testGroupStarting( std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount );
45 void testGroupEnded( std::string const& testSpec, Totals const& totals, std::size_t groupIndex, std::size_t groupsCount );
46
47 Totals runTest(TestCase const& testCase);
48
49 IConfigPtr config() const;
51
52 public: // IResultCapture
53
54 // Assertion handlers
55 void handleExpr
56 ( AssertionInfo const& info,
57 ITransientExpression const& expr,
58 AssertionReaction& reaction ) override;
59 void handleMessage
60 ( AssertionInfo const& info,
61 ResultWas::OfType resultType,
62 StringRef const& message,
63 AssertionReaction& reaction ) override;
65 ( AssertionInfo const& info,
66 AssertionReaction& reaction ) override;
68 ( AssertionInfo const& info,
69 std::string const& message,
70 AssertionReaction& reaction ) override;
72 ( AssertionInfo const& info ) override;
73 void handleNonExpr
74 ( AssertionInfo const &info,
75 ResultWas::OfType resultType,
76 AssertionReaction &reaction ) override;
77
78 bool sectionStarted( SectionInfo const& sectionInfo, Counts& assertions ) override;
79
80 void sectionEnded( SectionEndInfo const& endInfo ) override;
81 void sectionEndedEarly( SectionEndInfo const& endInfo ) override;
82
83 auto acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IGeneratorTracker& override;
84
85 void benchmarkStarting( BenchmarkInfo const& info ) override;
86 void benchmarkEnded( BenchmarkStats const& stats ) override;
87
88 void pushScopedMessage( MessageInfo const& message ) override;
89 void popScopedMessage( MessageInfo const& message ) override;
90
91 void emplaceUnscopedMessage( MessageBuilder const& builder ) override;
92
93 std::string getCurrentTestName() const override;
94
95 const AssertionResult* getLastResult() const override;
96
97 void exceptionEarlyReported() override;
98
99 void handleFatalErrorCondition( StringRef message ) override;
100
101 bool lastAssertionPassed() override;
102
103 void assertionPassed() override;
104
105 public:
106 // !TBD We need to do this another way!
107 bool aborting() const final;
108
109 private:
110
111 void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr );
112 void invokeActiveTestCase();
113
114 void resetAssertionInfo();
115 bool testForMissingAssertions( Counts& assertions );
116
117 void assertionEnded( AssertionResult const& result );
118 void reportExpr
119 ( AssertionInfo const &info,
120 ResultWas::OfType resultType,
121 ITransientExpression const *expr,
122 bool negated );
123
124 void populateReaction( AssertionReaction& reaction );
125
126 private:
127
128 void handleUnfinishedSections();
129
130 TestRunInfo m_runInfo;
131 IMutableContext& m_context;
132 TestCase const* m_activeTestCase = nullptr;
133 ITracker* m_testCaseTracker = nullptr;
134 Option<AssertionResult> m_lastResult;
135
136 IConfigPtr m_config;
137 Totals m_totals;
138 IStreamingReporterPtr m_reporter;
139 std::vector<MessageInfo> m_messages;
140 std::vector<ScopedMessage> m_messageScopes; /* Keeps owners of so-called unscoped messages. */
141 AssertionInfo m_lastAssertionInfo;
142 std::vector<SectionEndInfo> m_unfinishedSections;
143 std::vector<ITracker*> m_activeSections;
144 TrackerContext m_trackerContext;
145 bool m_lastAssertionPassed = false;
146 bool m_shouldReportUnexpected = true;
147 bool m_includeSuccessfulResults;
148 };
149
150} // end namespace Catch
151
152#endif // TWOBLUECUBES_CATCH_RUNNER_IMPL_HPP_INCLUDED
void handleIncomplete(AssertionInfo const &info) override
IConfigPtr config() const
void benchmarkStarting(BenchmarkInfo const &info) override
auto acquireGeneratorTracker(SourceLineInfo const &lineInfo) -> IGeneratorTracker &override
RunContext(RunContext const &)=delete
void popScopedMessage(MessageInfo const &message) override
void benchmarkEnded(BenchmarkStats const &stats) override
void sectionEnded(SectionEndInfo const &endInfo) override
Totals runTest(TestCase const &testCase)
void emplaceUnscopedMessage(MessageBuilder const &builder) override
std::string getCurrentTestName() const override
RunContext & operator=(RunContext const &)=delete
void handleExpr(AssertionInfo const &info, ITransientExpression const &expr, AssertionReaction &reaction) override
void sectionEndedEarly(SectionEndInfo const &endInfo) override
void testGroupEnded(std::string const &testSpec, Totals const &totals, std::size_t groupIndex, std::size_t groupsCount)
IStreamingReporter & reporter() const
void exceptionEarlyReported() override
void assertionPassed() override
bool lastAssertionPassed() override
void pushScopedMessage(MessageInfo const &message) override
void handleNonExpr(AssertionInfo const &info, ResultWas::OfType resultType, AssertionReaction &reaction) override
const AssertionResult * getLastResult() const override
void handleFatalErrorCondition(StringRef message) override
void handleMessage(AssertionInfo const &info, ResultWas::OfType resultType, StringRef const &message, AssertionReaction &reaction) override
bool sectionStarted(SectionInfo const &sectionInfo, Counts &assertions) override
bool aborting() const final
void handleUnexpectedExceptionNotThrown(AssertionInfo const &info, AssertionReaction &reaction) override
void testGroupStarting(std::string const &testSpec, std::size_t groupIndex, std::size_t groupsCount)
void handleUnexpectedInflightException(AssertionInfo const &info, std::string const &message, AssertionReaction &reaction) override
std::unique_ptr< IStreamingReporter > IStreamingReporterPtr
std::shared_ptr< IConfig const > IConfigPtr
Definition name.hpp:106