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
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
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>
|
|
|
|
|
|
2016-04-29 10:13:35 +02:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QProcess;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
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; }
|
|
|
|
|
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
|
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);
|
2017-02-21 14:53:58 +01:00
|
|
|
void setExecutableFile(const QString &executableFile);
|
|
|
|
|
void setProjectFile(const QString &projectFile);
|
2016-01-26 17:24:11 +01:00
|
|
|
void setBuildDirectory(const QString &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; }
|
2016-01-26 17:24:11 +01:00
|
|
|
QString buildDirectory() const { return m_buildDir; }
|
2017-08-04 18:33:50 +02:00
|
|
|
QString 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;
|
2017-02-21 14:53:58 +01:00
|
|
|
QString m_projectFile;
|
2016-01-26 17:24:11 +01:00
|
|
|
QString 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
|
|
|
};
|
|
|
|
|
|
2014-10-07 15:51:02 +02:00
|
|
|
} // namespace Autotest
|