mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-23 10:22:55 +00:00
drop lightxml and xunit test log modes
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
b57c20755a
commit
eb9c8ebd43
12 changed files with 16 additions and 575 deletions
|
@ -957,10 +957,8 @@ include/katie/QtTest/QTestEventLoop
|
|||
include/katie/QtTest/QTestFileLogger
|
||||
include/katie/QtTest/QTestKeyClicksEvent
|
||||
include/katie/QtTest/QTestKeyEvent
|
||||
include/katie/QtTest/QTestLightXmlStreamer
|
||||
include/katie/QtTest/QTestMouseEvent
|
||||
include/katie/QtTest/QTestXmlStreamer
|
||||
include/katie/QtTest/QTestXunitStreamer
|
||||
include/katie/QtTest/QtTest
|
||||
include/katie/QtTest/QtTestGui
|
||||
include/katie/QtTest/qbenchmark.h
|
||||
|
@ -981,12 +979,10 @@ include/katie/QtTest/qtestevent.h
|
|||
include/katie/QtTest/qtesteventloop.h
|
||||
include/katie/QtTest/qtestfilelogger.h
|
||||
include/katie/QtTest/qtestkeyboard.h
|
||||
include/katie/QtTest/qtestlightxmlstreamer.h
|
||||
include/katie/QtTest/qtestmouse.h
|
||||
include/katie/QtTest/qtestspontaneevent.h
|
||||
include/katie/QtTest/qtestsystem.h
|
||||
include/katie/QtTest/qtestxmlstreamer.h
|
||||
include/katie/QtTest/qtestxunitstreamer.h
|
||||
include/katie/QtUiTools/QCustomWidget
|
||||
include/katie/QtUiTools/QCustomWidgetPlugin
|
||||
include/katie/QtUiTools/QUiLoader
|
||||
|
|
|
@ -514,10 +514,8 @@ classlist = [
|
|||
"QTestFileLogger",
|
||||
"QTestKeyClicksEvent",
|
||||
"QTestKeyEvent",
|
||||
"QTestLightXmlStreamer",
|
||||
"QTestMouseEvent",
|
||||
"QTestXmlStreamer",
|
||||
"QTestXunitStreamer",
|
||||
"QTextBlock",
|
||||
"QTextBlockFormat",
|
||||
"QTextBlockGroup",
|
||||
|
|
|
@ -17,9 +17,7 @@ set(TEST_PUBLIC_HEADERS
|
|||
QTestEvent
|
||||
QTestEventLoop
|
||||
QTestFileLogger
|
||||
QTestLightXmlStreamer
|
||||
QTestXmlStreamer
|
||||
QTestXunitStreamer
|
||||
)
|
||||
|
||||
include_directories(
|
||||
|
@ -47,12 +45,10 @@ set(TEST_HEADERS
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/qtest_gui.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qtest.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qtestkeyboard.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qtestlightxmlstreamer.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qtestmouse.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qtestspontaneevent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qtestsystem.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qtestxmlstreamer.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qtestxunitstreamer.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qbenchmarkmetric.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qtestlog_p.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qtesttable_p.h
|
||||
|
@ -86,9 +82,7 @@ set(TEST_SOURCES
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/qtestelement.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qtestelementattribute.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qtestbasicstreamer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qtestxunitstreamer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qtestxmlstreamer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qtestlightxmlstreamer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qtestlogger.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qtestfilelogger.cpp
|
||||
)
|
||||
|
|
|
@ -974,9 +974,7 @@ Q_TEST_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
|
|||
" -functions : Returns a list of current testfunctions\n"
|
||||
" -datatags : Returns a list of current data tags.\n"
|
||||
" A global data tag is preceded by ' __global__ '.\n"
|
||||
" -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"
|
||||
|
@ -1026,13 +1024,9 @@ Q_TEST_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
|
|||
qPrintDataTags();
|
||||
::exit(0);
|
||||
}
|
||||
} else if(strcmp(argv[i], "-xunitxml") == 0){
|
||||
QTestLog::setLogMode(QTestLog::XunitXML);
|
||||
} else if (strcmp(argv[i], "-xml") == 0) {
|
||||
QTestLog::setLogMode(QTestLog::XML);
|
||||
} else if (strcmp(argv[i], "-lightxml") == 0) {
|
||||
QTestLog::setLogMode(QTestLog::LightXML);
|
||||
}else if(strcmp(argv[i], "-flush") == 0){
|
||||
} else if(strcmp(argv[i], "-flush") == 0){
|
||||
QTestLog::setFlushMode(QTestLog::FLushOn);
|
||||
} else if (strcmp(argv[i], "-silent") == 0) {
|
||||
QTestLog::setVerboseLevel(-1);
|
||||
|
|
|
@ -1,163 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the QtTest module of the Katie 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qtestlightxmlstreamer.h"
|
||||
#include "qtestelement.h"
|
||||
#include "qtestelementattribute.h"
|
||||
#include "qtestlogger_p.h"
|
||||
#include "qtestlog_p.h"
|
||||
#include "qtestresult_p.h"
|
||||
#include "qxmltestlogger_p.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QTestLightXmlStreamer::QTestLightXmlStreamer()
|
||||
:QTestBasicStreamer()
|
||||
{
|
||||
}
|
||||
|
||||
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("edTf, 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));
|
||||
|
||||
QTest::qt_asprintf(formatted, " <Description><![CDATA[%s]]></Description>\n",
|
||||
cdataDesc.constData());
|
||||
break;
|
||||
}
|
||||
case QTest::LET_Error: {
|
||||
// assuming type and attribute names don't need quoting
|
||||
QTestCharBuffer quotedFile;
|
||||
QTestCharBuffer cdataDesc;
|
||||
QXmlTestLogger::xmlQuote("edFile, element->attributeValue(QTest::AI_File));
|
||||
QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description));
|
||||
|
||||
QTest::qt_asprintf(formatted, "<Message type=\"%s\" %s=\"%s\" %s=\"%s\">\n <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),
|
||||
cdataDesc.constData());
|
||||
break;
|
||||
}
|
||||
case QTest::LET_Benchmark: {
|
||||
// assuming value and iterations don't need quoting
|
||||
QTestCharBuffer quotedMetric;
|
||||
QTestCharBuffer quotedTag;
|
||||
QXmlTestLogger::xmlQuote("edMetric, element->attributeValue(QTest::AI_Metric));
|
||||
QXmlTestLogger::xmlQuote("edTag, 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) {
|
||||
if( element->attribute(QTest::AI_Result) && element->childElements())
|
||||
QTest::qt_asprintf(formatted, "</Incident>\n</TestFunction>\n");
|
||||
else
|
||||
QTest::qt_asprintf(formatted, "</TestFunction>\n");
|
||||
} else {
|
||||
formatted->data()[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
void QTestLightXmlStreamer::formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const
|
||||
{
|
||||
if(!element || !formatted)
|
||||
return;
|
||||
|
||||
if (element->elementType() == QTest::LET_TestCase && element->attribute(QTest::AI_Result)) {
|
||||
QTestCharBuffer buf;
|
||||
QTestCharBuffer quotedFile;
|
||||
QXmlTestLogger::xmlQuote("edFile, element->attributeValue(QTest::AI_File));
|
||||
|
||||
QTest::qt_asprintf(&buf, "%s=\"%s\" %s=\"%s\"",
|
||||
element->attributeName(QTest::AI_File),
|
||||
quotedFile.constData(),
|
||||
element->attributeName(QTest::AI_Line),
|
||||
element->attributeValue(QTest::AI_Line));
|
||||
|
||||
if( !element->childElements() )
|
||||
QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s/>\n",
|
||||
element->attributeValue(QTest::AI_Result), buf.constData());
|
||||
else
|
||||
QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s>\n",
|
||||
element->attributeValue(QTest::AI_Result), buf.constData());
|
||||
} else {
|
||||
formatted->data()[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
void QTestLightXmlStreamer::output(QTestElement *element) const
|
||||
{
|
||||
QTestCharBuffer buf;
|
||||
if (logger()->hasRandomSeed()) {
|
||||
QTest::qt_asprintf(&buf, "<Environment>\n <QtVersion>%s</QtVersion>\n <QTestVersion>%s</QTestVersion>\n <RandomSeed>%d</RandomSeed>\n",
|
||||
qVersion(), QT_VERSION_STR, logger()->randomSeed() );
|
||||
} else {
|
||||
QTest::qt_asprintf(&buf, "<Environment>\n <QtVersion>%s</QtVersion>\n <QTestVersion>%s</QTestVersion>\n",
|
||||
qVersion(), QT_VERSION_STR );
|
||||
}
|
||||
outputString(buf.constData());
|
||||
|
||||
QTest::qt_asprintf(&buf, "</Environment>\n");
|
||||
outputString(buf.constData());
|
||||
|
||||
QTestBasicStreamer::output(element);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the QtTest module of the Katie 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QTESTLIGHTXMLSTREAMER_H
|
||||
#define QTESTLIGHTXMLSTREAMER_H
|
||||
|
||||
#include <QtTest/qtestbasicstreamer.h>
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QTestElement;
|
||||
class QTestElementAttribute;
|
||||
|
||||
class QTestLightXmlStreamer: public QTestBasicStreamer
|
||||
{
|
||||
public:
|
||||
QTestLightXmlStreamer();
|
||||
~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
|
||||
|
||||
|
||||
#endif
|
|
@ -151,24 +151,18 @@ namespace QTest {
|
|||
void initLogger()
|
||||
{
|
||||
switch (QTest::logMode) {
|
||||
case QTestLog::Plain:
|
||||
case QTestLog::Plain: {
|
||||
QTest::testLogger = new QPlainTestLogger;
|
||||
break;
|
||||
case QTestLog::XML:{
|
||||
}
|
||||
case QTestLog::XML: {
|
||||
if(QTest::flushMode == QTestLog::FLushOn)
|
||||
QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Complete);
|
||||
else
|
||||
QTest::testLogger = new QTestLogger(QTestLogger::TLF_XML);
|
||||
break;
|
||||
}case QTestLog::LightXML:{
|
||||
if(QTest::flushMode == QTestLog::FLushOn)
|
||||
QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Light);
|
||||
else
|
||||
QTest::testLogger = new QTestLogger(QTestLogger::TLF_LightXml);
|
||||
break;
|
||||
}case QTestLog::XunitXML:
|
||||
QTest::testLogger = new QTestLogger(QTestLogger::TLF_XunitXml);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern Q_TEST_EXPORT bool printAvailableTags;
|
||||
|
|
|
@ -42,7 +42,7 @@ class QBenchmarkResult;
|
|||
class Q_TEST_EXPORT QTestLog
|
||||
{
|
||||
public:
|
||||
enum LogMode { Plain = 0, XML, LightXML, XunitXML };
|
||||
enum LogMode { Plain = 0, XML };
|
||||
enum FlushMode { NoFlush = 0, FLushOn };
|
||||
|
||||
static void enterTestFunction(const char* function);
|
||||
|
|
|
@ -21,9 +21,7 @@
|
|||
|
||||
#include "qtestlogger_p.h"
|
||||
#include "qtestelement.h"
|
||||
#include "qtestxunitstreamer.h"
|
||||
#include "qtestxmlstreamer.h"
|
||||
#include "qtestlightxmlstreamer.h"
|
||||
#include "qtestfilelogger.h"
|
||||
#include "qtestcase.h"
|
||||
#include "qtestresult_p.h"
|
||||
|
@ -35,7 +33,7 @@
|
|||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QTestLogger::QTestLogger(TestLoggerFormat fm)
|
||||
:listOfTestcases(0), currentLogElement(0), errorLogElement(0),
|
||||
: listOfTestcases(0), currentLogElement(0), errorLogElement(0),
|
||||
logFormatter(0), format( (TestLoggerFormat)fm ), filelogger(new QTestFileLogger),
|
||||
testCounter(0), passCounter(0), failureCounter(0), errorCounter(0),
|
||||
skipCounter(0), randomSeed_(0), hasRandomSeed_(false)
|
||||
|
@ -44,11 +42,7 @@ QTestLogger::QTestLogger(TestLoggerFormat fm)
|
|||
|
||||
QTestLogger::~QTestLogger()
|
||||
{
|
||||
if(format == TLF_XunitXml)
|
||||
delete currentLogElement;
|
||||
else
|
||||
delete listOfTestcases;
|
||||
|
||||
delete listOfTestcases;
|
||||
delete logFormatter;
|
||||
delete filelogger;
|
||||
}
|
||||
|
@ -56,21 +50,11 @@ QTestLogger::~QTestLogger()
|
|||
void QTestLogger::startLogging()
|
||||
{
|
||||
switch(format){
|
||||
case TLF_LightXml:{
|
||||
logFormatter = new QTestLightXmlStreamer;
|
||||
filelogger->init();
|
||||
break;
|
||||
}case TLF_XML:{
|
||||
logFormatter = new QTestXmlStreamer;
|
||||
filelogger->init();
|
||||
break;
|
||||
}case TLF_XunitXml:{
|
||||
logFormatter = new QTestXunitStreamer;
|
||||
delete errorLogElement;
|
||||
errorLogElement = new QTestElement(QTest::LET_SystemError);
|
||||
filelogger->init();
|
||||
break;
|
||||
}
|
||||
case TLF_XML: {
|
||||
logFormatter = new QTestXmlStreamer;
|
||||
filelogger->init();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
logFormatter->setLogger(this);
|
||||
|
@ -79,63 +63,7 @@ void QTestLogger::startLogging()
|
|||
|
||||
void QTestLogger::stopLogging()
|
||||
{
|
||||
QTestElement *iterator = listOfTestcases;
|
||||
|
||||
if(format == TLF_XunitXml ){
|
||||
QSTACKARRAY(char, buf, 10);
|
||||
|
||||
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", failureCounter);
|
||||
currentLogElement->addAttribute(QTest::AI_Failures, buf);
|
||||
|
||||
QTest::qt_snprintf(buf, sizeof(buf), "%i", errorCounter);
|
||||
currentLogElement->addAttribute(QTest::AI_Errors, buf);
|
||||
|
||||
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, QT_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);
|
||||
|
||||
if (hasRandomSeed()) {
|
||||
property = new QTestElement(QTest::LET_Property);
|
||||
property->addAttribute(QTest::AI_Name, "RandomSeed");
|
||||
QTest::qt_snprintf(buf, sizeof(buf), "%i", randomSeed());
|
||||
property->addAttribute(QTest::AI_PropertyValue, buf);
|
||||
properties->addLogElement(property);
|
||||
}
|
||||
|
||||
currentLogElement->addLogElement(properties);
|
||||
|
||||
currentLogElement->addLogElement(iterator);
|
||||
|
||||
/* For correct indenting, make sure every testcase knows its parent */
|
||||
QTestElement* testcase = iterator;
|
||||
while (testcase) {
|
||||
testcase->setParent(currentLogElement);
|
||||
testcase = testcase->nextElement();
|
||||
}
|
||||
|
||||
currentLogElement->addLogElement(errorLogElement);
|
||||
|
||||
QTestElement *it = currentLogElement;
|
||||
logFormatter->output(it);
|
||||
}else{
|
||||
logFormatter->output(iterator);
|
||||
}
|
||||
|
||||
logFormatter->output(listOfTestcases);
|
||||
logFormatter->stopStreaming();
|
||||
}
|
||||
|
||||
|
@ -185,7 +113,7 @@ void QTestLogger::addIncident(IncidentTypes type, const char *description,
|
|||
}
|
||||
|
||||
if (type == QAbstractTestLogger::Fail || type == QAbstractTestLogger::XPass
|
||||
|| ((format != TLF_XunitXml) && (type == QAbstractTestLogger::XFail))) {
|
||||
|| type == QAbstractTestLogger::XFail) {
|
||||
QTestElement *failureElement = new QTestElement(QTest::LET_Failure);
|
||||
failureElement->addAttribute(QTest::AI_Result, typeBuf);
|
||||
if(file)
|
||||
|
@ -230,14 +158,6 @@ void QTestLogger::addIncident(IncidentTypes type, const char *description,
|
|||
|
||||
QTest::qt_snprintf(buf, sizeof(buf), "%i", line);
|
||||
currentLogElement->addAttribute(QTest::AI_Line, buf);
|
||||
|
||||
/*
|
||||
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) {
|
||||
QTestLogger::addMessage(QAbstractTestLogger::Info, description, file, line);
|
||||
}
|
||||
}
|
||||
|
||||
void QTestLogger::addBenchmarkResult(const QBenchmarkResult &result)
|
||||
|
|
|
@ -46,9 +46,7 @@ class QTestLogger : public QAbstractTestLogger
|
|||
public:
|
||||
enum TestLoggerFormat
|
||||
{
|
||||
TLF_XML = 0,
|
||||
TLF_LightXml = 1,
|
||||
TLF_XunitXml = 2
|
||||
TLF_XML = 0
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,189 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the QtTest module of the Katie 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qtestxunitstreamer.h"
|
||||
#include "qtestelement.h"
|
||||
#include "qtestlog_p.h"
|
||||
#include "qtestresult_p.h"
|
||||
#include "qxmltestlogger_p.h"
|
||||
#include "qcorecommon_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QTestXunitStreamer::QTestXunitStreamer()
|
||||
:QTestBasicStreamer()
|
||||
{}
|
||||
|
||||
QTestXunitStreamer::~QTestXunitStreamer()
|
||||
{}
|
||||
|
||||
void QTestXunitStreamer::indentForElement(const QTestElement* element, char* buf, int size)
|
||||
{
|
||||
if (size == 0) return;
|
||||
|
||||
buf[0] = 0;
|
||||
|
||||
if (!element) return;
|
||||
|
||||
char* endbuf = buf + size;
|
||||
element = element->parentElement();
|
||||
while (element && buf+2 < endbuf) {
|
||||
*(buf++) = ' ';
|
||||
*(buf++) = ' ';
|
||||
*buf = 0;
|
||||
element = element->parentElement();
|
||||
}
|
||||
}
|
||||
|
||||
void QTestXunitStreamer::formatStart(const QTestElement *element, QTestCharBuffer *formatted) const
|
||||
{
|
||||
if(!element || !formatted )
|
||||
return;
|
||||
|
||||
QSTACKARRAY(char, indent, 20);
|
||||
indentForElement(element, indent, sizeof(indent));
|
||||
|
||||
// Errors are written as CDATA within system-err, comments elsewhere
|
||||
if (element->elementType() == QTest::LET_Error) {
|
||||
if (element->parentElement()->elementType() == QTest::LET_SystemError) {
|
||||
QTest::qt_asprintf(formatted, "<![CDATA[");
|
||||
} else {
|
||||
QTest::qt_asprintf(formatted, "%s<!--", indent);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
QTest::qt_asprintf(formatted, "%s<%s", indent, element->elementName());
|
||||
}
|
||||
|
||||
void QTestXunitStreamer::formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const
|
||||
{
|
||||
if (!element || !formatted )
|
||||
return;
|
||||
|
||||
if (!element->childElements()){
|
||||
formatted->data()[0] = '\0';
|
||||
return;
|
||||
}
|
||||
|
||||
QSTACKARRAY(char, indent, 20);
|
||||
indentForElement(element, indent, sizeof(indent));
|
||||
|
||||
QTest::qt_asprintf(formatted, "%s</%s>\n", indent, element->elementName());
|
||||
}
|
||||
|
||||
void QTestXunitStreamer::formatAttributes(const QTestElement* element, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const
|
||||
{
|
||||
if(!attribute || !formatted )
|
||||
return;
|
||||
|
||||
QTest::AttributeIndex attrindex = attribute->index();
|
||||
|
||||
// For errors within system-err, we only want to output `message'
|
||||
if (element && element->elementType() == QTest::LET_Error
|
||||
&& element->parentElement()->elementType() == QTest::LET_SystemError) {
|
||||
|
||||
if (attrindex != QTest::AI_Description) return;
|
||||
|
||||
QXmlTestLogger::xmlCdata(formatted, attribute->value());
|
||||
return;
|
||||
}
|
||||
|
||||
char const* key = 0;
|
||||
if (attrindex == QTest::AI_Description)
|
||||
key = "message";
|
||||
else if (attrindex != QTest::AI_File && attrindex != QTest::AI_Line)
|
||||
key = attribute->name();
|
||||
|
||||
if (key) {
|
||||
QTestCharBuffer quotedValue;
|
||||
QXmlTestLogger::xmlQuote("edValue, attribute->value());
|
||||
QTest::qt_asprintf(formatted, " %s=\"%s\"", key, quotedValue.constData());
|
||||
} else {
|
||||
formatted->data()[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
void QTestXunitStreamer::formatAfterAttributes(const QTestElement *element, QTestCharBuffer *formatted) const
|
||||
{
|
||||
if(!element || !formatted )
|
||||
return;
|
||||
|
||||
// Errors are written as CDATA within system-err, comments elsewhere
|
||||
if (element->elementType() == QTest::LET_Error) {
|
||||
if (element->parentElement()->elementType() == QTest::LET_SystemError) {
|
||||
QTest::qt_asprintf(formatted, "]]>\n");
|
||||
} else {
|
||||
QTest::qt_asprintf(formatted, " -->\n");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(!element->childElements())
|
||||
QTest::qt_asprintf(formatted, "/>\n");
|
||||
else
|
||||
QTest::qt_asprintf(formatted, ">\n");
|
||||
}
|
||||
|
||||
void QTestXunitStreamer::output(QTestElement *element) const
|
||||
{
|
||||
outputString("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
|
||||
QTestBasicStreamer::output(element);
|
||||
}
|
||||
|
||||
void QTestXunitStreamer::outputElements(QTestElement *element, bool) const
|
||||
{
|
||||
QTestCharBuffer buf;
|
||||
bool hasChildren;
|
||||
/*
|
||||
Elements are in reverse order of occurrence, so start from the end and work
|
||||
our way backwards.
|
||||
*/
|
||||
while (element && element->nextElement()) {
|
||||
element = element->nextElement();
|
||||
}
|
||||
while (element) {
|
||||
hasChildren = element->childElements();
|
||||
|
||||
if(element->elementType() != QTest::LET_Benchmark){
|
||||
formatStart(element, &buf);
|
||||
outputString(buf.data());
|
||||
|
||||
formatBeforeAttributes(element, &buf);
|
||||
outputString(buf.data());
|
||||
|
||||
outputElementAttributes(element, element->attributes());
|
||||
|
||||
formatAfterAttributes(element, &buf);
|
||||
outputString(buf.data());
|
||||
|
||||
if(hasChildren)
|
||||
outputElements(element->childElements(), true);
|
||||
|
||||
formatEnd(element, &buf);
|
||||
outputString(buf.data());
|
||||
}
|
||||
element = element->previousElement();
|
||||
}
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the QtTest module of the Katie 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QTESTXUNITSTREAMER_H
|
||||
#define QTESTXUNITSTREAMER_H
|
||||
|
||||
#include <QtTest/qtestbasicstreamer.h>
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QTestLogger;
|
||||
|
||||
class QTestXunitStreamer: public QTestBasicStreamer
|
||||
{
|
||||
public:
|
||||
QTestXunitStreamer();
|
||||
~QTestXunitStreamer();
|
||||
|
||||
void formatStart(const QTestElement *element, QTestCharBuffer *formatted) const;
|
||||
void formatEnd(const QTestElement *element, QTestCharBuffer *formatted) const;
|
||||
void formatAfterAttributes(const QTestElement *element, QTestCharBuffer *formatted) const;
|
||||
void formatAttributes(const QTestElement *element, const QTestElementAttribute *attribute, QTestCharBuffer *formatted) const;
|
||||
void output(QTestElement *element) const;
|
||||
void outputElements(QTestElement *element, bool isChildElement = false) const;
|
||||
|
||||
private:
|
||||
void displayXunitXmlHeader() const;
|
||||
static void indentForElement(const QTestElement* element, char* buf, int size);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
#endif
|
Loading…
Add table
Reference in a new issue