From f54b4793eeef2e83e661ffdfe1e2a582a6307a9b Mon Sep 17 00:00:00 2001 From: Magdalena Stojek Date: Thu, 12 Dec 2024 14:17:37 +0100 Subject: [PATCH] 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 (cherry picked from commit 95f02adf756d1ae485f39a060c6f23a5af3f64ee) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 7ab145a9ef20d1a7b787bcae82ce0196e60ca6c5) --- src/testlib/qplaintestlogger.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index 250015f7d62..5cb3f7dadc5 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -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);