forked from qt-creator/qt-creator
iOS: Move launch result from devicectl to a function
And add a test to document what we expect from devicectl. Change-Id: I1a7f03c50393b99eddb2bfd34b5857e15b28d0a7 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -107,4 +107,17 @@ Utils::expected_str<qint64> parseProcessIdentifier(const QByteArray &rawOutput)
|
||||
return -1;
|
||||
}
|
||||
|
||||
Utils::expected_str<qint64> parseLaunchResult(const QByteArray &rawOutput)
|
||||
{
|
||||
const Utils::expected_str<QJsonValue> result = parseDevicectlResult(rawOutput);
|
||||
if (!result)
|
||||
return make_unexpected(result.error());
|
||||
const qint64 pid = (*result)["process"]["processIdentifier"].toInteger(-1);
|
||||
if (pid < 0) {
|
||||
// something unexpected happened ...
|
||||
return make_unexpected(Tr::tr("devicectl returned unexpected output ... running failed."));
|
||||
}
|
||||
return pid;
|
||||
}
|
||||
|
||||
} // namespace Ios::Internal
|
||||
|
||||
@@ -24,5 +24,6 @@ Utils::expected_str<QMap<QString, QString>> parseDeviceInfo(const QByteArray &ra
|
||||
const QString &deviceUsbId);
|
||||
Utils::expected_str<QUrl> parseAppInfo(const QByteArray &rawOutput, const QString &bundleIdentifier);
|
||||
Utils::expected_str<qint64> parseProcessIdentifier(const QByteArray &rawOutput);
|
||||
Utils::expected_str<qint64> parseLaunchResult(const QByteArray &rawOutput);
|
||||
|
||||
} // namespace Ios::Internal
|
||||
|
||||
@@ -247,22 +247,15 @@ GroupItem DeviceCtlRunner::launchTask(const QString &bundleIdentifier)
|
||||
reportFailure(Tr::tr("Failed to run devicectl: %1.").arg(process.errorString()));
|
||||
return DoneResult::Error;
|
||||
}
|
||||
const Utils::expected_str<QJsonValue> resultValue = parseDevicectlResult(
|
||||
process.rawStdOut());
|
||||
if (resultValue) {
|
||||
// success
|
||||
m_processIdentifier = (*resultValue)["process"]["processIdentifier"].toInteger(-1);
|
||||
if (m_processIdentifier < 0) {
|
||||
// something unexpected happened ...
|
||||
reportFailure(Tr::tr("devicectl returned unexpected output ... running failed."));
|
||||
return DoneResult::Error;
|
||||
}
|
||||
const Utils::expected_str<qint64> pid = parseLaunchResult(process.rawStdOut());
|
||||
if (pid) {
|
||||
m_processIdentifier = *pid;
|
||||
m_pollTimer.start();
|
||||
reportStarted();
|
||||
return DoneResult::Success;
|
||||
}
|
||||
// failure
|
||||
reportFailure(resultValue.error());
|
||||
reportFailure(pid.error());
|
||||
return DoneResult::Error;
|
||||
};
|
||||
return ProcessTask(onSetup, onDone);
|
||||
|
||||
Reference in New Issue
Block a user