forked from qt-creator/qt-creator
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 <oliver.wolff@qt.io> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -154,10 +154,9 @@ void TestConfiguration::completeTestInformation(int runMode)
|
|||||||
return b.startsWith(currentBST);
|
return b.startsWith(currentBST);
|
||||||
}))) {
|
}))) {
|
||||||
qCDebug(LOG) << " Using this RunConfig.";
|
qCDebug(LOG) << " Using this RunConfig.";
|
||||||
m_executableFile = currentExecutable;
|
m_runnable = stdRunnable;
|
||||||
|
m_runnable.executable = currentExecutable;
|
||||||
m_displayName = runConfig->displayName();
|
m_displayName = runConfig->displayName();
|
||||||
m_workingDir = Utils::FileUtils::normalizePathName(stdRunnable.workingDirectory);
|
|
||||||
m_environment = stdRunnable.environment;
|
|
||||||
m_project = project;
|
m_project = project;
|
||||||
if (runMode == TestRunner::Debug)
|
if (runMode == TestRunner::Debug)
|
||||||
m_runConfig = new TestRunConfiguration(runConfig->target(), this);
|
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
|
// 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
|
// for this case try the original executable path of the BuildTargetInfo (the executable
|
||||||
// before installation) to have at least something to execute
|
// before installation) to have at least something to execute
|
||||||
if (m_executableFile.isEmpty() && !localExecutable.isEmpty())
|
if (m_runnable.executable.isEmpty() && !localExecutable.isEmpty())
|
||||||
m_executableFile = localExecutable;
|
m_runnable.executable = localExecutable;
|
||||||
if (m_displayName.isEmpty() && !m_executableFile.isEmpty()) {
|
if (m_displayName.isEmpty() && !m_runnable.executable.isEmpty()) {
|
||||||
qCDebug(LOG) << " Fallback";
|
qCDebug(LOG) << " Fallback";
|
||||||
// we failed to find a valid runconfiguration - but we've got the executable already
|
// we failed to find a valid runconfiguration - but we've got the executable already
|
||||||
if (auto rc = target->activeRunConfiguration()) {
|
if (auto rc = target->activeRunConfiguration()) {
|
||||||
@@ -179,7 +178,7 @@ void TestConfiguration::completeTestInformation(int runMode)
|
|||||||
Runnable runnable = rc->runnable();
|
Runnable runnable = rc->runnable();
|
||||||
if (runnable.is<StandardRunnable>()) {
|
if (runnable.is<StandardRunnable>()) {
|
||||||
StandardRunnable stdRunnable = runnable.as<StandardRunnable>();
|
StandardRunnable stdRunnable = runnable.as<StandardRunnable>();
|
||||||
m_environment = stdRunnable.environment;
|
m_runnable.environment = stdRunnable.environment;
|
||||||
m_project = project;
|
m_project = project;
|
||||||
m_guessedConfiguration = true;
|
m_guessedConfiguration = true;
|
||||||
m_guessedFrom = rc->displayName();
|
m_guessedFrom = rc->displayName();
|
||||||
@@ -219,7 +218,7 @@ void TestConfiguration::setTestCaseCount(int count)
|
|||||||
|
|
||||||
void TestConfiguration::setExecutableFile(const QString &executableFile)
|
void TestConfiguration::setExecutableFile(const QString &executableFile)
|
||||||
{
|
{
|
||||||
m_executableFile = executableFile;
|
m_runnable.executable = executableFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestConfiguration::setProjectFile(const QString &projectFile)
|
void TestConfiguration::setProjectFile(const QString &projectFile)
|
||||||
@@ -229,7 +228,7 @@ void TestConfiguration::setProjectFile(const QString &projectFile)
|
|||||||
|
|
||||||
void TestConfiguration::setWorkingDirectory(const QString &workingDirectory)
|
void TestConfiguration::setWorkingDirectory(const QString &workingDirectory)
|
||||||
{
|
{
|
||||||
m_workingDir = workingDirectory;
|
m_runnable.workingDirectory = workingDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestConfiguration::setBuildDirectory(const QString &buildDirectory)
|
void TestConfiguration::setBuildDirectory(const QString &buildDirectory)
|
||||||
@@ -244,7 +243,7 @@ void TestConfiguration::setDisplayName(const QString &displayName)
|
|||||||
|
|
||||||
void TestConfiguration::setEnvironment(const Utils::Environment &env)
|
void TestConfiguration::setEnvironment(const Utils::Environment &env)
|
||||||
{
|
{
|
||||||
m_environment = env;
|
m_runnable.environment = env;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestConfiguration::setProject(Project *project)
|
void TestConfiguration::setProject(Project *project)
|
||||||
@@ -259,17 +258,17 @@ void TestConfiguration::setInternalTargets(const QSet<QString> &targets)
|
|||||||
|
|
||||||
QString TestConfiguration::executableFilePath() const
|
QString TestConfiguration::executableFilePath() const
|
||||||
{
|
{
|
||||||
if (m_executableFile.isEmpty())
|
if (m_runnable.executable.isEmpty())
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
QFileInfo commandFileInfo(m_executableFile);
|
QFileInfo commandFileInfo(m_runnable.executable);
|
||||||
if (commandFileInfo.isExecutable() && commandFileInfo.path() != ".") {
|
if (commandFileInfo.isExecutable() && commandFileInfo.path() != ".") {
|
||||||
return commandFileInfo.absoluteFilePath();
|
return commandFileInfo.absoluteFilePath();
|
||||||
} else if (commandFileInfo.path() == "."){
|
} else if (commandFileInfo.path() == "."){
|
||||||
QString fullCommandFileName = m_executableFile;
|
QString fullCommandFileName = m_runnable.executable;
|
||||||
// TODO: check if we can use searchInPath() from Utils::Environment
|
// TODO: check if we can use searchInPath() from Utils::Environment
|
||||||
const QStringList &pathList = m_environment.toProcessEnvironment().value("PATH").split(
|
const QStringList &pathList = m_runnable.environment.toProcessEnvironment().value("PATH")
|
||||||
Utils::HostOsInfo::pathListSeparator());
|
.split(Utils::HostOsInfo::pathListSeparator());
|
||||||
|
|
||||||
foreach (const QString &path, pathList) {
|
foreach (const QString &path, pathList) {
|
||||||
QString filePath(path + QDir::separator() + fullCommandFileName);
|
QString filePath(path + QDir::separator() + fullCommandFileName);
|
||||||
@@ -282,8 +281,8 @@ QString TestConfiguration::executableFilePath() const
|
|||||||
|
|
||||||
QString TestConfiguration::workingDirectory() const
|
QString TestConfiguration::workingDirectory() const
|
||||||
{
|
{
|
||||||
if (!m_workingDir.isEmpty()) {
|
if (!m_runnable.workingDirectory.isEmpty()) {
|
||||||
const QFileInfo info(m_workingDir);
|
const QFileInfo info(m_runnable.workingDirectory);
|
||||||
if (info.isDir()) // ensure wanted working dir does exist
|
if (info.isDir()) // ensure wanted working dir does exist
|
||||||
return info.absoluteFilePath();
|
return info.absoluteFilePath();
|
||||||
}
|
}
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
#include "autotestconstants.h"
|
#include "autotestconstants.h"
|
||||||
|
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
|
#include <projectexplorer/runnables.h>
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
|
|
||||||
#include <QFutureInterface>
|
#include <QFutureInterface>
|
||||||
@@ -75,7 +76,7 @@ public:
|
|||||||
QString buildDirectory() const { return m_buildDir; }
|
QString buildDirectory() const { return m_buildDir; }
|
||||||
QString projectFile() const { return m_projectFile; }
|
QString projectFile() const { return m_projectFile; }
|
||||||
QString displayName() const { return m_displayName; }
|
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(); }
|
ProjectExplorer::Project *project() const { return m_project.data(); }
|
||||||
TestRunConfiguration *runConfiguration() const { return m_runConfig; }
|
TestRunConfiguration *runConfiguration() const { return m_runConfig; }
|
||||||
bool isGuessed() const { return m_guessedConfiguration; }
|
bool isGuessed() const { return m_guessedConfiguration; }
|
||||||
@@ -90,16 +91,14 @@ private:
|
|||||||
QStringList m_testCases;
|
QStringList m_testCases;
|
||||||
int m_testCaseCount = 0;
|
int m_testCaseCount = 0;
|
||||||
QString m_projectFile;
|
QString m_projectFile;
|
||||||
QString m_executableFile;
|
|
||||||
QString m_workingDir;
|
|
||||||
QString m_buildDir;
|
QString m_buildDir;
|
||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
QString m_guessedFrom;
|
QString m_guessedFrom;
|
||||||
Utils::Environment m_environment;
|
|
||||||
QPointer<ProjectExplorer::Project> m_project;
|
QPointer<ProjectExplorer::Project> m_project;
|
||||||
bool m_guessedConfiguration = false;
|
bool m_guessedConfiguration = false;
|
||||||
TestRunConfiguration *m_runConfig = 0;
|
TestRunConfiguration *m_runConfig = 0;
|
||||||
QSet<QString> m_buildTargets;
|
QSet<QString> m_buildTargets;
|
||||||
|
ProjectExplorer::StandardRunnable m_runnable;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DebuggableTestConfiguration : public TestConfiguration
|
class DebuggableTestConfiguration : public TestConfiguration
|
||||||
|
Reference in New Issue
Block a user