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
|
2015-01-16 13:44:24 +01:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2015-01-16 13:44:24 +01:00
|
|
|
|
2015-02-18 15:40:32 +01:00
|
|
|
#include "testresult.h"
|
2015-01-16 13:44:24 +01:00
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
2022-06-10 10:18:34 +02:00
|
|
|
namespace Utils { class QtcProcess; }
|
|
|
|
|
|
2015-01-16 13:44:24 +01:00
|
|
|
namespace Autotest {
|
|
|
|
|
|
2015-12-09 09:46:33 +01:00
|
|
|
class TestOutputReader : public QObject
|
2015-01-16 13:44:24 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
TestRunner: Reuse TaskTree
Get rid of QFutureInterface argument from
ITestConfiguration::createOutputReader() and from
TestOutputReader c'tor.
The fine-grained progress reporting was broken anyway:
1. The assumption was that testCaseCount was meant to be
the total number of test functions executed. It didn't
include the initTestCase() and cleanupTestCase(),
while those were reported on runtime apparently
(and exceeding the max progress by 2).
2. In case of tst_qtcprocess, when the whole test was run,
the testCaseCount reported 41, while the real
number of functions was 26 (+2 = 28 for init/cleanup).
3. While the max progress was set to testCaseCount initially,
the corresponding FutureProgress rendered the progress
always in 0-100 range, what didn't match the reality.
Instead, rely on TaskTree progress, which resolution
is per test as a whole. So, when executing a series
of tests this should scale fine. In addition, the
progress advances fluently according to the expected
run time - with 10 seconds hardcoded.
The original code locations, where progress was bumped,
are left with a TODO comment for any possible future tweaks.
Like in case of result reporting, fine-grained progress
reporting may be implemented by providing additional signal,
so there is no need for QFutureInterface inside
TestOutputReader.
Change-Id: Idc11d55e3a49dac8d1788948b9a82f68199203c6
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 00:45:50 +01:00
|
|
|
TestOutputReader(Utils::QtcProcess *testApplication, const Utils::FilePath &buildDirectory);
|
2020-07-27 17:52:59 +02:00
|
|
|
virtual ~TestOutputReader();
|
2019-11-11 08:03:16 +01:00
|
|
|
void processStdOutput(const QByteArray &outputLine);
|
|
|
|
|
virtual void processStdError(const QByteArray &outputLine);
|
2018-01-16 08:41:53 +01:00
|
|
|
void reportCrash();
|
2019-02-06 14:11:19 +01:00
|
|
|
void createAndReportResult(const QString &message, ResultType type);
|
2017-09-20 11:20:25 +02:00
|
|
|
bool hadValidOutput() const { return m_hadValidOutput; }
|
2019-03-20 09:03:11 +01:00
|
|
|
int disabledTests() const { return m_disabled; }
|
2019-05-24 14:34:01 +02:00
|
|
|
bool hasSummary() const { return !m_summary.isEmpty(); }
|
|
|
|
|
QHash<ResultType, int> summary() const { return m_summary; }
|
2018-05-09 10:48:23 +02:00
|
|
|
void setId(const QString &id) { m_id = id; }
|
|
|
|
|
QString id() const { return m_id; }
|
2016-07-21 16:02:42 +02:00
|
|
|
|
2019-11-06 14:26:40 +01:00
|
|
|
void resetCommandlineColor();
|
2017-05-05 13:01:06 +02:00
|
|
|
signals:
|
2023-01-16 15:47:36 +01:00
|
|
|
void newResult(const TestResult &result);
|
2019-11-06 14:25:16 +01:00
|
|
|
void newOutputLineAvailable(const QByteArray &outputLine, OutputChannel channel);
|
2016-07-21 16:02:42 +02:00
|
|
|
protected:
|
2021-05-26 15:50:03 +02:00
|
|
|
static Utils::FilePath constructSourceFilePath(const Utils::FilePath &base,
|
|
|
|
|
const QString &file);
|
|
|
|
|
|
2019-11-06 14:26:40 +01:00
|
|
|
QString removeCommandlineColors(const QString &original);
|
2019-11-11 08:03:16 +01:00
|
|
|
virtual void processOutputLine(const QByteArray &outputLine) = 0;
|
2023-01-14 16:25:51 +01:00
|
|
|
virtual TestResult createDefaultResult() const = 0;
|
2020-07-27 17:52:59 +02:00
|
|
|
void checkForSanitizerOutput(const QByteArray &line);
|
|
|
|
|
void sendAndResetSanitizerResult();
|
2018-01-16 08:41:18 +01:00
|
|
|
|
2023-01-14 16:25:51 +01:00
|
|
|
void reportResult(const TestResult &result);
|
2021-05-26 15:50:03 +02:00
|
|
|
Utils::FilePath m_buildDir;
|
2018-05-09 10:48:23 +02:00
|
|
|
QString m_id;
|
2019-05-24 14:34:01 +02:00
|
|
|
QHash<ResultType, int> m_summary;
|
2019-03-20 09:03:11 +01:00
|
|
|
int m_disabled = -1;
|
2017-09-20 11:20:25 +02:00
|
|
|
private:
|
2020-07-28 07:35:20 +02:00
|
|
|
enum class SanitizerOutputMode { None, Asan, Ubsan};
|
2023-01-14 16:25:51 +01:00
|
|
|
TestResult m_sanitizerResult;
|
2020-07-27 17:52:59 +02:00
|
|
|
QStringList m_sanitizerLines;
|
|
|
|
|
SanitizerOutputMode m_sanitizerOutputMode = SanitizerOutputMode::None;
|
2017-09-20 11:20:25 +02:00
|
|
|
bool m_hadValidOutput = false;
|
2016-01-20 08:26:10 +01:00
|
|
|
};
|
|
|
|
|
|
2015-01-16 13:44:24 +01:00
|
|
|
} // namespace Autotest
|