diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-07-28 15:40:22 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2021-08-05 03:58:49 +0200 |
commit | 177d259782f228257a376e3e87b30da6ad96f3fb (patch) | |
tree | bddc5820f210473d0a927e275c6b0ed46d3ee6db /src/testlib/qtestjunitstreamer.cpp | |
parent | f1ab1132ea6f8be5cf41e9bd77d5f582d5e25ee0 (diff) |
testlib: Simplify JUnit test logger
- Use the right name for the attribute (AI_Message),
rather than fixing it up in QTestJUnitStreamer.
- Don't pretend that we're adding line and file information,
only to discard it in QTestJUnitStreamer.
- Don't pretend to add benchmark information,
only to discard it in QTestJUnitStreamer.
Pick-to: 6.2
Change-Id: Ib6eadc12300157216fe9c6e8bcfebd7eb8a3ea68
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/testlib/qtestjunitstreamer.cpp')
-rw-r--r-- | src/testlib/qtestjunitstreamer.cpp | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/src/testlib/qtestjunitstreamer.cpp b/src/testlib/qtestjunitstreamer.cpp index 28879c6e06..d469e2a949 100644 --- a/src/testlib/qtestjunitstreamer.cpp +++ b/src/testlib/qtestjunitstreamer.cpp @@ -129,25 +129,16 @@ void QTestJUnitStreamer::formatAttributes(const QTestElement* element, const QTe && (element->parentElement()->elementType() == QTest::LET_SystemOutput || element->parentElement()->elementType() == QTest::LET_SystemError)) { - if (attrindex != QTest::AI_Description) return; + if (attrindex != QTest::AI_Message) return; QXmlTestLogger::xmlCdata(formatted, attribute->value()); return; } - char const* key = nullptr; - if (attrindex == QTest::AI_Description) - key = "message"; - else if (attrindex != QTest::AI_File && attrindex != QTest::AI_Line) - key = attribute->name(); - - if (key) { - QTestCharBuffer quotedValue; - QXmlTestLogger::xmlQuote("edValue, attribute->value()); - QTest::qt_asprintf(formatted, " %s=\"%s\"", key, quotedValue.constData()); - } else { - formatted->data()[0] = '\0'; - } + QTestCharBuffer quotedValue; + QXmlTestLogger::xmlQuote("edValue, attribute->value()); + QTest::qt_asprintf(formatted, " %s=\"%s\"", + attribute->name(), quotedValue.constData()); } void QTestJUnitStreamer::formatAfterAttributes(const QTestElement *element, QTestCharBuffer *formatted) const @@ -197,21 +188,20 @@ void QTestJUnitStreamer::outputElements(QTestElement *element, bool) const while (element) { hasChildren = element->childElements(); - if (element->elementType() != QTest::LET_Benchmark) { - formatStart(element, &buf); - outputString(buf.data()); + formatStart(element, &buf); + outputString(buf.data()); - outputElementAttributes(element, element->attributes()); + outputElementAttributes(element, element->attributes()); - formatAfterAttributes(element, &buf); - outputString(buf.data()); + formatAfterAttributes(element, &buf); + outputString(buf.data()); - if (hasChildren) - outputElements(element->childElements(), true); + if (hasChildren) + outputElements(element->childElements(), true); + + formatEnd(element, &buf); + outputString(buf.data()); - formatEnd(element, &buf); - outputString(buf.data()); - } element = element->previousElement(); } } |