forked from qt-creator/qt-creator
Dissolve RunControl::setRunnable
Change-Id: I52aea3bea0c4ea90a448f5a77bfa01414bc56702 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -129,15 +129,16 @@ void StartRemoteDialog::validate()
|
||||
d->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(valid);
|
||||
}
|
||||
|
||||
Runnable StartRemoteDialog::runnable() const
|
||||
CommandLine StartRemoteDialog::commandLine() const
|
||||
{
|
||||
const Kit *kit = d->kitChooser->currentKit();
|
||||
const FilePath filePath = DeviceKitAspect::deviceFilePath(kit, d->executable->text());
|
||||
return {filePath, d->arguments->text(), CommandLine::Raw};
|
||||
}
|
||||
|
||||
Runnable r;
|
||||
r.command = {filePath, d->arguments->text(), CommandLine::Raw};
|
||||
r.workingDirectory = FilePath::fromString(d->workingDirectory->text());
|
||||
return r;
|
||||
FilePath StartRemoteDialog::workingDirectory() const
|
||||
{
|
||||
return FilePath::fromString(d->workingDirectory->text());
|
||||
}
|
||||
|
||||
} // namespace Debugger
|
||||
|
||||
@@ -29,7 +29,10 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace ProjectExplorer { class Runnable; }
|
||||
namespace Utils {
|
||||
class CommandLine;
|
||||
class FilePath;
|
||||
} // Utils
|
||||
|
||||
namespace Debugger {
|
||||
|
||||
@@ -43,7 +46,8 @@ public:
|
||||
explicit StartRemoteDialog(QWidget *parent = nullptr);
|
||||
~StartRemoteDialog() override;
|
||||
|
||||
ProjectExplorer::Runnable runnable() const;
|
||||
Utils::CommandLine commandLine() const;
|
||||
Utils::FilePath workingDirectory() const;
|
||||
|
||||
private:
|
||||
void validate();
|
||||
|
||||
@@ -904,31 +904,46 @@ const Runnable &RunControl::runnable() const
|
||||
return d->runnable;
|
||||
}
|
||||
|
||||
void RunControl::setRunnable(const Runnable &runnable)
|
||||
{
|
||||
d->runnable = runnable;
|
||||
}
|
||||
|
||||
const CommandLine &RunControl::commandLine() const
|
||||
{
|
||||
return d->runnable.command;
|
||||
}
|
||||
|
||||
void RunControl::setCommandLine(const CommandLine &command)
|
||||
{
|
||||
d->runnable.command = command;
|
||||
}
|
||||
|
||||
const FilePath &RunControl::workingDirectory() const
|
||||
{
|
||||
return d->runnable.workingDirectory;
|
||||
}
|
||||
|
||||
void RunControl::setWorkingDirectory(const FilePath &workingDirectory)
|
||||
{
|
||||
d->runnable.workingDirectory = workingDirectory;
|
||||
}
|
||||
|
||||
const Environment &RunControl::environment() const
|
||||
{
|
||||
return d->runnable.environment;
|
||||
}
|
||||
|
||||
void RunControl::setEnvironment(const Environment &environment)
|
||||
{
|
||||
d->runnable.environment = environment;
|
||||
}
|
||||
|
||||
const QVariantHash &RunControl::extraData() const
|
||||
{
|
||||
return d->runnable.extraData;
|
||||
}
|
||||
|
||||
void RunControl::setExtraData(const QVariantHash &extraData)
|
||||
{
|
||||
d->runnable.extraData = extraData;
|
||||
}
|
||||
|
||||
QString RunControl::displayName() const
|
||||
{
|
||||
return d->displayName;
|
||||
|
||||
@@ -243,12 +243,18 @@ public:
|
||||
Utils::Id runMode() const;
|
||||
|
||||
const Runnable &runnable() const;
|
||||
void setRunnable(const Runnable &runnable);
|
||||
|
||||
const Utils::CommandLine &commandLine() const;
|
||||
void setCommandLine(const Utils::CommandLine &command);
|
||||
|
||||
const Utils::FilePath &workingDirectory() const;
|
||||
void setWorkingDirectory(const Utils::FilePath &workingDirectory);
|
||||
|
||||
const Utils::Environment &environment() const;
|
||||
void setEnvironment(const Utils::Environment &environment);
|
||||
|
||||
const QVariantHash &extraData() const;
|
||||
void setExtraData(const QVariantHash &extraData);
|
||||
|
||||
static bool showPromptToStopDialog(const QString &title, const QString &text,
|
||||
const QString &stopButtonText = QString(),
|
||||
|
||||
@@ -36,6 +36,9 @@
|
||||
#include <QtTest>
|
||||
#include <QTcpServer>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
@@ -45,9 +48,8 @@ LocalQmlProfilerRunnerTest::LocalQmlProfilerRunnerTest(QObject *parent) : QObjec
|
||||
|
||||
void LocalQmlProfilerRunnerTest::testRunner()
|
||||
{
|
||||
QPointer<ProjectExplorer::RunControl> runControl;
|
||||
QPointer<RunControl> runControl;
|
||||
QPointer<LocalQmlProfilerSupport> profiler;
|
||||
ProjectExplorer::Runnable debuggee;
|
||||
QUrl serverUrl;
|
||||
|
||||
bool running = false;
|
||||
@@ -56,37 +58,35 @@ void LocalQmlProfilerRunnerTest::testRunner()
|
||||
int runCount = 0;
|
||||
int stopCount = 0;
|
||||
|
||||
debuggee.command.setExecutable("\\-/|\\-/");
|
||||
debuggee.environment = Utils::Environment::systemEnvironment();
|
||||
|
||||
// should not be used anywhere but cannot be empty
|
||||
serverUrl.setScheme(Utils::urlSocketScheme());
|
||||
serverUrl.setPath("invalid");
|
||||
|
||||
runControl = new ProjectExplorer::RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
runControl->setRunnable(debuggee);
|
||||
runControl = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
runControl->setCommandLine({"\\-/|\\-/", {}});
|
||||
|
||||
profiler = new LocalQmlProfilerSupport(runControl, serverUrl);
|
||||
|
||||
auto connectRunner = [&]() {
|
||||
connect(runControl, &ProjectExplorer::RunControl::aboutToStart, this, [&]() {
|
||||
connect(runControl, &RunControl::aboutToStart, this, [&] {
|
||||
QVERIFY(!started);
|
||||
QVERIFY(!running);
|
||||
++startCount;
|
||||
started = true;
|
||||
});
|
||||
connect(runControl, &ProjectExplorer::RunControl::started, this, [&]() {
|
||||
connect(runControl, &RunControl::started, this, [&] {
|
||||
QVERIFY(started);
|
||||
QVERIFY(!running);
|
||||
++runCount;
|
||||
running = true;
|
||||
});
|
||||
connect(runControl, &ProjectExplorer::RunControl::stopped, this, [&]() {
|
||||
connect(runControl, &RunControl::stopped, this, [&] {
|
||||
QVERIFY(started);
|
||||
++stopCount;
|
||||
running = false;
|
||||
started = false;
|
||||
});
|
||||
connect(runControl, &ProjectExplorer::RunControl::finished, this, [&]() {
|
||||
connect(runControl, &RunControl::finished, this, [&]{
|
||||
running = false;
|
||||
started = false;
|
||||
});
|
||||
@@ -110,10 +110,10 @@ void LocalQmlProfilerRunnerTest::testRunner()
|
||||
|
||||
serverUrl = Utils::urlFromLocalSocket();
|
||||
// comma is used to specify a test function. In this case, an invalid one.
|
||||
debuggee.command = Utils::CommandLine(Utils::FilePath::fromString(QCoreApplication::applicationFilePath()),
|
||||
{"-test", "QmlProfiler,"});
|
||||
runControl = new ProjectExplorer::RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
runControl->setRunnable(debuggee);
|
||||
runControl = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
|
||||
const FilePath app = FilePath::fromString(QCoreApplication::applicationFilePath());
|
||||
runControl->setCommandLine({app, {"-test", "QmlProfiler,"}});
|
||||
profiler = new LocalQmlProfilerSupport(runControl, serverUrl);
|
||||
connectRunner();
|
||||
runControl->initiateStart();
|
||||
@@ -128,11 +128,10 @@ void LocalQmlProfilerRunnerTest::testRunner()
|
||||
QTRY_VERIFY(runControl.isNull());
|
||||
QVERIFY(profiler.isNull());
|
||||
|
||||
debuggee.command.setArguments({});
|
||||
serverUrl.clear();
|
||||
serverUrl = Utils::urlFromLocalHostAndFreePort();
|
||||
runControl = new ProjectExplorer::RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
runControl->setRunnable(debuggee);
|
||||
runControl = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
runControl->setCommandLine({app, {}});
|
||||
profiler = new LocalQmlProfilerSupport(runControl, serverUrl);
|
||||
connectRunner();
|
||||
runControl->initiateStart();
|
||||
@@ -148,7 +147,6 @@ void LocalQmlProfilerRunnerTest::testRunner()
|
||||
QTRY_VERIFY(runControl.isNull());
|
||||
QVERIFY(profiler.isNull());
|
||||
|
||||
debuggee.command.setArguments("-test QmlProfiler,");
|
||||
serverUrl.setScheme(Utils::urlSocketScheme());
|
||||
{
|
||||
Utils::TemporaryFile file("file with spaces");
|
||||
@@ -156,8 +154,8 @@ void LocalQmlProfilerRunnerTest::testRunner()
|
||||
serverUrl.setPath(file.fileName());
|
||||
}
|
||||
|
||||
runControl = new ProjectExplorer::RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
runControl->setRunnable(debuggee);
|
||||
runControl = new RunControl(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
|
||||
runControl->setCommandLine({app, {"-test", "QmlProfiler,"}});
|
||||
profiler = new LocalQmlProfilerSupport(runControl, serverUrl);
|
||||
connectRunner();
|
||||
runControl->initiateStart();
|
||||
|
||||
@@ -282,12 +282,13 @@ CallgrindToolPrivate::CallgrindToolPrivate()
|
||||
if (dlg.exec() != QDialog::Accepted)
|
||||
return;
|
||||
m_perspective.select();
|
||||
CommandLine command = dlg.commandLine();
|
||||
auto runControl = new RunControl(CALLGRIND_RUN_MODE);
|
||||
runControl->copyDataFromRunConfiguration(runConfig);
|
||||
runControl->createMainWorker();
|
||||
const auto runnable = dlg.runnable();
|
||||
runControl->setRunnable(runnable);
|
||||
runControl->setDisplayName(runnable.command.executable().toUserOutput());
|
||||
runControl->setCommandLine(command);
|
||||
runControl->setWorkingDirectory(dlg.workingDirectory());
|
||||
runControl->setDisplayName(command.executable().toUserOutput());
|
||||
ProjectExplorerPlugin::startRunControl(runControl);
|
||||
});
|
||||
|
||||
|
||||
@@ -704,12 +704,13 @@ MemcheckToolPrivate::MemcheckToolPrivate()
|
||||
return;
|
||||
TaskHub::clearTasks(Debugger::Constants::ANALYZERTASK_ID);
|
||||
m_perspective.select();
|
||||
const CommandLine cmd = dlg.commandLine();
|
||||
RunControl *rc = new RunControl(MEMCHECK_RUN_MODE);
|
||||
rc->copyDataFromRunConfiguration(runConfig);
|
||||
rc->createMainWorker();
|
||||
const auto runnable = dlg.runnable();
|
||||
rc->setRunnable(runnable);
|
||||
rc->setDisplayName(runnable.command.executable().toUserOutput());
|
||||
rc->setCommandLine(cmd);
|
||||
rc->setWorkingDirectory(dlg.workingDirectory());
|
||||
rc->setDisplayName(cmd.toUserOutput());
|
||||
ProjectExplorerPlugin::startRunControl(rc);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user