forked from qt-creator/qt-creator
AutoTest: Introduce ITestConfiguration
Preparation for an additional simpler test configuration which needs to have the same common base. Change-Id: I1800ed5d7301f1aea99eba6ef588a204697bd569 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -44,6 +44,7 @@ namespace Internal {
|
||||
class TestRunConfiguration;
|
||||
} // namespace Internal
|
||||
|
||||
class ITestBase;
|
||||
class ITestFramework;
|
||||
class TestOutputReader;
|
||||
class TestResult;
|
||||
@@ -51,66 +52,81 @@ enum class TestRunMode;
|
||||
|
||||
using TestResultPtr = QSharedPointer<TestResult>;
|
||||
|
||||
class TestConfiguration
|
||||
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; }
|
||||
void setWorkingDirectory(const QString &workingDirectory);
|
||||
QString workingDirectory() const;
|
||||
bool hasExecutable() const;
|
||||
QString executableFilePath() const;
|
||||
|
||||
virtual TestOutputReader *outputReader(const QFutureInterface<TestResultPtr> &fi,
|
||||
QProcess *app) const = 0;
|
||||
virtual Utils::Environment filteredEnvironment(const Utils::Environment &original) const = 0;
|
||||
|
||||
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
|
||||
{
|
||||
public:
|
||||
explicit TestConfiguration(ITestFramework *framework);
|
||||
virtual ~TestConfiguration();
|
||||
~TestConfiguration() override;
|
||||
|
||||
void completeTestInformation(TestRunMode runMode);
|
||||
void completeTestInformation(ProjectExplorer::RunConfiguration *rc, TestRunMode runMode);
|
||||
|
||||
void setTestCases(const QStringList &testCases);
|
||||
void setTestCaseCount(int count);
|
||||
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);
|
||||
void setEnvironment(const Utils::Environment &env);
|
||||
void setProject(ProjectExplorer::Project *project);
|
||||
void setInternalTarget(const QString &target);
|
||||
void setInternalTargets(const QSet<QString> &targets);
|
||||
void setOriginalRunConfiguration(ProjectExplorer::RunConfiguration *runConfig);
|
||||
|
||||
ITestFramework *framework() const;
|
||||
QStringList testCases() const { return m_testCases; }
|
||||
int testCaseCount() const { return m_testCaseCount; }
|
||||
QString executableFilePath() const;
|
||||
QString workingDirectory() const;
|
||||
QString buildDirectory() const { return m_buildDir; }
|
||||
QString projectFile() const { return m_projectFile; }
|
||||
QString displayName() const { return m_displayName; }
|
||||
Utils::Environment environment() const { return m_runnable.environment; }
|
||||
ProjectExplorer::Project *project() const { return m_project.data(); }
|
||||
QSet<QString> internalTargets() const { return m_buildTargets; }
|
||||
ProjectExplorer::RunConfiguration *originalRunConfiguration() const { return m_origRunConfig; }
|
||||
Internal::TestRunConfiguration *runConfiguration() const { return m_runConfig; }
|
||||
bool hasExecutable() const;
|
||||
bool isDeduced() const { return m_deducedConfiguration; }
|
||||
QString runConfigDisplayName() const { return m_deducedConfiguration ? m_deducedFrom
|
||||
: m_displayName; }
|
||||
: displayName(); }
|
||||
|
||||
ProjectExplorer::Runnable runnable() const { return m_runnable; }
|
||||
virtual TestOutputReader *outputReader(const QFutureInterface<TestResultPtr> &fi,
|
||||
QProcess *app) const = 0;
|
||||
virtual QStringList argumentsForTestRunner(QStringList *omitted = nullptr) const = 0;
|
||||
virtual Utils::Environment filteredEnvironment(const Utils::Environment &original) const = 0;
|
||||
|
||||
private:
|
||||
ITestFramework *m_framework;
|
||||
QStringList m_testCases;
|
||||
int m_testCaseCount = 0;
|
||||
QString m_projectFile;
|
||||
QString m_buildDir;
|
||||
QString m_displayName;
|
||||
QString m_deducedFrom;
|
||||
QPointer<ProjectExplorer::Project> m_project;
|
||||
bool m_deducedConfiguration = false;
|
||||
Internal::TestRunConfiguration *m_runConfig = nullptr;
|
||||
QSet<QString> m_buildTargets;
|
||||
ProjectExplorer::RunConfiguration *m_origRunConfig = nullptr;
|
||||
ProjectExplorer::Runnable m_runnable;
|
||||
};
|
||||
|
||||
class DebuggableTestConfiguration : public TestConfiguration
|
||||
|
||||
Reference in New Issue
Block a user