forked from qt-creator/qt-creator
GenericLinuxDeviceTester: Reuse LoopRepeat element
Instead of creating quite huge recipe. Change-Id: I8b4121d0a666f093885d1379f6f4c8093cd2619c Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -42,7 +42,6 @@ public:
|
|||||||
GroupItem transferTask(FileTransferMethod method,
|
GroupItem transferTask(FileTransferMethod method,
|
||||||
const Storage<TransferStorage> &storage) const;
|
const Storage<TransferStorage> &storage) const;
|
||||||
GroupItem transferTasks() const;
|
GroupItem transferTasks() const;
|
||||||
GroupItem commandTask(const QString &commandName) const;
|
|
||||||
GroupItem commandTasks() const;
|
GroupItem commandTasks() const;
|
||||||
|
|
||||||
GenericLinuxDeviceTester *q = nullptr;
|
GenericLinuxDeviceTester *q = nullptr;
|
||||||
@@ -242,15 +241,20 @@ GroupItem GenericLinuxDeviceTesterPrivate::transferTasks() const
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
GroupItem GenericLinuxDeviceTesterPrivate::commandTask(const QString &commandName) const
|
GroupItem GenericLinuxDeviceTesterPrivate::commandTasks() const
|
||||||
{
|
{
|
||||||
const auto onSetup = [this, commandName](Process &process) {
|
const QStringList commands = commandsToTest();
|
||||||
|
const LoopRepeat repeater(commands.size());
|
||||||
|
|
||||||
|
const auto onSetup = [this, commands, repeater](Process &process) {
|
||||||
|
const QString commandName = commands.at(repeater.iteration());
|
||||||
emit q->progressMessage(Tr::tr("%1...").arg(commandName));
|
emit q->progressMessage(Tr::tr("%1...").arg(commandName));
|
||||||
CommandLine command{m_device->filePath("/bin/sh"), {"-c"}};
|
CommandLine command{m_device->filePath("/bin/sh"), {"-c"}};
|
||||||
command.addArgs(QLatin1String("\"command -v %1\"").arg(commandName), CommandLine::Raw);
|
command.addArgs(QLatin1String("\"command -v %1\"").arg(commandName), CommandLine::Raw);
|
||||||
process.setCommand(command);
|
process.setCommand(command);
|
||||||
};
|
};
|
||||||
const auto onDone = [this, commandName](const Process &process, DoneWith result) {
|
const auto onDone = [this, commands, repeater](const Process &process, DoneWith result) {
|
||||||
|
const QString commandName = commands.at(repeater.iteration());
|
||||||
if (result == DoneWith::Success) {
|
if (result == DoneWith::Success) {
|
||||||
emit q->progressMessage(Tr::tr("%1 found.").arg(commandName));
|
emit q->progressMessage(Tr::tr("%1 found.").arg(commandName));
|
||||||
return;
|
return;
|
||||||
@@ -261,18 +265,16 @@ GroupItem GenericLinuxDeviceTesterPrivate::commandTask(const QString &commandNam
|
|||||||
: Tr::tr("%1 not found.").arg(commandName);
|
: Tr::tr("%1 not found.").arg(commandName);
|
||||||
emit q->errorMessage(message);
|
emit q->errorMessage(message);
|
||||||
};
|
};
|
||||||
return ProcessTask(onSetup, onDone);
|
|
||||||
}
|
|
||||||
|
|
||||||
GroupItem GenericLinuxDeviceTesterPrivate::commandTasks() const
|
const Group root {
|
||||||
{
|
continueOnError,
|
||||||
QList<GroupItem> tasks {continueOnError};
|
onGroupSetup([this] {
|
||||||
tasks.append(onGroupSetup([this] {
|
emit q->progressMessage(Tr::tr("Checking if required commands are available..."));
|
||||||
emit q->progressMessage(Tr::tr("Checking if required commands are available..."));
|
}),
|
||||||
}));
|
repeater,
|
||||||
for (const QString &commandName : commandsToTest())
|
ProcessTask(onSetup, onDone)
|
||||||
tasks.append(commandTask(commandName));
|
};
|
||||||
return Group {tasks};
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
Reference in New Issue
Block a user