2014-10-07 15:51:02 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2014-10-07 15:51:02 +02:00
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** This file is part of Qt Creator.
|
2014-10-07 15:51:02 +02:00
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
2014-10-07 15:51:02 +02:00
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-22 10:37:55 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2014-10-07 15:51:02 +02:00
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2014-10-07 15:51:02 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "testconfiguration.h"
|
2016-04-29 10:13:35 +02:00
|
|
|
#include "testoutputreader.h"
|
2016-06-15 12:29:24 +02:00
|
|
|
#include "testrunconfiguration.h"
|
2014-10-07 15:51:02 +02:00
|
|
|
|
2015-04-27 16:11:28 +02:00
|
|
|
#include <cpptools/cppmodelmanager.h>
|
2016-01-13 12:14:43 +01:00
|
|
|
#include <cpptools/projectinfo.h>
|
2015-04-27 16:11:28 +02:00
|
|
|
|
2016-01-26 17:24:11 +01:00
|
|
|
#include <projectexplorer/buildconfiguration.h>
|
2020-03-23 14:14:03 +01:00
|
|
|
#include <projectexplorer/buildsystem.h>
|
2015-04-27 16:11:28 +02:00
|
|
|
#include <projectexplorer/buildtargetinfo.h>
|
2017-07-12 15:53:31 +02:00
|
|
|
#include <projectexplorer/deploymentdata.h>
|
2015-04-27 16:11:28 +02:00
|
|
|
#include <projectexplorer/environmentaspect.h>
|
2016-01-25 15:00:20 +01:00
|
|
|
#include <projectexplorer/kitinformation.h>
|
2015-04-27 16:11:28 +02:00
|
|
|
#include <projectexplorer/runconfiguration.h>
|
|
|
|
|
#include <projectexplorer/session.h>
|
|
|
|
|
#include <projectexplorer/target.h>
|
|
|
|
|
|
2017-07-31 14:59:35 +02:00
|
|
|
#include <QLoggingCategory>
|
|
|
|
|
|
2018-10-12 09:33:30 +03:00
|
|
|
static Q_LOGGING_CATEGORY(LOG, "qtc.autotest.testconfiguration", QtWarningMsg)
|
2017-07-31 14:59:35 +02:00
|
|
|
|
2015-04-27 16:11:28 +02:00
|
|
|
using namespace ProjectExplorer;
|
2019-06-20 17:19:12 +02:00
|
|
|
using namespace Utils;
|
2014-10-07 15:51:02 +02:00
|
|
|
|
|
|
|
|
namespace Autotest {
|
|
|
|
|
|
2020-03-26 10:11:39 +01:00
|
|
|
TestConfiguration::TestConfiguration(ITestFramework *framework)
|
|
|
|
|
: m_framework(framework)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-07 15:51:02 +02:00
|
|
|
TestConfiguration::~TestConfiguration()
|
|
|
|
|
{
|
|
|
|
|
m_testCases.clear();
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-13 09:02:23 +01:00
|
|
|
static bool isLocal(Target *target)
|
2015-04-27 16:11:28 +02:00
|
|
|
{
|
2018-05-31 07:38:04 +02:00
|
|
|
Kit *kit = target ? target->kit() : nullptr;
|
2019-02-06 12:50:51 +01:00
|
|
|
return DeviceTypeKitAspect::deviceTypeId(kit) == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
|
2015-04-27 16:11:28 +02:00
|
|
|
}
|
|
|
|
|
|
2019-06-20 17:19:12 +02:00
|
|
|
static FilePath ensureExeEnding(const FilePath &file)
|
2017-07-12 15:53:31 +02:00
|
|
|
{
|
2019-06-20 17:19:12 +02:00
|
|
|
if (!HostOsInfo::isWindowsHost() || file.isEmpty() || file.toString().toLower().endsWith(".exe"))
|
2017-07-12 15:53:31 +02:00
|
|
|
return file;
|
2019-06-20 17:19:12 +02:00
|
|
|
return FilePath::fromString(HostOsInfo::withExecutableSuffix(file.toString()));
|
2017-07-12 15:53:31 +02:00
|
|
|
}
|
|
|
|
|
|
2017-09-13 14:27:20 +02:00
|
|
|
void TestConfiguration::completeTestInformation(ProjectExplorer::RunConfiguration *rc,
|
|
|
|
|
TestRunMode runMode)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(rc, return);
|
2018-06-21 10:36:50 +02:00
|
|
|
QTC_ASSERT(m_project, return);
|
|
|
|
|
|
2017-09-28 13:51:31 +02:00
|
|
|
if (hasExecutable()) {
|
|
|
|
|
qCDebug(LOG) << "Executable has been set already - not completing configuration again.";
|
|
|
|
|
return;
|
|
|
|
|
}
|
2017-09-13 14:27:20 +02:00
|
|
|
Project *project = SessionManager::startupProject();
|
2018-06-21 10:36:50 +02:00
|
|
|
if (!project || project != m_project)
|
2017-09-13 14:27:20 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Target *target = project->activeTarget();
|
|
|
|
|
if (!target)
|
|
|
|
|
return;
|
|
|
|
|
|
2019-08-13 15:12:54 +02:00
|
|
|
if (!target->runConfigurations().contains(rc))
|
2017-09-13 14:27:20 +02:00
|
|
|
return;
|
|
|
|
|
|
2018-05-16 15:42:03 +02:00
|
|
|
m_runnable = rc->runnable();
|
2017-09-13 14:27:20 +02:00
|
|
|
m_displayName = rc->displayName();
|
|
|
|
|
|
2019-02-18 18:24:10 +01:00
|
|
|
BuildTargetInfo targetInfo = rc->buildTargetInfo();
|
2017-09-13 14:27:20 +02:00
|
|
|
if (!targetInfo.targetFilePath.isEmpty())
|
2019-06-20 17:19:12 +02:00
|
|
|
m_runnable.executable = ensureExeEnding(targetInfo.targetFilePath);
|
2017-09-13 14:27:20 +02:00
|
|
|
|
|
|
|
|
QString buildBase;
|
|
|
|
|
if (auto buildConfig = target->activeBuildConfiguration()) {
|
|
|
|
|
buildBase = buildConfig->buildDirectory().toString();
|
|
|
|
|
const QString projBase = m_project->projectDirectory().toString();
|
|
|
|
|
if (m_projectFile.startsWith(projBase))
|
|
|
|
|
m_buildDir = QFileInfo(buildBase + m_projectFile.mid(projBase.length())).absolutePath();
|
|
|
|
|
}
|
|
|
|
|
if (runMode == TestRunMode::Debug || runMode == TestRunMode::DebugWithoutDeploy)
|
2019-08-19 10:55:32 +02:00
|
|
|
m_runConfig = new Internal::TestRunConfiguration(rc->target(), this);
|
2017-09-13 14:27:20 +02:00
|
|
|
}
|
|
|
|
|
|
2017-09-05 13:57:22 +02:00
|
|
|
void TestConfiguration::completeTestInformation(TestRunMode runMode)
|
2015-04-27 16:11:28 +02:00
|
|
|
{
|
2017-02-21 14:53:58 +01:00
|
|
|
QTC_ASSERT(!m_projectFile.isEmpty(), return);
|
2017-06-09 09:30:21 +02:00
|
|
|
QTC_ASSERT(!m_buildTargets.isEmpty(), return);
|
2018-06-21 10:36:50 +02:00
|
|
|
QTC_ASSERT(m_project, return);
|
2015-04-27 16:11:28 +02:00
|
|
|
|
2017-09-13 14:27:20 +02:00
|
|
|
if (m_origRunConfig) {
|
|
|
|
|
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
|
|
|
|
|
<< "\nWorking directory:" << m_runnable.workingDirectory;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
qCDebug(LOG) << "Failed to complete - using 'normal' way.";
|
|
|
|
|
}
|
2015-04-27 16:11:28 +02:00
|
|
|
Project *project = SessionManager::startupProject();
|
2018-06-21 10:36:50 +02:00
|
|
|
if (!project || project != m_project) {
|
|
|
|
|
m_project = nullptr;
|
2015-04-27 16:11:28 +02:00
|
|
|
return;
|
2018-06-21 10:36:50 +02:00
|
|
|
}
|
2015-04-27 16:11:28 +02:00
|
|
|
|
|
|
|
|
Target *target = project->activeTarget();
|
|
|
|
|
if (!target)
|
|
|
|
|
return;
|
2017-07-31 14:59:35 +02:00
|
|
|
qCDebug(LOG) << "ActiveTargetName\n " << target->displayName();
|
|
|
|
|
if (const auto kit = target->kit())
|
|
|
|
|
qCDebug(LOG) << "SupportedPlatforms\n " << kit->supportedPlatforms();
|
2015-04-27 16:11:28 +02:00
|
|
|
|
2017-06-09 09:30:21 +02:00
|
|
|
const QSet<QString> buildSystemTargets = m_buildTargets;
|
2017-07-31 14:59:35 +02:00
|
|
|
qCDebug(LOG) << "BuildSystemTargets\n " << buildSystemTargets;
|
2020-07-01 17:01:10 +02:00
|
|
|
const QList<BuildTargetInfo> buildTargets
|
|
|
|
|
= Utils::filtered(target->buildSystem()->applicationTargets(),
|
|
|
|
|
[&buildSystemTargets](const BuildTargetInfo &bti) {
|
2018-04-13 09:22:26 +02:00
|
|
|
return buildSystemTargets.contains(bti.buildKey);
|
2017-02-01 15:42:55 +01:00
|
|
|
});
|
2020-07-01 17:01:10 +02:00
|
|
|
if (buildTargets.size() > 1 ) // there are multiple executables with the same build target
|
|
|
|
|
return; // let the user decide which one to run
|
|
|
|
|
|
2020-08-04 08:21:26 +02:00
|
|
|
const BuildTargetInfo targetInfo = buildTargets.size() ? buildTargets.first()
|
|
|
|
|
: BuildTargetInfo();
|
2020-07-01 17:01:10 +02:00
|
|
|
|
2017-09-13 11:03:29 +02:00
|
|
|
// we might end up with an empty targetFilePath - e.g. when having a library we just link to
|
|
|
|
|
// there would be no BuildTargetInfo that could match
|
|
|
|
|
if (targetInfo.targetFilePath.isEmpty()) {
|
2017-07-31 14:59:35 +02:00
|
|
|
qCDebug(LOG) << "BuildTargetInfos";
|
2018-09-21 09:10:54 +02:00
|
|
|
// if there is only one build target just use it (but be honest that we're deducing)
|
2020-07-01 17:01:10 +02:00
|
|
|
m_deducedConfiguration = true;
|
|
|
|
|
m_deducedFrom = targetInfo.buildKey;
|
2017-07-31 14:59:35 +02:00
|
|
|
}
|
2017-09-13 11:03:29 +02:00
|
|
|
|
2019-06-20 17:19:12 +02:00
|
|
|
const FilePath localExecutable = ensureExeEnding(targetInfo.targetFilePath);
|
2017-09-22 12:19:13 +02:00
|
|
|
if (localExecutable.isEmpty())
|
|
|
|
|
return;
|
2017-07-12 15:53:31 +02:00
|
|
|
|
|
|
|
|
QString buildBase;
|
|
|
|
|
if (auto buildConfig = target->activeBuildConfiguration()) {
|
|
|
|
|
buildBase = buildConfig->buildDirectory().toString();
|
|
|
|
|
const QString projBase = project->projectDirectory().toString();
|
|
|
|
|
if (m_projectFile.startsWith(projBase))
|
|
|
|
|
m_buildDir = QFileInfo(buildBase + m_projectFile.mid(projBase.length())).absolutePath();
|
2017-06-26 10:25:46 +02:00
|
|
|
}
|
|
|
|
|
|
2017-07-12 15:53:31 +02:00
|
|
|
// deployment information should get taken into account, but it pretty much seems as if
|
|
|
|
|
// each build system uses it differently
|
|
|
|
|
const DeploymentData &deployData = target->deploymentData();
|
2019-08-27 13:47:24 +02:00
|
|
|
const DeployableFile deploy = deployData.deployableForLocalFile(localExecutable);
|
2017-07-12 15:53:31 +02:00
|
|
|
// we might have a deployable executable
|
2019-06-20 17:19:12 +02:00
|
|
|
const FilePath deployedExecutable = ensureExeEnding((deploy.isValid() && deploy.isExecutable())
|
|
|
|
|
? FilePath::fromString(QDir::cleanPath(deploy.remoteFilePath())) : localExecutable);
|
2017-07-12 15:53:31 +02:00
|
|
|
|
2017-07-31 14:59:35 +02:00
|
|
|
qCDebug(LOG) << " LocalExecutable" << localExecutable;
|
|
|
|
|
qCDebug(LOG) << " DeployedExecutable" << deployedExecutable;
|
2020-10-15 13:30:11 +02:00
|
|
|
qCDebug(LOG) << "Iterating run configurations - prefer active over others";
|
|
|
|
|
QList<RunConfiguration *> runConfigurations = target->runConfigurations();
|
|
|
|
|
runConfigurations.removeOne(target->activeRunConfiguration());
|
|
|
|
|
runConfigurations.prepend(target->activeRunConfiguration());
|
|
|
|
|
for (RunConfiguration *runConfig : qAsConst(runConfigurations)) {
|
2017-07-31 14:59:35 +02:00
|
|
|
qCDebug(LOG) << "RunConfiguration" << runConfig->id();
|
2019-03-13 09:02:23 +01:00
|
|
|
if (!isLocal(target)) { // TODO add device support
|
2017-07-31 14:59:35 +02:00
|
|
|
qCDebug(LOG) << " Skipped as not being local";
|
2017-02-01 15:42:55 +01:00
|
|
|
continue;
|
2017-07-31 14:59:35 +02:00
|
|
|
}
|
2017-02-01 15:42:55 +01:00
|
|
|
|
2018-05-16 15:42:03 +02:00
|
|
|
const Runnable runnable = runConfig->runnable();
|
2017-07-12 15:53:31 +02:00
|
|
|
// 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...
|
2019-06-20 17:19:12 +02:00
|
|
|
const FilePath currentExecutable = ensureExeEnding(runnable.executable);
|
2018-05-30 12:41:05 +02:00
|
|
|
const QString currentBST = runConfig->buildKey();
|
2017-07-31 14:59:35 +02:00
|
|
|
qCDebug(LOG) << " CurrentExecutable" << currentExecutable;
|
|
|
|
|
qCDebug(LOG) << " BST of RunConfig" << currentBST;
|
2017-07-12 15:53:31 +02:00
|
|
|
if ((localExecutable == currentExecutable)
|
|
|
|
|
|| (deployedExecutable == currentExecutable)
|
2018-05-30 12:41:05 +02:00
|
|
|
|| (buildSystemTargets.contains(currentBST))) {
|
2017-07-31 14:59:35 +02:00
|
|
|
qCDebug(LOG) << " Using this RunConfig.";
|
2017-09-13 14:27:20 +02:00
|
|
|
m_origRunConfig = runConfig;
|
2018-05-16 15:42:03 +02:00
|
|
|
m_runnable = runnable;
|
2017-08-31 11:26:02 +02:00
|
|
|
m_runnable.executable = currentExecutable;
|
2017-02-01 15:42:55 +01:00
|
|
|
m_displayName = runConfig->displayName();
|
2017-09-05 13:57:22 +02:00
|
|
|
if (runMode == TestRunMode::Debug || runMode == TestRunMode::DebugWithoutDeploy)
|
2019-08-19 10:55:32 +02:00
|
|
|
m_runConfig = new Internal::TestRunConfiguration(target, this);
|
2017-07-12 15:53:31 +02:00
|
|
|
break;
|
2015-04-27 16:11:28 +02:00
|
|
|
}
|
|
|
|
|
}
|
2017-07-12 15:53:31 +02:00
|
|
|
|
2017-02-01 15:42:55 +01:00
|
|
|
// RunConfiguration for this target could be explicitly removed or not created at all
|
2017-07-12 15:53:31 +02:00
|
|
|
// 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
|
2017-09-13 14:27:20 +02:00
|
|
|
if (!hasExecutable() && !localExecutable.isEmpty())
|
2017-08-31 11:26:02 +02:00
|
|
|
m_runnable.executable = localExecutable;
|
2017-09-13 14:27:20 +02:00
|
|
|
if (m_displayName.isEmpty() && hasExecutable()) {
|
2017-07-31 14:59:35 +02:00
|
|
|
qCDebug(LOG) << " Fallback";
|
2017-02-01 15:42:55 +01:00
|
|
|
// we failed to find a valid runconfiguration - but we've got the executable already
|
2016-01-25 15:00:20 +01:00
|
|
|
if (auto rc = target->activeRunConfiguration()) {
|
2019-03-13 09:02:23 +01:00
|
|
|
if (isLocal(target)) { // FIXME for now only Desktop support
|
2018-05-16 15:42:03 +02:00
|
|
|
const Runnable runnable = rc->runnable();
|
|
|
|
|
m_runnable.environment = runnable.environment;
|
2018-09-21 09:10:54 +02:00
|
|
|
m_deducedConfiguration = true;
|
|
|
|
|
m_deducedFrom = rc->displayName();
|
2018-05-16 15:42:03 +02:00
|
|
|
if (runMode == TestRunMode::Debug)
|
2019-08-19 10:55:32 +02:00
|
|
|
m_runConfig = new Internal::TestRunConfiguration(rc->target(), this);
|
2017-07-31 14:59:35 +02:00
|
|
|
} else {
|
|
|
|
|
qCDebug(LOG) << "not using the fallback as the current active run configuration "
|
|
|
|
|
"appears to be non-Desktop";
|
2016-01-25 15:00:20 +01:00
|
|
|
}
|
2015-04-27 16:11:28 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-21 09:10:54 +02:00
|
|
|
if (m_displayName.isEmpty()) // happens e.g. when deducing the TestConfiguration or error
|
2018-05-30 12:41:05 +02:00
|
|
|
m_displayName = (*buildSystemTargets.begin());
|
2017-02-01 15:42:55 +01:00
|
|
|
}
|
2015-04-27 16:11:28 +02:00
|
|
|
|
2014-11-06 16:01:06 +01:00
|
|
|
/**
|
|
|
|
|
* @brief sets the test cases for this test configuration.
|
|
|
|
|
*
|
|
|
|
|
* Watch out for special handling of test configurations, because this method also
|
|
|
|
|
* updates the test case count to the current size of \a testCases.
|
|
|
|
|
*
|
|
|
|
|
* @param testCases list of names of the test functions / test cases
|
|
|
|
|
*/
|
|
|
|
|
void TestConfiguration::setTestCases(const QStringList &testCases)
|
|
|
|
|
{
|
|
|
|
|
m_testCases.clear();
|
|
|
|
|
m_testCases << testCases;
|
|
|
|
|
m_testCaseCount = m_testCases.size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestConfiguration::setTestCaseCount(int count)
|
|
|
|
|
{
|
|
|
|
|
m_testCaseCount = count;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-21 14:53:58 +01:00
|
|
|
void TestConfiguration::setExecutableFile(const QString &executableFile)
|
2014-10-07 15:51:02 +02:00
|
|
|
{
|
2019-06-20 17:19:12 +02:00
|
|
|
m_runnable.executable = Utils::FilePath::fromString(executableFile);
|
2014-10-07 15:51:02 +02:00
|
|
|
}
|
|
|
|
|
|
2017-02-21 14:53:58 +01:00
|
|
|
void TestConfiguration::setProjectFile(const QString &projectFile)
|
2014-10-07 15:51:02 +02:00
|
|
|
{
|
2017-02-21 14:53:58 +01:00
|
|
|
m_projectFile = projectFile;
|
2014-10-07 15:51:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TestConfiguration::setWorkingDirectory(const QString &workingDirectory)
|
|
|
|
|
{
|
2017-08-31 11:26:02 +02:00
|
|
|
m_runnable.workingDirectory = workingDirectory;
|
2014-10-07 15:51:02 +02:00
|
|
|
}
|
|
|
|
|
|
2016-01-26 17:24:11 +01:00
|
|
|
void TestConfiguration::setBuildDirectory(const QString &buildDirectory)
|
|
|
|
|
{
|
|
|
|
|
m_buildDir = buildDirectory;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-13 12:31:58 +01:00
|
|
|
void TestConfiguration::setDisplayName(const QString &displayName)
|
|
|
|
|
{
|
|
|
|
|
m_displayName = displayName;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-07 15:51:02 +02:00
|
|
|
void TestConfiguration::setEnvironment(const Utils::Environment &env)
|
|
|
|
|
{
|
2017-08-31 11:26:02 +02:00
|
|
|
m_runnable.environment = env;
|
2014-10-07 15:51:02 +02:00
|
|
|
}
|
|
|
|
|
|
2015-04-27 16:11:28 +02:00
|
|
|
void TestConfiguration::setProject(Project *project)
|
2014-10-07 15:51:02 +02:00
|
|
|
{
|
|
|
|
|
m_project = project;
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-12 08:08:27 +02:00
|
|
|
void TestConfiguration::setInternalTarget(const QString &target)
|
|
|
|
|
{
|
|
|
|
|
m_buildTargets.clear();
|
|
|
|
|
m_buildTargets.insert(target);
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-09 09:30:21 +02:00
|
|
|
void TestConfiguration::setInternalTargets(const QSet<QString> &targets)
|
|
|
|
|
{
|
|
|
|
|
m_buildTargets = targets;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-13 14:27:20 +02:00
|
|
|
void TestConfiguration::setOriginalRunConfiguration(RunConfiguration *runConfig)
|
|
|
|
|
{
|
|
|
|
|
m_origRunConfig = runConfig;
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-05 15:02:37 +02:00
|
|
|
QString TestConfiguration::executableFilePath() const
|
|
|
|
|
{
|
2017-09-13 14:27:20 +02:00
|
|
|
if (!hasExecutable())
|
2016-08-05 15:02:37 +02:00
|
|
|
return QString();
|
|
|
|
|
|
2019-06-20 17:19:12 +02:00
|
|
|
QFileInfo commandFileInfo = m_runnable.executable.toFileInfo();
|
2016-08-05 15:02:37 +02:00
|
|
|
if (commandFileInfo.isExecutable() && commandFileInfo.path() != ".") {
|
|
|
|
|
return commandFileInfo.absoluteFilePath();
|
|
|
|
|
} else if (commandFileInfo.path() == "."){
|
2019-06-20 17:19:12 +02:00
|
|
|
QString fullCommandFileName = m_runnable.executable.toString();
|
2016-08-05 15:02:37 +02:00
|
|
|
// TODO: check if we can use searchInPath() from Utils::Environment
|
2017-08-31 11:26:02 +02:00
|
|
|
const QStringList &pathList = m_runnable.environment.toProcessEnvironment().value("PATH")
|
|
|
|
|
.split(Utils::HostOsInfo::pathListSeparator());
|
2016-08-05 15:02:37 +02:00
|
|
|
|
|
|
|
|
foreach (const QString &path, pathList) {
|
|
|
|
|
QString filePath(path + QDir::separator() + fullCommandFileName);
|
|
|
|
|
if (QFileInfo(filePath).isExecutable())
|
|
|
|
|
return commandFileInfo.absoluteFilePath();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString TestConfiguration::workingDirectory() const
|
|
|
|
|
{
|
2017-08-31 11:26:02 +02:00
|
|
|
if (!m_runnable.workingDirectory.isEmpty()) {
|
|
|
|
|
const QFileInfo info(m_runnable.workingDirectory);
|
2016-08-05 15:02:37 +02:00
|
|
|
if (info.isDir()) // ensure wanted working dir does exist
|
|
|
|
|
return info.absoluteFilePath();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString executable = executableFilePath();
|
|
|
|
|
return executable.isEmpty() ? executable : QFileInfo(executable).absolutePath();
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-05 13:57:22 +02:00
|
|
|
bool DebuggableTestConfiguration::isDebugRunMode() const
|
|
|
|
|
{
|
|
|
|
|
return m_runMode == TestRunMode::Debug || m_runMode == TestRunMode::DebugWithoutDeploy;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-13 14:27:20 +02:00
|
|
|
bool TestConfiguration::hasExecutable() const
|
|
|
|
|
{
|
|
|
|
|
return !m_runnable.executable.isEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-26 10:11:39 +01:00
|
|
|
ITestFramework *TestConfiguration::framework() const
|
|
|
|
|
{
|
|
|
|
|
return m_framework;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-07 15:51:02 +02:00
|
|
|
} // namespace Autotest
|