summaryrefslogtreecommitdiff
path: root/src/testlib
diff options
context:
space:
mode:
authorRohan McGovern <rohan.mcgovern@nokia.com>2010-04-16 14:39:35 +1000
committerRohan McGovern <rohan.mcgovern@nokia.com>2010-04-19 17:31:22 +1000
commit47fc8188c76cf4f2d2cec7155c8293c634f6c653 (patch)
treebe36c96189ae17a3c79b14658770e372b7142444 /src/testlib
parentd5124956d635be68d9891fd720806534f129ce76 (diff)
downloadqt4-tools-47fc8188c76cf4f2d2cec7155c8293c634f6c653.tar.gz
Fixed "pass" incident missing from test xml in some cases
Task-number: QTBUG-6278
Diffstat (limited to 'src/testlib')
-rw-r--r--src/testlib/qtestxmlstreamer.cpp48
1 files changed, 26 insertions, 22 deletions
diff --git a/src/testlib/qtestxmlstreamer.cpp b/src/testlib/qtestxmlstreamer.cpp
index 2ae8ad8bed..a44ea50e18 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, "</TestFunction>\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, "<Incident type=\"pass\" file=\"\" line=\"0\" />\n</TestFunction>\n");
+ }
+ else {
+ QTest::qt_asprintf(formatted, "</TestFunction>\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(&quotedFile, 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, "<Incident type=\"%s\" %s />\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