Testlib: Output total test time in plain text logger.
This makes it easier to spot slow tests. Produces: Totals: 314 passed, 0 failed, 0 skipped, 0 blacklisted, 137ms ********* Finished testing of tst_QStringRef ********* Task-number: QTBUG-38890 Change-Id: Iaee4dd677fd8f18b82f7c9c4934eb5b1119ade43 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>
This commit is contained in:
parent
c23a086e4f
commit
84042523f2
@ -348,16 +348,17 @@ void QPlainTestLogger::startLogging()
|
|||||||
void QPlainTestLogger::stopLogging()
|
void QPlainTestLogger::stopLogging()
|
||||||
{
|
{
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
const int timeMs = qRound(QTestLog::msecsTotalTime());
|
||||||
if (QTestLog::verboseLevel() < 0) {
|
if (QTestLog::verboseLevel() < 0) {
|
||||||
qsnprintf(buf, sizeof(buf), "Totals: %d passed, %d failed, %d skipped, %d blacklisted\n",
|
qsnprintf(buf, sizeof(buf), "Totals: %d passed, %d failed, %d skipped, %d blacklisted, %dms\n",
|
||||||
QTestLog::passCount(), QTestLog::failCount(),
|
QTestLog::passCount(), QTestLog::failCount(),
|
||||||
QTestLog::skipCount(), QTestLog::blacklistCount());
|
QTestLog::skipCount(), QTestLog::blacklistCount(), timeMs);
|
||||||
} else {
|
} else {
|
||||||
qsnprintf(buf, sizeof(buf),
|
qsnprintf(buf, sizeof(buf),
|
||||||
"Totals: %d passed, %d failed, %d skipped, %d blacklisted\n"
|
"Totals: %d passed, %d failed, %d skipped, %d blacklisted, %dms\n"
|
||||||
"********* Finished testing of %s *********\n",
|
"********* Finished testing of %s *********\n",
|
||||||
QTestLog::passCount(), QTestLog::failCount(),
|
QTestLog::passCount(), QTestLog::failCount(),
|
||||||
QTestLog::skipCount(), QTestLog::blacklistCount(),
|
QTestLog::skipCount(), QTestLog::blacklistCount(), timeMs,
|
||||||
QTestResult::currentTestObjectName());
|
QTestResult::currentTestObjectName());
|
||||||
}
|
}
|
||||||
outputMessage(buf);
|
outputMessage(buf);
|
||||||
|
@ -775,6 +775,10 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge
|
|||||||
QRegularExpressionMatch match = durationRegExp.match(line);
|
QRegularExpressionMatch match = durationRegExp.match(line);
|
||||||
QVERIFY2(match.hasMatch(), qPrintable(QString::fromLatin1("Invalid Duration tag at line %1 (%2): '%3'")
|
QVERIFY2(match.hasMatch(), qPrintable(QString::fromLatin1("Invalid Duration tag at line %1 (%2): '%3'")
|
||||||
.arg(i).arg(loggers.at(n), output)));
|
.arg(i).arg(loggers.at(n), output)));
|
||||||
|
} else if (line.startsWith("Totals:")) {
|
||||||
|
const int lastCommaPos = line.lastIndexOf(',');
|
||||||
|
if (lastCommaPos > 0)
|
||||||
|
line.truncate(lastCommaPos); // Plain text logger: strip time (", 2323dms").
|
||||||
} else {
|
} else {
|
||||||
QVERIFY2(output == expected,
|
QVERIFY2(output == expected,
|
||||||
qPrintable(QString::fromLatin1("Mismatch at line %1 (%2, %3):\n'%4'\n !=\n'%5'")
|
qPrintable(QString::fromLatin1("Mismatch at line %1 (%2, %3):\n'%4'\n !=\n'%5'")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user