Changeset 769 for trunk/src/testlib


Ignore:
Timestamp:
Aug 2, 2010, 9:27:30 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/testlib/qplaintestlogger.cpp

    r651 r769  
    182182                RDebug::Print(format, hbuffer);
    183183            }
     184
    184185        }
    185186        else {
  • trunk/src/testlib/qtestcase.cpp

    r651 r769  
    965965         " -xml       : Outputs results as XML document\n"
    966966         " -lightxml  : Outputs results as stream of XML tags\n"
    967          " -flush     : Flushes the resutls\n"
     967         " -flush     : Flushes the resus\n"
    968968         " -o filename: Writes all output into a file\n"
    969969         " -silent    : Only outputs warnings and failures\n"
     
    11141114        } else if (strcmp(argv[i], "-qws") == 0) {
    11151115            // do nothing
     1116
     1117
     1118
     1119
     1120
     1121
     1122
     1123
    11161124        } else if (argv[i][0] == '-') {
    11171125            printf("Unknown option: '%s'\n\n%s", argv[i], testOptions);
     
    12991307            QTestResult::setSkipCurrentTest(false);
    13001308
     1309
     1310
     1311
     1312
     1313
     1314
     1315
     1316
     1317
     1318
     1319
     1320
    13011321            /* For each entry in the data table, do: */
    13021322            do {
    13031323                if (!data || !qstrcmp(data, table.testData(curDataIndex)->dataTag())) {
    13041324                    foundFunction = true;
    1305                     QTestDataSetter s(table.isEmpty() ? static_cast<QTestData *>(0)
     1325                    QTestDataSetter s( ? static_cast<QTestData *>(0)
    13061326                                                      : table.testData(curDataIndex));
    13071327
  • trunk/src/testlib/qtestlogger.cpp

    r651 r769  
    212212        failureElement->addAttribute(QTest::AI_Line, buf);
    213213        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);
    218215        currentLogElement->addLogElement(failureElement);
    219216    }
     
    278275}
    279276
     277
     278
     279
     280
     281
     282
     283
     284
     285
     286
     287
     288
     289
     290
     291
     292
     293
     294
     295
     296
     297
    280298void QTestLogger::addMessage(MessageTypes type, const char *message, const char *file, int line)
    281299{
     
    298316    case QAbstractTestLogger::QWarning:
    299317        ++qwarnCounter;
    300         typeBuf = "qwarning";
     318        typeBuf = "qwarn";
    301319        break;
    302320    case QAbstractTestLogger::QFatal:
     
    319337    errorElement->addAttribute(QTest::AI_Type, typeBuf);
    320338    errorElement->addAttribute(QTest::AI_Description, message);
     339
    321340
    322341    if(file)
  • trunk/src/testlib/qtestlogger_p.h

    r651 r769  
    8484                     const char *file = 0, int line = 0);
    8585        void addBenchmarkResult(const QBenchmarkResult &result);
     86
    8687
    8788        void addMessage(MessageTypes type, const char *message,
  • trunk/src/testlib/qtestxmlstreamer.cpp

    r651 r769  
    112112        QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description));
    113113
    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",
    115122                           element->attributeValue(QTest::AI_Type),
    116123                           element->attributeName(QTest::AI_File),
     
    118125                           element->attributeName(QTest::AI_Line),
    119126                           element->attributeValue(QTest::AI_Line),
     127
    120128                           cdataDesc.constData());
    121129        break;
     
    150158
    151159    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        }
    153183    } else {
    154184        formatted->data()[0] = '\0';
     
    158188void QTestXmlStreamer::formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const
    159189{
    160     if(!element || !formatted)
     190    Q_UNUSED(element);
     191    if (!formatted)
    161192        return;
    162193
    163     if (element->elementType() == QTest::LET_TestCase && element->attribute(QTest::AI_Result)){
    164         QTestCharBuffer buf;
    165         QTestCharBuffer quotedFile;
    166         QXmlTestLogger::xmlQuote(&quotedFile, 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';
    183195}
    184196
Note: See TracChangeset for help on using the changeset viewer.