Remove circular dependency in testlib logging code
Pass the output file name from the QTestLog to the test logger when commencing logging rather than having the logger call back into the QTestLog. Change-Id: Id484635f9fcfca08a66c92f3442887e9473b6f9b Reviewed-on: http://codereview.qt.nokia.com/3454 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
This commit is contained in:
parent
14c2d4700c
commit
865c27460e
@ -40,7 +40,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "QtTest/private/qabstracttestlogger_p.h"
|
||||
#include "QtTest/private/qtestlog_p.h"
|
||||
#include "QtTest/qtestassert.h"
|
||||
|
||||
#include "QtCore/qbytearray.h"
|
||||
@ -81,22 +80,21 @@ bool QAbstractTestLogger::isTtyOutput()
|
||||
}
|
||||
|
||||
|
||||
void QAbstractTestLogger::startLogging()
|
||||
void QAbstractTestLogger::startLogging(const char *filename)
|
||||
{
|
||||
QTEST_ASSERT(!QTest::stream);
|
||||
|
||||
const char *out = QTestLog::outputFileName();
|
||||
if (!out) {
|
||||
if (!filename) {
|
||||
QTest::stream = stdout;
|
||||
return;
|
||||
}
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(Q_OS_WINCE)
|
||||
if (::fopen_s(&QTest::stream, out, "wt")) {
|
||||
if (::fopen_s(&QTest::stream, filename, "wt")) {
|
||||
#else
|
||||
QTest::stream = ::fopen(out, "wt");
|
||||
QTest::stream = ::fopen(filename, "wt");
|
||||
if (!QTest::stream) {
|
||||
#endif
|
||||
printf("Unable to open file for logging: %s", out);
|
||||
printf("Unable to open file for logging: %s", filename);
|
||||
::exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ public:
|
||||
QAbstractTestLogger() {}
|
||||
virtual ~QAbstractTestLogger() {}
|
||||
|
||||
virtual void startLogging();
|
||||
virtual void startLogging(const char *filename);
|
||||
virtual void stopLogging();
|
||||
|
||||
virtual void enterTestFunction(const char *function) = 0;
|
||||
|
@ -407,9 +407,9 @@ QPlainTestLogger::~QPlainTestLogger()
|
||||
#endif
|
||||
}
|
||||
|
||||
void QPlainTestLogger::startLogging()
|
||||
void QPlainTestLogger::startLogging(const char *filename)
|
||||
{
|
||||
QAbstractTestLogger::startLogging();
|
||||
QAbstractTestLogger::startLogging(filename);
|
||||
|
||||
char buf[1024];
|
||||
if (QTestLog::verboseLevel() < 0) {
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
QPlainTestLogger();
|
||||
~QPlainTestLogger();
|
||||
|
||||
void startLogging();
|
||||
void startLogging(const char *filename);
|
||||
void stopLogging();
|
||||
|
||||
void enterTestFunction(const char *function);
|
||||
|
@ -296,7 +296,7 @@ void QTestLog::startLogging(unsigned int randomSeed)
|
||||
QTEST_ASSERT(!QTest::testLogger);
|
||||
QTest::initLogger();
|
||||
QTest::testLogger->registerRandomSeed(randomSeed);
|
||||
QTest::testLogger->startLogging();
|
||||
QTest::testLogger->startLogging(QTest::outFile);
|
||||
QTest::oldMessageHandler = qInstallMsgHandler(QTest::messageHandler);
|
||||
}
|
||||
|
||||
@ -304,7 +304,7 @@ void QTestLog::startLogging()
|
||||
{
|
||||
QTEST_ASSERT(!QTest::testLogger);
|
||||
QTest::initLogger();
|
||||
QTest::testLogger->startLogging();
|
||||
QTest::testLogger->startLogging(QTest::outFile);
|
||||
QTest::oldMessageHandler = qInstallMsgHandler(QTest::messageHandler);
|
||||
}
|
||||
|
||||
|
@ -78,9 +78,9 @@ QTestLogger::~QTestLogger()
|
||||
delete filelogger;
|
||||
}
|
||||
|
||||
void QTestLogger::startLogging()
|
||||
void QTestLogger::startLogging(const char *filename)
|
||||
{
|
||||
QAbstractTestLogger::startLogging();
|
||||
QAbstractTestLogger::startLogging(filename);
|
||||
|
||||
switch(format){
|
||||
case TLF_LightXml:{
|
||||
|
@ -74,7 +74,7 @@ class QTestLogger : public QAbstractTestLogger
|
||||
TLF_XunitXml = 2
|
||||
};
|
||||
|
||||
void startLogging();
|
||||
void startLogging(const char *filename);
|
||||
void stopLogging();
|
||||
|
||||
void enterTestFunction(const char *function);
|
||||
|
@ -102,9 +102,9 @@ QXmlTestLogger::~QXmlTestLogger()
|
||||
{
|
||||
}
|
||||
|
||||
void QXmlTestLogger::startLogging()
|
||||
void QXmlTestLogger::startLogging(const char *filename)
|
||||
{
|
||||
QAbstractTestLogger::startLogging();
|
||||
QAbstractTestLogger::startLogging(filename);
|
||||
QTestCharBuffer buf;
|
||||
|
||||
if (xmlmode == QXmlTestLogger::Complete) {
|
||||
|
@ -66,7 +66,7 @@ public:
|
||||
QXmlTestLogger(XmlMode mode = Complete);
|
||||
~QXmlTestLogger();
|
||||
|
||||
void startLogging();
|
||||
void startLogging(const char *filename);
|
||||
void stopLogging();
|
||||
|
||||
void enterTestFunction(const char *function);
|
||||
|
Loading…
Reference in New Issue
Block a user