diff options
| author | Edward Welbourne <edward.welbourne@qt.io> | 2021-09-23 15:59:32 +0200 |
|---|---|---|
| committer | Edward Welbourne <edward.welbourne@qt.io> | 2021-12-09 20:54:26 +0100 |
| commit | 77a93e6df331e5ed22aef4335d8de38abe2ca586 (patch) | |
| tree | ace152ec3685282a07f890e4c95aac057693b5e5 /src/testlib/qteamcitylogger.cpp | |
| parent | 1c24b4b8d9fe16eaa4bc1598df117593d814bf50 (diff) | |
Make Skip an incident in test logging
Skip ends the test (albeit inconclusively). Rearrange the enums in
the abstract logger, move code to handle skip between relevant
function and tidy up various things that became simpler as a result.
Also reorder the message enum, and its switches, to separate testlib's
internals from the usual Qt messages, and put each group in ascending
order of severity.
Task-number: QTBUG-96844
Change-Id: I2c7a634b9f849830d64eafa750155e66e244b729
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/testlib/qteamcitylogger.cpp')
| -rw-r--r-- | src/testlib/qteamcitylogger.cpp | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/src/testlib/qteamcitylogger.cpp b/src/testlib/qteamcitylogger.cpp index 5ee68af9ad2..10d91be178d 100644 --- a/src/testlib/qteamcitylogger.cpp +++ b/src/testlib/qteamcitylogger.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2016 Borgar Ovsthus +** Copyright (C) 2021 The Qt Company Ltd. +** Copyright (C) 2017 Borgar Ovsthus ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtTest module of the Qt Toolkit. @@ -54,6 +55,8 @@ namespace QTest { static const char *incidentType2String(QAbstractTestLogger::IncidentTypes type) { switch (type) { + case QAbstractTestLogger::Skip: + return "SKIP"; case QAbstractTestLogger::Pass: return "PASS"; case QAbstractTestLogger::XFail: @@ -77,22 +80,20 @@ namespace QTest { static const char *messageType2String(QAbstractTestLogger::MessageTypes type) { switch (type) { - case QAbstractTestLogger::Skip: - return "SKIP"; - case QAbstractTestLogger::Warn: - return "WARNING"; - case QAbstractTestLogger::QWarning: - return "QWARN"; case QAbstractTestLogger::QDebug: return "QDEBUG"; case QAbstractTestLogger::QInfo: return "QINFO"; + case QAbstractTestLogger::QWarning: + return "QWARN"; case QAbstractTestLogger::QCritical: return "QCRITICAL"; case QAbstractTestLogger::QFatal: return "QFATAL"; case QAbstractTestLogger::Info: return "INFO"; + case QAbstractTestLogger::Warn: + return "WARNING"; } return "??????"; } @@ -173,6 +174,14 @@ void QTeamCityLogger::addIncident(IncidentTypes type, const char *description, flowID); outputString(qPrintable(buf)); + } else if (type == QAbstractTestLogger::Skip) { + if (file) + detailedText.append(QLatin1String(" |[Loc: %1(%2)|]").arg(QString::fromUtf8(file)).arg(line)); + + buf = QLatin1String("##teamcity[testIgnored name='%1' message='%2' flowId='%3']\n") + .arg(escapedTestFuncName(), detailedText, flowID); + + outputString(qPrintable(buf)); } if (!pendingMessages.isEmpty()) { @@ -201,21 +210,7 @@ void QTeamCityLogger::addMessage(MessageTypes type, const QString &message, return; QString escapedMessage = tcEscapedString(message); - - QString buf; - - if (type == QAbstractTestLogger::Skip) { - if (file) - escapedMessage.append(QString(QLatin1String(" |[Loc: %1(%2)|]")).arg(QString::fromUtf8(file)).arg(line)); - - buf = QString(QLatin1String("##teamcity[testIgnored name='%1' message='%2' flowId='%3']\n")) - .arg(escapedTestFuncName(), escapedMessage, flowID); - - outputString(qPrintable(buf)); - } - else { - addPendingMessage(QTest::messageType2String(type), escapedMessage, file, line); - } + addPendingMessage(QTest::messageType2String(type), escapedMessage, file, line); } QString QTeamCityLogger::tcEscapedString(const QString &str) const |
