diff options
author | Ed Baak <ed.baak@nokia.com> | 2010-08-04 16:08:53 +1000 |
---|---|---|
committer | Ed Baak <ed.baak@nokia.com> | 2010-08-04 16:08:53 +1000 |
commit | d35eeff3c3c26e5fc94a0e49a57e5706175e8770 (patch) | |
tree | 475853b5a20842fb90c1a26879cb1923f20874f3 | |
parent | 0272193716552ab30c689cef54be634965d9fb7c (diff) |
Add basic support for XML logging
-rw-r--r-- | libqsystemtest/qtestlog.cpp | 168 | ||||
-rw-r--r-- | libqsystemtest/qtestlog.h | 15 | ||||
-rw-r--r-- | libqsystemtest/qtestresult.cpp | 459 | ||||
-rw-r--r-- | libqsystemtest/qtestresult.h | 11 |
4 files changed, 417 insertions, 236 deletions
diff --git a/libqsystemtest/qtestlog.cpp b/libqsystemtest/qtestlog.cpp index 1d2fc40..f64a3ee 100644 --- a/libqsystemtest/qtestlog.cpp +++ b/libqsystemtest/qtestlog.cpp @@ -40,7 +40,7 @@ QTestLog::QTestLog() log_file = 0; log_stream = 0; logging_disabled = FALSE; - raw_mode = FALSE; + logging_mode = LogXml; is_gui_mode = FALSE; cache_enabled = FALSE; } @@ -208,156 +208,30 @@ void QTestLog::writeLog( QTestResultRecord rec ) if (loggingDisabled()) return; - QString test = rec.testName(); - if (cache_enabled) { cached_results.append( rec.keyString() ); return; } - if (is_gui_mode) { //qvalidator - if (rec.result == QTestBase::FailTest || - rec.result == QTestBase::FailCompile) { - emit logResult( rec.keyString() ); - } + QString S; + switch (logging_mode) + { + case LogXml: S = rec.xmlString(); break; + case LogXmlLight: S = rec.keyString(); break; + case LogText: S = rec.normalString(); break; } - if ( rawLoggingMode() ) { - if (is_gui_mode) { - emit logEvent( rec.keyString() ); - } else { - if (isLogging() ) { - QString key_string = rec.keyString(); // just for debugging... - *log_stream << rec.keyString() << "\n"; - log_stream->flush(); - } else { - // FIXME OutputDebugString( rec.keyString() ); - } - } - } else { - QString S; - if (rec.result == QTestBase::StartingTestcase || - rec.result == QTestBase::FinishedTestcase) { - QString insert; - if (rec.result == QTestBase::StartingTestcase) - insert = "Start testing of "; - else - insert = "Finished testing of "; - insert += test; - int c = (78 - insert.length()) / 2; - if (c < 78) { - while ((int)S.length() < c) - S += "*"; - } - S += " " + insert + " "; - while (S.length() < 78) - S += "*"; - - } else if (rec.result == QTestBase::StartingBuild || - rec.result == QTestBase::FinishedBuild) { - QString insert; - if (rec.result == QTestBase::StartingBuild) - insert = "Start building of "; - else - insert = "Finished building of "; - insert += test; - int c = (78 - insert.length()) / 2; - if (c < 78) { - while ((int)S.length() < c) - S += "*"; - } - S += " " + insert + " "; - while (S.length() < 78) - S += "*"; - - } else if (rec.result == QTestBase::StartingScript || - rec.result == QTestBase::FinishedScript) { - QString insert; - if (rec.result == QTestBase::StartingScript) - insert = "Start script execution on "; - else - insert = "Finished script execution on "; - insert += test; - int c = (78 - insert.length()) / 2; - if (c < 78) { - while ((int)S.length() < c) - S += "*"; - } - S += " " + insert + " "; - while (S.length() < 78) - S += "*"; - - } else { - S = resultToStr( rec.result ) + ": "; - - if (rec.result != QTestBase::Note && - rec.result != QTestBase::StartingTestcase && - rec.result != QTestBase::StartingBuild && - rec.result != QTestBase::StartingScript && - rec.result != QTestBase::FinishedTestcase && - rec.result != QTestBase::FinishedBuild && - rec.result != QTestBase::FinishedScript && - rec.result != QTestBase::DetectedConfiguration && - rec.result != QTestBase::DetectedStyle && - rec.result != QTestBase::ScriptRes && - rec.result != QTestBase::MakeRes) { - if (test != "" ) { - S += test; - - if (test.indexOf( "::") > 0) { - if ( rec.result != QTestBase::PassTest && - rec.result != QTestBase::IgnoreResult && - rec.dataTag != "" ) { - S += QString( "(%1) " ).arg( rec.dataTag ); - } else { - S += "() "; - } - } else { - S += " "; - } - } - } - - if (rec.result == QTestBase::IgnoreResult) { - // ignoreResult is a message in a message. - // the actual res is hidden in the dataTag, so we decode it here. - int actual_res = rec.dataTag.toInt(); - // and present it in the string - S += "Ignore a '" + resultToStr( (QTestBase::TestResult)actual_res ).simplified() + "' with string '" + rec.reason + "'"; - } else { - if ( rec.reason != "" ) - S += rec.reason; - } - - if ( rec.file != "" ) { - if (rec.line > -1) - S += "\n Loc: " + rec.file; - - if (rec.line > -1) - S += QString("::%1").arg(rec.line); - } - - if ( rec.comment != "" ) { - S += " " + rec.comment; - } - } + if (S.isEmpty()) return; - qDebug(S.toLatin1()); - - if (is_gui_mode) { - emit logEvent( S ); - } else { - if (isLogging() ) { - if (log_stream != 0) { - *log_stream << S << "\n"; - log_stream->flush(); - } - } else { -// if (rec.result == QTestBase::IgnoreResult || -// rec.result == QTestBase::RemoteIgnoreResult) -// OutputDebugString( QString(S).ucs2() ); - } + if (is_gui_mode) { + emit logResult( S ); + } else if (isLogging() ) { + if (log_stream != 0) { + *log_stream << S << "\n"; + log_stream->flush(); } + } else { + printf(S.toLatin1()); } } @@ -376,16 +250,6 @@ bool QTestLog::isLogging() const return log_stream != 0; } -void QTestLog::setRawLoggingMode( bool enableRaw ) -{ - raw_mode = enableRaw; -} - -bool QTestLog::rawLoggingMode() -{ - return raw_mode; -} - QString QTestLog::fileName() { if (log_file != 0) diff --git a/libqsystemtest/qtestlog.h b/libqsystemtest/qtestlog.h index cf9c13f..64a53d7 100644 --- a/libqsystemtest/qtestlog.h +++ b/libqsystemtest/qtestlog.h @@ -99,8 +99,6 @@ public: QTestLog(); virtual ~QTestLog(); - void selectGUIMode(); - QString resultToStr( QTestBase::TestResult res ); int verboseLevel() {return 0;} //FIXME @@ -126,26 +124,25 @@ public: void closeLogging(); bool isLogging() const; - void setRawLoggingMode( bool enableRaw ); - bool rawLoggingMode(); - void disableLogging( bool disable ); bool loggingDisabled(); void cacheResults( bool doCache ); void flushCachedResults(); + enum LoggingMode {LogXml, LogXmlLight, LogText}; + void setLoggingMode( LoggingMode mode ) {logging_mode = mode;} + void selectGUIMode(); + signals: - void logEvent( const QString &s ); - void logResult( const QKeyString &s ); - void logScreen( const QString &s ); + void logResult( const QString &s ); private: QFile *log_file; QTextStream *log_stream; + LoggingMode logging_mode; bool logging_disabled; - bool raw_mode; QStringList cached_results; bool cache_enabled; diff --git a/libqsystemtest/qtestresult.cpp b/libqsystemtest/qtestresult.cpp index 0d27bec..2c06737 100644 --- a/libqsystemtest/qtestresult.cpp +++ b/libqsystemtest/qtestresult.cpp @@ -490,7 +490,7 @@ void QTestResult::addWarning( const QString &text ) void QTestResult::addFailure( const QString &text, const QString &file, int line ) { if (text != "TEST_ALREADY_FAILED") { -// if (use_debug) qDebug() << "QTestResult::addFailure()" << text; + if (use_debug) qDebug() << "QTestResult::addFailure()" << text; p.testCase()->addResult( TRUE, QTestBase::FailTest, text, file, line, "" ); } } @@ -794,20 +794,12 @@ QString QTestResult::resultToStr( QTestBase::TestResult res ) switch (res) { case QTestBase::PassCompile: - result = "PASS "; - break; case QTestBase::PassSelf: - result = "PASS "; - break; case QTestBase::PassTest: result = "PASS "; break; case QTestBase::FailCompile: - result = "FAIL! "; - break; case QTestBase::FailSelf: - result = "FAIL! "; - break; case QTestBase::FailTest: result = "FAIL! "; break; @@ -828,8 +820,105 @@ QString QTestResult::resultToStr( QTestBase::TestResult res ) result = "ERROR "; break; case QTestBase::MakeRes: + case QTestBase::ScriptRes: result = "$"; break; + case QTestBase::Note: + result = "NOTE "; + break; + case QTestBase::Totals: + result = "TOTALS "; + break; + case QTestBase::Msg: + result = "MSG "; + break; + case QTestBase::QDebug: + result = "QDEBUG "; + break; + case QTestBase::QFatal: + result = "QFATAL "; + break; + case QTestBase::InternFatal: + result = "FATAL! "; + break; + case QTestBase::QWarning: + result = "QWARN "; + break; + case QTestBase::DetectedConfiguration: + result = "CONFIG "; + break; + case QTestBase::DetectedStyle: + result = "STYLE "; + break; + case QTestBase::Printf: + result = "PRINTF "; + break; + case QTestBase::IgnoreResult: + result = "IGNORE "; + break; + case QTestBase::RemoteIgnoreResult: + result = "IGNORE2"; + break; + case QTestBase::StartingTestcase: + case QTestBase::StartingBuild: + case QTestBase::StartingScript: + case QTestBase::FinishedTestcase: + case QTestBase::FinishedBuild: + case QTestBase::FinishedScript: + result = "NOTE "; + break; + case QTestBase::TestFunction_: + result = "TF "; + break; + case QTestBase::TestState: + result = "STATE "; + break; + case QTestBase::Performance: + result = "PERFORM"; + break; + default: + result = "???? "; + break; + } + return result; +} + +/*! +Returns the result string that is associated with the given \a res value in xml form. +*/ +QString QTestResult::resultToXmlStr( QTestBase::TestResult res ) +{ + QString result; + + switch (res) + { + case QTestBase::PassCompile: + case QTestBase::PassSelf: + case QTestBase::PassTest: + result = "pass"; + break; + case QTestBase::FailCompile: + case QTestBase::FailSelf: + case QTestBase::FailTest: + result = "fail"; + break; + case QTestBase::PassUnexpected: + result = "xpass"; + break; + case QTestBase::FailExpected: + result = "xfail"; + break; + case QTestBase::SkipAll: + case QTestBase::SkipSingle: + result = "skip"; + break; + case QTestBase::Warn: + result = "warning"; + break; + case QTestBase::__Error: + result = "error"; + break; + case QTestBase::MakeRes: case QTestBase::ScriptRes: result = "$"; break; @@ -1231,6 +1320,216 @@ QString QTestResultRecord::keyString() return key_string; } +QString QTestResultRecord::xmlTfStart() +{ + return QString("<TestFunction name=\"%1\">\n").arg(testFunc); +} + +QString QTestResultRecord::xmlTfEnd() +{ + return "</TestFunction>\n"; +} + +QString QTestResultRecord::xmlFileAndLine() +{ + return QString("file=\"%1\" line=\"%2\"").arg(file).arg(line); +} + +QString QTestResultRecord::xmlFailIncident() +{ + QString ret = QString("<Incident type=\"%1\" %2>\n") + .arg(QTestResult::resultToXmlStr( result )) + .arg(xmlFileAndLine()); + + if (!dataTag.isEmpty()) + ret += QString(" <DataTag><![CDATA[%1]]></DataTag>\n") + .arg(dataTag); + + ret += QString(" <Description><![CDATA[%1]]></Description>\n" + "</Incident>\n") + .arg(reason); + + return ret; +} + +QString QTestResultRecord::xmlString() +{ + QString ret; + switch (result) + { + case PassCompile: ret = "PassCompile"; break; + case FailCompile: ret = "FailCompile"; break; + case PassTest: ret = xmlTfStart() + + "<Incident type=\"pass\" file=\"\" line=\"0\" />\n" + + xmlTfEnd(); break; + case FailTest: ret = xmlTfStart() + + xmlFailIncident() + + xmlTfEnd(); break; + case PassUnexpected: ret = "PassUnexpected"; break; + case FailExpected: ret = "FailExpected"; break; + case Warn: ret = "Warn"; break; + case __Error: ret = "__Error"; break; + case Msg: ret = "Msg"; break; + /* +"<Message type=\"%s\" %s=\"%s\" %s=\"%s\">\n%s <Description><![CDATA[%s]]></Description>\n</Message>\n", + element->attributeValue(QTest::AI_Type), + "file", + arg(file), + "line", + arg(line), + arg(dataTag), + arg(reason); + */ + case MakeRes: ret = "MakeRes"; break; + case SkipAll: ret = "SkipAll"; break; + case QDebug: ret = "QDebug"; break; + case QFatal: ret = "QFatal"; break; + case QWarning: ret = "QWarning"; break; + case DetectedConfiguration: ret = "<Environment>\n <QtVersion>%s</QtVersion>\n <QTestVersion>%s</QTestVersion>\n</Environment>\n"; break; + case DetectedStyle: ret = "DetectedStyle"; break; + case Printf: ret = "Printf"; break; + case IgnoreResult: ret = "IgnoreResult"; break; + case StartingTestcase: ret = QString("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<TestCase name=\"%1\">\n").arg(testCase); break; + case FinishedTestcase: ret = "</TestCase>\n"; break; + case InternFatal: ret = "InternFatal"; break; + case TestFunction_: ret = "TestFunction_"; break; + case Performance: ret = "Performance"; break; + case StartingBuild: ret = "StartingBuild"; break; + case FinishedBuild: ret = "FinishedBuild"; break; + case TestState: ret = "TestState"; break; + case StartingScript: ret = "StartingScript"; break; + case FinishedScript: ret = "FinishedScript"; break; + case PassScript: ret = "PassScript"; break; + case FailScript: ret = "FailScript"; break; + case ScriptRes: ret = "ScriptRes"; break; + case ExpectFailure: ret = "ExpectFailure"; break; + case RemoteIgnoreResult: ret = "RemoteIgnoreResult"; break; + case Retest: ret = "Retest"; break; + case SkipSingle: ret = "SkipSingle"; break; + + case Note: break; + case Totals: break; + } + + return ret; +} + +QString QTestResultRecord::normalString() +{ + QString test = testCase; + if (!testFunc.isEmpty()) + test += "::" + testFunc; + + QString S; + if (result == QTestBase::StartingTestcase || + result == QTestBase::FinishedTestcase) { + QString insert; + if (result == QTestBase::StartingTestcase) + insert = "Start testing of "; + else + insert = "Finished testing of "; + insert += test; + int c = (78 - insert.length()) / 2; + if (c < 78) { + while ((int)S.length() < c) + S += "*"; + } + S += " " + insert + " "; + while (S.length() < 78) + S += "*"; + + } else if (result == QTestBase::StartingBuild || + result == QTestBase::FinishedBuild) { + QString insert; + if (result == QTestBase::StartingBuild) + insert = "Start building of "; + else + insert = "Finished building of "; + insert += test; + int c = (78 - insert.length()) / 2; + if (c < 78) { + while ((int)S.length() < c) + S += "*"; + } + S += " " + insert + " "; + while (S.length() < 78) + S += "*"; + + } else if (result == QTestBase::StartingScript || + result == QTestBase::FinishedScript) { + QString insert; + if (result == QTestBase::StartingScript) + insert = "Start script execution on "; + else + insert = "Finished script execution on "; + insert += test; + int c = (78 - insert.length()) / 2; + if (c < 78) { + while ((int)S.length() < c) + S += "*"; + } + S += " " + insert + " "; + while (S.length() < 78) + S += "*"; + + } else { + S = QTestResult::resultToStr( result ) + ": "; + + if (result != QTestBase::Note && + result != QTestBase::StartingTestcase && + result != QTestBase::StartingBuild && + result != QTestBase::StartingScript && + result != QTestBase::FinishedTestcase && + result != QTestBase::FinishedBuild && + result != QTestBase::FinishedScript && + result != QTestBase::DetectedConfiguration && + result != QTestBase::DetectedStyle && + result != QTestBase::ScriptRes && + result != QTestBase::MakeRes) { + if (test != "" ) { + S += test; + + if (test.indexOf( "::") > 0) { + if ( result != QTestBase::PassTest && + result != QTestBase::IgnoreResult && + dataTag != "" ) { + S += QString( "(%1) " ).arg( dataTag ); + } else { + S += "() "; + } + } else { + S += " "; + } + } + } + + if (result == QTestBase::IgnoreResult) { + // ignoreResult is a message in a message. + // the actual res is hidden in the dataTag, so we decode it here. + int actual_res = dataTag.toInt(); + // and present it in the string + S += "Ignore a '" + QTestResult::resultToStr( (QTestBase::TestResult)actual_res ).simplified() + "' with string '" + reason + "'"; + } else { + if ( reason != "" ) + S += reason; + } + + if ( file != "" ) { + if (line > -1) + S += "\n Loc: " + file; + + if (line > -1) + S += QString("::%1").arg(line); + } + + if ( comment != "" ) { + S += " " + comment; + } + } + + return S; +} + QString QTestResultRecord::testName() { QString ret = testCase; @@ -1317,9 +1616,7 @@ void QTestResultTestBase::setRetest( bool busy ) { retest_busy = busy; test_result = QTestBase::Invalid; - if (g_test_result.testLog()->rawLoggingMode()) { - appendResult( TRUE, QTestBase::Retest, "", "", -1, QString( "%1" ).arg( busy ) ); - } + appendResult( TRUE, QTestBase::Retest, "", "", -1, QString( "%1" ).arg( busy ) ); } void QTestResultTestBase::resetResult() @@ -1477,12 +1774,12 @@ void QTestResultTestBase::appendResult( bool spontaneous, } if (rec.passed()) { -//#ifndef QTEST_SUPPORT if (rec.line >= -1) return; -//#endif - rec.file = ""; - rec.line = -1; + { + rec.file = ""; + rec.line = -1; + } } // Don't log anything if we are re-testing the same testfunction multiple times. @@ -1827,34 +2124,31 @@ void QTestResultTestCase::setName( const QString &name, bool verbose, bool build if (cur_func != 0) setCurrentTestFunction( "" ); - if (!g_test_result.testLog()->rawLoggingMode()) { - QString errors; - if (local_ignores.resetIgnoreResult( errors )) - addResult( FALSE, QTestBase::FailTest, errors ); - if (remote_ignores.resetIgnoreResult( errors )) - addResult( FALSE, QTestBase::FailTest, errors ); + QString errors; + if (local_ignores.resetIgnoreResult( errors )) + addResult( FALSE, QTestBase::FailTest, errors ); + if (remote_ignores.resetIgnoreResult( errors )) + addResult( FALSE, QTestBase::FailTest, errors ); - if (build_mode) { -// FIXME: this fails when building qpe?? + if (build_mode) { // if (totalFailed() == 0 && totalPassed() == 0) // addResult( FALSE, QTestBase::FailTest, "Nothing is tested at all." ); - } else { + } else { #ifndef QTEST_SUPPORT - if (totalTests() == 0 && totalFailed() == 0) - addResult( FALSE, QTestBase::FailTest, "Nothing is tested at all." ); + if (totalTests() == 0 && totalFailed() == 0) + addResult( FALSE, QTestBase::FailTest, "Nothing is tested at all." ); #endif - } + } - if (!build_mode) - addResult( TRUE, QTestBase::Totals, QString("%1 passed, %2 failed, %3 skipped").arg(totalPassed()).arg(totalFailed()).arg(totalSkipped())); + if (!build_mode) + addResult( TRUE, QTestBase::Totals, QString("%1 passed, %2 failed, %3 skipped").arg(totalPassed()).arg(totalFailed()).arg(totalSkipped())); - QString txt = QString("Testcase took %1 ms to ").arg(timer.elapsed()); - if (build_mode) - txt += "compile."; - else - txt += "execute."; - addResult( TRUE, QTestBase::Note, txt ); - } + QString txt = QString("Testcase took %1 ms to ").arg(timer.elapsed()); + if (build_mode) + txt += "compile."; + else + txt += "execute."; + addResult( TRUE, QTestBase::Note, txt ); if (build_mode) { addResult( TRUE, QTestBase::FinishedBuild, "", "", -1, "" ); @@ -1946,6 +2240,7 @@ QTestResultTestFunc* QTestResultTestCase::findFunction( const QString &funcName void QTestResultTestCase::setCurrentTestFunction( const QString &funcName ) { +// qDebug() << "QTestResultTestCase::setCurrentTestFunction()" << funcName; if (funcName.isEmpty()) { if ( cur_func == 0 ) return; @@ -1953,23 +2248,21 @@ void QTestResultTestCase::setCurrentTestFunction( const QString &funcName ) if (cur_func->cur_data != 0) cur_func->setCurrentTestData( "" ); - if (!g_test_result.testLog()->rawLoggingMode()) { - QString errors; - if (cur_func->resetIgnoreResult( FALSE, errors )) - addResult( FALSE, QTestBase::FailTest, errors ); - if (cur_func->resetIgnoreResult( TRUE, errors )) - addResult( FALSE, QTestBase::FailTest, errors ); - - if (!cur_func->hasFailures()) { - if (curDataCount() == curSkipCount() && - curSkipCount() > 0) { - // don't show a PASS - } else { - QString S = ""; - if (curSkipCount() > 0) - S = QString("Passed with %1 skipped tests.").arg( curSkipCount() ); - appendResult( FALSE, QTestBase::PassTest, S, "", -2 ); - } + QString errors; + if (cur_func->resetIgnoreResult( FALSE, errors )) + addResult( FALSE, QTestBase::FailTest, errors ); + if (cur_func->resetIgnoreResult( TRUE, errors )) + addResult( FALSE, QTestBase::FailTest, errors ); + + if (!cur_func->hasFailures()) { + if (curDataCount() == curSkipCount() && + curSkipCount() > 0) { + // don't show a PASS + } else { + QString S = ""; + if (curSkipCount() > 0) + S = QString("Passed with %1 skipped tests.").arg( curSkipCount() ); + appendResult( FALSE, QTestBase::PassTest, S, "", -2 ); } } @@ -1984,8 +2277,22 @@ void QTestResultTestCase::setCurrentTestFunction( const QString &funcName ) cur_func = 0; } else { - if (cur_func != 0 && cur_func->name() == funcName) - return; + if (cur_func != 0) { + if (cur_func->name() == funcName) + return; + + if (!cur_func->hasFailures()) { + if (curDataCount() == curSkipCount() && + curSkipCount() > 0) { + // don't show a PASS + } else { + QString S = ""; + if (curSkipCount() > 0) + S = QString("Passed with %1 skipped tests.").arg( curSkipCount() ); + appendResult( FALSE, QTestBase::PassTest, S, "", -2 ); + } + } + } QTestResultTestFunc *tmp = findFunction( funcName ); if (tmp != 0) { @@ -2259,13 +2566,11 @@ void QTestResultTestFunc::setCurrentTestData( const QString &dataName ) if (!cur_data->verified()) addResult( TRUE, QTestBase::FailTest, "Nothing is tested in this testfunction." ); - if (!g_test_result.testLog()->rawLoggingMode()) { - QString errors; - if (cur_data->resetIgnoreResult( FALSE, errors )) - addResult( FALSE, QTestBase::FailTest, errors ); - if (cur_data->resetIgnoreResult( TRUE, errors )) - addResult( FALSE, QTestBase::FailTest, errors ); - } + QString errors; + if (cur_data->resetIgnoreResult( FALSE, errors )) + addResult( FALSE, QTestBase::FailTest, errors ); + if (cur_data->resetIgnoreResult( TRUE, errors )) + addResult( FALSE, QTestBase::FailTest, errors ); cur_data = 0; } else { @@ -2443,23 +2748,29 @@ bool QTestResultTestFunc::verified( bool current ) return TRUE; } +bool isFailed( QTestBase::TestResult res ) +{ + // a test failed if it didn't pass and isn't skipped + if (res != QTestBase::PassSelf && + res != QTestBase::PassCompile && + res != QTestBase::PassTest && + res != QTestBase::PassScript && + res != QTestBase::SkipAll && + res != QTestBase::SkipSingle) + return true; + return false; +} + bool QTestResultTestFunc::hasFailures() { // a test hasn't passed if no test has been executed - if (first_data == 0) - return TRUE; - -// qDebug( func_name ); + if (first_data == 0) { + return isFailed(result()); + } QTestResultTestData *d = first_data; while (d != 0) { - // a test failed if it didn't pass and isn't skipped - if (d->result() != QTestBase::PassSelf && - d->result() != QTestBase::PassCompile && - d->result() != QTestBase::PassTest && - d->result() != QTestBase::PassScript && - d->result() != QTestBase::SkipAll && - d->result() != QTestBase::SkipSingle) + if (isFailed(d->result())) return TRUE; d = d->next(); } diff --git a/libqsystemtest/qtestresult.h b/libqsystemtest/qtestresult.h index 530b681..8fa559b 100644 --- a/libqsystemtest/qtestresult.h +++ b/libqsystemtest/qtestresult.h @@ -37,6 +37,8 @@ public: QString testName(); bool passed(); + QString normalString(); + QString xmlString(); QString keyString(); bool decode( const QString &logText ); @@ -48,6 +50,12 @@ public: QString file; int line; QString comment; + +protected: + QString xmlTfStart(); + QString xmlTfEnd(); + QString xmlFileAndLine(); + QString xmlFailIncident(); }; class QTestResultSuite : public QObject @@ -134,7 +142,7 @@ public: bool shouldAbort() const; bool skipCurrentTest() const {return false;} // FIXME need to return a better value here - void setSkipCurrentTest( bool skip ) {} //FIXME Don't know what to do with this + void setSkipCurrentTest( bool skip ) {Q_UNUSED(skip);} //FIXME Don't know what to do with this bool debugMode() const; QTestBase::LearnMode learnMode(); @@ -145,6 +153,7 @@ public: // void setIgnoreResult( const QTestBase::TestResult res, const QString &reason, bool exactMatch = FALSE ); static QString resultToStr( QTestBase::TestResult res ); + static QString resultToXmlStr( QTestBase::TestResult res ); void retest( bool busy ); void clear(); |