mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 15:26:11 +01:00
Devirtualize more things in trackers
This commit is contained in:
parent
61461dfd1d
commit
70f5392210
@ -29,6 +29,10 @@ namespace TestCaseTracking {
|
||||
|
||||
ITracker::~ITracker() = default;
|
||||
|
||||
void ITracker::markAsNeedingAnotherRun() {
|
||||
m_runState = NeedsAnotherRun;
|
||||
}
|
||||
|
||||
void ITracker::addChild( ITrackerPtr&& child ) {
|
||||
m_children.push_back( std::move(child) );
|
||||
}
|
||||
@ -48,6 +52,24 @@ namespace TestCaseTracking {
|
||||
bool ITracker::isSectionTracker() const { return false; }
|
||||
bool ITracker::isGeneratorTracker() const { return false; }
|
||||
|
||||
bool ITracker::isSuccessfullyCompleted() const {
|
||||
return m_runState == CompletedSuccessfully;
|
||||
}
|
||||
|
||||
bool ITracker::isOpen() const {
|
||||
return m_runState != NotStarted && !isComplete();
|
||||
}
|
||||
|
||||
bool ITracker::hasStarted() const { return m_runState != NotStarted; }
|
||||
|
||||
void ITracker::openChild() {
|
||||
if (m_runState != ExecutingChildren) {
|
||||
m_runState = ExecutingChildren;
|
||||
if (m_parent) {
|
||||
m_parent->openChild();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ITracker& TrackerContext::startRun() {
|
||||
using namespace std::string_literals;
|
||||
@ -93,20 +115,6 @@ namespace TestCaseTracking {
|
||||
bool TrackerBase::isComplete() const {
|
||||
return m_runState == CompletedSuccessfully || m_runState == Failed;
|
||||
}
|
||||
bool TrackerBase::isSuccessfullyCompleted() const {
|
||||
return m_runState == CompletedSuccessfully;
|
||||
}
|
||||
bool TrackerBase::isOpen() const {
|
||||
return m_runState != NotStarted && !isComplete();
|
||||
}
|
||||
|
||||
void TrackerBase::openChild() {
|
||||
if( m_runState != ExecutingChildren ) {
|
||||
m_runState = ExecutingChildren;
|
||||
if( m_parent )
|
||||
m_parent->openChild();
|
||||
}
|
||||
}
|
||||
|
||||
void TrackerBase::open() {
|
||||
m_runState = Executing;
|
||||
@ -151,9 +159,6 @@ namespace TestCaseTracking {
|
||||
moveToParent();
|
||||
m_ctx.completeCycle();
|
||||
}
|
||||
void TrackerBase::markAsNeedingAnotherRun() {
|
||||
m_runState = NeedsAnotherRun;
|
||||
}
|
||||
|
||||
void TrackerBase::moveToParent() {
|
||||
assert( m_parent );
|
||||
|
@ -38,8 +38,18 @@ namespace TestCaseTracking {
|
||||
using Children = std::vector<ITrackerPtr>;
|
||||
|
||||
protected:
|
||||
enum CycleState {
|
||||
NotStarted,
|
||||
Executing,
|
||||
ExecutingChildren,
|
||||
NeedsAnotherRun,
|
||||
CompletedSuccessfully,
|
||||
Failed
|
||||
};
|
||||
|
||||
ITracker* m_parent = nullptr;
|
||||
Children m_children;
|
||||
CycleState m_runState = NotStarted;
|
||||
|
||||
public:
|
||||
ITracker( NameAndLocation const& nameAndLoc, ITracker* parent ):
|
||||
@ -60,15 +70,20 @@ namespace TestCaseTracking {
|
||||
|
||||
|
||||
// dynamic queries
|
||||
virtual bool isComplete() const = 0; // Successfully completed or failed
|
||||
virtual bool isSuccessfullyCompleted() const = 0;
|
||||
virtual bool isOpen() const = 0; // Started but not complete
|
||||
virtual bool hasStarted() const = 0;
|
||||
|
||||
//! Returns true if tracker run to completion (successfully or not)
|
||||
virtual bool isComplete() const = 0;
|
||||
//! Returns true if tracker run to completion succesfully
|
||||
bool isSuccessfullyCompleted() const;
|
||||
//! Returns true if tracker has started but hasn't been completed
|
||||
bool isOpen() const;
|
||||
//! Returns true iff tracker has started
|
||||
bool hasStarted() const;
|
||||
|
||||
// actions
|
||||
virtual void close() = 0; // Successfully complete
|
||||
virtual void fail() = 0;
|
||||
virtual void markAsNeedingAnotherRun() = 0;
|
||||
void markAsNeedingAnotherRun();
|
||||
|
||||
//! Register a nested ITracker
|
||||
void addChild( ITrackerPtr&& child );
|
||||
@ -84,7 +99,8 @@ namespace TestCaseTracking {
|
||||
}
|
||||
|
||||
|
||||
virtual void openChild() = 0;
|
||||
//! Marks tracker as executing a child, doing se recursively up the tree
|
||||
void openChild();
|
||||
|
||||
/**
|
||||
* Returns true if the instance is a section tracker
|
||||
@ -129,35 +145,18 @@ namespace TestCaseTracking {
|
||||
|
||||
class TrackerBase : public ITracker {
|
||||
protected:
|
||||
enum CycleState {
|
||||
NotStarted,
|
||||
Executing,
|
||||
ExecutingChildren,
|
||||
NeedsAnotherRun,
|
||||
CompletedSuccessfully,
|
||||
Failed
|
||||
};
|
||||
|
||||
TrackerContext& m_ctx;
|
||||
CycleState m_runState = NotStarted;
|
||||
|
||||
public:
|
||||
TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent );
|
||||
|
||||
bool isComplete() const override;
|
||||
bool isSuccessfullyCompleted() const override;
|
||||
bool isOpen() const override;
|
||||
bool hasStarted() const override {
|
||||
return m_runState != NotStarted;
|
||||
}
|
||||
|
||||
void openChild() override;
|
||||
|
||||
void open();
|
||||
|
||||
void close() override;
|
||||
void fail() override;
|
||||
void markAsNeedingAnotherRun() override;
|
||||
|
||||
private:
|
||||
void moveToParent();
|
||||
|
Loading…
Reference in New Issue
Block a user