mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36: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;
|
ITracker::~ITracker() = default;
|
||||||
|
|
||||||
|
void ITracker::markAsNeedingAnotherRun() {
|
||||||
|
m_runState = NeedsAnotherRun;
|
||||||
|
}
|
||||||
|
|
||||||
void ITracker::addChild( ITrackerPtr&& child ) {
|
void ITracker::addChild( ITrackerPtr&& child ) {
|
||||||
m_children.push_back( std::move(child) );
|
m_children.push_back( std::move(child) );
|
||||||
}
|
}
|
||||||
@ -48,6 +52,24 @@ namespace TestCaseTracking {
|
|||||||
bool ITracker::isSectionTracker() const { return false; }
|
bool ITracker::isSectionTracker() const { return false; }
|
||||||
bool ITracker::isGeneratorTracker() 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() {
|
ITracker& TrackerContext::startRun() {
|
||||||
using namespace std::string_literals;
|
using namespace std::string_literals;
|
||||||
@ -93,20 +115,6 @@ namespace TestCaseTracking {
|
|||||||
bool TrackerBase::isComplete() const {
|
bool TrackerBase::isComplete() const {
|
||||||
return m_runState == CompletedSuccessfully || m_runState == Failed;
|
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() {
|
void TrackerBase::open() {
|
||||||
m_runState = Executing;
|
m_runState = Executing;
|
||||||
@ -151,9 +159,6 @@ namespace TestCaseTracking {
|
|||||||
moveToParent();
|
moveToParent();
|
||||||
m_ctx.completeCycle();
|
m_ctx.completeCycle();
|
||||||
}
|
}
|
||||||
void TrackerBase::markAsNeedingAnotherRun() {
|
|
||||||
m_runState = NeedsAnotherRun;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrackerBase::moveToParent() {
|
void TrackerBase::moveToParent() {
|
||||||
assert( m_parent );
|
assert( m_parent );
|
||||||
|
@ -38,8 +38,18 @@ namespace TestCaseTracking {
|
|||||||
using Children = std::vector<ITrackerPtr>;
|
using Children = std::vector<ITrackerPtr>;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
enum CycleState {
|
||||||
|
NotStarted,
|
||||||
|
Executing,
|
||||||
|
ExecutingChildren,
|
||||||
|
NeedsAnotherRun,
|
||||||
|
CompletedSuccessfully,
|
||||||
|
Failed
|
||||||
|
};
|
||||||
|
|
||||||
ITracker* m_parent = nullptr;
|
ITracker* m_parent = nullptr;
|
||||||
Children m_children;
|
Children m_children;
|
||||||
|
CycleState m_runState = NotStarted;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ITracker( NameAndLocation const& nameAndLoc, ITracker* parent ):
|
ITracker( NameAndLocation const& nameAndLoc, ITracker* parent ):
|
||||||
@ -60,15 +70,20 @@ namespace TestCaseTracking {
|
|||||||
|
|
||||||
|
|
||||||
// dynamic queries
|
// dynamic queries
|
||||||
virtual bool isComplete() const = 0; // Successfully completed or failed
|
|
||||||
virtual bool isSuccessfullyCompleted() const = 0;
|
//! Returns true if tracker run to completion (successfully or not)
|
||||||
virtual bool isOpen() const = 0; // Started but not complete
|
virtual bool isComplete() const = 0;
|
||||||
virtual bool hasStarted() 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
|
// actions
|
||||||
virtual void close() = 0; // Successfully complete
|
virtual void close() = 0; // Successfully complete
|
||||||
virtual void fail() = 0;
|
virtual void fail() = 0;
|
||||||
virtual void markAsNeedingAnotherRun() = 0;
|
void markAsNeedingAnotherRun();
|
||||||
|
|
||||||
//! Register a nested ITracker
|
//! Register a nested ITracker
|
||||||
void addChild( ITrackerPtr&& child );
|
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
|
* Returns true if the instance is a section tracker
|
||||||
@ -129,35 +145,18 @@ namespace TestCaseTracking {
|
|||||||
|
|
||||||
class TrackerBase : public ITracker {
|
class TrackerBase : public ITracker {
|
||||||
protected:
|
protected:
|
||||||
enum CycleState {
|
|
||||||
NotStarted,
|
|
||||||
Executing,
|
|
||||||
ExecutingChildren,
|
|
||||||
NeedsAnotherRun,
|
|
||||||
CompletedSuccessfully,
|
|
||||||
Failed
|
|
||||||
};
|
|
||||||
|
|
||||||
TrackerContext& m_ctx;
|
TrackerContext& m_ctx;
|
||||||
CycleState m_runState = NotStarted;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent );
|
TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent );
|
||||||
|
|
||||||
bool isComplete() const override;
|
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 open();
|
||||||
|
|
||||||
void close() override;
|
void close() override;
|
||||||
void fail() override;
|
void fail() override;
|
||||||
void markAsNeedingAnotherRun() override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void moveToParent();
|
void moveToParent();
|
||||||
|
Loading…
Reference in New Issue
Block a user