From 47fc8188c76cf4f2d2cec7155c8293c634f6c653 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Fri, 16 Apr 2010 14:39:35 +1000 Subject: Fixed "pass" incident missing from test xml in some cases Task-number: QTBUG-6278 --- src/testlib/qtestxmlstreamer.cpp | 48 ++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/src/testlib/qtestxmlstreamer.cpp b/src/testlib/qtestxmlstreamer.cpp index 2ae8ad8..a44ea50 100644 --- a/src/testlib/qtestxmlstreamer.cpp +++ b/src/testlib/qtestxmlstreamer.cpp @@ -149,7 +149,29 @@ void QTestXmlStreamer::formatEnd(const QTestElement *element, QTestCharBuffer *f return; if (element->elementType() == QTest::LET_TestCase) { - QTest::qt_asprintf(formatted, "\n"); + bool failed = false; + for (QTestElement* child = element->childElements(); child; child = child->nextElement()) { + if ( child->elementType() == QTest::LET_Failure + && child->attribute(QTest::AI_Result) + && ( !strcmp(child->attributeValue(QTest::AI_Result), "fail") + || !strcmp(child->attributeValue(QTest::AI_Result), "xpass")) + ) + { + failed = true; + break; + } + } + + // For passing functions, no Incident has been output yet. + // For failing functions, we already output one. + // Please note: we are outputting "pass" even if there was an xfail etc. + // This is by design (arguably bad design, but dangerous to change now!) + if (element->attribute(QTest::AI_Result) && !failed) { + QTest::qt_asprintf(formatted, "\n\n"); + } + else { + QTest::qt_asprintf(formatted, "\n"); + } } else { formatted->data()[0] = '\0'; } @@ -157,29 +179,11 @@ void QTestXmlStreamer::formatEnd(const QTestElement *element, QTestCharBuffer *f void QTestXmlStreamer::formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const { - if(!element || !formatted) + Q_UNUSED(element); + if (!formatted) return; - if (element->elementType() == QTest::LET_TestCase && element->attribute(QTest::AI_Result)){ - QTestCharBuffer buf; - QTestCharBuffer quotedFile; - QXmlTestLogger::xmlQuote("edFile, element->attributeValue(QTest::AI_File)); - - QTest::qt_asprintf(&buf, "%s=\"%s\" %s=\"%s\"", - element->attributeName(QTest::AI_File), - quotedFile.constData(), - element->attributeName(QTest::AI_Line), - element->attributeValue(QTest::AI_Line)); - - if( !element->childElements() ) { - QTest::qt_asprintf(formatted, "\n", - element->attributeValue(QTest::AI_Result), buf.constData()); - } else { - formatted->data()[0] = '\0'; - } - } else { - formatted->data()[0] = '\0'; - } + formatted->data()[0] = '\0'; } void QTestXmlStreamer::output(QTestElement *element) const -- cgit v0.12