2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2014-10-07 15:51:02 +02:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2014-10-07 15:51:02 +02:00
|
|
|
|
2016-01-12 13:52:21 +01:00
|
|
|
#include "autotestconstants.h"
|
|
|
|
|
|
2016-01-18 14:37:32 +01:00
|
|
|
#include <projectexplorer/project.h>
|
2019-03-13 08:06:08 +01:00
|
|
|
#include <projectexplorer/runcontrol.h>
|
2014-10-07 15:51:02 +02:00
|
|
|
#include <utils/environment.h>
|
|
|
|
|
|
2016-04-29 10:13:35 +02:00
|
|
|
#include <QFutureInterface>
|
2016-01-18 14:37:32 +01:00
|
|
|
#include <QPointer>
|
2014-10-07 15:51:02 +02:00
|
|
|
#include <QStringList>
|
|
|
|
|
|
2022-06-10 10:18:34 +02:00
|
|
|
namespace Utils { class QtcProcess; }
|
2016-04-29 10:13:35 +02:00
|
|
|
|
2014-10-07 15:51:02 +02:00
|
|
|
namespace Autotest {
|
|
|
|
|
namespace Internal {
|
2019-08-19 10:55:32 +02:00
|
|
|
class TestRunConfiguration;
|
|
|
|
|
} // namespace Internal
|
2014-10-07 15:51:02 +02:00
|
|
|
|
2020-10-13 11:37:37 +02:00
|
|
|
class ITestBase;
|
2020-03-26 10:11:39 +01:00
|
|
|
class ITestFramework;
|
2016-04-29 10:13:35 +02:00
|
|
|
class TestOutputReader;
|
|
|
|
|
class TestResult;
|
2019-08-19 10:55:32 +02:00
|
|
|
enum class TestRunMode;
|
2016-04-29 10:13:35 +02:00
|
|
|
|
|
|
|
|
using TestResultPtr = QSharedPointer<TestResult>;
|
|
|
|
|
|
2020-10-13 11:37:37 +02:00
|
|
|
class ITestConfiguration
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
explicit ITestConfiguration(ITestBase *testBase);
|
|
|
|
|
virtual ~ITestConfiguration() = default;
|
|
|
|
|
|
|
|
|
|
void setEnvironment(const Utils::Environment &env) { m_runnable.environment = env; }
|
|
|
|
|
Utils::Environment environment() const { return m_runnable.environment; }
|
2021-08-02 18:02:10 +02:00
|
|
|
void setWorkingDirectory(const Utils::FilePath &workingDirectory);
|
2021-05-26 15:50:03 +02:00
|
|
|
Utils::FilePath workingDirectory() const;
|
2020-10-13 11:37:37 +02:00
|
|
|
bool hasExecutable() const;
|
2021-05-26 15:50:03 +02:00
|
|
|
Utils::FilePath executableFilePath() const;
|
2020-10-13 11:37:37 +02:00
|
|
|
|
2023-01-13 12:13:45 +01:00
|
|
|
virtual TestOutputReader *createOutputReader(const QFutureInterface<TestResultPtr> &fi,
|
|
|
|
|
Utils::QtcProcess *app) const = 0;
|
2020-10-19 14:42:25 +02:00
|
|
|
virtual Utils::Environment filteredEnvironment(const Utils::Environment &original) const;
|
2020-10-13 11:37:37 +02:00
|
|
|
|
|
|
|
|
ITestBase *testBase() const { return m_testBase; }
|
|
|
|
|
void setProject(ProjectExplorer::Project *project) { m_project = project; }
|
|
|
|
|
void setDisplayName(const QString &displayName) { m_displayName = displayName; }
|
|
|
|
|
QString displayName() const { return m_displayName; }
|
|
|
|
|
void setTestCaseCount(int count) { m_testCaseCount = count; }
|
|
|
|
|
int testCaseCount() const { return m_testCaseCount; }
|
|
|
|
|
ProjectExplorer::Project *project() const { return m_project.data(); }
|
|
|
|
|
ProjectExplorer::Runnable runnable() const { return m_runnable; }
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
ProjectExplorer::Runnable m_runnable;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
ITestBase *m_testBase = nullptr;
|
|
|
|
|
QPointer<ProjectExplorer::Project> m_project;
|
|
|
|
|
QString m_displayName;
|
|
|
|
|
int m_testCaseCount = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class TestConfiguration : public ITestConfiguration
|
2014-10-07 15:51:02 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2020-03-26 10:11:39 +01:00
|
|
|
explicit TestConfiguration(ITestFramework *framework);
|
2020-10-13 11:37:37 +02:00
|
|
|
~TestConfiguration() override;
|
2014-10-07 15:51:02 +02:00
|
|
|
|
2017-09-05 13:57:22 +02:00
|
|
|
void completeTestInformation(TestRunMode runMode);
|
2017-09-13 14:27:20 +02:00
|
|
|
void completeTestInformation(ProjectExplorer::RunConfiguration *rc, TestRunMode runMode);
|
2015-04-27 16:11:28 +02:00
|
|
|
|
2014-11-06 16:01:06 +01:00
|
|
|
void setTestCases(const QStringList &testCases);
|
2021-05-26 15:50:03 +02:00
|
|
|
void setProjectFile(const Utils::FilePath &projectFile);
|
|
|
|
|
void setBuildDirectory(const Utils::FilePath &buildDirectory);
|
2017-10-12 08:08:27 +02:00
|
|
|
void setInternalTarget(const QString &target);
|
2017-06-09 09:30:21 +02:00
|
|
|
void setInternalTargets(const QSet<QString> &targets);
|
2017-09-13 14:27:20 +02:00
|
|
|
void setOriginalRunConfiguration(ProjectExplorer::RunConfiguration *runConfig);
|
2014-10-07 15:51:02 +02:00
|
|
|
|
2020-03-26 10:11:39 +01:00
|
|
|
ITestFramework *framework() const;
|
2014-10-07 15:51:02 +02:00
|
|
|
QStringList testCases() const { return m_testCases; }
|
2021-05-26 15:50:03 +02:00
|
|
|
Utils::FilePath buildDirectory() const { return m_buildDir; }
|
|
|
|
|
Utils::FilePath projectFile() const { return m_projectFile; }
|
2017-09-13 14:27:20 +02:00
|
|
|
QSet<QString> internalTargets() const { return m_buildTargets; }
|
|
|
|
|
ProjectExplorer::RunConfiguration *originalRunConfiguration() const { return m_origRunConfig; }
|
2019-08-19 10:55:32 +02:00
|
|
|
Internal::TestRunConfiguration *runConfiguration() const { return m_runConfig; }
|
2018-09-21 09:10:54 +02:00
|
|
|
bool isDeduced() const { return m_deducedConfiguration; }
|
|
|
|
|
QString runConfigDisplayName() const { return m_deducedConfiguration ? m_deducedFrom
|
2020-10-13 11:37:37 +02:00
|
|
|
: displayName(); }
|
2016-04-29 10:13:35 +02:00
|
|
|
|
2017-09-01 14:59:39 +02:00
|
|
|
virtual QStringList argumentsForTestRunner(QStringList *omitted = nullptr) const = 0;
|
2020-03-26 10:11:39 +01:00
|
|
|
|
2014-10-07 15:51:02 +02:00
|
|
|
private:
|
|
|
|
|
QStringList m_testCases;
|
2021-05-26 15:50:03 +02:00
|
|
|
Utils::FilePath m_projectFile;
|
|
|
|
|
Utils::FilePath m_buildDir;
|
2018-09-21 09:10:54 +02:00
|
|
|
QString m_deducedFrom;
|
|
|
|
|
bool m_deducedConfiguration = false;
|
2019-08-19 10:55:32 +02:00
|
|
|
Internal::TestRunConfiguration *m_runConfig = nullptr;
|
2017-06-09 09:30:21 +02:00
|
|
|
QSet<QString> m_buildTargets;
|
2017-09-13 14:27:20 +02:00
|
|
|
ProjectExplorer::RunConfiguration *m_origRunConfig = nullptr;
|
2016-04-29 10:13:35 +02:00
|
|
|
};
|
|
|
|
|
|
2016-08-12 09:07:38 +02:00
|
|
|
class DebuggableTestConfiguration : public TestConfiguration
|
|
|
|
|
{
|
|
|
|
|
public:
|
2020-03-26 10:11:39 +01:00
|
|
|
explicit DebuggableTestConfiguration(ITestFramework *framework, TestRunMode runMode = TestRunMode::Run)
|
|
|
|
|
: TestConfiguration(framework), m_runMode(runMode) {}
|
2016-08-12 09:07:38 +02:00
|
|
|
|
2017-09-05 13:57:22 +02:00
|
|
|
void setRunMode(TestRunMode mode) { m_runMode = mode; }
|
|
|
|
|
TestRunMode runMode() const { return m_runMode; }
|
|
|
|
|
bool isDebugRunMode() const;
|
2017-09-29 15:01:32 +02:00
|
|
|
void setMixedDebugging(bool enable) { m_mixedDebugging = enable; }
|
|
|
|
|
bool mixedDebugging() const { return m_mixedDebugging; }
|
2016-08-12 09:07:38 +02:00
|
|
|
private:
|
2017-09-05 13:57:22 +02:00
|
|
|
TestRunMode m_runMode;
|
2017-09-29 15:01:32 +02:00
|
|
|
bool m_mixedDebugging = false;
|
2016-08-12 09:07:38 +02:00
|
|
|
};
|
|
|
|
|
|
2020-10-19 14:42:25 +02:00
|
|
|
class TestToolConfiguration : public ITestConfiguration
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
explicit TestToolConfiguration(ITestBase *testBase) : ITestConfiguration(testBase) {}
|
|
|
|
|
Utils::CommandLine commandLine() const { return m_commandLine; }
|
|
|
|
|
void setCommandLine(const Utils::CommandLine &cmdline) { m_commandLine = cmdline; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Utils::CommandLine m_commandLine;
|
|
|
|
|
};
|
|
|
|
|
|
2014-10-07 15:51:02 +02:00
|
|
|
} // namespace Autotest
|