forked from qt-creator/qt-creator
AutoTest: Fix displaying XML content
CDATA sections that have line breaks at their line ends within a multiline CDATA section should get handled that these (inner) line breaks do not get lost. This patch fixes displaying failed Qt tests when using the XML output. Change-Id: I3aa7100836613372ac5b2b409c5cfacfb34209ba Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -62,7 +62,7 @@ GTestOutputReader::GTestOutputReader(const QFutureInterface<TestResultPtr> &futu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GTestOutputReader::processOutput(const QByteArray &outputLine)
|
void GTestOutputReader::processOutput(const QByteArray &outputLineWithNewLine)
|
||||||
{
|
{
|
||||||
static QRegExp newTestStarts("^\\[-{10}\\] \\d+ tests? from (.*)$");
|
static QRegExp newTestStarts("^\\[-{10}\\] \\d+ tests? from (.*)$");
|
||||||
static QRegExp testEnds("^\\[-{10}\\] \\d+ tests? from (.*) \\((.*)\\)$");
|
static QRegExp testEnds("^\\[-{10}\\] \\d+ tests? from (.*) \\((.*)\\)$");
|
||||||
@@ -74,7 +74,7 @@ void GTestOutputReader::processOutput(const QByteArray &outputLine)
|
|||||||
static QRegExp errorLocation("^(.*)\\((\\d+)\\): error:.*$");
|
static QRegExp errorLocation("^(.*)\\((\\d+)\\): error:.*$");
|
||||||
static QRegExp iterations("^Repeating all tests \\(iteration (\\d+)\\) \\. \\. \\.$");
|
static QRegExp iterations("^Repeating all tests \\(iteration (\\d+)\\) \\. \\. \\.$");
|
||||||
|
|
||||||
const QString line = QString::fromLatin1(outputLine);
|
const QString line = QString::fromLatin1(chopLineBreak(outputLineWithNewLine));
|
||||||
if (line.trimmed().isEmpty())
|
if (line.trimmed().isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@@ -44,7 +44,7 @@ public:
|
|||||||
QProcess *testApplication, const QString &buildDirectory,
|
QProcess *testApplication, const QString &buildDirectory,
|
||||||
const QString &projectFile);
|
const QString &projectFile);
|
||||||
protected:
|
protected:
|
||||||
void processOutput(const QByteArray &outputLine) override;
|
void processOutput(const QByteArray &outputLineWithNewLine) override;
|
||||||
TestResultPtr createDefaultResult() const override;
|
TestResultPtr createDefaultResult() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -329,7 +329,7 @@ static QStringList extractFunctionInformation(const QString &testClassName,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtTestOutputReader::processPlainTextOutput(const QByteArray &outputLine)
|
void QtTestOutputReader::processPlainTextOutput(const QByteArray &outputLineWithNewLine)
|
||||||
{
|
{
|
||||||
static QRegExp start("^[*]{9} Start testing of (.*) [*]{9}$");
|
static QRegExp start("^[*]{9} Start testing of (.*) [*]{9}$");
|
||||||
static QRegExp config("^Config: Using QtTest library (.*), (Qt (\\d+(\\.\\d+){2}) \\(.*\\))$");
|
static QRegExp config("^Config: Using QtTest library (.*), (Qt (\\d+(\\.\\d+){2}) \\(.*\\))$");
|
||||||
@@ -346,7 +346,7 @@ void QtTestOutputReader::processPlainTextOutput(const QByteArray &outputLine)
|
|||||||
if (m_futureInterface.isCanceled())
|
if (m_futureInterface.isCanceled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const QString &line = QString::fromLatin1(outputLine);
|
const QString line = QString::fromLatin1(chopLineBreak(outputLineWithNewLine));
|
||||||
|
|
||||||
if (result.exactMatch(line)) {
|
if (result.exactMatch(line)) {
|
||||||
processResultOutput(result.cap(1).toLower().trimmed(), result.cap(2));
|
processResultOutput(result.cap(1).toLower().trimmed(), result.cap(2));
|
||||||
|
@@ -55,8 +55,8 @@ protected:
|
|||||||
TestResultPtr createDefaultResult() const override;
|
TestResultPtr createDefaultResult() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void processXMLOutput(const QByteArray &outputLine);
|
void processXMLOutput(const QByteArray &outputLineWithNewline);
|
||||||
void processPlainTextOutput(const QByteArray &outputLine);
|
void processPlainTextOutput(const QByteArray &outputLineWithNewline);
|
||||||
void processResultOutput(const QString &result, const QString &message);
|
void processResultOutput(const QString &result, const QString &message);
|
||||||
void processLocationOutput(const QString &fileWithLine);
|
void processLocationOutput(const QString &fileWithLine);
|
||||||
void processSummaryFinishOutput();
|
void processSummaryFinishOutput();
|
||||||
|
@@ -27,6 +27,8 @@
|
|||||||
#include "testresult.h"
|
#include "testresult.h"
|
||||||
#include "testresultspane.h"
|
#include "testresultspane.h"
|
||||||
|
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
||||||
@@ -44,11 +46,7 @@ TestOutputReader::TestOutputReader(const QFutureInterface<TestResultPtr> &future
|
|||||||
connect(m_testApplication, &QProcess::readyRead,
|
connect(m_testApplication, &QProcess::readyRead,
|
||||||
this, [this] () {
|
this, [this] () {
|
||||||
while (m_testApplication->canReadLine()) {
|
while (m_testApplication->canReadLine()) {
|
||||||
QByteArray output = m_testApplication->readLine();
|
const QByteArray output = m_testApplication->readLine();
|
||||||
output.chop(1); // remove the newline from the output
|
|
||||||
if (output.endsWith('\r'))
|
|
||||||
output.chop(1);
|
|
||||||
|
|
||||||
emit newOutputAvailable(output);
|
emit newOutputAvailable(output);
|
||||||
processOutput(output);
|
processOutput(output);
|
||||||
}
|
}
|
||||||
@@ -62,9 +60,9 @@ TestOutputReader::TestOutputReader(const QFutureInterface<TestResultPtr> &future
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestOutputReader::processStdError(const QByteArray &output)
|
void TestOutputReader::processStdError(const QByteArray &outputLineWithNewLine)
|
||||||
{
|
{
|
||||||
qWarning() << "AutoTest.Run: Ignored plain output:" << output;
|
qWarning() << "AutoTest.Run: Ignored plain output:" << outputLineWithNewLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestOutputReader::reportCrash()
|
void TestOutputReader::reportCrash()
|
||||||
@@ -83,6 +81,16 @@ void TestOutputReader::createAndReportResult(const QString &message, Result::Typ
|
|||||||
reportResult(result);
|
reportResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QByteArray TestOutputReader::chopLineBreak(const QByteArray &original)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(original.endsWith('\n'), return original);
|
||||||
|
QByteArray output(original);
|
||||||
|
output.chop(1); // remove the newline from the output
|
||||||
|
if (output.endsWith('\r'))
|
||||||
|
output.chop(1);
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
void TestOutputReader::reportResult(const TestResultPtr &result)
|
void TestOutputReader::reportResult(const TestResultPtr &result)
|
||||||
{
|
{
|
||||||
m_futureInterface.reportResult(result);
|
m_futureInterface.reportResult(result);
|
||||||
|
@@ -42,16 +42,18 @@ public:
|
|||||||
TestOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
|
TestOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
|
||||||
QProcess *testApplication, const QString &buildDirectory);
|
QProcess *testApplication, const QString &buildDirectory);
|
||||||
|
|
||||||
virtual void processOutput(const QByteArray &outputLine) = 0;
|
virtual void processOutput(const QByteArray &outputLineWithNewLine) = 0;
|
||||||
virtual void processStdError(const QByteArray &output);
|
virtual void processStdError(const QByteArray &outputLineWithNewLine);
|
||||||
void reportCrash();
|
void reportCrash();
|
||||||
void createAndReportResult(const QString &message, Result::Type type);
|
void createAndReportResult(const QString &message, Result::Type type);
|
||||||
bool hadValidOutput() const { return m_hadValidOutput; }
|
bool hadValidOutput() const { return m_hadValidOutput; }
|
||||||
void setId(const QString &id) { m_id = id; }
|
void setId(const QString &id) { m_id = id; }
|
||||||
QString id() const { return m_id; }
|
QString id() const { return m_id; }
|
||||||
|
|
||||||
|
static QByteArray chopLineBreak(const QByteArray &original);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void newOutputAvailable(const QByteArray &output);
|
void newOutputAvailable(const QByteArray &outputWithLineBreak);
|
||||||
protected:
|
protected:
|
||||||
virtual TestResultPtr createDefaultResult() const = 0;
|
virtual TestResultPtr createDefaultResult() const = 0;
|
||||||
|
|
||||||
|
@@ -236,7 +236,7 @@ void TestResultsPane::addTestResult(const TestResultPtr &result)
|
|||||||
|
|
||||||
void TestResultsPane::addOutput(const QByteArray &output)
|
void TestResultsPane::addOutput(const QByteArray &output)
|
||||||
{
|
{
|
||||||
m_textOutput->appendPlainText(QString::fromLatin1(output));
|
m_textOutput->insertPlainText(QString::fromLatin1(output));
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *TestResultsPane::outputWidget(QWidget *parent)
|
QWidget *TestResultsPane::outputWidget(QWidget *parent)
|
||||||
|
Reference in New Issue
Block a user