Output both global and local data tags in benchmark result header

Modified QPlainTestLogger::printBenchmarkResultsHeader() to
concatenate and display both global and local data tags, in
the benchmark result header, in the format `global:local`.
If only one tag is available, it is printed alone.

Pick-to: 6.5
Fixes: QTBUG-127522
Change-Id: Ic9f3c712ef3f6858aad2546b80d8867ce860b644
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
(cherry picked from commit 95f02adf756d1ae485f39a060c6f23a5af3f64ee)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 7ab145a9ef20d1a7b787bcae82ce0196e60ca6c5)
This commit is contained in:
Magdalena Stojek 2024-12-12 14:17:37 +01:00 committed by Qt Cherry-pick Bot
parent 29a793f3ff
commit f54b4793ee

View File

@ -301,8 +301,15 @@ void QPlainTestLogger::printBenchmarkResultsHeader(const QBenchmarkResult &resul
buf.appendf("%s: %s::%s", QTest::benchmarkResult2String(),
QTestResult::currentTestObjectName(), result.context.slotName.toLatin1().data());
if (QByteArray tag = result.context.tag.toLocal8Bit(); !tag.isEmpty())
buf.appendf(":\"%s\":\n", tag.data());
QByteArray tag = QTestResult::currentDataTag();
QByteArray gtag = QTestResult::currentGlobalDataTag();
if (!gtag.isEmpty() && !tag.isEmpty())
buf.appendf(":\"%s:%s\":\n", gtag.constData(), tag.constData());
else if (!gtag.isEmpty())
buf.appendf(":\"%s\":\n", gtag.constData());
else if (!tag.isEmpty())
buf.appendf(":\"%s\":\n", tag.constData());
else
buf.append(":\n");
outputMessage(buf);