Ios: Finish deploy on failure

Previously the deploy step would seemingly run forever if the
startSimulator step failed, as no result was added to the promise.

Change-Id: Ib320d051e78057e536d4ad371cb30108e848c65f
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-10-30 09:46:39 +01:00
parent 78b56e7def
commit 250b82ba32
3 changed files with 32 additions and 7 deletions

View File

@@ -746,6 +746,8 @@ void IosSimulatorToolHandlerPrivate::requestTransferApp(const FilePath &appBundl
installAppOnSimulator(); installAppOnSimulator();
} else { } else {
errorMsg(Tr::tr("Application install on simulator failed. Simulator not running.")); errorMsg(Tr::tr("Application install on simulator failed. Simulator not running."));
if (!response.commandOutput.isEmpty())
errorMsg(response.commandOutput);
didTransferApp(m_bundlePath, m_deviceId, IosToolHandler::Failure); didTransferApp(m_bundlePath, m_deviceId, IosToolHandler::Failure);
emit q->finished(q); emit q->finished(q);
} }

View File

@@ -3,6 +3,7 @@
#include "simulatorcontrol.h" #include "simulatorcontrol.h"
#include "iosconfigurations.h" #include "iosconfigurations.h"
#include "iostr.h"
#include <utils/algorithm.h> #include <utils/algorithm.h>
#include <utils/async.h> #include <utils/async.h>
@@ -399,10 +400,10 @@ void startSimulator(QPromise<SimulatorControl::ResponseData> &promise, const QSt
SimulatorInfo simInfo = deviceInfo(simUdid); SimulatorInfo simInfo = deviceInfo(simUdid);
if (!simInfo.available) { if (!simInfo.available) {
qCDebug(simulatorLog) << "Simulator device is not available." << simUdid; promise.addResult(
response.withError(Tr::tr("Simulator device is not available. (%1)").arg(simUdid)));
return; return;
} }
// Shutting down state checks are for the case when simulator start is called within a short // Shutting down state checks are for the case when simulator start is called within a short
// interval of closing the previous interval of the simulator. We wait untill the shutdown // interval of closing the previous interval of the simulator. We wait untill the shutdown
// process is complete. // process is complete.
@@ -414,8 +415,14 @@ void startSimulator(QPromise<SimulatorControl::ResponseData> &promise, const QSt
} }
if (simInfo.isShuttingDown()) { if (simInfo.isShuttingDown()) {
qCDebug(simulatorLog) << "Cannot start Simulator device. " promise.addResult(response.withError(
<< "Previous instance taking too long to shutdown." << simInfo; Tr::tr("Cannot start Simulator device. Previous instance taking "
"too long to shut down. (name=%1, udid=%2, available=%3, state=%4, runtime=%5)")
.arg(simInfo.name)
.arg(simInfo.identifier)
.arg(simInfo.available)
.arg(simInfo.state)
.arg(simInfo.runtimeName)));
return; return;
} }
@@ -436,11 +443,19 @@ void startSimulator(QPromise<SimulatorControl::ResponseData> &promise, const QSt
if (info.isBooted()) if (info.isBooted())
response.success = true; response.success = true;
} else { } else {
qCDebug(simulatorLog) << "Error starting simulator."; promise.addResult(response.withError(Tr::tr("Error starting simulator.")));
return;
} }
} else { } else {
qCDebug(simulatorLog) << "Cannot start Simulator device. Simulator not in shutdown state." promise.addResult(response.withError(
<< simInfo; Tr::tr("Cannot start Simulator device. Simulator not in shutdown state.(name=%1, "
"udid=%2, available=%3, state=%4, runtime=%5)")
.arg(simInfo.name)
.arg(simInfo.identifier)
.arg(simInfo.available)
.arg(simInfo.state)
.arg(simInfo.runtimeName)));
return;
} }
if (!promise.isCanceled()) if (!promise.isCanceled())

View File

@@ -61,6 +61,14 @@ public:
bool success = false; bool success = false;
qint64 pID = -1; qint64 pID = -1;
QString commandOutput; QString commandOutput;
ResponseData withError(const QString errorMsg)
{
ResponseData result = *this;
result.commandOutput = errorMsg;
result.success = false;
return result;
}
}; };
public: public: