Skip to content

Commit

Permalink
Merge pull request #59 from rweickelt/bugfix/no-stack-recursion
Browse files Browse the repository at this point in the history
Removes stack recursion during test case execution
  • Loading branch information
rweickelt authored Nov 1, 2018
2 parents 0412700 + 544575e commit 18cbbdc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/qst/job.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class Job
Id m_id = InvalidId;
};

Q_DECLARE_METATYPE(Job)

uint qHash(const Job& job);

inline bool Job::isValid() const { return m_id != InvalidId; }
Expand Down
18 changes: 16 additions & 2 deletions src/qst/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

#include <QtCore/QCoreApplication>
#include <QtCore/QPointer>
#include <QtCore/QEventLoop>
#include <QtQml/QQmlContext>
#include <QtQml/QQmlEngine>

Expand Down Expand Up @@ -131,6 +132,7 @@ void execRunCommand()
qmlRegisterType<QstService>("qst", 1, 0, "QstService");
qmlRegisterUncreatableType<TextFile>("qst", 1, 0, "TextFile", "TextFile can only be created in a JS context");

qRegisterMetaType<Job>();
qRegisterMetaType<Testcase::State>();
qRegisterMetaType<QmlContext>();
qRegisterMetaType<QList<QmlContext> >();
Expand Down Expand Up @@ -177,9 +179,21 @@ void execRunCommand()

// Schedules jobs one-by-one, taking dependency relations into account.
SerialJobScheduler scheduler(dependencyResolver.jobGraph());
QObject::connect(&scheduler, &SerialJobScheduler::jobReady, &dispatcher, &JobDispatcher::dispatch);
QObject::connect(&dispatcher, &JobDispatcher::finished, &scheduler, &SerialJobScheduler::onJobFinished);
QEventLoop eventLoop;

QObject::connect(&scheduler, &SerialJobScheduler::jobReady,
&dispatcher, &JobDispatcher::dispatch,
Qt::QueuedConnection);

QObject::connect(&dispatcher, &JobDispatcher::finished,
&scheduler, &SerialJobScheduler::onJobFinished,
Qt::QueuedConnection);

QObject::connect(&scheduler, &SerialJobScheduler::finished,
&eventLoop, &QEventLoop::quit);

scheduler.start();
eventLoop.exec();

if (dispatcher.results().contains(Testcase::Fail))
{
Expand Down

0 comments on commit 18cbbdc

Please sign in to comment.