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
|
|
|
|
2018-06-07 17:55:02 +03:00
|
|
|
#include "autotest_global.h"
|
2014-10-07 15:51:02 +02:00
|
|
|
#include "testresult.h"
|
|
|
|
|
|
2017-09-13 14:27:20 +02:00
|
|
|
#include <QDialog>
|
2016-01-19 14:24:09 +01:00
|
|
|
#include <QFutureWatcher>
|
2023-01-13 12:58:08 +01:00
|
|
|
#include <QList>
|
2014-10-07 15:51:02 +02:00
|
|
|
#include <QObject>
|
2022-06-10 10:18:34 +02:00
|
|
|
#include <QTimer>
|
2014-10-07 15:51:02 +02:00
|
|
|
|
2017-09-13 14:27:20 +02:00
|
|
|
QT_BEGIN_NAMESPACE
|
2018-08-08 12:40:03 +02:00
|
|
|
class QCheckBox;
|
2017-09-13 14:27:20 +02:00
|
|
|
class QComboBox;
|
|
|
|
|
class QDialogButtonBox;
|
|
|
|
|
class QLabel;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
2020-10-09 13:07:55 +02:00
|
|
|
namespace ProjectExplorer { class Project; }
|
2022-06-10 10:18:34 +02:00
|
|
|
namespace Utils { class QtcProcess; }
|
2014-10-07 15:51:02 +02:00
|
|
|
|
|
|
|
|
namespace Autotest {
|
2019-08-19 10:55:32 +02:00
|
|
|
|
|
|
|
|
enum class TestRunMode;
|
2020-10-13 11:37:37 +02:00
|
|
|
class ITestConfiguration;
|
2020-10-09 13:07:55 +02:00
|
|
|
class TestOutputReader;
|
2019-08-19 10:55:32 +02:00
|
|
|
|
2014-10-07 15:51:02 +02:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2020-03-26 09:21:25 +01:00
|
|
|
class AUTOTESTSHARED_EXPORT TestRunner final : public QObject
|
2014-10-07 15:51:02 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2020-03-26 09:21:25 +01:00
|
|
|
|
2014-10-07 15:51:02 +02:00
|
|
|
public:
|
2020-03-26 09:21:25 +01:00
|
|
|
TestRunner();
|
|
|
|
|
~TestRunner() final;
|
|
|
|
|
|
2018-06-21 10:36:50 +02:00
|
|
|
enum CancelReason { UserCanceled, Timeout, KitChanged };
|
2018-05-17 12:16:56 +02:00
|
|
|
|
2014-10-07 15:51:02 +02:00
|
|
|
static TestRunner* instance();
|
|
|
|
|
|
2023-01-13 12:30:42 +01:00
|
|
|
void runTests(TestRunMode mode, const QList<ITestConfiguration *> &selectedTests);
|
2020-10-13 11:37:37 +02:00
|
|
|
void runTest(TestRunMode mode, const ITestTreeItem *item);
|
2014-11-06 10:48:17 +01:00
|
|
|
bool isTestRunning() const { return m_executingTests; }
|
2014-10-07 15:51:02 +02:00
|
|
|
|
|
|
|
|
signals:
|
2014-11-03 08:30:22 +01:00
|
|
|
void testRunStarted();
|
|
|
|
|
void testRunFinished();
|
2015-01-13 11:24:41 +01:00
|
|
|
void requestStopTestRun();
|
2023-01-14 16:25:51 +01:00
|
|
|
void testResultReady(const TestResult &result);
|
2019-03-20 09:03:11 +01:00
|
|
|
void hadDisabledTests(int disabled);
|
2019-05-24 14:34:01 +02:00
|
|
|
void reportSummary(const QString &id, const QHash<ResultType, int> &summary);
|
2014-10-07 15:51:02 +02:00
|
|
|
|
2016-06-28 22:38:54 +03:00
|
|
|
private:
|
2014-10-07 15:51:02 +02:00
|
|
|
void buildProject(ProjectExplorer::Project *project);
|
|
|
|
|
void buildFinished(bool success);
|
2019-08-08 09:57:42 +02:00
|
|
|
void onBuildQueueFinished(bool success);
|
2014-11-06 10:48:17 +01:00
|
|
|
void onFinished();
|
2014-10-07 15:51:02 +02:00
|
|
|
|
2018-05-17 08:34:03 +02:00
|
|
|
int precheckTestConfigurations();
|
2020-10-13 11:37:37 +02:00
|
|
|
bool currentConfigValid();
|
|
|
|
|
void setUpProcessEnv();
|
2018-05-17 12:16:56 +02:00
|
|
|
void scheduleNext();
|
|
|
|
|
void cancelCurrent(CancelReason reason);
|
2022-06-20 11:45:36 +02:00
|
|
|
void onProcessDone();
|
2018-05-17 12:16:56 +02:00
|
|
|
void resetInternalPointers();
|
2018-05-17 08:34:03 +02:00
|
|
|
|
2023-01-13 12:30:42 +01:00
|
|
|
void runTestsHelper();
|
2016-06-15 12:29:24 +02:00
|
|
|
void debugTests();
|
|
|
|
|
void runOrDebugTests();
|
2019-02-06 14:11:19 +01:00
|
|
|
void reportResult(ResultType type, const QString &description);
|
2020-03-17 09:23:55 +01:00
|
|
|
bool postponeTestRunWithEmptyExecutable(ProjectExplorer::Project *project);
|
|
|
|
|
void onBuildSystemUpdated();
|
2014-10-07 15:51:02 +02:00
|
|
|
|
2023-01-14 16:25:51 +01:00
|
|
|
QFutureWatcher<TestResult> m_futureWatcher;
|
|
|
|
|
QFutureInterface<TestResult> *m_fakeFutureInterface = nullptr;
|
2023-01-13 12:58:08 +01:00
|
|
|
QList<ITestConfiguration *> m_selectedTests;
|
2018-05-17 12:16:56 +02:00
|
|
|
bool m_executingTests = false;
|
2018-06-21 10:36:50 +02:00
|
|
|
bool m_canceled = false;
|
2020-10-13 11:37:37 +02:00
|
|
|
ITestConfiguration *m_currentConfig = nullptr;
|
2022-06-10 10:18:34 +02:00
|
|
|
Utils::QtcProcess *m_currentProcess = nullptr;
|
2018-05-17 12:16:56 +02:00
|
|
|
TestOutputReader *m_currentOutputReader = nullptr;
|
2019-08-08 09:57:42 +02:00
|
|
|
TestRunMode m_runMode = TestRunMode::None;
|
2014-10-07 15:51:02 +02:00
|
|
|
|
2015-06-29 09:22:58 +02:00
|
|
|
// temporarily used if building before running is necessary
|
|
|
|
|
QMetaObject::Connection m_buildConnect;
|
2018-08-02 15:56:26 +02:00
|
|
|
// temporarily used when debugging
|
|
|
|
|
QMetaObject::Connection m_stopDebugConnect;
|
2019-12-11 15:15:01 +01:00
|
|
|
QMetaObject::Connection m_finishDebugConnect;
|
2018-06-21 10:36:50 +02:00
|
|
|
// temporarily used for handling of switching the current target
|
|
|
|
|
QMetaObject::Connection m_targetConnect;
|
2022-06-10 10:18:34 +02:00
|
|
|
QTimer m_cancelTimer;
|
2020-03-17 09:23:55 +01:00
|
|
|
bool m_skipTargetsCheck = false;
|
2014-10-07 15:51:02 +02:00
|
|
|
};
|
|
|
|
|
|
2017-09-13 14:27:20 +02:00
|
|
|
class RunConfigurationSelectionDialog : public QDialog
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2018-08-08 12:34:19 +02:00
|
|
|
explicit RunConfigurationSelectionDialog(const QString &buildTargetKey, QWidget *parent = nullptr);
|
2017-09-13 14:27:20 +02:00
|
|
|
QString displayName() const;
|
|
|
|
|
QString executable() const;
|
2018-08-08 12:40:03 +02:00
|
|
|
bool rememberChoice() const;
|
2017-09-13 14:27:20 +02:00
|
|
|
private:
|
|
|
|
|
void populate();
|
|
|
|
|
void updateLabels();
|
|
|
|
|
QLabel *m_details;
|
|
|
|
|
QLabel *m_executable;
|
|
|
|
|
QLabel *m_arguments;
|
|
|
|
|
QLabel *m_workingDir;
|
|
|
|
|
QComboBox *m_rcCombo;
|
2018-08-08 12:40:03 +02:00
|
|
|
QCheckBox *m_rememberCB;
|
2017-09-13 14:27:20 +02:00
|
|
|
QDialogButtonBox *m_buttonBox;
|
|
|
|
|
};
|
|
|
|
|
|
2014-10-07 15:51:02 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Autotest
|