summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-04-20 21:36:40 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-04-20 21:36:40 (GMT)
commitf8ae6e9f9819023913699ca7370ea32ea8ab94b3 (patch)
tree0f17e1c3d38f92d20a4ca937e99a70e7acce9c82 /src
parentb2c6e4d666dba9c068a0052ba018b0438f72eede (diff)
parentb47ded1bb23fe3b8af006bbf4b2fac30e57f0a8e (diff)
downloadQt-f8ae6e9f9819023913699ca7370ea32ea8ab94b3.zip
Qt-f8ae6e9f9819023913699ca7370ea32ea8ab94b3.tar.gz
Qt-f8ae6e9f9819023913699ca7370ea32ea8ab94b3.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/qt-multimedia-staging into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/qt-multimedia-staging: Fixed failure of tst_qbytearraymatcher on 64 bit. Fixed DataTag missing from testlib XML in some cases. Fixed "pass" incident missing from test xml in some cases Reverted "qwarn" -> "qwarning" attribute change in XML test logs. Fixed failure of tst_selftests::runSubTest(subtest xml) Extend testlib selftest to cover all loggers, not just plain text.
Diffstat (limited to 'src')
-rw-r--r--src/testlib/qtestlogger.cpp29
-rw-r--r--src/testlib/qtestlogger_p.h1
-rw-r--r--src/testlib/qtestxmlstreamer.cpp58
3 files changed, 60 insertions, 28 deletions
diff --git a/src/testlib/qtestlogger.cpp b/src/testlib/qtestlogger.cpp
index c0bc26c..4e4bc3c 100644
--- a/src/testlib/qtestlogger.cpp
+++ b/src/testlib/qtestlogger.cpp
@@ -211,10 +211,7 @@ void QTestLogger::addIncident(IncidentTypes type, const char *description,
QTest::qt_snprintf(buf, sizeof(buf), "%i", line);
failureElement->addAttribute(QTest::AI_Line, buf);
failureElement->addAttribute(QTest::AI_Description, description);
- const char* tag = QTestResult::currentDataTag();
- if (tag) {
- failureElement->addAttribute(QTest::AI_Tag, tag);
- }
+ addTag(failureElement);
currentLogElement->addLogElement(failureElement);
}
@@ -277,6 +274,27 @@ void QTestLogger::addBenchmarkResult(const QBenchmarkResult &result)
currentLogElement->addLogElement(benchmarkElement);
}
+void QTestLogger::addTag(QTestElement* element)
+{
+ const char *tag = QTestResult::currentDataTag();
+ const char *gtag = QTestResult::currentGlobalDataTag();
+ const char *filler = (tag && gtag) ? ":" : "";
+ if ((!tag || !tag[0]) && (!gtag || !gtag[0])) {
+ return;
+ }
+
+ if (!tag) {
+ tag = "";
+ }
+ if (!gtag) {
+ gtag = "";
+ }
+
+ QTestCharBuffer buf;
+ QTest::qt_asprintf(&buf, "%s%s%s", gtag, filler, tag);
+ element->addAttribute(QTest::AI_Tag, buf.constData());
+}
+
void QTestLogger::addMessage(MessageTypes type, const char *message, const char *file, int line)
{
QTestElement *errorElement = new QTestElement(QTest::LET_Error);
@@ -297,7 +315,7 @@ void QTestLogger::addMessage(MessageTypes type, const char *message, const char
break;
case QAbstractTestLogger::QWarning:
++qwarnCounter;
- typeBuf = "qwarning";
+ typeBuf = "qwarn";
break;
case QAbstractTestLogger::QFatal:
++qfatalCounter;
@@ -318,6 +336,7 @@ void QTestLogger::addMessage(MessageTypes type, const char *message, const char
errorElement->addAttribute(QTest::AI_Type, typeBuf);
errorElement->addAttribute(QTest::AI_Description, message);
+ addTag(errorElement);
if(file)
errorElement->addAttribute(QTest::AI_File, file);
diff --git a/src/testlib/qtestlogger_p.h b/src/testlib/qtestlogger_p.h
index 31f7d55..bb7a358 100644
--- a/src/testlib/qtestlogger_p.h
+++ b/src/testlib/qtestlogger_p.h
@@ -83,6 +83,7 @@ class QTestLogger : public QAbstractTestLogger
void addIncident(IncidentTypes type, const char *description,
const char *file = 0, int line = 0);
void addBenchmarkResult(const QBenchmarkResult &result);
+ void addTag(QTestElement* element);
void addMessage(MessageTypes type, const char *message,
const char *file = 0, int line = 0);
diff --git a/src/testlib/qtestxmlstreamer.cpp b/src/testlib/qtestxmlstreamer.cpp
index b9946e5..f63c221 100644
--- a/src/testlib/qtestxmlstreamer.cpp
+++ b/src/testlib/qtestxmlstreamer.cpp
@@ -111,12 +111,20 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, QTestCharBuffer
QXmlTestLogger::xmlQuote(&quotedFile, element->attributeValue(QTest::AI_File));
QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description));
- QTest::qt_asprintf(formatted, "<Message type=\"%s\" %s=\"%s\" %s=\"%s\">\n <Description><![CDATA[%s]]></Description>\n</Message>\n",
+ QTestCharBuffer tagbuf;
+ if (element->attribute(QTest::AI_Tag)) {
+ QTestCharBuffer cdataTag;
+ QXmlTestLogger::xmlCdata(&cdataTag, element->attributeValue(QTest::AI_Tag));
+ QTest::qt_asprintf(&tagbuf, " <DataTag><![CDATA[%s]]></DataTag>\n", cdataTag.constData());
+ }
+
+ QTest::qt_asprintf(formatted, "<Message type=\"%s\" %s=\"%s\" %s=\"%s\">\n%s <Description><![CDATA[%s]]></Description>\n</Message>\n",
element->attributeValue(QTest::AI_Type),
element->attributeName(QTest::AI_File),
quotedFile.constData(),
element->attributeName(QTest::AI_Line),
element->attributeValue(QTest::AI_Line),
+ tagbuf.constData(),
cdataDesc.constData());
break;
}
@@ -149,7 +157,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 +187,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