summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtestlogger.cpp
diff options
context:
space:
mode:
authorRohan McGovern <rohan.mcgovern@nokia.com>2010-04-16 05:29:08 (GMT)
committerRohan McGovern <rohan.mcgovern@nokia.com>2010-04-19 07:31:22 (GMT)
commitcf2996cceb1ee07d8969867981c8caeabf2d35c3 (patch)
treeaa205394766a6c9e979e650f461979252aec61dd /src/testlib/qtestlogger.cpp
parent47fc8188c76cf4f2d2cec7155c8293c634f6c653 (diff)
downloadQt-cf2996cceb1ee07d8969867981c8caeabf2d35c3.zip
Qt-cf2996cceb1ee07d8969867981c8caeabf2d35c3.tar.gz
Qt-cf2996cceb1ee07d8969867981c8caeabf2d35c3.tar.bz2
Fixed DataTag missing from testlib XML in some cases.
Task-number: QTBUG-6320
Diffstat (limited to 'src/testlib/qtestlogger.cpp')
-rw-r--r--src/testlib/qtestlogger.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/testlib/qtestlogger.cpp b/src/testlib/qtestlogger.cpp
index fa76b9e..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);
@@ -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);