remove async mode

This commit is contained in:
Andrei Yankovich 2020-01-20 16:40:18 +03:00
parent 5d03b3951b
commit fab70df688
6 changed files with 24 additions and 178 deletions

View File

@ -30,21 +30,7 @@ int main(int argc, char *argv[]) {
}
QuasarAppUtils::Params::setEnable("noWriteInFileLog", true);
QCoreApplication app(argc, argv);
Deploy deploy;
if (deploy.run(true)) {
app.exit(1);
}
QObject::connect(&deploy, &Deploy::sigFinish, [&app](int code){
app.exit(code);
});
QTimer::singleShot(10 * 60 * 1000, [&app](){
app.exit(ASyncPackingError);
});
return app.exec();
return deploy.run();
}

View File

@ -18,16 +18,21 @@ Deploy::Deploy() {
_packing = new Packing();
_paramsParser = new ConfigParser(_fileManager, _scaner, _packing);
connect(this, &Deploy::sigStart, this, &Deploy::handleStart, Qt::QueuedConnection);
}
int Deploy::run(bool async) {
if (async) {
emit sigStart();
return Good;
int Deploy::run() {
if (!prepare()) {
return PrepareError;
}
return runPrivate();
if (!deploy()) {
return DeployError;
}
if (!packing())
return PackingError;
return Good;
}
Deploy::~Deploy() {
@ -84,41 +89,7 @@ bool Deploy::deploy() {
return true;
}
bool Deploy::packing(bool async) {
if (async) {
connect(_packing, &Packing::sigFinished, this, &Deploy::sigFinish, Qt::QueuedConnection);
}
bool Deploy::packing() {
return _packing->create(async);
}
int Deploy::runPrivate(bool async) {
if (!prepare()) {
return PrepareError;
}
if (!deploy()) {
return DeployError;
}
if (async) {
if (!packing(async))
return PackingError;
return ASyncGood;
}
if (!packing(async))
return PackingError;
return Good;
}
void Deploy::handleStart() {
int exit = runPrivate(true);
if (exit == ASyncGood) {
return;
}
emit sigFinish(exit);
return _packing->create();
}

View File

@ -10,9 +10,6 @@
#include "deploy_global.h"
#include <QObject>
class ConfigParser;
class Extracter;
@ -26,16 +23,11 @@ enum exitCodes {
DeployError = 0x2,
PackingError = 0x3,
ASync = 0x10,
ASyncGood = Good | ASync,
ASyncPackingError = PackingError | ASync,
};
class DEPLOYSHARED_EXPORT Deploy : public QObject
class DEPLOYSHARED_EXPORT Deploy
{
Q_OBJECT
private:
ConfigParser * _paramsParser = nullptr;
@ -46,22 +38,14 @@ private:
bool prepare();
bool deploy();
bool packing(bool async);
int runPrivate(bool async = false);
bool packing();
private slots:
void handleStart();
signals:
void sigFinish(int code);
void sigStart();
public:
Deploy();
int run(bool async = false);
int run();
~Deploy();
friend class deploytest;
};

View File

@ -15,10 +15,6 @@ Packing::Packing() {
connect(_proc, SIGNAL(readyReadStandardOutput()),
this, SLOT(handleOutputUpdate()));
connect(_proc, qOverload<int, QProcess::ExitStatus>(&QProcess::finished),
this, &Packing::handleFinished, Qt::QueuedConnection);
// moveToThread( new QThread(this));
}
Packing::~Packing() {
@ -29,7 +25,7 @@ void Packing::setDistribution(iDistribution *pakage) {
_pakage = pakage;
}
bool Packing::create(bool async) {
bool Packing::create() {
if (!_pakage)
return false;
@ -53,7 +49,7 @@ bool Packing::create(bool async) {
return false;
}
if (!async && !_proc->waitForFinished(-1)) {
if (!_proc->waitForFinished(-1)) {
return false;
}
@ -65,9 +61,7 @@ bool Packing::create(bool async) {
QuasarAppUtils::Params::verboseLog(message,
QuasarAppUtils::Info);
if (!async) {
handleFinished(_proc->exitCode(), {});
}
_pakage->removeTemplate();
return true;
}
@ -84,9 +78,4 @@ void Packing::handleOutputUpdate() {
qInfo() << erroutLog;
}
void Packing::handleFinished(int exitCode, QProcess::ExitStatus ) {
_pakage->removeTemplate();
emit sigFinished(exitCode);
}

View File

@ -21,17 +21,14 @@ public:
Packing();
~Packing();
void setDistribution(iDistribution *pakage);
bool create(bool async);
bool create();
private:
iDistribution *_pakage = nullptr;
QProcess *_proc = nullptr;
private slots:
void handleOutputUpdate();
void handleFinished(int exitCode, QProcess::ExitStatus);
signals:
void sigFinished(int code);
};
#endif // PACKING_H

View File

@ -48,8 +48,7 @@ private:
void runTestParams(const QStringList &list, QSet<QString> *tree = nullptr,
bool noWarnings = false,
bool onlySize = false,
bool async = false);
bool onlySize = false);
void checkResults(const QSet<QString> &tree, bool noWarnings, bool onlySize = false);
public:
@ -137,9 +136,6 @@ private slots:
// qif flags
void testQIF();
void testAsync();
void testDependencyMap();
};
@ -626,83 +622,6 @@ void deploytest::testQIF() {
}
void deploytest::testAsync()
{
TestUtils utils;
#ifdef Q_OS_UNIX
QString bin = TestBinDir + "TestQMLWidgets";
QString target1 = TestBinDir + "TestOnlyC";
QString qmake = TestQtDir + "bin/qmake";
auto comapareTree = utils.createTree({
"./" + DISTRO_DIR + "/Application.run",
});
#else
QString bin = TestBinDir + "TestQMLWidgets.exe";
QString target1 = TestBinDir + "TestOnlyC.exe";
QString qmake = TestQtDir + "bin/qmake.exe";
auto comapareTree = utils.createTree({
"./" + DISTRO_DIR + "/Application.exe",
});
#endif
#ifdef Q_OS_UNIX
QString target2 = TestBinDir + "TestQMLWidgets";
QString target3 = TestBinDir + "QtWidgetsProject";
#else
QString target2 = TestBinDir + "TestQMLWidgets.exe";
QString target3 = TestBinDir + "QtWidgetsProject.exe";
#endif
bin = target1;
bin += "," + target2;
bin += "," + target3;
auto prefixString = "/prefix1/;" + QFileInfo(target1).absoluteFilePath() + ",/prefix2/;" + QFileInfo(target2).absoluteFilePath();
// async test
int argc =0;
char * argv[] = {nullptr};
QCoreApplication app(argc, argv);
Deploy deploy;
QTimer::singleShot(1, [&deploy, &prefixString, &bin](){
QuasarAppUtils::Params::parseParams({"-bin", bin, "force-clear",
"-binOut", "/lol",
"-libOut", "/lolLib",
"-trOut", "/lolTr",
"-pluginOut", "/p",
"-qmlOut", "/q",
"-qmlDir", "prefix2;" + TestBinDir + "/../TestQMLWidgets",
"-targetPrefix", prefixString, "qif"});
QVERIFY(deploy.run(true) == Good);
});
QObject::connect(&deploy, &Deploy::sigFinish, [&app](int code){
app.exit(code);
});
QTimer::singleShot(10 * 60 * 1000, [&app](){
app.exit(ASyncPackingError);
});
QVERIFY(app.exec() == Good);
checkResults(comapareTree, false, false);
}
void deploytest::testDependencyMap() {
DependencyMap dep1, dep2, dep3;
@ -936,12 +855,12 @@ void deploytest::testSetTargetDir() {
}
void deploytest::runTestParams(const QStringList &list, QSet<QString>* tree,
bool noWarnings, bool onlySize, bool async) {
bool noWarnings, bool onlySize) {
QuasarAppUtils::Params::parseParams(list);
Deploy deploy;
QVERIFY(deploy.run(async) == Good);
QVERIFY(deploy.run() == Good);
if (tree) {
checkResults(*tree, noWarnings, onlySize);