OpenCoverage

qteamcitylogger.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/testlib/qteamcitylogger.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8namespace QTest {-
9-
10 static const char *incidentType2String(QAbstractTestLogger::IncidentTypes type)-
11 {-
12 switch (type) {-
13 case
never executed: case QAbstractTestLogger::Pass:
QAbstractTestLogger::Pass:
never executed: case QAbstractTestLogger::Pass:
0
14 return
never executed: return "PASS";
"PASS";
never executed: return "PASS";
0
15 case
executed 75 times by 1 test: case QAbstractTestLogger::XFail:
Executed by:
  • tst_selftests - unknown status
QAbstractTestLogger::XFail:
executed 75 times by 1 test: case QAbstractTestLogger::XFail:
Executed by:
  • tst_selftests - unknown status
75
16 return
executed 75 times by 1 test: return "XFAIL";
Executed by:
  • tst_selftests - unknown status
"XFAIL";
executed 75 times by 1 test: return "XFAIL";
Executed by:
  • tst_selftests - unknown status
75
17 case
never executed: case QAbstractTestLogger::Fail:
QAbstractTestLogger::Fail:
never executed: case QAbstractTestLogger::Fail:
0
18 return
never executed: return "FAIL!";
"FAIL!";
never executed: return "FAIL!";
0
19 case
never executed: case QAbstractTestLogger::XPass:
QAbstractTestLogger::XPass:
never executed: case QAbstractTestLogger::XPass:
0
20 return
never executed: return "XPASS";
"XPASS";
never executed: return "XPASS";
0
21 case
never executed: case QAbstractTestLogger::BlacklistedPass:
QAbstractTestLogger::BlacklistedPass:
never executed: case QAbstractTestLogger::BlacklistedPass:
0
22 return
never executed: return "BPASS";
"BPASS";
never executed: return "BPASS";
0
23 case
never executed: case QAbstractTestLogger::BlacklistedFail:
QAbstractTestLogger::BlacklistedFail:
never executed: case QAbstractTestLogger::BlacklistedFail:
0
24 return
never executed: return "BFAIL";
"BFAIL";
never executed: return "BFAIL";
0
25 }-
26 return
never executed: return "??????";
"??????";
never executed: return "??????";
0
27 }-
28-
29 static const char *messageType2String(QAbstractTestLogger::MessageTypes type)-
30 {-
31 switch (type) {-
32 case
never executed: case QAbstractTestLogger::Skip:
QAbstractTestLogger::Skip:
never executed: case QAbstractTestLogger::Skip:
0
33 return
never executed: return "SKIP";
"SKIP";
never executed: return "SKIP";
0
34 case
executed 10 times by 1 test: case QAbstractTestLogger::Warn:
Executed by:
  • tst_selftests - unknown status
QAbstractTestLogger::Warn:
executed 10 times by 1 test: case QAbstractTestLogger::Warn:
Executed by:
  • tst_selftests - unknown status
10
35 return
executed 10 times by 1 test: return "WARNING";
Executed by:
  • tst_selftests - unknown status
"WARNING";
executed 10 times by 1 test: return "WARNING";
Executed by:
  • tst_selftests - unknown status
10
36 case
executed 10020 times by 1 test: case QAbstractTestLogger::QWarning:
Executed by:
  • tst_selftests - unknown status
QAbstractTestLogger::QWarning:
executed 10020 times by 1 test: case QAbstractTestLogger::QWarning:
Executed by:
  • tst_selftests - unknown status
10020
37 return
executed 10020 times by 1 test: return "QWARN";
Executed by:
  • tst_selftests - unknown status
"QWARN";
executed 10020 times by 1 test: return "QWARN";
Executed by:
  • tst_selftests - unknown status
10020
38 case
executed 448 times by 1 test: case QAbstractTestLogger::QDebug:
Executed by:
  • tst_selftests - unknown status
QAbstractTestLogger::QDebug:
executed 448 times by 1 test: case QAbstractTestLogger::QDebug:
Executed by:
  • tst_selftests - unknown status
448
39 return
executed 448 times by 1 test: return "QDEBUG";
Executed by:
  • tst_selftests - unknown status
"QDEBUG";
executed 448 times by 1 test: return "QDEBUG";
Executed by:
  • tst_selftests - unknown status
448
40 case
executed 10 times by 1 test: case QAbstractTestLogger::QInfo:
Executed by:
  • tst_selftests - unknown status
QAbstractTestLogger::QInfo:
executed 10 times by 1 test: case QAbstractTestLogger::QInfo:
Executed by:
  • tst_selftests - unknown status
10
41 return
executed 10 times by 1 test: return "QINFO";
Executed by:
  • tst_selftests - unknown status
"QINFO";
executed 10 times by 1 test: return "QINFO";
Executed by:
  • tst_selftests - unknown status
10
42 case
executed 5 times by 1 test: case QAbstractTestLogger::QSystem:
Executed by:
  • tst_selftests - unknown status
QAbstractTestLogger::QSystem:
executed 5 times by 1 test: case QAbstractTestLogger::QSystem:
Executed by:
  • tst_selftests - unknown status
5
43 return
executed 5 times by 1 test: return "QSYSTEM";
Executed by:
  • tst_selftests - unknown status
"QSYSTEM";
executed 5 times by 1 test: return "QSYSTEM";
Executed by:
  • tst_selftests - unknown status
5
44 case
executed 10 times by 1 test: case QAbstractTestLogger::QFatal:
Executed by:
  • tst_selftests - unknown status
QAbstractTestLogger::QFatal:
executed 10 times by 1 test: case QAbstractTestLogger::QFatal:
Executed by:
  • tst_selftests - unknown status
10
45 return
executed 10 times by 1 test: return "QFATAL";
Executed by:
  • tst_selftests - unknown status
"QFATAL";
executed 10 times by 1 test: return "QFATAL";
Executed by:
  • tst_selftests - unknown status
10
46 case
executed 155 times by 1 test: case QAbstractTestLogger::Info:
Executed by:
  • tst_selftests - unknown status
QAbstractTestLogger::Info:
executed 155 times by 1 test: case QAbstractTestLogger::Info:
Executed by:
  • tst_selftests - unknown status
155
47 return
executed 155 times by 1 test: return "INFO";
Executed by:
  • tst_selftests - unknown status
"INFO";
executed 155 times by 1 test: return "INFO";
Executed by:
  • tst_selftests - unknown status
155
48 }-
49 return
never executed: return "??????";
"??????";
never executed: return "??????";
0
50 }-
51}-
52-
53QTeamCityLogger::QTeamCityLogger(const char *filename)-
54 : QAbstractTestLogger(filename)-
55{-
56}
executed 146 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
146
57-
58QTeamCityLogger::~QTeamCityLogger()-
59{-
60}-
61-
62void QTeamCityLogger::startLogging()-
63{-
64 QAbstractTestLogger::startLogging();-
65-
66 QString testSuiteName = tcEscapedString(QString::fromUtf8(QTestResult::currentTestObjectName()));-
67-
68 QString str = QString(QLatin1String("##teamcity[testSuiteStarted name='%1']\n")).arg(testSuiteName);-
69 outputString(QString(str).toLocal8Bit().constData());-
70}
executed 146 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
146
71-
72void QTeamCityLogger::stopLogging()-
73{-
74 QString testSuiteName = tcEscapedString(QString::fromUtf8(QTestResult::currentTestObjectName()));-
75-
76 QString str = QString(QLatin1String("##teamcity[testSuiteFinished name='%1']\n")).arg(testSuiteName);-
77 outputString(QString(str).toLocal8Bit().constData());-
78-
79 QAbstractTestLogger::stopLogging();-
80}
executed 146 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
146
81-
82void QTeamCityLogger::enterTestFunction(const char * )-
83{-
84-
85}-
86-
87void QTeamCityLogger::leaveTestFunction()-
88{-
89-
90}-
91-
92void QTeamCityLogger::addIncident(IncidentTypes type, const char *description,-
93 const char *file, int line)-
94{-
95-
96 if ((type == QAbstractTestLogger::Pass
type == QAbstr...stLogger::PassDescription
TRUEevaluated 887 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 611 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
|| type == QAbstractTestLogger::XFail
type == QAbstr...tLogger::XFailDescription
TRUEevaluated 75 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 536 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) && QTestLog::verboseLevel() < 0
QTestLog::verboseLevel() < 0Description
TRUEnever evaluated
FALSEevaluated 962 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
)
0-962
97 return;
never executed: return;
0
98-
99 QString buf;-
100-
101 QString tmpFuncName = escapedTestFuncName();-
102-
103 if (tmpFuncName != currTestFuncName
tmpFuncName !=...rrTestFuncNameDescription
TRUEevaluated 1418 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 80 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) {
80-1418
104 buf = QString(QLatin1String("##teamcity[testStarted name='%1']\n")).arg(tmpFuncName);-
105 outputString(QString(buf).toLocal8Bit().constData());-
106 }
executed 1418 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
1418
107-
108 currTestFuncName = tmpFuncName;-
109-
110 if (type == QAbstractTestLogger::XFail
type == QAbstr...tLogger::XFailDescription
TRUEevaluated 75 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 1423 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) {
75-1423
111 addPendingMessage(QTest::incidentType2String(type), QString::fromUtf8(description), file, line);-
112 return;
executed 75 times by 1 test: return;
Executed by:
  • tst_selftests - unknown status
75
113 }-
114-
115 QString detailedText = QString::fromUtf8(description);-
116 detailedText = tcEscapedString(detailedText);-
117-
118-
119 if ((
(type == QAbst...tLogger::Fail)Description
TRUEevaluated 516 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 907 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
type == QAbstractTestLogger::Fail)
(type == QAbst...tLogger::Fail)Description
TRUEevaluated 516 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 907 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
|| (
(type == QAbst...Logger::XPass)Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 887 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
type == QAbstractTestLogger::XPass)
(type == QAbst...Logger::XPass)Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 887 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) {
20-907
120 QString messageText(QLatin1String("Failure!"));-
121-
122 if (file
fileDescription
TRUEevaluated 502 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 34 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
)
34-502
123 messageText += QString(QLatin1String(" |[Loc: %1(%2)|]")).arg(QString::fromUtf8(file)).arg(line);
executed 502 times by 1 test: messageText += QString(QLatin1String(" |[Loc: %1(%2)|]")).arg(QString::fromUtf8(file)).arg(line);
Executed by:
  • tst_selftests - unknown status
502
124-
125 buf = QString(QLatin1String("##teamcity[testFailed name='%1' message='%2' details='%3']\n"))-
126 .arg(tmpFuncName)-
127 .arg(messageText)-
128 .arg(detailedText);-
129-
130 outputString(QString(buf).toLocal8Bit().constData());-
131 }
executed 536 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
536
132-
133 if (!pendingMessages.isEmpty()
!pendingMessages.isEmpty()Description
TRUEevaluated 378 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 1045 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) {
378-1045
134 buf = QString(QLatin1String("##teamcity[testStdOut name='%1' out='%2']\n"))-
135 .arg(tmpFuncName)-
136 .arg(pendingMessages);-
137-
138 outputString(QString(buf).toLocal8Bit().constData());-
139-
140 pendingMessages.clear();-
141 }
executed 378 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
378
142-
143 buf = QString(QLatin1String("##teamcity[testFinished name='%1']\n")).arg(tmpFuncName);-
144 outputString(QString(buf).toLocal8Bit().constData());-
145}
executed 1423 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
1423
146-
147void QTeamCityLogger::addBenchmarkResult(const QBenchmarkResult &)-
148{-
149-
150}-
151-
152void QTeamCityLogger::addMessage(MessageTypes type, const QString &message,-
153 const char *file, int line)-
154{-
155-
156 if (type != QAbstractTestLogger::QFatal
type != QAbstr...Logger::QFatalDescription
TRUEevaluated 10833 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
&& QTestLog::verboseLevel() < 0
QTestLog::verboseLevel() < 0Description
TRUEnever evaluated
FALSEevaluated 10833 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
)
0-10833
157 return;
never executed: return;
0
158-
159 QString escapedMessage = tcEscapedString(message);-
160-
161 QString buf;-
162-
163 if (type == QAbstractTestLogger::Skip
type == QAbstr...stLogger::SkipDescription
TRUEevaluated 185 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 10658 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) {
185-10658
164 if (file
fileDescription
TRUEevaluated 185 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEnever evaluated
)
0-185
165 escapedMessage.append(QString(QLatin1String(" |[Loc: %1(%2)|]")).arg(QString::fromUtf8(file)).arg(line));
executed 185 times by 1 test: escapedMessage.append(QString(QLatin1String(" |[Loc: %1(%2)|]")).arg(QString::fromUtf8(file)).arg(line));
Executed by:
  • tst_selftests - unknown status
185
166-
167 buf = QString(QLatin1String("##teamcity[testIgnored name='%1' message='%2']\n"))-
168 .arg(escapedTestFuncName())-
169 .arg(escapedMessage);-
170-
171 outputString(QString(buf).toLocal8Bit().constData());-
172 }
executed 185 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
185
173 else {-
174 addPendingMessage(QTest::messageType2String(type), escapedMessage, file, line);-
175 }
executed 10658 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
10658
176}-
177-
178QString QTeamCityLogger::tcEscapedString(const QString &str) const-
179{-
180 QString formattedString;-
181-
182 for (int i = 0; i < str.length()
i < str.length()Description
TRUEevaluated 144034 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 14241 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
; i++) {
14241-144034
183 QChar ch = str.at(i);-
184-
185 switch (ch.toLatin1()) {-
186 case
executed 380 times by 1 test: case '\n':
Executed by:
  • tst_selftests - unknown status
'\n':
executed 380 times by 1 test: case '\n':
Executed by:
  • tst_selftests - unknown status
380
187 formattedString.append(QLatin1Literal("|n"));-
188 break;
executed 380 times by 1 test: break;
Executed by:
  • tst_selftests - unknown status
380
189 case
never executed: case '\r':
'\r':
never executed: case '\r':
0
190 formattedString.append(QLatin1Literal("|r"));-
191 break;
never executed: break;
0
192 case
never executed: case '|':
'|':
never executed: case '|':
0
193 formattedString.append(QLatin1Literal("||"));-
194 break;
never executed: break;
0
195 case
executed 10 times by 1 test: case '[':
Executed by:
  • tst_selftests - unknown status
'[':
executed 10 times by 1 test: case '[':
Executed by:
  • tst_selftests - unknown status
10
196 formattedString.append(QLatin1Literal("|["));-
197 break;
executed 10 times by 1 test: break;
Executed by:
  • tst_selftests - unknown status
10
198 case
executed 130 times by 1 test: case ']':
Executed by:
  • tst_selftests - unknown status
']':
executed 130 times by 1 test: case ']':
Executed by:
  • tst_selftests - unknown status
130
199 formattedString.append(QLatin1Literal("|]"));-
200 break;
executed 130 times by 1 test: break;
Executed by:
  • tst_selftests - unknown status
130
201 case
executed 420 times by 1 test: case '\'':
Executed by:
  • tst_selftests - unknown status
'\'':
executed 420 times by 1 test: case '\'':
Executed by:
  • tst_selftests - unknown status
420
202 formattedString.append(QLatin1Literal("|'"));-
203 break;
executed 420 times by 1 test: break;
Executed by:
  • tst_selftests - unknown status
420
204 default
executed 143094 times by 1 test: default:
Executed by:
  • tst_selftests - unknown status
:
executed 143094 times by 1 test: default:
Executed by:
  • tst_selftests - unknown status
143094
205 formattedString.append(ch);-
206 }
executed 143094 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
143094
207 }-
208-
209 return
executed 14241 times by 1 test: return std::move(formattedString).simplified();
Executed by:
  • tst_selftests - unknown status
std::move(formattedString).simplified();
executed 14241 times by 1 test: return std::move(formattedString).simplified();
Executed by:
  • tst_selftests - unknown status
14241
210}-
211-
212QString QTeamCityLogger::escapedTestFuncName() const-
213{-
214 const char *fn = QTestResult::currentTestFunction()
QTestResult::c...TestFunction()Description
TRUEevaluated 1683 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEnever evaluated
? QTestResult::currentTestFunction()
0-1683
215 : "UnknownTestFunc";-
216 const char *tag = QTestResult::currentDataTag()
QTestResult::currentDataTag()Description
TRUEevaluated 1070 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 613 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
? QTestResult::currentDataTag() : "";
613-1070
217-
218 QString str = QString(QLatin1String("%1(%2)")).arg(QString::fromUtf8(fn)).arg(QString::fromUtf8(tag));-
219 str = tcEscapedString(str);-
220-
221 return
executed 1683 times by 1 test: return str;
Executed by:
  • tst_selftests - unknown status
str;
executed 1683 times by 1 test: return str;
Executed by:
  • tst_selftests - unknown status
1683
222}-
223-
224void QTeamCityLogger::addPendingMessage(const char *type, const QString &msg, const char *file, int line)-
225{-
226 QString pendMessage;-
227-
228 if (!pendingMessages.isEmpty()
!pendingMessages.isEmpty()Description
TRUEevaluated 10355 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 378 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
)
378-10355
229 pendMessage += QLatin1String("|n");
executed 10355 times by 1 test: pendMessage += QLatin1String("|n");
Executed by:
  • tst_selftests - unknown status
10355
230-
231 if (file
fileDescription
TRUEevaluated 205 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEevaluated 10528 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
) {
205-10528
232 pendMessage += QString(QLatin1String("%1 |[Loc: %2(%3)|]: %4"))-
233 .arg(QString::fromUtf8(type))-
234 .arg(QString::fromUtf8(file))-
235 .arg(line)-
236 .arg(msg);-
237-
238 }
executed 205 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
205
239 else {-
240 pendMessage += QString(QLatin1String("%1: %2"))-
241 .arg(QString::fromUtf8(type))-
242 .arg(msg);-
243 }
executed 10528 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
10528
244-
245 pendingMessages.append(pendMessage);-
246}
executed 10733 times by 1 test: end of block
Executed by:
  • tst_selftests - unknown status
10733
247-
248-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9