forked from qt-creator/qt-creator
AutoTest: Improve handling unexpected output
If tests prints out non-XML data to stdout the XML parser gets nuts and refuses to handle the result. Ignore unexpected output as it will be printed out on the command line view anyhow. Task-number: QTCREATORBUG-22354 Change-Id: I96f453fadd834d21572080857c86d25b2d6f6aa9 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -34,6 +34,8 @@
|
||||
#include <QFileInfo>
|
||||
#include <QRegularExpression>
|
||||
|
||||
#include <cctype>
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
@@ -188,6 +190,15 @@ void QtTestOutputReader::processXMLOutput(const QByteArray &outputLine)
|
||||
if (m_className.isEmpty() && outputLine.trimmed().isEmpty())
|
||||
return;
|
||||
|
||||
if (m_expectTag) {
|
||||
for (auto ch : outputLine) {
|
||||
if (std::isspace(ch))
|
||||
continue;
|
||||
if (ch != '<')
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_xmlReader.addData(QString::fromUtf8(outputLine));
|
||||
while (!m_xmlReader.atEnd()) {
|
||||
if (m_futureInterface.isCanceled())
|
||||
@@ -255,6 +266,7 @@ void QtTestOutputReader::processXMLOutput(const QByteArray &outputLine)
|
||||
break;
|
||||
}
|
||||
case QXmlStreamReader::Characters: {
|
||||
m_expectTag = false;
|
||||
QStringRef text = m_xmlReader.text().trimmed();
|
||||
if (text.isEmpty())
|
||||
break;
|
||||
@@ -285,6 +297,7 @@ void QtTestOutputReader::processXMLOutput(const QByteArray &outputLine)
|
||||
break;
|
||||
}
|
||||
case QXmlStreamReader::EndElement: {
|
||||
m_expectTag = true;
|
||||
m_cdataMode = None;
|
||||
const QStringRef currentTag = m_xmlReader.name();
|
||||
if (currentTag == QStringLiteral("TestFunction")) {
|
||||
|
@@ -91,7 +91,7 @@ private:
|
||||
QXmlStreamReader m_xmlReader;
|
||||
OutputMode m_mode = XML;
|
||||
TestType m_testType = TestType::QtTest;
|
||||
|
||||
bool m_expectTag = true;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
Reference in New Issue
Block a user