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
|
|
|
|
2018-06-07 17:55:02 +03:00
|
|
|
#include "autotest_global.h"
|
|
|
|
|
|
2014-10-07 15:51:02 +02:00
|
|
|
#include "testconfiguration.h"
|
|
|
|
|
#include "testresult.h"
|
|
|
|
|
|
2017-09-13 14:27:20 +02:00
|
|
|
#include <QDialog>
|
2016-01-19 14:24:09 +01:00
|
|
|
#include <QFutureWatcher>
|
2014-10-07 15:51:02 +02:00
|
|
|
#include <QObject>
|
2018-05-17 12:16:56 +02:00
|
|
|
#include <QQueue>
|
2014-10-07 15:51:02 +02:00
|
|
|
|
2017-09-13 14:27:20 +02:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QComboBox;
|
|
|
|
|
class QDialogButtonBox;
|
|
|
|
|
class QLabel;
|
2018-05-17 12:16:56 +02:00
|
|
|
class QProcess;
|
2017-09-13 14:27:20 +02:00
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
2014-10-07 15:51:02 +02:00
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
class Project;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace Autotest {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2018-06-07 17:55:02 +03:00
|
|
|
class AUTOTESTSHARED_EXPORT TestRunner : public QObject
|
2014-10-07 15:51:02 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
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();
|
2018-07-11 15:44:51 +02:00
|
|
|
~TestRunner() override;
|
2014-10-07 15:51:02 +02:00
|
|
|
|
|
|
|
|
void setSelectedTests(const QList<TestConfiguration *> &selected);
|
2017-09-09 16:46:43 +02:00
|
|
|
void runTest(TestRunMode mode, const TestTreeItem *item);
|
2014-11-06 10:48:17 +01:00
|
|
|
bool isTestRunning() const { return m_executingTests; }
|
2014-10-07 15:51:02 +02:00
|
|
|
|
2017-09-05 13:57:22 +02:00
|
|
|
void prepareToRunTests(TestRunMode mode);
|
2016-06-28 22:38:54 +03:00
|
|
|
|
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();
|
2016-02-25 13:02:31 +01:00
|
|
|
void testResultReady(const TestResultPtr &result);
|
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);
|
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();
|
2018-05-17 12:16:56 +02:00
|
|
|
void scheduleNext();
|
|
|
|
|
void cancelCurrent(CancelReason reason);
|
|
|
|
|
void onProcessFinished();
|
|
|
|
|
void resetInternalPointers();
|
2018-05-17 08:34:03 +02:00
|
|
|
|
2015-06-29 09:22:58 +02:00
|
|
|
void runTests();
|
2016-06-15 12:29:24 +02:00
|
|
|
void debugTests();
|
|
|
|
|
void runOrDebugTests();
|
2018-05-31 07:38:04 +02:00
|
|
|
explicit TestRunner(QObject *parent = nullptr);
|
2014-10-07 15:51:02 +02:00
|
|
|
|
2016-02-25 13:02:31 +01:00
|
|
|
QFutureWatcher<TestResultPtr> m_futureWatcher;
|
2018-05-17 12:16:56 +02:00
|
|
|
QFutureInterface<TestResultPtr> *m_fakeFutureInterface = nullptr;
|
|
|
|
|
QQueue<TestConfiguration *> m_selectedTests;
|
|
|
|
|
bool m_executingTests = false;
|
2018-06-21 10:36:50 +02:00
|
|
|
bool m_canceled = false;
|
2018-05-17 12:16:56 +02:00
|
|
|
TestConfiguration *m_currentConfig = nullptr;
|
|
|
|
|
QProcess *m_currentProcess = nullptr;
|
|
|
|
|
TestOutputReader *m_currentOutputReader = nullptr;
|
2017-09-05 13:57:22 +02:00
|
|
|
TestRunMode m_runMode = TestRunMode::Run;
|
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;
|
2018-06-21 10:36:50 +02:00
|
|
|
// temporarily used for handling of switching the current target
|
|
|
|
|
QMetaObject::Connection m_targetConnect;
|
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;
|
|
|
|
|
private:
|
|
|
|
|
void populate();
|
|
|
|
|
void updateLabels();
|
|
|
|
|
QLabel *m_details;
|
|
|
|
|
QLabel *m_executable;
|
|
|
|
|
QLabel *m_arguments;
|
|
|
|
|
QLabel *m_workingDir;
|
|
|
|
|
QComboBox *m_rcCombo;
|
|
|
|
|
QDialogButtonBox *m_buttonBox;
|
|
|
|
|
};
|
|
|
|
|
|
2014-10-07 15:51:02 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Autotest
|