summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason McDonald <jason.mcdonald@nokia.com>2011-08-30 18:36:46 +1000
committerQt by Nokia <qt-info@nokia.com>2011-09-01 03:10:39 +0200
commitb17e9b3d94dc041ed80854076d2053e2c750eb50 (patch)
treea9835f6e982f071a59653d5dfb8680309c13159f
parenta4878db8df3fbaf9d222ec1206813b16dcdd90c7 (diff)
Simplify qtestlib logging code, part 1
Both the old and new XML loggers produce the Complete and Light XML log formats, while only the new logger produces Xunit XML logs. The disadvantage of the new logger is that it is more complex and doesn't produce a partial log if the test fails to terminate gracefully. This behaviour arises because Xunit format output cannot be written correctly until all tests have been executed. This commit removes the Complete and Light XML formats from the new logger, using the old logger to produce those formats and the new logger to produce only Xunit XML. Prior to this commit, the qtestlib selftests demonstrate that the old and new loggers produce identical output for Complete and Light XML. This commit also removes the undocumented -flush command-line option, which was used rather obscurely to select between the old and new loggers. The newer logger will be renamed to QXunitTestLogger in a subsequent commit. Change-Id: Id304f5b411bdd520409ee233f6bc34e8917942ab Reviewed-on: http://codereview.qt.nokia.com/3923 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
-rw-r--r--src/testlib/qtestcase.cpp3
-rw-r--r--src/testlib/qtestlightxmlstreamer.cpp211
-rw-r--r--src/testlib/qtestlightxmlstreamer.h72
-rw-r--r--src/testlib/qtestlog.cpp20
-rw-r--r--src/testlib/qtestlog_p.h2
-rw-r--r--src/testlib/qtestlogger.cpp96
-rw-r--r--src/testlib/qtestlogger_p.h10
-rw-r--r--src/testlib/qtestxmlstreamer.cpp222
-rw-r--r--src/testlib/qtestxmlstreamer.h72
-rw-r--r--src/testlib/testlib.pro4
-rw-r--r--src/tools/uic/qclass_lib_map.h2
-rw-r--r--tests/auto/selftests/tst_selftests.cpp10
12 files changed, 46 insertions, 678 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 3802794281..d3176bbe09 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -1006,7 +1006,6 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
" -xunitxml : Outputs results as XML XUnit document\n"
" -xml : Outputs results as XML document\n"
" -lightxml : Outputs results as stream of XML tags\n"
- " -flush : Flushes the results\n"
" -o filename: Writes all output into a file\n"
" -silent : Only outputs warnings and failures\n"
" -v1 : Print enter messages for each testfunction\n"
@@ -1066,8 +1065,6 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
QTestLog::setLogMode(QTestLog::XML);
} else if (strcmp(argv[i], "-lightxml") == 0) {
QTestLog::setLogMode(QTestLog::LightXML);
- } else if (strcmp(argv[i], "-flush") == 0){
- QTestLog::setFlushMode(QTestLog::FlushOn);
} else if (strcmp(argv[i], "-silent") == 0) {
QTestLog::setVerboseLevel(-1);
} else if (strcmp(argv[i], "-v1") == 0) {
diff --git a/src/testlib/qtestlightxmlstreamer.cpp b/src/testlib/qtestlightxmlstreamer.cpp
deleted file mode 100644
index 4aba2a2bf8..0000000000
--- a/src/testlib/qtestlightxmlstreamer.cpp
+++ /dev/null
@@ -1,211 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtTest module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qtestlightxmlstreamer.h"
-#include "qtestelement.h"
-#include "qtestelementattribute.h"
-#include "qtestlogger_p.h"
-
-#include "QtTest/private/qtestlog_p.h"
-#include "QtTest/private/qtestresult_p.h"
-#include "QtTest/private/qxmltestlogger_p.h"
-
-#include <string.h>
-
-QT_BEGIN_NAMESPACE
-
-QTestLightXmlStreamer::QTestLightXmlStreamer(QTestLogger *logger)
- : QTestBasicStreamer(logger)
-{
-}
-
-QTestLightXmlStreamer::~QTestLightXmlStreamer()
-{}
-
-void QTestLightXmlStreamer::formatStart(const QTestElement *element, QTestCharBuffer *formatted) const
-{
- if(!element || !formatted)
- return;
-
- switch(element->elementType()){
- case QTest::LET_TestCase: {
- QTestCharBuffer quotedTf;
- QXmlTestLogger::xmlQuote(&quotedTf, element->attributeValue(QTest::AI_Name));
-
- QTest::qt_asprintf(formatted, "<TestFunction name=\"%s\">\n", quotedTf.constData());
- break;
- }
- case QTest::LET_Failure: {
- QTestCharBuffer cdataDesc;
- QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description));
-
- QTestCharBuffer location;
- QTestCharBuffer quotedFile;
- QXmlTestLogger::xmlQuote(&quotedFile, element->attributeValue(QTest::AI_File));
-
- QTest::qt_asprintf(&location, "%s=\"%s\" %s=\"%s\"",
- element->attributeName(QTest::AI_File),
- quotedFile.constData(),
- element->attributeName(QTest::AI_Line),
- element->attributeValue(QTest::AI_Line));
-
- if (element->attribute(QTest::AI_Tag)) {
- QTestCharBuffer cdataTag;
- QXmlTestLogger::xmlCdata(&cdataTag, element->attributeValue(QTest::AI_Tag));
- QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s>\n"
- " <DataTag><![CDATA[%s]]></DataTag>\n"
- " <Description><![CDATA[%s]]></Description>\n"
- "</Incident>\n", element->attributeValue(QTest::AI_Result),
- location.constData(), cdataTag.constData(), cdataDesc.constData());
- }
- else {
- QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s>\n"
- " <Description><![CDATA[%s]]></Description>\n"
- "</Incident>\n", element->attributeValue(QTest::AI_Result),
- location.constData(), cdataDesc.constData());
- }
- break;
- }
- case QTest::LET_Error: {
- // assuming type and attribute names don't need quoting
- QTestCharBuffer quotedFile;
- QTestCharBuffer cdataDesc;
- QXmlTestLogger::xmlQuote(&quotedFile, element->attributeValue(QTest::AI_File));
- QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description));
-
- 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;
- }
- case QTest::LET_Benchmark: {
- // assuming value and iterations don't need quoting
- QTestCharBuffer quotedMetric;
- QTestCharBuffer quotedTag;
- QXmlTestLogger::xmlQuote(&quotedMetric, element->attributeValue(QTest::AI_Metric));
- QXmlTestLogger::xmlQuote(&quotedTag, element->attributeValue(QTest::AI_Tag));
-
- QTest::qt_asprintf(formatted, "<BenchmarkResult %s=\"%s\" %s=\"%s\" %s=\"%s\" %s=\"%s\" />\n",
- element->attributeName(QTest::AI_Metric),
- quotedMetric.constData(),
- element->attributeName(QTest::AI_Tag),
- quotedTag.constData(),
- element->attributeName(QTest::AI_Value),
- element->attributeValue(QTest::AI_Value),
- element->attributeName(QTest::AI_Iterations),
- element->attributeValue(QTest::AI_Iterations) );
- break;
- }
- default:
- formatted->data()[0] = '\0';
- }
-}
-
-void QTestLightXmlStreamer::formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const
-{
- if(!element || !formatted)
- return;
-
- if (element->elementType() == QTest::LET_TestCase) {
- 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';
- }
-}
-
-void QTestLightXmlStreamer::formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const
-{
- Q_UNUSED(element);
- if (!formatted)
- return;
-
- formatted->data()[0] = '\0';
-}
-
-void QTestLightXmlStreamer::output(QTestElement *element) const
-{
- QTestCharBuffer buf;
- QTest::qt_asprintf(&buf, "<Environment>\n <QtVersion>%s</QtVersion>\n <QTestVersion>%s</QTestVersion>\n",
- qVersion(), QTEST_VERSION_STR );
- outputString(buf.constData());
-
- QTest::qt_asprintf(&buf, "</Environment>\n");
- outputString(buf.constData());
-
- QTestBasicStreamer::output(element);
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/testlib/qtestlightxmlstreamer.h b/src/testlib/qtestlightxmlstreamer.h
deleted file mode 100644
index b3076c1623..0000000000
--- a/src/testlib/qtestlightxmlstreamer.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtTest module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTESTLIGHTXMLSTREAMER_H
-#define QTESTLIGHTXMLSTREAMER_H
-
-#include <QtTest/qtestbasicstreamer.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Test)
-
-class QTestElement;
-class QTestElementAttribute;
-
-class QTestLightXmlStreamer: public QTestBasicStreamer
-{
- public:
- QTestLightXmlStreamer(QTestLogger *logger);
- ~QTestLightXmlStreamer();
-
- void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const;
- void formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const;
- void formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const;
- void output(QTestElement *element) const;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp
index 0a87a4ce14..77ddae65be 100644
--- a/src/testlib/qtestlog.cpp
+++ b/src/testlib/qtestlog.cpp
@@ -83,7 +83,6 @@ namespace QTest {
static IgnoreResultList *ignoreResultList = 0;
static QTestLog::LogMode logMode = QTestLog::Plain;
- static QTestLog::FlushMode flushMode = QTestLog::NoFlush;
static int verbosity = 0;
static int maxWarnings = 2002;
@@ -173,22 +172,16 @@ namespace QTest {
QTest::testLogger = new QPlainTestLogger;
break;
case QTestLog::XML:
- if (QTest::flushMode == QTestLog::FlushOn)
- QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Complete);
- else
- QTest::testLogger = new QTestLogger(QTestLogger::TLF_XML);
+ QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Complete);
break;
case QTestLog::LightXML:
- if (QTest::flushMode == QTestLog::FlushOn)
- QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Light);
- else
- QTest::testLogger = new QTestLogger(QTestLogger::TLF_LightXml);
+ QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Light);
break;
case QTestLog::XunitXML:
- QTest::testLogger = new QTestLogger(QTestLogger::TLF_XunitXml);
+ QTest::testLogger = new QTestLogger();
+ break;
}
}
-
}
void QTestLog::enterTestFunction(const char* function)
@@ -368,9 +361,4 @@ void QTestLog::setMaxWarnings(int m)
QTest::maxWarnings = m <= 0 ? INT_MAX : m + 2;
}
-void QTestLog::setFlushMode(FlushMode mode)
-{
- QTest::flushMode = mode;
-}
-
QT_END_NAMESPACE
diff --git a/src/testlib/qtestlog_p.h b/src/testlib/qtestlog_p.h
index 9b580eb8cc..c667289b66 100644
--- a/src/testlib/qtestlog_p.h
+++ b/src/testlib/qtestlog_p.h
@@ -63,7 +63,6 @@ class Q_TESTLIB_EXPORT QTestLog
{
public:
enum LogMode { Plain = 0, XML, LightXML, XunitXML };
- enum FlushMode { NoFlush = 0, FlushOn };
static void enterTestFunction(const char* function);
static void leaveTestFunction();
@@ -95,7 +94,6 @@ public:
static void setMaxWarnings(int max);
- static void setFlushMode(FlushMode mode);
private:
QTestLog();
~QTestLog();
diff --git a/src/testlib/qtestlogger.cpp b/src/testlib/qtestlogger.cpp
index 385fb866c2..1665dde6e7 100644
--- a/src/testlib/qtestlogger.cpp
+++ b/src/testlib/qtestlogger.cpp
@@ -42,8 +42,6 @@
#include "qtestlogger_p.h"
#include "qtestelement.h"
#include "qtestxunitstreamer.h"
-#include "qtestxmlstreamer.h"
-#include "qtestlightxmlstreamer.h"
#include "QtTest/qtestcase.h"
#include "QtTest/private/qtestresult_p.h"
@@ -53,12 +51,11 @@
QT_BEGIN_NAMESPACE
-QTestLogger::QTestLogger(int fm)
+QTestLogger::QTestLogger()
: listOfTestcases(0)
, currentLogElement(0)
, errorLogElement(0)
, logFormatter(0)
- , format( (TestLoggerFormat)fm )
, testCounter(0)
, failureCounter(0)
, errorCounter(0)
@@ -67,11 +64,7 @@ QTestLogger::QTestLogger(int fm)
QTestLogger::~QTestLogger()
{
- if(format == TLF_XunitXml)
- delete currentLogElement;
- else
- delete listOfTestcases;
-
+ delete currentLogElement;
delete logFormatter;
}
@@ -79,71 +72,57 @@ void QTestLogger::startLogging(const char *filename)
{
QAbstractTestLogger::startLogging(filename);
- switch(format){
- case TLF_LightXml:
- logFormatter = new QTestLightXmlStreamer(this);
- break;
- case TLF_XML:
- logFormatter = new QTestXmlStreamer(this);
- break;
- case TLF_XunitXml:
- logFormatter = new QTestXunitStreamer(this);
- delete errorLogElement;
- errorLogElement = new QTestElement(QTest::LET_SystemError);
- break;
- }
+ logFormatter = new QTestXunitStreamer(this);
+ delete errorLogElement;
+ errorLogElement = new QTestElement(QTest::LET_SystemError);
}
void QTestLogger::stopLogging()
{
QTestElement *iterator = listOfTestcases;
- if(format == TLF_XunitXml ){
- char buf[10];
+ char buf[10];
- currentLogElement = new QTestElement(QTest::LET_TestSuite);
- currentLogElement->addAttribute(QTest::AI_Name, QTestResult::currentTestObjectName());
+ currentLogElement = new QTestElement(QTest::LET_TestSuite);
+ currentLogElement->addAttribute(QTest::AI_Name, QTestResult::currentTestObjectName());
- QTest::qt_snprintf(buf, sizeof(buf), "%i", testCounter);
- currentLogElement->addAttribute(QTest::AI_Tests, buf);
+ QTest::qt_snprintf(buf, sizeof(buf), "%i", testCounter);
+ currentLogElement->addAttribute(QTest::AI_Tests, buf);
- QTest::qt_snprintf(buf, sizeof(buf), "%i", failureCounter);
- currentLogElement->addAttribute(QTest::AI_Failures, buf);
+ QTest::qt_snprintf(buf, sizeof(buf), "%i", failureCounter);
+ currentLogElement->addAttribute(QTest::AI_Failures, buf);
- QTest::qt_snprintf(buf, sizeof(buf), "%i", errorCounter);
- currentLogElement->addAttribute(QTest::AI_Errors, buf);
+ QTest::qt_snprintf(buf, sizeof(buf), "%i", errorCounter);
+ currentLogElement->addAttribute(QTest::AI_Errors, buf);
- QTestElement *property;
- QTestElement *properties = new QTestElement(QTest::LET_Properties);
+ QTestElement *property;
+ QTestElement *properties = new QTestElement(QTest::LET_Properties);
- property = new QTestElement(QTest::LET_Property);
- property->addAttribute(QTest::AI_Name, "QTestVersion");
- property->addAttribute(QTest::AI_PropertyValue, QTEST_VERSION_STR);
- properties->addLogElement(property);
+ property = new QTestElement(QTest::LET_Property);
+ property->addAttribute(QTest::AI_Name, "QTestVersion");
+ property->addAttribute(QTest::AI_PropertyValue, QTEST_VERSION_STR);
+ properties->addLogElement(property);
- property = new QTestElement(QTest::LET_Property);
- property->addAttribute(QTest::AI_Name, "QtVersion");
- property->addAttribute(QTest::AI_PropertyValue, qVersion());
- properties->addLogElement(property);
+ property = new QTestElement(QTest::LET_Property);
+ property->addAttribute(QTest::AI_Name, "QtVersion");
+ property->addAttribute(QTest::AI_PropertyValue, qVersion());
+ properties->addLogElement(property);
- currentLogElement->addLogElement(properties);
+ currentLogElement->addLogElement(properties);
- currentLogElement->addLogElement(iterator);
+ currentLogElement->addLogElement(iterator);
- /* For correct indenting, make sure every testcase knows its parent */
- QTestElement* testcase = iterator;
- while (testcase) {
- testcase->setParent(currentLogElement);
- testcase = testcase->nextElement();
- }
+ /* For correct indenting, make sure every testcase knows its parent */
+ QTestElement* testcase = iterator;
+ while (testcase) {
+ testcase->setParent(currentLogElement);
+ testcase = testcase->nextElement();
+ }
- currentLogElement->addLogElement(errorLogElement);
+ currentLogElement->addLogElement(errorLogElement);
- QTestElement *it = currentLogElement;
- logFormatter->output(it);
- }else{
- logFormatter->output(iterator);
- }
+ QTestElement *it = currentLogElement;
+ logFormatter->output(it);
QAbstractTestLogger::stopLogging();
}
@@ -187,8 +166,7 @@ void QTestLogger::addIncident(IncidentTypes type, const char *description,
break;
}
- if (type == QAbstractTestLogger::Fail || type == QAbstractTestLogger::XPass
- || ((format != TLF_XunitXml) && (type == QAbstractTestLogger::XFail))) {
+ if (type == QAbstractTestLogger::Fail || type == QAbstractTestLogger::XPass) {
QTestElement *failureElement = new QTestElement(QTest::LET_Failure);
failureElement->addAttribute(QTest::AI_Result, typeBuf);
if(file)
@@ -241,7 +219,7 @@ void QTestLogger::addIncident(IncidentTypes type, const char *description,
Since XFAIL does not add a failure to the testlog in xunitxml, add a message, so we still
have some information about the expected failure.
*/
- if (format == TLF_XunitXml && type == QAbstractTestLogger::XFail) {
+ if (type == QAbstractTestLogger::XFail) {
QTestLogger::addMessage(QAbstractTestLogger::Info, description, file, line);
}
}
diff --git a/src/testlib/qtestlogger_p.h b/src/testlib/qtestlogger_p.h
index 5e5b0f2f3f..b9c9f2b6b6 100644
--- a/src/testlib/qtestlogger_p.h
+++ b/src/testlib/qtestlogger_p.h
@@ -63,16 +63,9 @@ class QTestElement;
class QTestLogger : public QAbstractTestLogger
{
public:
- QTestLogger(int fm = 0);
+ QTestLogger();
~QTestLogger();
- enum TestLoggerFormat
- {
- TLF_XML = 0,
- TLF_LightXml = 1,
- TLF_XunitXml = 2
- };
-
void startLogging(const char *filename);
void stopLogging();
@@ -92,7 +85,6 @@ class QTestLogger : public QAbstractTestLogger
QTestElement *currentLogElement;
QTestElement *errorLogElement;
QTestBasicStreamer *logFormatter;
- TestLoggerFormat format;
int testCounter;
int failureCounter;
diff --git a/src/testlib/qtestxmlstreamer.cpp b/src/testlib/qtestxmlstreamer.cpp
deleted file mode 100644
index 47c4463b5a..0000000000
--- a/src/testlib/qtestxmlstreamer.cpp
+++ /dev/null
@@ -1,222 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtTest module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qtestxmlstreamer.h"
-#include "qtestelement.h"
-#include "qtestelementattribute.h"
-#include "qtestlogger_p.h"
-
-#include "QtTest/private/qtestlog_p.h"
-#include "QtTest/private/qtestresult_p.h"
-#include "QtTest/private/qxmltestlogger_p.h"
-
-#include <string.h>
-#include <stdio.h>
-
-QT_BEGIN_NAMESPACE
-
-QTestXmlStreamer::QTestXmlStreamer(QTestLogger *logger)
- : QTestBasicStreamer(logger)
-{
-}
-
-QTestXmlStreamer::~QTestXmlStreamer()
-{}
-
-void QTestXmlStreamer::formatStart(const QTestElement *element, QTestCharBuffer *formatted) const
-{
- if(!element || !formatted)
- return;
-
- switch(element->elementType()){
- case QTest::LET_TestCase: {
- QTestCharBuffer quotedTf;
- QXmlTestLogger::xmlQuote(&quotedTf, element->attributeValue(QTest::AI_Name));
-
- QTest::qt_asprintf(formatted, "<TestFunction name=\"%s\">\n", quotedTf.constData());
- break;
- }
- case QTest::LET_Failure: {
- QTestCharBuffer cdataDesc;
- QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description));
-
- QTestCharBuffer location;
- QTestCharBuffer quotedFile;
- QXmlTestLogger::xmlQuote(&quotedFile, element->attributeValue(QTest::AI_File));
-
- QTest::qt_asprintf(&location, "%s=\"%s\" %s=\"%s\"",
- element->attributeName(QTest::AI_File),
- quotedFile.constData(),
- element->attributeName(QTest::AI_Line),
- element->attributeValue(QTest::AI_Line));
-
- if (element->attribute(QTest::AI_Tag)) {
- QTestCharBuffer cdataTag;
- QXmlTestLogger::xmlCdata(&cdataTag, element->attributeValue(QTest::AI_Tag));
- QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s>\n"
- " <DataTag><![CDATA[%s]]></DataTag>\n"
- " <Description><![CDATA[%s]]></Description>\n"
- "</Incident>\n", element->attributeValue(QTest::AI_Result),
- location.constData(), cdataTag.constData(), cdataDesc.constData());
- }
- else {
- QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s>\n"
- " <Description><![CDATA[%s]]></Description>\n"
- "</Incident>\n", element->attributeValue(QTest::AI_Result),
- location.constData(), cdataDesc.constData());
- }
- break;
- }
- case QTest::LET_Error: {
- // assuming type and attribute names don't need quoting
- QTestCharBuffer quotedFile;
- QTestCharBuffer cdataDesc;
- QXmlTestLogger::xmlQuote(&quotedFile, element->attributeValue(QTest::AI_File));
- QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description));
-
- 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;
- }
- case QTest::LET_Benchmark: {
- // assuming value and iterations don't need quoting
- QTestCharBuffer quotedMetric;
- QTestCharBuffer quotedTag;
- QXmlTestLogger::xmlQuote(&quotedMetric, element->attributeValue(QTest::AI_Metric));
- QXmlTestLogger::xmlQuote(&quotedTag, element->attributeValue(QTest::AI_Tag));
-
- QTest::qt_asprintf(formatted, "<BenchmarkResult %s=\"%s\" %s=\"%s\" %s=\"%s\" %s=\"%s\" />\n",
- element->attributeName(QTest::AI_Metric),
- quotedMetric.constData(),
- element->attributeName(QTest::AI_Tag),
- quotedTag.constData(),
- element->attributeName(QTest::AI_Value),
- element->attributeValue(QTest::AI_Value),
- element->attributeName(QTest::AI_Iterations),
- element->attributeValue(QTest::AI_Iterations) );
- break;
- }
- default:
- formatted->data()[0] = '\0';
- }
-}
-
-void QTestXmlStreamer::formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const
-{
- if(!element || !formatted)
- return;
-
- if (element->elementType() == QTest::LET_TestCase) {
- 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';
- }
-}
-
-void QTestXmlStreamer::formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const
-{
- Q_UNUSED(element);
- if (!formatted)
- return;
-
- formatted->data()[0] = '\0';
-}
-
-void QTestXmlStreamer::output(QTestElement *element) const
-{
- QTestCharBuffer buf;
- QTestCharBuffer quotedTc;
- QXmlTestLogger::xmlQuote(&quotedTc, QTestResult::currentTestObjectName());
-
- QTest::qt_asprintf(&buf, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<TestCase name=\"%s\">\n",
- quotedTc.constData());
- outputString(buf.constData());
-
- QTest::qt_asprintf(&buf, "<Environment>\n <QtVersion>%s</QtVersion>\n <QTestVersion>%s</QTestVersion>\n",
- qVersion(), QTEST_VERSION_STR );
- outputString(buf.constData());
-
- QTest::qt_asprintf(&buf, "</Environment>\n");
- outputString(buf.constData());
-
- QTestBasicStreamer::output(element);
-
- QTest::qt_asprintf(&buf, "</TestCase>\n");
- outputString(buf.constData());
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/testlib/qtestxmlstreamer.h b/src/testlib/qtestxmlstreamer.h
deleted file mode 100644
index 96e8246779..0000000000
--- a/src/testlib/qtestxmlstreamer.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtTest module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTESTXMLSTREAMER_H
-#define QTESTXMLSTREAMER_H
-
-#include <QtTest/qtestbasicstreamer.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Test)
-
-class QTestElement;
-class QTestElementAttribute;
-
-class QTestXmlStreamer: public QTestBasicStreamer
-{
- public:
- QTestXmlStreamer(QTestLogger *logger);
- ~QTestXmlStreamer();
-
- void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const;
- void formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const;
- void formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const;
- void output(QTestElement *element) const;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/testlib/testlib.pro b/src/testlib/testlib.pro
index 482c82cfd3..4133472738 100644
--- a/src/testlib/testlib.pro
+++ b/src/testlib/testlib.pro
@@ -31,12 +31,10 @@ HEADERS = qbenchmark.h \
qtest_gui.h \
qtest.h \
qtestkeyboard.h \
- qtestlightxmlstreamer.h \
qtestmouse.h \
qtestspontaneevent.h \
qtestsystem.h \
qtesttouch.h \
- qtestxmlstreamer.h \
qtestxunitstreamer.h
SOURCES = qtestcase.cpp \
qtestlog.cpp \
@@ -57,8 +55,6 @@ SOURCES = qtestcase.cpp \
qtestelementattribute.cpp \
qtestbasicstreamer.cpp \
qtestxunitstreamer.cpp \
- qtestxmlstreamer.cpp \
- qtestlightxmlstreamer.cpp \
qtestlogger.cpp
DEFINES *= QT_NO_CAST_TO_ASCII \
QT_NO_CAST_FROM_ASCII \
diff --git a/src/tools/uic/qclass_lib_map.h b/src/tools/uic/qclass_lib_map.h
index f86f458d45..a4b71defd0 100644
--- a/src/tools/uic/qclass_lib_map.h
+++ b/src/tools/uic/qclass_lib_map.h
@@ -527,11 +527,9 @@ QT_CLASS_LIB(QTestMouseEvent, QtTest, qtestevent.h)
QT_CLASS_LIB(QTestDelayEvent, QtTest, qtestevent.h)
QT_CLASS_LIB(QTestEventList, QtTest, qtestevent.h)
QT_CLASS_LIB(QTestEventLoop, QtTest, qtesteventloop.h)
-QT_CLASS_LIB(QTestLightXmlStreamer, QtTest, qtestlightxmlstreamer.h)
QT_CLASS_LIB(QEventSizeOfChecker, QtTest, qtestspontaneevent.h)
QT_CLASS_LIB(QEventSizeOfChecker, QtTest, qtestspontaneevent.h)
QT_CLASS_LIB(QSpontaneKeyEvent, QtTest, qtestspontaneevent.h)
-QT_CLASS_LIB(QTestXmlStreamer, QtTest, qtestxmlstreamer.h)
QT_CLASS_LIB(QTestXunitStreamer, QtTest, qtestxunitstreamer.h)
QT_CLASS_LIB(QDBusAbstractAdaptor, QtDBus, qdbusabstractadaptor.h)
QT_CLASS_LIB(QDBusAbstractInterfaceBase, QtDBus, qdbusabstractinterface.h)
diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp
index cb5cd077b6..138e47927f 100644
--- a/tests/auto/selftests/tst_selftests.cpp
+++ b/tests/auto/selftests/tst_selftests.cpp
@@ -173,12 +173,10 @@ Logger::Logger(QString const& _name, QString const& _testdata_suffix, QStringLis
static QList<Logger> allLoggers()
{
return QList<Logger>()
- << Logger("plain", "txt", QStringList())
- << Logger("xml", "xml", QStringList() << "-xml")
- << Logger("xml flush", "xml", QStringList() << "-xml" << "-flush")
- << Logger("xunitxml", "xunitxml", QStringList() << "-xunitxml")
- << Logger("lightxml", "lightxml", QStringList() << "-lightxml")
- << Logger("lightxml flush", "lightxml", QStringList() << "-lightxml" << "-flush")
+ << Logger("plain", "txt", QStringList())
+ << Logger("xml", "xml", QStringList() << "-xml")
+ << Logger("xunitxml", "xunitxml", QStringList() << "-xunitxml")
+ << Logger("lightxml", "lightxml", QStringList() << "-lightxml")
;
}