ProjectExplorer: Use Utils::CommandLine in ProjectExplorer::Runnable

Change-Id: Id965f1f9047dcbc3ea5c9ddaa550d12668cf8ae6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2021-08-10 09:19:30 +02:00
parent 33108795d6
commit 52e5023bcc
72 changed files with 257 additions and 295 deletions

View File

@@ -508,7 +508,7 @@ QVector<QObject *> AutotestPlugin::createTestObjects() const
bool ChoicePair::matches(const ProjectExplorer::RunConfiguration *rc) const
{
return rc && rc->displayName() == displayName && rc->runnable().executable.toString() == executable;
return rc && rc->displayName() == displayName && rc->runnable().command.executable().toString() == executable;
}
} // Internal

View File

@@ -128,7 +128,7 @@ QStringList BoostTestConfiguration::argumentsForTestRunner(QStringList *omitted)
arguments << "-t" << test;
if (AutotestPlugin::settings()->processArgs) {
arguments << filterInterfering(runnable().commandLineArguments.split(
arguments << filterInterfering(runnable().command.arguments().split(
' ', Qt::SkipEmptyParts), omitted);
}
return arguments;

View File

@@ -101,7 +101,7 @@ QStringList CatchConfiguration::argumentsForTestRunner(QStringList *omitted) con
arguments << "--reporter" << "xml";
if (AutotestPlugin::settings()->processArgs) {
arguments << filterInterfering(runnable().commandLineArguments.split(
arguments << filterInterfering(runnable().command.arguments().split(
' ', Qt::SkipEmptyParts), omitted);
}

View File

@@ -76,7 +76,7 @@ QStringList GTestConfiguration::argumentsForTestRunner(QStringList *omitted) con
{
QStringList arguments;
if (AutotestPlugin::settings()->processArgs) {
arguments << filterInterfering(runnable().commandLineArguments.split(
arguments << filterInterfering(runnable().command.arguments().split(
' ', Qt::SkipEmptyParts), omitted);
}

View File

@@ -52,7 +52,7 @@ QStringList QtTestConfiguration::argumentsForTestRunner(QStringList *omitted) co
QStringList arguments;
if (AutotestPlugin::settings()->processArgs) {
arguments.append(QTestUtils::filterInterfering(
runnable().commandLineArguments.split(' ', Qt::SkipEmptyParts),
runnable().command.arguments().split(' ', Qt::SkipEmptyParts),
omitted, false));
}
auto qtSettings = static_cast<QtTestSettings *>(framework()->testSettings());

View File

@@ -59,7 +59,7 @@ QStringList QuickTestConfiguration::argumentsForTestRunner(QStringList *omitted)
QStringList arguments;
if (AutotestPlugin::settings()->processArgs) {
arguments.append(QTestUtils::filterInterfering
(runnable().commandLineArguments.split(' ', Qt::SkipEmptyParts),
(runnable().command.arguments().split(' ', Qt::SkipEmptyParts),
omitted, true));
}

View File

@@ -75,7 +75,7 @@ Utils::FilePath ITestConfiguration::workingDirectory() const
bool ITestConfiguration::hasExecutable() const
{
return !m_runnable.executable.isEmpty();
return !m_runnable.command.isEmpty();
}
Utils::FilePath ITestConfiguration::executableFilePath() const
@@ -83,10 +83,10 @@ Utils::FilePath ITestConfiguration::executableFilePath() const
if (!hasExecutable())
return {};
if (m_runnable.executable.isExecutableFile() && m_runnable.executable.path() != ".") {
return m_runnable.executable.absoluteFilePath();
} else if (m_runnable.executable.path() == "."){
QString fullCommandFileName = m_runnable.executable.toString();
if (m_runnable.command.executable().isExecutableFile() && m_runnable.command.executable().path() != ".") {
return m_runnable.command.executable().absoluteFilePath();
} else if (m_runnable.command.executable().path() == "."){
QString fullCommandFileName = m_runnable.command.executable().toString();
// TODO: check if we can use searchInPath() from Utils::Environment
const QStringList &pathList = m_runnable.environment.toProcessEnvironment().value("PATH")
.split(Utils::HostOsInfo::pathListSeparator());
@@ -94,7 +94,7 @@ Utils::FilePath ITestConfiguration::executableFilePath() const
for (const QString &path : pathList) {
QString filePath(path + QDir::separator() + fullCommandFileName);
if (QFileInfo(filePath).isExecutable())
return m_runnable.executable.absoluteFilePath();
return m_runnable.command.executable().absoluteFilePath();
}
}
return {};
@@ -154,7 +154,7 @@ void TestConfiguration::completeTestInformation(ProjectExplorer::RunConfiguratio
BuildTargetInfo targetInfo = rc->buildTargetInfo();
if (!targetInfo.targetFilePath.isEmpty())
m_runnable.executable = ensureExeEnding(targetInfo.targetFilePath);
m_runnable.command.setExecutable(ensureExeEnding(targetInfo.targetFilePath));
Utils::FilePath buildBase;
if (auto buildConfig = target->activeBuildConfiguration()) {
@@ -177,8 +177,7 @@ void TestConfiguration::completeTestInformation(TestRunMode runMode)
qCDebug(LOG) << "Using run configuration specified by user or found by first call";
completeTestInformation(m_origRunConfig, runMode);
if (hasExecutable()) {
qCDebug(LOG) << "Completed.\nRunnable:" << m_runnable.executable
<< "\nArgs:" << m_runnable.commandLineArguments
qCDebug(LOG) << "Completed.\nCommand:" << m_runnable.command.toUserOutput()
<< "\nWorking directory:" << m_runnable.workingDirectory;
return;
}
@@ -255,7 +254,7 @@ void TestConfiguration::completeTestInformation(TestRunMode runMode)
const Runnable runnable = runConfig->runnable();
// not the best approach - but depending on the build system and whether the executables
// are going to get installed or not we have to soften the condition...
const FilePath currentExecutable = ensureExeEnding(runnable.executable);
const FilePath currentExecutable = ensureExeEnding(runnable.command.executable());
const QString currentBST = runConfig->buildKey();
qCDebug(LOG) << " CurrentExecutable" << currentExecutable;
qCDebug(LOG) << " BST of RunConfig" << currentBST;
@@ -265,7 +264,7 @@ void TestConfiguration::completeTestInformation(TestRunMode runMode)
qCDebug(LOG) << " Using this RunConfig.";
m_origRunConfig = runConfig;
m_runnable = runnable;
m_runnable.executable = currentExecutable;
m_runnable.command.setExecutable(currentExecutable);
setDisplayName(runConfig->displayName());
if (runMode == TestRunMode::Debug || runMode == TestRunMode::DebugWithoutDeploy)
m_runConfig = new Internal::TestRunConfiguration(target, this);
@@ -278,7 +277,7 @@ void TestConfiguration::completeTestInformation(TestRunMode runMode)
// for this case try the original executable path of the BuildTargetInfo (the executable
// before installation) to have at least something to execute
if (!hasExecutable() && !localExecutable.isEmpty())
m_runnable.executable = localExecutable;
m_runnable.command.setExecutable(localExecutable);
if (displayName().isEmpty() && hasExecutable()) {
qCDebug(LOG) << " Fallback";
// we failed to find a valid runconfiguration - but we've got the executable already
@@ -318,7 +317,7 @@ void TestConfiguration::setTestCases(const QStringList &testCases)
void TestConfiguration::setExecutableFile(const QString &executableFile)
{
m_runnable.executable = Utils::FilePath::fromString(executableFile);
m_runnable.command.setExecutable(Utils::FilePath::fromString(executableFile));
}
void TestConfiguration::setProjectFile(const Utils::FilePath &projectFile)

View File

@@ -65,8 +65,8 @@ public:
{
ProjectExplorer::Runnable r;
QTC_ASSERT(m_testConfig, return r);
r.executable = m_testConfig->executableFilePath();
r.commandLineArguments = m_testConfig->argumentsForTestRunner().join(' ');
r.command.setExecutable(m_testConfig->executableFilePath());
r.command.setArguments(m_testConfig->argumentsForTestRunner().join(' '));
r.workingDirectory = m_testConfig->workingDirectory();
r.environment = m_testConfig->environment();
return r;

View File

@@ -438,7 +438,7 @@ static RunConfiguration *getRunConfiguration(const QString &buildTargetKey)
RunConfiguration *runConfig = nullptr;
const QList<RunConfiguration *> runConfigurations
= Utils::filtered(target->runConfigurations(), [] (const RunConfiguration *rc) {
return !rc->runnable().executable.isEmpty();
return !rc->runnable().command.isEmpty();
});
const ChoicePair oldChoice = AutotestPlugin::cachedChoiceFor(buildTargetKey);
@@ -464,7 +464,7 @@ static RunConfiguration *getRunConfiguration(const QString &buildTargetKey)
runConfig = Utils::findOr(runConfigurations, nullptr, [&dName, &exe] (const RunConfiguration *rc) {
if (rc->displayName() != dName)
return false;
return rc->runnable().executable.toString() == exe;
return rc->runnable().command.executable().toString() == exe;
});
if (runConfig && dialog.rememberChoice())
AutotestPlugin::cacheRunConfigChoice(buildTargetKey, ChoicePair(dName, exe));
@@ -638,10 +638,10 @@ void TestRunner::debugTests()
QStringList omitted;
Runnable inferior = config->runnable();
inferior.executable = commandFilePath;
inferior.command.setExecutable(commandFilePath);
const QStringList args = config->argumentsForTestRunner(&omitted);
inferior.commandLineArguments = Utils::ProcessArgs::joinArgs(args);
inferior.command.setArguments(Utils::ProcessArgs::joinArgs(args));
if (!omitted.isEmpty()) {
const QString &details = constructOmittedDetailsString(omitted);
reportResult(ResultType::MessageWarn, details.arg(config->displayName()));
@@ -677,7 +677,7 @@ void TestRunner::debugTests()
if (useOutputProcessor) {
TestOutputReader *outputreader = config->outputReader(*futureInterface, nullptr);
outputreader->setId(inferior.executable.toString());
outputreader->setId(inferior.command.executable().toString());
connect(outputreader, &TestOutputReader::newOutputLineAvailable,
TestResultsPane::instance(), &TestResultsPane::addOutputLine);
connect(runControl, &RunControl::appendMessage,
@@ -909,8 +909,8 @@ void RunConfigurationSelectionDialog::populate()
if (auto target = project->activeTarget()) {
for (RunConfiguration *rc : target->runConfigurations()) {
auto runnable = rc->runnable();
const QStringList rcDetails = { runnable.executable.toString(),
runnable.commandLineArguments,
const QStringList rcDetails = { runnable.command.executable().toString(),
runnable.command.arguments(),
runnable.workingDirectory.toString() };
m_rcCombo->addItem(rc->displayName(), rcDetails);
}