diff options
author | Jason McDonald <jason.mcdonald@nokia.com> | 2011-09-02 17:08:20 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-09-05 06:33:07 +0200 |
commit | cab90f8c8b19892b2e026d12411702dbc8c10fb9 (patch) | |
tree | 5163e3739d118b646b56cda5a48228e15ae49d6c /src/testlib/qtestlog.cpp | |
parent | 91fe1fd9e8f5b040511721cb64b11772e034b265 (diff) |
Pass log file name when constructing loggers.
Pass the filename when creating the logger rather than when commencing
output. This will simplify forthcoming changes for running multiple
loggers.
Change-Id: I563aa97661caf279a5dcccb1321ff3ce4725b332
Reviewed-on: http://codereview.qt.nokia.com/4116
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'src/testlib/qtestlog.cpp')
-rw-r--r-- | src/testlib/qtestlog.cpp | 62 |
1 files changed, 23 insertions, 39 deletions
diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp index 410972db0f..d53b00ca7f 100644 --- a/src/testlib/qtestlog.cpp +++ b/src/testlib/qtestlog.cpp @@ -87,7 +87,6 @@ namespace QTest { static int maxWarnings = 2002; static QAbstractTestLogger *testLogger = 0; - static const char *outFile = 0; static QtMsgHandler oldMessageHandler; @@ -164,24 +163,6 @@ namespace QTest { break; } } - - void initLogger() - { - switch (QTest::logMode) { - case QTestLog::Plain: - QTest::testLogger = new QPlainTestLogger; - break; - case QTestLog::XML: - QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Complete); - break; - case QTestLog::LightXML: - QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Light); - break; - case QTestLog::XunitXML: - QTest::testLogger = new QXunitTestLogger(); - break; - } - } } void QTestLog::enterTestFunction(const char* function) @@ -276,9 +257,8 @@ void QTestLog::addBenchmarkResult(const QBenchmarkResult &result) void QTestLog::startLogging() { - QTEST_ASSERT(!QTest::testLogger); - QTest::initLogger(); - QTest::testLogger->startLogging(QTest::outFile); + QTEST_ASSERT(QTest::testLogger); + QTest::testLogger->startLogging(); QTest::oldMessageHandler = qInstallMsgHandler(QTest::messageHandler); } @@ -292,6 +272,27 @@ void QTestLog::stopLogging() QTest::testLogger = 0; } +void QTestLog::initLogger(LogMode mode, const char *filename) +{ + QTest::logMode = mode; + + switch (mode) { + case QTestLog::Plain: + QTest::testLogger = new QPlainTestLogger(filename); + break; + case QTestLog::XML: + QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Complete, filename); + break; + case QTestLog::LightXML: + QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Light, filename); + break; + case QTestLog::XunitXML: + QTest::testLogger = new QXunitTestLogger(filename); + break; + } + QTEST_ASSERT(QTest::testLogger); +} + void QTestLog::warn(const char *msg) { QTEST_ASSERT(QTest::testLogger); @@ -308,11 +309,6 @@ void QTestLog::info(const char *msg, const char *file, int line) QTest::testLogger->addMessage(QAbstractTestLogger::Info, msg, file, line); } -void QTestLog::setLogMode(LogMode mode) -{ - QTest::logMode = mode; -} - QTestLog::LogMode QTestLog::logMode() { return QTest::logMode; @@ -344,18 +340,6 @@ void QTestLog::addIgnoreMessage(QtMsgType type, const char *msg) list->next = item; } -void QTestLog::redirectOutput(const char *fileName) -{ - QTEST_ASSERT(fileName); - - QTest::outFile = fileName; -} - -const char *QTestLog::outputFileName() -{ - return QTest::outFile; -} - void QTestLog::setMaxWarnings(int m) { QTest::maxWarnings = m <= 0 ? INT_MAX : m + 2; |