testlib: Let logger report whether it is logging to stdout
Change-Id: I7df61b4fdc8c431a73c4b399e2f620923a7c7217 Reviewed-by: Simon Hausmann <hausmann@gmail.com>
This commit is contained in:
parent
04549f68ab
commit
81957e753e
@ -90,6 +90,11 @@ QAbstractTestLogger::~QAbstractTestLogger()
|
||||
stream = nullptr;
|
||||
}
|
||||
|
||||
bool QAbstractTestLogger::isLoggingToStdout() const
|
||||
{
|
||||
return stream == stdout;
|
||||
}
|
||||
|
||||
void QAbstractTestLogger::filterUnprintable(char *str) const
|
||||
{
|
||||
unsigned char *idx = reinterpret_cast<unsigned char *>(str);
|
||||
|
@ -106,6 +106,8 @@ public:
|
||||
virtual void addMessage(MessageTypes type, const QString &message,
|
||||
const char *file = nullptr, int line = 0) = 0;
|
||||
|
||||
bool isLoggingToStdout() const;
|
||||
|
||||
void outputString(const char *msg);
|
||||
|
||||
protected:
|
||||
|
@ -169,7 +169,6 @@ namespace QTest {
|
||||
static IgnoreResultList *ignoreResultList = nullptr;
|
||||
|
||||
static QList<QAbstractTestLogger *> loggers;
|
||||
static bool loggerUsingStdout = false;
|
||||
|
||||
static int verbosity = 0;
|
||||
static int maxWarnings = 2002;
|
||||
@ -431,7 +430,6 @@ void QTestLog::stopLogging()
|
||||
delete logger;
|
||||
}
|
||||
QTest::loggers.clear();
|
||||
QTest::loggerUsingStdout = false;
|
||||
saveCoverageTool(QTestResult::currentAppName(), failCount() != 0, QTestLog::installedTestCoverage());
|
||||
}
|
||||
|
||||
@ -439,8 +437,6 @@ void QTestLog::addLogger(LogMode mode, const char *filename)
|
||||
{
|
||||
if (filename && strcmp(filename, "-") == 0)
|
||||
filename = nullptr;
|
||||
if (!filename)
|
||||
QTest::loggerUsingStdout = true;
|
||||
|
||||
QAbstractTestLogger *logger = nullptr;
|
||||
switch (mode) {
|
||||
@ -488,7 +484,12 @@ int QTestLog::loggerCount()
|
||||
|
||||
bool QTestLog::loggerUsingStdout()
|
||||
{
|
||||
return QTest::loggerUsingStdout;
|
||||
FOREACH_TEST_LOGGER {
|
||||
if (logger->isLoggingToStdout())
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void QTestLog::warn(const char *msg, const char *file, int line)
|
||||
|
Loading…
x
Reference in New Issue
Block a user