2015-01-16 13:44:24 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2015-02-19 08:09:02 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd
|
2015-01-16 13:44:24 +01:00
|
|
|
** All rights reserved.
|
2015-02-19 08:09:02 +01:00
|
|
|
** For any questions to The Qt Company, please use contact form at
|
|
|
|
|
** http://www.qt.io/contact-us
|
2015-01-16 13:44:24 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of the Qt Creator Enterprise Auto Test Add-on.
|
|
|
|
|
**
|
|
|
|
|
** Licensees holding valid Qt Enterprise licenses may use this file in
|
|
|
|
|
** accordance with the Qt Enterprise License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-02-19 08:09:02 +01:00
|
|
|
** a written agreement between you and The Qt Company.
|
2015-01-16 13:44:24 +01:00
|
|
|
**
|
|
|
|
|
** If you have questions regarding the use of this file, please use
|
2015-02-19 08:09:02 +01:00
|
|
|
** contact form at http://www.qt.io/contact-us
|
2015-01-16 13:44:24 +01:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2015-12-09 09:46:33 +01:00
|
|
|
#include "testoutputreader.h"
|
2015-01-16 13:44:24 +01:00
|
|
|
#include "testresult.h"
|
|
|
|
|
|
2015-04-20 13:22:01 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
2015-09-23 07:47:12 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2015-04-20 13:22:01 +02:00
|
|
|
|
2015-10-09 14:19:53 +02:00
|
|
|
#include <QDebug>
|
2015-04-10 09:35:41 +02:00
|
|
|
#include <QRegExp>
|
2015-01-16 13:44:24 +01:00
|
|
|
#include <QProcess>
|
|
|
|
|
#include <QFileInfo>
|
|
|
|
|
#include <QDir>
|
2015-12-09 09:46:33 +01:00
|
|
|
#include <QXmlStreamReader>
|
2015-01-16 13:44:24 +01:00
|
|
|
|
|
|
|
|
namespace Autotest {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2015-04-10 09:35:41 +02:00
|
|
|
static QString decode(const QString& original)
|
|
|
|
|
{
|
|
|
|
|
QString result(original);
|
|
|
|
|
static QRegExp regex(QLatin1String("&#((x[0-9A-F]+)|([0-9]+));"), Qt::CaseInsensitive);
|
|
|
|
|
regex.setMinimal(true);
|
|
|
|
|
|
|
|
|
|
int pos = 0;
|
|
|
|
|
while ((pos = regex.indexIn(original, pos)) != -1) {
|
|
|
|
|
const QString value = regex.cap(1);
|
|
|
|
|
if (value.startsWith(QLatin1Char('x')))
|
|
|
|
|
result.replace(regex.cap(0), QChar(value.mid(1).toInt(0, 16)));
|
|
|
|
|
else
|
|
|
|
|
result.replace(regex.cap(0), QChar(value.toInt(0, 10)));
|
|
|
|
|
pos += regex.matchedLength();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-20 13:22:01 +02:00
|
|
|
static QString constructSourceFilePath(const QString &path, const QString &filePath,
|
|
|
|
|
const QString &app)
|
|
|
|
|
{
|
|
|
|
|
if (Utils::HostOsInfo::isMacHost() && !app.isEmpty()) {
|
|
|
|
|
const QString fileName(QFileInfo(app).fileName());
|
|
|
|
|
return QFileInfo(path.left(path.lastIndexOf(fileName + QLatin1String(".app"))), filePath)
|
|
|
|
|
.canonicalFilePath();
|
|
|
|
|
}
|
|
|
|
|
return QFileInfo(path, filePath).canonicalFilePath();
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-16 13:44:24 +01:00
|
|
|
// adapted from qplaintestlogger.cpp
|
|
|
|
|
static QString formatResult(double value)
|
|
|
|
|
{
|
|
|
|
|
//NAN is not supported with visual studio 2010
|
2015-01-21 11:03:50 +01:00
|
|
|
if (value < 0)// || value == NAN)
|
|
|
|
|
return QLatin1String("NAN");
|
2015-01-16 13:44:24 +01:00
|
|
|
if (value == 0)
|
|
|
|
|
return QLatin1String("0");
|
|
|
|
|
|
|
|
|
|
int significantDigits = 0;
|
|
|
|
|
qreal divisor = 1;
|
|
|
|
|
|
|
|
|
|
while (value / divisor >= 1) {
|
|
|
|
|
divisor *= 10;
|
|
|
|
|
++significantDigits;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString beforeDecimalPoint = QString::number(value, 'f', 0);
|
|
|
|
|
QString afterDecimalPoint = QString::number(value, 'f', 20);
|
|
|
|
|
afterDecimalPoint.remove(0, beforeDecimalPoint.count() + 1);
|
|
|
|
|
|
|
|
|
|
const int beforeUse = qMin(beforeDecimalPoint.count(), significantDigits);
|
|
|
|
|
const int beforeRemove = beforeDecimalPoint.count() - beforeUse;
|
|
|
|
|
|
|
|
|
|
beforeDecimalPoint.chop(beforeRemove);
|
|
|
|
|
for (int i = 0; i < beforeRemove; ++i)
|
|
|
|
|
beforeDecimalPoint.append(QLatin1Char('0'));
|
|
|
|
|
|
|
|
|
|
int afterUse = significantDigits - beforeUse;
|
|
|
|
|
if (beforeDecimalPoint == QLatin1String("0") && !afterDecimalPoint.isEmpty()) {
|
|
|
|
|
++afterUse;
|
|
|
|
|
int i = 0;
|
|
|
|
|
while (i < afterDecimalPoint.count() && afterDecimalPoint.at(i) == QLatin1Char('0'))
|
|
|
|
|
++i;
|
|
|
|
|
afterUse += i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const int afterRemove = afterDecimalPoint.count() - afterUse;
|
|
|
|
|
afterDecimalPoint.chop(afterRemove);
|
|
|
|
|
|
|
|
|
|
QString result = beforeDecimalPoint;
|
|
|
|
|
if (afterUse > 0)
|
|
|
|
|
result.append(QLatin1Char('.'));
|
|
|
|
|
result += afterDecimalPoint;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-23 07:47:12 +02:00
|
|
|
static QString constructBenchmarkInformation(const QString &metric, double value, int iterations)
|
2015-01-16 13:44:24 +01:00
|
|
|
{
|
2015-09-23 07:47:12 +02:00
|
|
|
QString metricsText;
|
|
|
|
|
if (metric == QLatin1String("WalltimeMilliseconds")) // default
|
|
|
|
|
metricsText = QLatin1String("msecs");
|
|
|
|
|
else if (metric == QLatin1String("CPUTicks")) // -tickcounter
|
|
|
|
|
metricsText = QLatin1String("CPU ticks");
|
|
|
|
|
else if (metric == QLatin1String("Events")) // -eventcounter
|
|
|
|
|
metricsText = QLatin1String("events");
|
|
|
|
|
else if (metric == QLatin1String("InstructionReads")) // -callgrind
|
|
|
|
|
metricsText = QLatin1String("instruction reads");
|
|
|
|
|
else if (metric == QLatin1String("CPUCycles")) // -perf
|
|
|
|
|
metricsText = QLatin1String("CPU cycles");
|
|
|
|
|
return QObject::tr("%1 %2 per iteration (total: %3, iterations: %4)")
|
|
|
|
|
.arg(formatResult(value))
|
|
|
|
|
.arg(metricsText)
|
|
|
|
|
.arg(formatResult(value * (double)iterations))
|
|
|
|
|
.arg(iterations);
|
2015-01-16 13:44:24 +01:00
|
|
|
}
|
|
|
|
|
|
2015-12-09 09:46:33 +01:00
|
|
|
TestOutputReader::TestOutputReader(QProcess *testApplication, OutputType type)
|
|
|
|
|
: m_testApplication(testApplication)
|
|
|
|
|
, m_type(type)
|
2015-01-16 13:44:24 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-23 07:47:12 +02:00
|
|
|
enum CDATAMode {
|
|
|
|
|
None,
|
|
|
|
|
DataTag,
|
|
|
|
|
Description,
|
|
|
|
|
QtVersion,
|
2015-11-26 13:41:26 +01:00
|
|
|
QtBuild,
|
2015-09-23 07:47:12 +02:00
|
|
|
QTestVersion
|
|
|
|
|
};
|
2015-01-16 13:44:24 +01:00
|
|
|
|
2015-12-09 09:46:33 +01:00
|
|
|
void TestOutputReader::processOutput()
|
2015-01-16 13:44:24 +01:00
|
|
|
{
|
|
|
|
|
if (!m_testApplication || m_testApplication->state() != QProcess::Running)
|
|
|
|
|
return;
|
2015-09-23 07:47:12 +02:00
|
|
|
static QStringList validEndTags = { QStringLiteral("Incident"),
|
|
|
|
|
QStringLiteral("Message"),
|
|
|
|
|
QStringLiteral("BenchmarkResult"),
|
|
|
|
|
QStringLiteral("QtVersion"),
|
2015-11-26 13:41:26 +01:00
|
|
|
QStringLiteral("QtBuild"),
|
2015-09-23 07:47:12 +02:00
|
|
|
QStringLiteral("QTestVersion") };
|
|
|
|
|
static CDATAMode cdataMode = None;
|
2015-01-16 13:44:24 +01:00
|
|
|
static QString className;
|
|
|
|
|
static QString testCase;
|
|
|
|
|
static QString dataTag;
|
2015-12-07 08:26:54 +01:00
|
|
|
static Result::Type result = Result::Invalid;
|
2015-01-16 13:44:24 +01:00
|
|
|
static QString description;
|
|
|
|
|
static QString file;
|
|
|
|
|
static int lineNumber = 0;
|
|
|
|
|
static QString duration;
|
2015-09-23 07:47:12 +02:00
|
|
|
static QXmlStreamReader xmlReader;
|
2015-01-16 13:44:24 +01:00
|
|
|
|
|
|
|
|
while (m_testApplication->canReadLine()) {
|
2015-09-23 07:47:12 +02:00
|
|
|
xmlReader.addData(m_testApplication->readLine());
|
|
|
|
|
while (!xmlReader.atEnd()) {
|
|
|
|
|
QXmlStreamReader::TokenType token = xmlReader.readNext();
|
|
|
|
|
switch (token) {
|
|
|
|
|
case QXmlStreamReader::StartDocument:
|
|
|
|
|
className.clear();
|
|
|
|
|
break;
|
|
|
|
|
case QXmlStreamReader::EndDocument:
|
|
|
|
|
xmlReader.clear();
|
|
|
|
|
return;
|
|
|
|
|
case QXmlStreamReader::StartElement: {
|
|
|
|
|
const QString currentTag = xmlReader.name().toString();
|
|
|
|
|
if (currentTag == QStringLiteral("TestCase")) {
|
|
|
|
|
className = xmlReader.attributes().value(QStringLiteral("name")).toString();
|
|
|
|
|
QTC_ASSERT(!className.isEmpty(), continue);
|
2015-12-14 10:19:37 +01:00
|
|
|
auto testResult = new QTestResult(className);
|
2015-12-07 08:26:54 +01:00
|
|
|
testResult->setResult(Result::MessageTestCaseStart);
|
2015-09-23 07:47:12 +02:00
|
|
|
testResult->setDescription(tr("Executing test case %1").arg(className));
|
|
|
|
|
testResultCreated(testResult);
|
|
|
|
|
} else if (currentTag == QStringLiteral("TestFunction")) {
|
|
|
|
|
testCase = xmlReader.attributes().value(QStringLiteral("name")).toString();
|
|
|
|
|
QTC_ASSERT(!testCase.isEmpty(), continue);
|
2015-12-14 10:19:37 +01:00
|
|
|
auto testResult = new QTestResult();
|
2015-12-07 08:26:54 +01:00
|
|
|
testResult->setResult(Result::MessageCurrentTest);
|
2015-09-23 07:47:12 +02:00
|
|
|
testResult->setDescription(tr("Entering test function %1::%2").arg(className,
|
|
|
|
|
testCase));
|
|
|
|
|
testResultCreated(testResult);
|
|
|
|
|
} else if (currentTag == QStringLiteral("Duration")) {
|
|
|
|
|
duration = xmlReader.attributes().value(QStringLiteral("msecs")).toString();
|
|
|
|
|
QTC_ASSERT(!duration.isEmpty(), continue);
|
|
|
|
|
} else if (currentTag == QStringLiteral("Message")
|
|
|
|
|
|| currentTag == QStringLiteral("Incident")) {
|
|
|
|
|
dataTag.clear();
|
|
|
|
|
description.clear();
|
|
|
|
|
duration.clear();
|
|
|
|
|
file.clear();
|
2015-12-07 08:26:54 +01:00
|
|
|
result = Result::Invalid;
|
2015-09-23 07:47:12 +02:00
|
|
|
lineNumber = 0;
|
|
|
|
|
const QXmlStreamAttributes &attributes = xmlReader.attributes();
|
|
|
|
|
result = TestResult::resultFromString(
|
|
|
|
|
attributes.value(QStringLiteral("type")).toString());
|
|
|
|
|
file = decode(attributes.value(QStringLiteral("file")).toString());
|
2016-01-15 12:24:10 +01:00
|
|
|
if (!file.isEmpty()) {
|
|
|
|
|
const QString base = QFileInfo(m_testApplication->program()).absolutePath();
|
|
|
|
|
file = constructSourceFilePath(base, file,
|
2015-09-23 07:47:12 +02:00
|
|
|
m_testApplication->program());
|
2016-01-15 12:24:10 +01:00
|
|
|
}
|
2015-09-23 07:47:12 +02:00
|
|
|
lineNumber = attributes.value(QStringLiteral("line")).toInt();
|
|
|
|
|
} else if (currentTag == QStringLiteral("BenchmarkResult")) {
|
|
|
|
|
const QXmlStreamAttributes &attributes = xmlReader.attributes();
|
|
|
|
|
const QString metric = attributes.value(QStringLiteral("metrics")).toString();
|
|
|
|
|
const double value = attributes.value(QStringLiteral("value")).toDouble();
|
|
|
|
|
const int iterations = attributes.value(QStringLiteral("iterations")).toInt();
|
|
|
|
|
description = constructBenchmarkInformation(metric, value, iterations);
|
2015-12-07 08:26:54 +01:00
|
|
|
result = Result::Benchmark;
|
2015-09-23 07:47:12 +02:00
|
|
|
} else if (currentTag == QStringLiteral("DataTag")) {
|
|
|
|
|
cdataMode = DataTag;
|
|
|
|
|
} else if (currentTag == QStringLiteral("Description")) {
|
|
|
|
|
cdataMode = Description;
|
|
|
|
|
} else if (currentTag == QStringLiteral("QtVersion")) {
|
2015-12-07 08:26:54 +01:00
|
|
|
result = Result::MessageInternal;
|
2015-09-23 07:47:12 +02:00
|
|
|
cdataMode = QtVersion;
|
2015-11-26 13:41:26 +01:00
|
|
|
} else if (currentTag == QStringLiteral("QtBuild")) {
|
2015-12-07 08:26:54 +01:00
|
|
|
result = Result::MessageInternal;
|
2015-11-26 13:41:26 +01:00
|
|
|
cdataMode = QtBuild;
|
2015-09-23 07:47:12 +02:00
|
|
|
} else if (currentTag == QStringLiteral("QTestVersion")) {
|
2015-12-07 08:26:54 +01:00
|
|
|
result = Result::MessageInternal;
|
2015-09-23 07:47:12 +02:00
|
|
|
cdataMode = QTestVersion;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2015-01-16 13:44:24 +01:00
|
|
|
}
|
2015-09-23 07:47:12 +02:00
|
|
|
case QXmlStreamReader::Characters: {
|
|
|
|
|
QStringRef text = xmlReader.text().trimmed();
|
|
|
|
|
if (text.isEmpty())
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
switch (cdataMode) {
|
|
|
|
|
case DataTag:
|
|
|
|
|
dataTag = text.toString();
|
|
|
|
|
break;
|
|
|
|
|
case Description:
|
|
|
|
|
if (!description.isEmpty())
|
|
|
|
|
description.append(QLatin1Char('\n'));
|
|
|
|
|
description.append(text);
|
|
|
|
|
break;
|
|
|
|
|
case QtVersion:
|
|
|
|
|
description = tr("Qt version: %1").arg(text.toString());
|
|
|
|
|
break;
|
2015-11-26 13:41:26 +01:00
|
|
|
case QtBuild:
|
2015-12-14 09:44:03 +01:00
|
|
|
description = tr("Qt build: %1").arg(text.toString());
|
2015-11-26 13:41:26 +01:00
|
|
|
break;
|
2015-09-23 07:47:12 +02:00
|
|
|
case QTestVersion:
|
|
|
|
|
description = tr("QTest version: %1").arg(text.toString());
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
QString message = QString::fromLatin1("unexpected cdatamode %1 for text \"%2\"")
|
|
|
|
|
.arg(cdataMode)
|
|
|
|
|
.arg(text.toString());
|
|
|
|
|
QTC_ASSERT(false, qWarning() << message);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case QXmlStreamReader::EndElement: {
|
|
|
|
|
cdataMode = None;
|
|
|
|
|
const QStringRef currentTag = xmlReader.name();
|
|
|
|
|
if (currentTag == QStringLiteral("TestFunction")) {
|
|
|
|
|
if (!duration.isEmpty()) {
|
2015-12-14 10:19:37 +01:00
|
|
|
auto testResult = new QTestResult(className);
|
2015-09-23 07:47:12 +02:00
|
|
|
testResult->setTestCase(testCase);
|
2015-12-07 08:26:54 +01:00
|
|
|
testResult->setResult(Result::MessageInternal);
|
2015-09-23 07:47:12 +02:00
|
|
|
testResult->setDescription(tr("Execution took %1 ms.").arg(duration));
|
|
|
|
|
testResultCreated(testResult);
|
|
|
|
|
}
|
|
|
|
|
emit increaseProgress();
|
2015-12-14 07:23:18 +01:00
|
|
|
} else if (currentTag == QStringLiteral("TestCase")) {
|
2015-12-14 10:19:37 +01:00
|
|
|
auto testResult = new QTestResult(className);
|
2015-12-07 08:26:54 +01:00
|
|
|
testResult->setResult(Result::MessageTestCaseEnd);
|
2015-12-14 07:23:18 +01:00
|
|
|
testResult->setDescription(
|
|
|
|
|
duration.isEmpty() ? tr("Test finished.")
|
|
|
|
|
: tr("Test execution took %1 ms.").arg(duration));
|
2015-09-23 07:47:12 +02:00
|
|
|
testResultCreated(testResult);
|
|
|
|
|
} else if (validEndTags.contains(currentTag.toString())) {
|
2015-12-14 10:19:37 +01:00
|
|
|
auto testResult = new QTestResult(className);
|
2015-09-23 07:47:12 +02:00
|
|
|
testResult->setTestCase(testCase);
|
|
|
|
|
testResult->setDataTag(dataTag);
|
|
|
|
|
testResult->setResult(result);
|
|
|
|
|
testResult->setFileName(file);
|
|
|
|
|
testResult->setLine(lineNumber);
|
|
|
|
|
testResult->setDescription(description);
|
|
|
|
|
testResultCreated(testResult);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2015-01-16 13:44:24 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-09 09:46:33 +01:00
|
|
|
void TestOutputReader::processGTestOutput()
|
|
|
|
|
{
|
|
|
|
|
if (!m_testApplication || m_testApplication->state() != QProcess::Running)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
static QRegExp newTestStarts(QStringLiteral("^\\[-{10}\\] \\d+ tests? from (.*)$"));
|
|
|
|
|
static QRegExp testEnds(QStringLiteral("^\\[-{10}\\] \\d+ tests? from (.*) \\((.*)\\)$"));
|
|
|
|
|
static QRegExp newTestSetStarts(QStringLiteral("^\\[ RUN \\] (.*)$"));
|
|
|
|
|
static QRegExp testSetSuccess(QStringLiteral("^\\[ OK \\] (.*) \\((.*)\\)$"));
|
|
|
|
|
static QRegExp testSetFail(QStringLiteral("^\\\[ FAILED \\] (.*) \\((.*)\\)$"));
|
|
|
|
|
static QRegExp disabledTests(QStringLiteral("^ YOU HAVE (\\d+) DISABLED TESTS?$"));
|
|
|
|
|
|
|
|
|
|
static QString currentTestName;
|
|
|
|
|
static QString currentTestSet;
|
|
|
|
|
static QString description;
|
|
|
|
|
static QByteArray unprocessed;
|
|
|
|
|
|
2016-01-12 17:53:13 +01:00
|
|
|
while (m_testApplication->canReadLine()) {
|
|
|
|
|
QByteArray read = m_testApplication->readLine();
|
|
|
|
|
if (!unprocessed.isEmpty()) {
|
|
|
|
|
read = unprocessed + read;
|
|
|
|
|
unprocessed.clear();
|
|
|
|
|
}
|
|
|
|
|
if (!read.endsWith('\n')) {
|
|
|
|
|
unprocessed = read;
|
2015-12-09 09:46:33 +01:00
|
|
|
continue;
|
|
|
|
|
}
|
2016-01-12 17:53:13 +01:00
|
|
|
read.chop(1); // remove the newline from the output
|
|
|
|
|
|
|
|
|
|
const QString line = QString::fromLatin1(read);
|
|
|
|
|
if (line.trimmed().isEmpty())
|
|
|
|
|
continue;
|
|
|
|
|
|
2015-12-09 09:46:33 +01:00
|
|
|
if (!line.startsWith(QLatin1Char('['))) {
|
|
|
|
|
description.append(line).append(QLatin1Char('\n'));
|
|
|
|
|
if (line.startsWith(QStringLiteral("Note:"))) {
|
2015-12-14 10:19:37 +01:00
|
|
|
auto testResult = new GTestResult();
|
2015-12-09 09:46:33 +01:00
|
|
|
testResult->setResult(Result::MessageInternal);
|
|
|
|
|
testResult->setDescription(line);
|
|
|
|
|
testResultCreated(testResult);
|
|
|
|
|
description.clear();
|
|
|
|
|
} else if (disabledTests.exactMatch(line)) {
|
2015-12-14 10:19:37 +01:00
|
|
|
auto testResult = new GTestResult();
|
2015-12-14 12:48:58 +01:00
|
|
|
testResult->setResult(Result::MessageDisabledTests);
|
2015-12-09 09:46:33 +01:00
|
|
|
int disabled = disabledTests.cap(1).toInt();
|
|
|
|
|
testResult->setDescription(tr("You have %n disabled test(s).", 0, disabled));
|
2015-12-14 12:48:58 +01:00
|
|
|
testResult->setLine(disabled); // misuse line property to hold number of disabled
|
2015-12-09 09:46:33 +01:00
|
|
|
testResultCreated(testResult);
|
|
|
|
|
description.clear();
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (testEnds.exactMatch(line)) {
|
2015-12-14 10:19:37 +01:00
|
|
|
auto testResult = new GTestResult(currentTestName);
|
2015-12-09 09:46:33 +01:00
|
|
|
testResult->setTestCase(currentTestSet);
|
|
|
|
|
testResult->setResult(Result::MessageTestCaseEnd);
|
|
|
|
|
testResult->setDescription(tr("Test execution took %1").arg(testEnds.cap(2)));
|
|
|
|
|
testResultCreated(testResult);
|
|
|
|
|
currentTestName.clear();
|
|
|
|
|
currentTestSet.clear();
|
|
|
|
|
} else if (newTestStarts.exactMatch(line)) {
|
|
|
|
|
currentTestName = newTestStarts.cap(1);
|
2015-12-14 10:19:37 +01:00
|
|
|
auto testResult = new GTestResult(currentTestName);
|
2015-12-09 09:46:33 +01:00
|
|
|
testResult->setResult(Result::MessageTestCaseStart);
|
|
|
|
|
testResult->setDescription(tr("Executing test case %1").arg(currentTestName));
|
|
|
|
|
testResultCreated(testResult);
|
|
|
|
|
} else if (newTestSetStarts.exactMatch(line)) {
|
|
|
|
|
currentTestSet = newTestSetStarts.cap(1);
|
2015-12-14 10:19:37 +01:00
|
|
|
auto testResult = new GTestResult();
|
2015-12-09 09:46:33 +01:00
|
|
|
testResult->setResult(Result::MessageCurrentTest);
|
|
|
|
|
testResult->setDescription(tr("Entering test set %1").arg(currentTestSet));
|
|
|
|
|
testResultCreated(testResult);
|
|
|
|
|
} else if (testSetSuccess.exactMatch(line)) {
|
2015-12-14 10:19:37 +01:00
|
|
|
auto testResult = new GTestResult(currentTestName);
|
2015-12-09 09:46:33 +01:00
|
|
|
testResult->setTestCase(currentTestSet);
|
|
|
|
|
testResult->setResult(Result::Pass);
|
|
|
|
|
testResultCreated(testResult);
|
2015-12-14 10:19:37 +01:00
|
|
|
testResult = new GTestResult(currentTestName);
|
2015-12-09 09:46:33 +01:00
|
|
|
testResult->setTestCase(currentTestSet);
|
|
|
|
|
testResult->setResult(Result::MessageInternal);
|
|
|
|
|
testResult->setDescription(tr("Execution took %1.").arg(testSetSuccess.cap(2)));
|
|
|
|
|
testResultCreated(testResult);
|
|
|
|
|
emit increaseProgress();
|
|
|
|
|
} else if (testSetFail.exactMatch(line)) {
|
2015-12-14 10:19:37 +01:00
|
|
|
auto testResult = new GTestResult(currentTestName);
|
2015-12-09 09:46:33 +01:00
|
|
|
testResult->setTestCase(currentTestSet);
|
|
|
|
|
testResult->setResult(Result::Fail);
|
|
|
|
|
description.chop(1);
|
|
|
|
|
testResult->setDescription(description);
|
|
|
|
|
int firstColon = description.indexOf(QLatin1Char(':'));
|
|
|
|
|
if (firstColon != -1) {
|
|
|
|
|
int secondColon = description.indexOf(QLatin1Char(':'), firstColon + 1);
|
2016-01-15 12:24:10 +01:00
|
|
|
const QString base = QFileInfo(m_testApplication->program()).absolutePath();
|
|
|
|
|
QString file = constructSourceFilePath(base, description.left(firstColon),
|
2015-12-09 09:46:33 +01:00
|
|
|
m_testApplication->program());
|
|
|
|
|
QString line = description.mid(firstColon + 1, secondColon - firstColon - 1);
|
|
|
|
|
testResult->setFileName(file);
|
|
|
|
|
testResult->setLine(line.toInt());
|
|
|
|
|
}
|
|
|
|
|
testResultCreated(testResult);
|
|
|
|
|
description.clear();
|
2015-12-14 10:19:37 +01:00
|
|
|
testResult = new GTestResult(currentTestName);
|
2015-12-09 09:46:33 +01:00
|
|
|
testResult->setTestCase(currentTestSet);
|
|
|
|
|
testResult->setResult(Result::MessageInternal);
|
|
|
|
|
testResult->setDescription(tr("Execution took %1.").arg(testSetFail.cap(2)));
|
|
|
|
|
testResultCreated(testResult);
|
|
|
|
|
emit increaseProgress();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-16 13:44:24 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Autotest
|