Warning, file /include/catch2/internal/catch_run_context.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef CATCH_RUN_CONTEXT_HPP_INCLUDED
0009 #define CATCH_RUN_CONTEXT_HPP_INCLUDED
0010
0011 #include <catch2/interfaces/catch_interfaces_capture.hpp>
0012 #include <catch2/internal/catch_test_registry.hpp>
0013 #include <catch2/internal/catch_test_run_info.hpp>
0014 #include <catch2/internal/catch_fatal_condition_handler.hpp>
0015 #include <catch2/catch_test_case_info.hpp>
0016 #include <catch2/catch_message.hpp>
0017 #include <catch2/catch_totals.hpp>
0018 #include <catch2/internal/catch_test_case_tracker.hpp>
0019 #include <catch2/catch_assertion_info.hpp>
0020 #include <catch2/catch_assertion_result.hpp>
0021 #include <catch2/internal/catch_optional.hpp>
0022 #include <catch2/internal/catch_move_and_forward.hpp>
0023
0024 #include <string>
0025
0026 namespace Catch {
0027
0028 class IGeneratorTracker;
0029 class IConfig;
0030 class IEventListener;
0031 using IEventListenerPtr = Detail::unique_ptr<IEventListener>;
0032 class OutputRedirect;
0033
0034
0035
0036 class RunContext final : public IResultCapture {
0037
0038 public:
0039 RunContext( RunContext const& ) = delete;
0040 RunContext& operator =( RunContext const& ) = delete;
0041
0042 explicit RunContext( IConfig const* _config, IEventListenerPtr&& reporter );
0043
0044 ~RunContext() override;
0045
0046 Totals runTest(TestCaseHandle const& testCase);
0047
0048 public:
0049
0050
0051 void handleExpr
0052 ( AssertionInfo const& info,
0053 ITransientExpression const& expr,
0054 AssertionReaction& reaction ) override;
0055 void handleMessage
0056 ( AssertionInfo const& info,
0057 ResultWas::OfType resultType,
0058 std::string&& message,
0059 AssertionReaction& reaction ) override;
0060 void handleUnexpectedExceptionNotThrown
0061 ( AssertionInfo const& info,
0062 AssertionReaction& reaction ) override;
0063 void handleUnexpectedInflightException
0064 ( AssertionInfo const& info,
0065 std::string&& message,
0066 AssertionReaction& reaction ) override;
0067 void handleIncomplete
0068 ( AssertionInfo const& info ) override;
0069 void handleNonExpr
0070 ( AssertionInfo const &info,
0071 ResultWas::OfType resultType,
0072 AssertionReaction &reaction ) override;
0073
0074 void notifyAssertionStarted( AssertionInfo const& info ) override;
0075 bool sectionStarted( StringRef sectionName,
0076 SourceLineInfo const& sectionLineInfo,
0077 Counts& assertions ) override;
0078
0079 void sectionEnded( SectionEndInfo&& endInfo ) override;
0080 void sectionEndedEarly( SectionEndInfo&& endInfo ) override;
0081
0082 IGeneratorTracker*
0083 acquireGeneratorTracker( StringRef generatorName,
0084 SourceLineInfo const& lineInfo ) override;
0085 IGeneratorTracker* createGeneratorTracker(
0086 StringRef generatorName,
0087 SourceLineInfo lineInfo,
0088 Generators::GeneratorBasePtr&& generator ) override;
0089
0090
0091 void benchmarkPreparing( StringRef name ) override;
0092 void benchmarkStarting( BenchmarkInfo const& info ) override;
0093 void benchmarkEnded( BenchmarkStats<> const& stats ) override;
0094 void benchmarkFailed( StringRef error ) override;
0095
0096 void pushScopedMessage( MessageInfo const& message ) override;
0097 void popScopedMessage( MessageInfo const& message ) override;
0098
0099 void emplaceUnscopedMessage( MessageBuilder&& builder ) override;
0100
0101 std::string getCurrentTestName() const override;
0102
0103 const AssertionResult* getLastResult() const override;
0104
0105 void exceptionEarlyReported() override;
0106
0107 void handleFatalErrorCondition( StringRef message ) override;
0108
0109 bool lastAssertionPassed() override;
0110
0111 void assertionPassed() override;
0112
0113 public:
0114
0115 bool aborting() const;
0116
0117 private:
0118
0119 void runCurrentTest();
0120 void invokeActiveTestCase();
0121
0122 void resetAssertionInfo();
0123 bool testForMissingAssertions( Counts& assertions );
0124
0125 void assertionEnded( AssertionResult&& result );
0126 void reportExpr
0127 ( AssertionInfo const &info,
0128 ResultWas::OfType resultType,
0129 ITransientExpression const *expr,
0130 bool negated );
0131
0132 void populateReaction( AssertionReaction& reaction );
0133
0134 private:
0135
0136 void handleUnfinishedSections();
0137
0138 TestRunInfo m_runInfo;
0139 TestCaseHandle const* m_activeTestCase = nullptr;
0140 ITracker* m_testCaseTracker = nullptr;
0141 Optional<AssertionResult> m_lastResult;
0142
0143 IConfig const* m_config;
0144 Totals m_totals;
0145 IEventListenerPtr m_reporter;
0146 std::vector<MessageInfo> m_messages;
0147 std::vector<ScopedMessage> m_messageScopes;
0148 AssertionInfo m_lastAssertionInfo;
0149 std::vector<SectionEndInfo> m_unfinishedSections;
0150 std::vector<ITracker*> m_activeSections;
0151 TrackerContext m_trackerContext;
0152 Detail::unique_ptr<OutputRedirect> m_outputRedirect;
0153 FatalConditionHandler m_fatalConditionhandler;
0154 bool m_lastAssertionPassed = false;
0155 bool m_shouldReportUnexpected = true;
0156 bool m_includeSuccessfulResults;
0157 };
0158
0159 void seedRng(IConfig const& config);
0160 unsigned int rngSeed();
0161 }
0162
0163 #endif