Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
catch_test_case_tracker.h
Go to the documentation of this file.
1/*
2 * Created by Phil Nash on 23/7/2013
3 * Copyright 2013 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_TEST_CASE_TRACKER_HPP_INCLUDED
9#define TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
10
12#include "catch_common.h"
13
14#include <string>
15#include <vector>
16#include <memory>
17
18namespace Catch {
19namespace TestCaseTracking {
20
22 std::string name;
24
25 NameAndLocation( std::string const& _name, SourceLineInfo const& _location );
26 };
27
28 struct ITracker;
29
30 using ITrackerPtr = std::shared_ptr<ITracker>;
31
32 struct ITracker {
33 virtual ~ITracker();
34
35 // static queries
36 virtual NameAndLocation const& nameAndLocation() const = 0;
37
38 // dynamic queries
39 virtual bool isComplete() const = 0; // Successfully completed or failed
40 virtual bool isSuccessfullyCompleted() const = 0;
41 virtual bool isOpen() const = 0; // Started but not complete
42 virtual bool hasChildren() const = 0;
43
44 virtual ITracker& parent() = 0;
45
46 // actions
47 virtual void close() = 0; // Successfully complete
48 virtual void fail() = 0;
49 virtual void markAsNeedingAnotherRun() = 0;
50
51 virtual void addChild( ITrackerPtr const& child ) = 0;
53 virtual void openChild() = 0;
54
55 // Debug/ checking
56 virtual bool isSectionTracker() const = 0;
57 virtual bool isGeneratorTracker() const = 0;
58 };
59
61
62 enum RunState {
63 NotStarted,
64 Executing,
65 CompletedCycle
66 };
67
68 ITrackerPtr m_rootTracker;
69 ITracker* m_currentTracker = nullptr;
70 RunState m_runState = NotStarted;
71
72 public:
73
75 void endRun();
76
77 void startCycle();
78 void completeCycle();
79
80 bool completedCycle() const;
82 void setCurrentTracker( ITracker* tracker );
83 };
84
85 class TrackerBase : public ITracker {
86 protected:
95
96 using Children = std::vector<ITrackerPtr>;
102
103 public:
105
106 NameAndLocation const& nameAndLocation() const override;
107 bool isComplete() const override;
108 bool isSuccessfullyCompleted() const override;
109 bool isOpen() const override;
110 bool hasChildren() const override;
111
112
113 void addChild( ITrackerPtr const& child ) override;
114
116 ITracker& parent() override;
117
118 void openChild() override;
119
120 bool isSectionTracker() const override;
121 bool isGeneratorTracker() const override;
122
123 void open();
124
125 void close() override;
126 void fail() override;
127 void markAsNeedingAnotherRun() override;
128
129 private:
130 void moveToParent();
131 void moveToThis();
132 };
133
135 std::vector<std::string> m_filters;
136 public:
138
139 bool isSectionTracker() const override;
140
141 bool isComplete() const override;
142
144
145 void tryOpen();
146
147 void addInitialFilters( std::vector<std::string> const& filters );
148 void addNextFilters( std::vector<std::string> const& filters );
149 };
150
151} // namespace TestCaseTracking
152
156
157} // namespace Catch
158
159#endif // TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
void addNextFilters(std::vector< std::string > const &filters)
void addInitialFilters(std::vector< std::string > const &filters)
static SectionTracker & acquire(TrackerContext &ctx, NameAndLocation const &nameAndLocation)
SectionTracker(NameAndLocation const &nameAndLocation, TrackerContext &ctx, ITracker *parent)
ITrackerPtr findChild(NameAndLocation const &nameAndLocation) override
void addChild(ITrackerPtr const &child) override
NameAndLocation const & nameAndLocation() const override
TrackerBase(NameAndLocation const &nameAndLocation, TrackerContext &ctx, ITracker *parent)
std::shared_ptr< ITracker > ITrackerPtr
virtual void markAsNeedingAnotherRun()=0
virtual bool hasChildren() const =0
virtual ITracker & parent()=0
virtual bool isGeneratorTracker() const =0
virtual ITrackerPtr findChild(NameAndLocation const &nameAndLocation)=0
virtual bool isOpen() const =0
virtual bool isSectionTracker() const =0
virtual bool isComplete() const =0
virtual bool isSuccessfullyCompleted() const =0
virtual NameAndLocation const & nameAndLocation() const =0
virtual void addChild(ITrackerPtr const &child)=0
NameAndLocation(std::string const &_name, SourceLineInfo const &_location)