Commit 74fb4bb0 authored by Christian Stenger's avatar Christian Stenger

AutoTest: Use better names and remove unused code

Change-Id: Ifb7f252e7c3fd020537eb46c62d8f5700b8a55ef
Reviewed-by: David Schulz's avatarDavid Schulz <david.schulz@qt.io>
parent 721c902c
......@@ -86,7 +86,7 @@ TestConfiguration *GTestTreeItem::testConfiguration() const
config = new GTestConfiguration;
config->setTestCases(QStringList(testSpecifier));
config->setTestCaseCount(count);
config->setProFile(proFile());
config->setProjectFile(proFile());
config->setProject(project);
// item has no filePath set - so take it of the first children
config->setDisplayName(
......@@ -101,7 +101,7 @@ TestConfiguration *GTestTreeItem::testConfiguration() const
const QString &testSpecifier = gtestFilter(parent->state()).arg(parent->name()).arg(name());
config = new GTestConfiguration;
config->setTestCases(QStringList(testSpecifier));
config->setProFile(proFile());
config->setProjectFile(proFile());
config->setProject(project);
config->setDisplayName(
TestUtils::getCMakeDisplayNameIfNecessary(filePath(), parent->proFile()));
......@@ -178,7 +178,7 @@ QList<TestConfiguration *> GTestTreeItem::getAllTestConfigurations() const
const ProFileWithDisplayName &key = it.key();
GTestConfiguration *tc = new GTestConfiguration;
tc->setTestCaseCount(it.value());
tc->setProFile(key.proFile);
tc->setProjectFile(key.proFile);
tc->setDisplayName(key.displayName);
tc->setProject(project);
result << tc;
......@@ -243,7 +243,7 @@ QList<TestConfiguration *> GTestTreeItem::getSelectedTestConfigurations() const
GTestConfiguration *tc = new GTestConfiguration;
tc->setTestCases(it.value().filters);
tc->setTestCaseCount(tc->testCaseCount() + it.value().additionalTestCaseCount);
tc->setProFile(proFileWithDisplayName.proFile);
tc->setProjectFile(proFileWithDisplayName.proFile);
tc->setDisplayName(proFileWithDisplayName.displayName);
tc->setProject(project);
result << tc;
......
......@@ -109,7 +109,7 @@ TestConfiguration *QtTestTreeItem::testConfiguration() const
case TestCase:
config = new QtTestConfiguration;
config->setTestCaseCount(childCount());
config->setProFile(proFile());
config->setProjectFile(proFile());
config->setProject(project);
config->setDisplayName(TestUtils::getCMakeDisplayNameIfNecessary(filePath(), proFile()));
break;
......@@ -117,7 +117,7 @@ TestConfiguration *QtTestTreeItem::testConfiguration() const
TestTreeItem *parent = parentItem();
config = new QtTestConfiguration();
config->setTestCases(QStringList(name()));
config->setProFile(parent->proFile());
config->setProjectFile(parent->proFile());
config->setProject(project);
config->setDisplayName(
TestUtils::getCMakeDisplayNameIfNecessary(filePath(), parent->proFile()));
......@@ -131,7 +131,7 @@ TestConfiguration *QtTestTreeItem::testConfiguration() const
const QString functionWithTag = function->name() + ':' + name();
config = new QtTestConfiguration();
config->setTestCases(QStringList(functionWithTag));
config->setProFile(parent->proFile());
config->setProjectFile(parent->proFile());
config->setProject(project);
config->setDisplayName(TestUtils::getCMakeDisplayNameIfNecessary(filePath(),
parent->proFile()));
......@@ -164,7 +164,7 @@ QList<TestConfiguration *> QtTestTreeItem::getAllTestConfigurations() const
TestConfiguration *tc = new QtTestConfiguration();
tc->setTestCaseCount(child->childCount());
tc->setProFile(child->proFile());
tc->setProjectFile(child->proFile());
tc->setProject(project);
tc->setDisplayName(TestUtils::getCMakeDisplayNameIfNecessary(child->filePath(),
child->proFile()));
......@@ -191,7 +191,7 @@ QList<TestConfiguration *> QtTestTreeItem::getSelectedTestConfigurations() const
case Qt::Checked:
testConfiguration = new QtTestConfiguration();
testConfiguration->setTestCaseCount(child->childCount());
testConfiguration->setProFile(child->proFile());
testConfiguration->setProjectFile(child->proFile());
testConfiguration->setProject(project);
testConfiguration->setDisplayName(
TestUtils::getCMakeDisplayNameIfNecessary(child->filePath(), child->proFile()));
......@@ -218,7 +218,7 @@ QList<TestConfiguration *> QtTestTreeItem::getSelectedTestConfigurations() const
testConfiguration = new QtTestConfiguration();
testConfiguration->setTestCases(testCases);
testConfiguration->setProFile(child->proFile());
testConfiguration->setProjectFile(child->proFile());
testConfiguration->setProject(project);
testConfiguration->setDisplayName(
TestUtils::getCMakeDisplayNameIfNecessary(child->filePath(), child->proFile()));
......
......@@ -122,7 +122,7 @@ TestConfiguration *QuickTestTreeItem::testConfiguration() const
testFunctions << name() + "::" + childItem(row)->name();
config = new QuickTestConfiguration;
config->setTestCases(testFunctions);
config->setProFile(proFile());
config->setProjectFile(proFile());
config->setProject(project);
break;
}
......@@ -131,7 +131,7 @@ TestConfiguration *QuickTestTreeItem::testConfiguration() const
QStringList testFunction(parent->name() + "::" + name());
config = new QuickTestConfiguration;
config->setTestCases(testFunction);
config->setProFile(parent->proFile());
config->setProjectFile(parent->proFile());
config->setProject(project);
break;
}
......@@ -171,7 +171,7 @@ QList<TestConfiguration *> QuickTestTreeItem::getAllTestConfigurations() const
for ( ; it != end; ++it) {
QuickTestConfiguration *tc = new QuickTestConfiguration;
tc->setTestCaseCount(it.value());
tc->setProFile(it.key());
tc->setProjectFile(it.key());
tc->setProject(project);
result << tc;
}
......@@ -201,7 +201,7 @@ QList<TestConfiguration *> QuickTestTreeItem::getSelectedTestConfigurations() co
tc = new QuickTestConfiguration;
tc->setTestCaseCount(1);
tc->setUnnamedOnly(true);
tc->setProFile(proFile);
tc->setProjectFile(proFile);
tc->setProject(project);
foundProFiles.insert(proFile, tc);
}
......@@ -244,7 +244,7 @@ QList<TestConfiguration *> QuickTestTreeItem::getSelectedTestConfigurations() co
} else {
tc = new QuickTestConfiguration;
tc->setTestCases(testFunctions);
tc->setProFile(child->proFile());
tc->setProjectFile(child->proFile());
tc->setProject(project);
foundProFiles.insert(child->proFile(), tc);
}
......
......@@ -87,13 +87,13 @@ static bool isLocal(RunConfiguration *runConfiguration)
void TestConfiguration::completeTestInformation(int runMode)
{
QTC_ASSERT(!m_proFile.isEmpty(), return);
QTC_ASSERT(!m_projectFile.isEmpty(), return);
Project *project = SessionManager::startupProject();
if (!project)
return;
QString targetFile;
QString executable;
QString targetName;
QString workDir;
QString displayName = m_displayName;
......@@ -105,7 +105,7 @@ void TestConfiguration::completeTestInformation(int runMode)
bool guessedRunConfiguration = false;
setProject(0);
completeBasicProjectInformation(project, m_proFile, &displayName, &targetProject);
completeBasicProjectInformation(project, m_projectFile, &displayName, &targetProject);
Target *target = project->activeTarget();
if (!target)
......@@ -115,10 +115,10 @@ void TestConfiguration::completeTestInformation(int runMode)
if (m_displayName.isEmpty()) {
foreach (const BuildTargetInfo &bti, appTargets.list) {
// some project manager store line/column information as well inside ProjectPart
if (bti.isValid() && m_proFile.startsWith(bti.projectFilePath.toString())) {
targetFile = bti.targetFilePath.toString();
if (Utils::HostOsInfo::isWindowsHost() && !targetFile.toLower().endsWith(".exe"))
targetFile = Utils::HostOsInfo::withExecutableSuffix(targetFile);
if (bti.isValid() && m_projectFile.startsWith(bti.projectFilePath.toString())) {
executable = bti.targetFilePath.toString();
if (Utils::HostOsInfo::isWindowsHost() && !executable.toLower().endsWith(".exe"))
executable = Utils::HostOsInfo::withExecutableSuffix(executable);
targetName = bti.targetName;
break;
}
......@@ -127,7 +127,7 @@ void TestConfiguration::completeTestInformation(int runMode)
foreach (const BuildTargetInfo &bti, appTargets.list) {
if (bti.isValid() && m_displayName == bti.targetName) {
// for CMake base projects targetFilePath has executable suffix already
targetFile = bti.targetFilePath.toString();
executable = bti.targetFilePath.toString();
targetName = m_displayName;
break;
}
......@@ -138,8 +138,8 @@ void TestConfiguration::completeTestInformation(int runMode)
if (auto buildConfig = target->activeBuildConfiguration()) {
const QString buildBase = buildConfig->buildDirectory().toString();
const QString projBase = targetProject->projectDirectory().toString();
if (m_proFile.startsWith(projBase))
buildDir = QFileInfo(buildBase + m_proFile.mid(projBase.length())).absolutePath();
if (m_projectFile.startsWith(projBase))
buildDir = QFileInfo(buildBase + m_projectFile.mid(projBase.length())).absolutePath();
}
}
......@@ -149,11 +149,11 @@ void TestConfiguration::completeTestInformation(int runMode)
if (isLocal(rc) && runnable.is<StandardRunnable>()) {
StandardRunnable stdRunnable = runnable.as<StandardRunnable>();
// we might have an executable that gets installed - in such a case the
// runnable's executable and targetFile won't match - but the (unique) display name
// runnable's executable and executable won't match - but the (unique) display name
// of the run configuration should match targetName
if (stdRunnable.executable == targetFile
if (stdRunnable.executable == executable
|| (!targetName.isEmpty() && rc->displayName() == targetName)) {
targetFile = stdRunnable.executable;
executable = stdRunnable.executable;
workDir = Utils::FileUtils::normalizePathName(stdRunnable.workingDirectory);
env = stdRunnable.environment;
hasDesktopTarget = true;
......@@ -165,7 +165,7 @@ void TestConfiguration::completeTestInformation(int runMode)
// if we could not figure out the run configuration
// try to use the run configuration of the parent project
if (!hasDesktopTarget && targetProject && !targetFile.isEmpty()) {
if (!hasDesktopTarget && targetProject && !executable.isEmpty()) {
if (auto rc = target->activeRunConfiguration()) {
Runnable runnable = rc->runnable();
if (isLocal(rc) && runnable.is<StandardRunnable>()) {
......@@ -182,8 +182,7 @@ void TestConfiguration::completeTestInformation(int runMode)
setDisplayName(displayName);
if (hasDesktopTarget) {
setTargetFile(targetFile);
setTargetName(targetName);
setExecutableFile(executable);
setWorkingDirectory(workDir);
setBuildDirectory(buildDir);
setEnvironment(env);
......@@ -215,19 +214,14 @@ void TestConfiguration::setTestCaseCount(int count)
m_testCaseCount = count;
}
void TestConfiguration::setTargetFile(const QString &targetFile)
void TestConfiguration::setExecutableFile(const QString &executableFile)
{
m_targetFile = targetFile;
m_executableFile = executableFile;
}
void TestConfiguration::setTargetName(const QString &targetName)
void TestConfiguration::setProjectFile(const QString &projectFile)
{
m_targetName = targetName;
}
void TestConfiguration::setProFile(const QString &proFile)
{
m_proFile = proFile;
m_projectFile = projectFile;
}
void TestConfiguration::setWorkingDirectory(const QString &workingDirectory)
......@@ -262,16 +256,14 @@ void TestConfiguration::setGuessedConfiguration(bool guessed)
QString TestConfiguration::executableFilePath() const
{
if (m_targetFile.isEmpty())
if (m_executableFile.isEmpty())
return QString();
QFileInfo commandFileInfo(m_targetFile);
QFileInfo commandFileInfo(m_executableFile);
if (commandFileInfo.isExecutable() && commandFileInfo.path() != ".") {
return commandFileInfo.absoluteFilePath();
} else if (commandFileInfo.path() == "."){
QString fullCommandFileName = m_targetFile;
if (Utils::HostOsInfo::isWindowsHost() && !m_targetFile.endsWith(".exe"))
fullCommandFileName = m_targetFile + ".exe";
QString fullCommandFileName = m_executableFile;
// TODO: check if we can use searchInPath() from Utils::Environment
const QStringList &pathList = m_environment.toProcessEnvironment().value("PATH").split(
Utils::HostOsInfo::pathListSeparator());
......
......@@ -59,9 +59,8 @@ public:
void setTestCases(const QStringList &testCases);
void setTestCaseCount(int count);
void setTargetFile(const QString &targetFile);
void setTargetName(const QString &targetName);
void setProFile(const QString &proFile);
void setExecutableFile(const QString &executableFile);
void setProjectFile(const QString &projectFile);
void setWorkingDirectory(const QString &workingDirectory);
void setBuildDirectory(const QString &buildDirectory);
void setDisplayName(const QString &displayName);
......@@ -71,10 +70,7 @@ public:
QStringList testCases() const { return m_testCases; }
int testCaseCount() const { return m_testCaseCount; }
QString proFile() const { return m_proFile; }
QString targetFile() const { return m_targetFile; }
QString executableFilePath() const;
QString targetName() const { return m_targetName; }
QString workingDirectory() const;
QString buildDirectory() const { return m_buildDir; }
QString displayName() const { return m_displayName; }
......@@ -90,9 +86,8 @@ public:
private:
QStringList m_testCases;
int m_testCaseCount = 0;
QString m_proFile;
QString m_targetFile;
QString m_targetName;
QString m_projectFile;
QString m_executableFile;
QString m_workingDir;
QString m_buildDir;
QString m_displayName;
......
......@@ -62,7 +62,7 @@ public:
{
ProjectExplorer::StandardRunnable r;
QTC_ASSERT(m_testConfig, return r);
r.executable = m_testConfig->targetFile();
r.executable = m_testConfig->executableFilePath();
r.commandLineArguments = m_testConfig->argumentsForTestRunner().join(' ');
r.workingDirectory = m_testConfig->workingDirectory();
r.environment = m_testConfig->environment();
......
......@@ -134,7 +134,7 @@ static void performTestRun(QFutureInterface<TestResultPtr> &futureInterface,
if (commandFilePath.isEmpty()) {
futureInterface.reportResult(TestResultPtr(new FaultyTestResult(Result::MessageFatal,
TestRunner::tr("Could not find command \"%1\". (%2)")
.arg(testConfiguration->targetFile())
.arg(testConfiguration->executableFilePath())
.arg(testConfiguration->displayName()))));
continue;
}
......@@ -294,7 +294,7 @@ void TestRunner::debugTests()
if (commandFilePath.isEmpty()) {
emit testResultReady(TestResultPtr(new FaultyTestResult(Result::MessageFatal,
TestRunner::tr("Could not find command \"%1\". (%2)")
.arg(config->targetFile())
.arg(config->executableFilePath())
.arg(config->displayName()))));
onFinished();
return;
......
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