Commit 1acf748f authored by Christian Stenger's avatar Christian Stenger

AutoTest: Use StandardRunnable inside TestConfiguration

Replace some members by a single one.
By using the StandardRunnable we automatically get more
information that can be used later (arguments, device).

Change-Id: Id2afb6dffc27d97da568372f6ee13c7181fc393a
Reviewed-by: Oliver Wolff's avatarOliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent 2edbefcb
......@@ -154,10 +154,9 @@ void TestConfiguration::completeTestInformation(int runMode)
return b.startsWith(currentBST);
}))) {
qCDebug(LOG) << " Using this RunConfig.";
m_executableFile = currentExecutable;
m_runnable = stdRunnable;
m_runnable.executable = currentExecutable;
m_displayName = runConfig->displayName();
m_workingDir = Utils::FileUtils::normalizePathName(stdRunnable.workingDirectory);
m_environment = stdRunnable.environment;
m_project = project;
if (runMode == TestRunner::Debug)
m_runConfig = new TestRunConfiguration(runConfig->target(), this);
......@@ -169,9 +168,9 @@ void TestConfiguration::completeTestInformation(int runMode)
// or we might have end up using the (wrong) path of a locally installed executable
// for this case try the original executable path of the BuildTargetInfo (the executable
// before installation) to have at least something to execute
if (m_executableFile.isEmpty() && !localExecutable.isEmpty())
m_executableFile = localExecutable;
if (m_displayName.isEmpty() && !m_executableFile.isEmpty()) {
if (m_runnable.executable.isEmpty() && !localExecutable.isEmpty())
m_runnable.executable = localExecutable;
if (m_displayName.isEmpty() && !m_runnable.executable.isEmpty()) {
qCDebug(LOG) << " Fallback";
// we failed to find a valid runconfiguration - but we've got the executable already
if (auto rc = target->activeRunConfiguration()) {
......@@ -179,7 +178,7 @@ void TestConfiguration::completeTestInformation(int runMode)
Runnable runnable = rc->runnable();
if (runnable.is<StandardRunnable>()) {
StandardRunnable stdRunnable = runnable.as<StandardRunnable>();
m_environment = stdRunnable.environment;
m_runnable.environment = stdRunnable.environment;
m_project = project;
m_guessedConfiguration = true;
m_guessedFrom = rc->displayName();
......@@ -219,7 +218,7 @@ void TestConfiguration::setTestCaseCount(int count)
void TestConfiguration::setExecutableFile(const QString &executableFile)
{
m_executableFile = executableFile;
m_runnable.executable = executableFile;
}
void TestConfiguration::setProjectFile(const QString &projectFile)
......@@ -229,7 +228,7 @@ void TestConfiguration::setProjectFile(const QString &projectFile)
void TestConfiguration::setWorkingDirectory(const QString &workingDirectory)
{
m_workingDir = workingDirectory;
m_runnable.workingDirectory = workingDirectory;
}
void TestConfiguration::setBuildDirectory(const QString &buildDirectory)
......@@ -244,7 +243,7 @@ void TestConfiguration::setDisplayName(const QString &displayName)
void TestConfiguration::setEnvironment(const Utils::Environment &env)
{
m_environment = env;
m_runnable.environment = env;
}
void TestConfiguration::setProject(Project *project)
......@@ -259,17 +258,17 @@ void TestConfiguration::setInternalTargets(const QSet<QString> &targets)
QString TestConfiguration::executableFilePath() const
{
if (m_executableFile.isEmpty())
if (m_runnable.executable.isEmpty())
return QString();
QFileInfo commandFileInfo(m_executableFile);
QFileInfo commandFileInfo(m_runnable.executable);
if (commandFileInfo.isExecutable() && commandFileInfo.path() != ".") {
return commandFileInfo.absoluteFilePath();
} else if (commandFileInfo.path() == "."){
QString fullCommandFileName = m_executableFile;
QString fullCommandFileName = m_runnable.executable;
// TODO: check if we can use searchInPath() from Utils::Environment
const QStringList &pathList = m_environment.toProcessEnvironment().value("PATH").split(
Utils::HostOsInfo::pathListSeparator());
const QStringList &pathList = m_runnable.environment.toProcessEnvironment().value("PATH")
.split(Utils::HostOsInfo::pathListSeparator());
foreach (const QString &path, pathList) {
QString filePath(path + QDir::separator() + fullCommandFileName);
......@@ -282,8 +281,8 @@ QString TestConfiguration::executableFilePath() const
QString TestConfiguration::workingDirectory() const
{
if (!m_workingDir.isEmpty()) {
const QFileInfo info(m_workingDir);
if (!m_runnable.workingDirectory.isEmpty()) {
const QFileInfo info(m_runnable.workingDirectory);
if (info.isDir()) // ensure wanted working dir does exist
return info.absoluteFilePath();
}
......
......@@ -28,6 +28,7 @@
#include "autotestconstants.h"
#include <projectexplorer/project.h>
#include <projectexplorer/runnables.h>
#include <utils/environment.h>
#include <QFutureInterface>
......@@ -75,7 +76,7 @@ public:
QString buildDirectory() const { return m_buildDir; }
QString projectFile() const { return m_projectFile; }
QString displayName() const { return m_displayName; }
Utils::Environment environment() const { return m_environment; }
Utils::Environment environment() const { return m_runnable.environment; }
ProjectExplorer::Project *project() const { return m_project.data(); }
TestRunConfiguration *runConfiguration() const { return m_runConfig; }
bool isGuessed() const { return m_guessedConfiguration; }
......@@ -90,16 +91,14 @@ private:
QStringList m_testCases;
int m_testCaseCount = 0;
QString m_projectFile;
QString m_executableFile;
QString m_workingDir;
QString m_buildDir;
QString m_displayName;
QString m_guessedFrom;
Utils::Environment m_environment;
QPointer<ProjectExplorer::Project> m_project;
bool m_guessedConfiguration = false;
TestRunConfiguration *m_runConfig = 0;
QSet<QString> m_buildTargets;
ProjectExplorer::StandardRunnable m_runnable;
};
class DebuggableTestConfiguration : public TestConfiguration
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment