From 58f2ac3a2993423ab247c43b307513f054b65870 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Tue, 23 Aug 2011 18:35:27 +1000 Subject: 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 Reviewed-by: Rohan McGovern --- src/testlib/qtestfilelogger.cpp | 114 ---------------------------------------- src/testlib/qtestfilelogger.h | 67 ----------------------- src/testlib/qtestlogger.cpp | 18 ++----- src/testlib/qtestlogger_p.h | 2 - src/testlib/testlib.pro | 4 +- src/tools/uic/qclass_lib_map.h | 1 - 6 files changed, 5 insertions(+), 201 deletions(-) delete mode 100644 src/testlib/qtestfilelogger.cpp delete mode 100644 src/testlib/qtestfilelogger.h diff --git a/src/testlib/qtestfilelogger.cpp b/src/testlib/qtestfilelogger.cpp deleted file mode 100644 index 2349ca3cd5..0000000000 --- a/src/testlib/qtestfilelogger.cpp +++ /dev/null @@ -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 - -#include -#include - -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 - diff --git a/src/testlib/qtestfilelogger.h b/src/testlib/qtestfilelogger.h deleted file mode 100644 index 9b10a49539..0000000000 --- a/src/testlib/qtestfilelogger.h +++ /dev/null @@ -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 - -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 diff --git a/src/testlib/qtestlogger.cpp b/src/testlib/qtestlogger.cpp index af069d76b2..7e9332a4b6 100644 --- a/src/testlib/qtestlogger.cpp +++ b/src/testlib/qtestlogger.cpp @@ -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); diff --git a/src/testlib/qtestlogger_p.h b/src/testlib/qtestlogger_p.h index 5793537e78..c9b9da1ee8 100644 --- a/src/testlib/qtestlogger_p.h +++ b/src/testlib/qtestlogger_p.h @@ -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; diff --git a/src/testlib/testlib.pro b/src/testlib/testlib.pro index c3df1b4ec7..482c82cfd3 100644 --- a/src/testlib/testlib.pro +++ b/src/testlib/testlib.pro @@ -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 \ diff --git a/src/tools/uic/qclass_lib_map.h b/src/tools/uic/qclass_lib_map.h index 35b4f928ef..f86f458d45 100644 --- a/src/tools/uic/qclass_lib_map.h +++ b/src/tools/uic/qclass_lib_map.h @@ -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) -- cgit v1.2.3