Changeset 769 for trunk/src/testlib
- Timestamp:
- Aug 2, 2010, 9:27:30 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.6.3 (added) merged: 768 /branches/vendor/nokia/qt/current merged: 767 /branches/vendor/nokia/qt/4.6.2 removed
- Property svn:mergeinfo changed
-
trunk/src/testlib/qplaintestlogger.cpp
r651 r769 182 182 RDebug::Print(format, hbuffer); 183 183 } 184 delete hbuffer; 184 185 } 185 186 else { -
trunk/src/testlib/qtestcase.cpp
r651 r769 965 965 " -xml : Outputs results as XML document\n" 966 966 " -lightxml : Outputs results as stream of XML tags\n" 967 " -flush : Flushes the resu tls\n"967 " -flush : Flushes the results\n" 968 968 " -o filename: Writes all output into a file\n" 969 969 " -silent : Only outputs warnings and failures\n" … … 1114 1114 } else if (strcmp(argv[i], "-qws") == 0) { 1115 1115 // do nothing 1116 } else if (strcmp(argv[i], "-graphicssystem") == 0) { 1117 // do nothing 1118 if (i + 1 >= argc) { 1119 printf("-graphicssystem needs an extra parameter specifying the graphics system\n"); 1120 exit(1); 1121 } else { 1122 ++i; 1123 } 1116 1124 } else if (argv[i][0] == '-') { 1117 1125 printf("Unknown option: '%s'\n\n%s", argv[i], testOptions); … … 1299 1307 QTestResult::setSkipCurrentTest(false); 1300 1308 1309 // Data tag requested but none available? 1310 if (data && !dataCount) { 1311 // Let empty data tag through. 1312 if (!*data) 1313 data = 0; 1314 else { 1315 printf("Unknown testdata for function %s: '%s'\n", slotName, data); 1316 printf("Function has no testdata.\n"); 1317 return false; 1318 } 1319 } 1320 1301 1321 /* For each entry in the data table, do: */ 1302 1322 do { 1303 1323 if (!data || !qstrcmp(data, table.testData(curDataIndex)->dataTag())) { 1304 1324 foundFunction = true; 1305 QTestDataSetter s( table.isEmpty()? static_cast<QTestData *>(0)1325 QTestDataSetter s(curDataIndex >= dataCount ? static_cast<QTestData *>(0) 1306 1326 : table.testData(curDataIndex)); 1307 1327 -
trunk/src/testlib/qtestlogger.cpp
r651 r769 212 212 failureElement->addAttribute(QTest::AI_Line, buf); 213 213 failureElement->addAttribute(QTest::AI_Description, description); 214 const char* tag = QTestResult::currentDataTag(); 215 if (tag) { 216 failureElement->addAttribute(QTest::AI_Tag, tag); 217 } 214 addTag(failureElement); 218 215 currentLogElement->addLogElement(failureElement); 219 216 } … … 278 275 } 279 276 277 void QTestLogger::addTag(QTestElement* element) 278 { 279 const char *tag = QTestResult::currentDataTag(); 280 const char *gtag = QTestResult::currentGlobalDataTag(); 281 const char *filler = (tag && gtag) ? ":" : ""; 282 if ((!tag || !tag[0]) && (!gtag || !gtag[0])) { 283 return; 284 } 285 286 if (!tag) { 287 tag = ""; 288 } 289 if (!gtag) { 290 gtag = ""; 291 } 292 293 QTestCharBuffer buf; 294 QTest::qt_asprintf(&buf, "%s%s%s", gtag, filler, tag); 295 element->addAttribute(QTest::AI_Tag, buf.constData()); 296 } 297 280 298 void QTestLogger::addMessage(MessageTypes type, const char *message, const char *file, int line) 281 299 { … … 298 316 case QAbstractTestLogger::QWarning: 299 317 ++qwarnCounter; 300 typeBuf = "qwarn ing";318 typeBuf = "qwarn"; 301 319 break; 302 320 case QAbstractTestLogger::QFatal: … … 319 337 errorElement->addAttribute(QTest::AI_Type, typeBuf); 320 338 errorElement->addAttribute(QTest::AI_Description, message); 339 addTag(errorElement); 321 340 322 341 if(file) -
trunk/src/testlib/qtestlogger_p.h
r651 r769 84 84 const char *file = 0, int line = 0); 85 85 void addBenchmarkResult(const QBenchmarkResult &result); 86 void addTag(QTestElement* element); 86 87 87 88 void addMessage(MessageTypes type, const char *message, -
trunk/src/testlib/qtestxmlstreamer.cpp
r651 r769 112 112 QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description)); 113 113 114 QTest::qt_asprintf(formatted, "<Message type=\"%s\" %s=\"%s\" %s=\"%s\">\n <Description><![CDATA[%s]]></Description>\n</Message>\n", 114 QTestCharBuffer tagbuf; 115 if (element->attribute(QTest::AI_Tag)) { 116 QTestCharBuffer cdataTag; 117 QXmlTestLogger::xmlCdata(&cdataTag, element->attributeValue(QTest::AI_Tag)); 118 QTest::qt_asprintf(&tagbuf, " <DataTag><![CDATA[%s]]></DataTag>\n", cdataTag.constData()); 119 } 120 121 QTest::qt_asprintf(formatted, "<Message type=\"%s\" %s=\"%s\" %s=\"%s\">\n%s <Description><![CDATA[%s]]></Description>\n</Message>\n", 115 122 element->attributeValue(QTest::AI_Type), 116 123 element->attributeName(QTest::AI_File), … … 118 125 element->attributeName(QTest::AI_Line), 119 126 element->attributeValue(QTest::AI_Line), 127 tagbuf.constData(), 120 128 cdataDesc.constData()); 121 129 break; … … 150 158 151 159 if (element->elementType() == QTest::LET_TestCase) { 152 QTest::qt_asprintf(formatted, "</TestFunction>\n"); 160 bool failed = false; 161 for (QTestElement* child = element->childElements(); child; child = child->nextElement()) { 162 if ( child->elementType() == QTest::LET_Failure 163 && child->attribute(QTest::AI_Result) 164 && ( !strcmp(child->attributeValue(QTest::AI_Result), "fail") 165 || !strcmp(child->attributeValue(QTest::AI_Result), "xpass")) 166 ) 167 { 168 failed = true; 169 break; 170 } 171 } 172 173 // For passing functions, no Incident has been output yet. 174 // For failing functions, we already output one. 175 // Please note: we are outputting "pass" even if there was an xfail etc. 176 // This is by design (arguably bad design, but dangerous to change now!) 177 if (element->attribute(QTest::AI_Result) && !failed) { 178 QTest::qt_asprintf(formatted, "<Incident type=\"pass\" file=\"\" line=\"0\" />\n</TestFunction>\n"); 179 } 180 else { 181 QTest::qt_asprintf(formatted, "</TestFunction>\n"); 182 } 153 183 } else { 154 184 formatted->data()[0] = '\0'; … … 158 188 void QTestXmlStreamer::formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const 159 189 { 160 if(!element || !formatted) 190 Q_UNUSED(element); 191 if (!formatted) 161 192 return; 162 193 163 if (element->elementType() == QTest::LET_TestCase && element->attribute(QTest::AI_Result)){ 164 QTestCharBuffer buf; 165 QTestCharBuffer quotedFile; 166 QXmlTestLogger::xmlQuote("edFile, element->attributeValue(QTest::AI_File)); 167 168 QTest::qt_asprintf(&buf, "%s=\"%s\" %s=\"%s\"", 169 element->attributeName(QTest::AI_File), 170 quotedFile.constData(), 171 element->attributeName(QTest::AI_Line), 172 element->attributeValue(QTest::AI_Line)); 173 174 if( !element->childElements() ) { 175 QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s/>\n", 176 element->attributeValue(QTest::AI_Result), buf.constData()); 177 } else { 178 formatted->data()[0] = '\0'; 179 } 180 } else { 181 formatted->data()[0] = '\0'; 182 } 194 formatted->data()[0] = '\0'; 183 195 } 184 196
Note:
See TracChangeset
for help on using the changeset viewer.