Remove QTestFileLogger class.
This class is not very useful -- it just creates a text file that records each occasion that an autotest enters a test function as a stop-gap solution for the fact that the newer XML logger produces no output if the autotest fails to terminate gracefully. Addressing QTBUG-20615 will provide a better solution by allowing the user to get a partial plain text test log in those circumstances. Change-Id: I179bb98dbd696d0734cd3f12046e5c567def30cc Reviewed-on: http://codereview.qt.nokia.com/3390 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
This commit is contained in:
parent
36533edf71
commit
58f2ac3a29
@ -1,114 +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 "qtestfilelogger.h"
|
||||
#include "qtestassert.h"
|
||||
#include "QtTest/private/qtestlog_p.h"
|
||||
#include "QtTest/private/qtestresult_p.h"
|
||||
|
||||
#include <QtCore/qdir.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QTest
|
||||
{
|
||||
static FILE *stream = 0;
|
||||
}
|
||||
|
||||
QTestFileLogger::QTestFileLogger()
|
||||
{
|
||||
}
|
||||
|
||||
QTestFileLogger::~QTestFileLogger()
|
||||
{
|
||||
if(QTest::stream)
|
||||
fclose(QTest::stream);
|
||||
|
||||
QTest::stream = 0;
|
||||
}
|
||||
|
||||
void QTestFileLogger::init()
|
||||
{
|
||||
char filename[100];
|
||||
int index = 0;
|
||||
#if defined(Q_OS_SYMBIAN)
|
||||
QByteArray ba(QDir::toNativeSeparators(QString(QDir::homePath()+QDir::separator())).toUtf8());
|
||||
index = ba.length();
|
||||
QTest::qt_snprintf(filename, sizeof(filename), "%s%s.log",
|
||||
ba.constData(), QTestResult::currentTestObjectName());
|
||||
#else
|
||||
QTest::qt_snprintf(filename, sizeof(filename), "%s.log",
|
||||
QTestResult::currentTestObjectName());
|
||||
#endif
|
||||
|
||||
// Keep filenames simple
|
||||
for (uint i = index; i < sizeof(filename) && filename[i]; ++i) {
|
||||
char& c = filename[i];
|
||||
if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
|
||||
|| (c >= '0' && c <= '9') || c == '-' || c == '.')) {
|
||||
c = '_';
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(Q_OS_WINCE)
|
||||
if (::fopen_s(&QTest::stream, filename, "wt")) {
|
||||
#else
|
||||
QTest::stream = ::fopen(filename, "wt");
|
||||
if (!QTest::stream) {
|
||||
#endif
|
||||
printf("Unable to open file for simple logging: %s", filename);
|
||||
::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void QTestFileLogger::flush(const char *msg)
|
||||
{
|
||||
QTEST_ASSERT(QTest::stream);
|
||||
|
||||
::fputs(msg, QTest::stream);
|
||||
::fflush(QTest::stream);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -1,67 +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 QTESTFILELOGGER_H
|
||||
#define QTESTFILELOGGER_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Test)
|
||||
|
||||
class QTestFileLogger
|
||||
{
|
||||
public:
|
||||
QTestFileLogger();
|
||||
~QTestFileLogger();
|
||||
|
||||
void init();
|
||||
void flush(const char *msg);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QT_END_HEADER
|
||||
|
||||
#endif // QTESTFILELOGGER_H
|
@ -44,7 +44,6 @@
|
||||
#include "qtestxunitstreamer.h"
|
||||
#include "qtestxmlstreamer.h"
|
||||
#include "qtestlightxmlstreamer.h"
|
||||
#include "qtestfilelogger.h"
|
||||
|
||||
#include "QtTest/qtestcase.h"
|
||||
#include "QtTest/private/qtestresult_p.h"
|
||||
@ -56,7 +55,7 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
QTestLogger::QTestLogger(int fm)
|
||||
:listOfTestcases(0), currentLogElement(0), errorLogElement(0),
|
||||
logFormatter(0), format( (TestLoggerFormat)fm ), filelogger(new QTestFileLogger),
|
||||
logFormatter(0), format( (TestLoggerFormat)fm ),
|
||||
testCounter(0), passCounter(0),
|
||||
failureCounter(0), errorCounter(0),
|
||||
warningCounter(0), skipCounter(0),
|
||||
@ -75,7 +74,6 @@ QTestLogger::~QTestLogger()
|
||||
delete listOfTestcases;
|
||||
|
||||
delete logFormatter;
|
||||
delete filelogger;
|
||||
}
|
||||
|
||||
void QTestLogger::startLogging(const char *filename)
|
||||
@ -83,22 +81,18 @@ void QTestLogger::startLogging(const char *filename)
|
||||
QAbstractTestLogger::startLogging(filename);
|
||||
|
||||
switch(format){
|
||||
case TLF_LightXml:{
|
||||
case TLF_LightXml:
|
||||
logFormatter = new QTestLightXmlStreamer(this);
|
||||
filelogger->init();
|
||||
break;
|
||||
}case TLF_XML:{
|
||||
case TLF_XML:
|
||||
logFormatter = new QTestXmlStreamer(this);
|
||||
filelogger->init();
|
||||
break;
|
||||
}case TLF_XunitXml:{
|
||||
case TLF_XunitXml:
|
||||
logFormatter = new QTestXunitStreamer(this);
|
||||
delete errorLogElement;
|
||||
errorLogElement = new QTestElement(QTest::LET_SystemError);
|
||||
filelogger->init();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QTestLogger::stopLogging()
|
||||
@ -165,10 +159,6 @@ void QTestLogger::stopLogging()
|
||||
|
||||
void QTestLogger::enterTestFunction(const char *function)
|
||||
{
|
||||
char buf[1024];
|
||||
QTest::qt_snprintf(buf, sizeof(buf), "Entered test-function: %s\n", function);
|
||||
filelogger->flush(buf);
|
||||
|
||||
currentLogElement = new QTestElement(QTest::LET_TestCase);
|
||||
currentLogElement->addAttribute(QTest::AI_Name, function);
|
||||
currentLogElement->addToList(&listOfTestcases);
|
||||
|
@ -59,7 +59,6 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
class QTestBasicStreamer;
|
||||
class QTestElement;
|
||||
class QTestFileLogger;
|
||||
|
||||
class QTestLogger : public QAbstractTestLogger
|
||||
{
|
||||
@ -111,7 +110,6 @@ class QTestLogger : public QAbstractTestLogger
|
||||
QTestElement *errorLogElement;
|
||||
QTestBasicStreamer *logFormatter;
|
||||
TestLoggerFormat format;
|
||||
QTestFileLogger *filelogger;
|
||||
|
||||
int testCounter;
|
||||
int passCounter;
|
||||
|
@ -27,7 +27,6 @@ HEADERS = qbenchmark.h \
|
||||
qtestelement.h \
|
||||
qtestevent.h \
|
||||
qtesteventloop.h \
|
||||
qtestfilelogger.h \
|
||||
qtest_global.h \
|
||||
qtest_gui.h \
|
||||
qtest.h \
|
||||
@ -60,8 +59,7 @@ SOURCES = qtestcase.cpp \
|
||||
qtestxunitstreamer.cpp \
|
||||
qtestxmlstreamer.cpp \
|
||||
qtestlightxmlstreamer.cpp \
|
||||
qtestlogger.cpp \
|
||||
qtestfilelogger.cpp
|
||||
qtestlogger.cpp
|
||||
DEFINES *= QT_NO_CAST_TO_ASCII \
|
||||
QT_NO_CAST_FROM_ASCII \
|
||||
QTESTLIB_MAKEDLL \
|
||||
|
@ -527,7 +527,6 @@ 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(QTestFileLogger, QtTest, qtestfilelogger.h)
|
||||
QT_CLASS_LIB(QTestLightXmlStreamer, QtTest, qtestlightxmlstreamer.h)
|
||||
QT_CLASS_LIB(QEventSizeOfChecker, QtTest, qtestspontaneevent.h)
|
||||
QT_CLASS_LIB(QEventSizeOfChecker, QtTest, qtestspontaneevent.h)
|
||||
|
Loading…
x
Reference in New Issue
Block a user