From 3d8702378ba7f8252862aac8d71995d61f4f2b69 Mon Sep 17 00:00:00 2001 From: Maximilian Goldstein Date: Mon, 23 May 2022 10:43:24 +0200 Subject: tst_qmllint: Write clearer descriptions when unexpected output is found Previously we just crammed it all into one line. This made debugging really painful. You either had to properly cut out the source code, remove all the additional quoting and reformat it or run qmllint manually to get proper formatted output. This way you can actually debug these issues without resorting to any external tools. Change-Id: Iafdaaaa0ef7b96e70057b9b637b7c8f051d9e43a Reviewed-by: Fabian Kosmale Reviewed-by: Ulf Hermann --- tests/auto/qml/qmllint/tst_qmllint.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index ecc7641cc8..fa87617bfb 100644 --- a/tests/auto/qml/qmllint/tst_qmllint.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -1535,13 +1535,9 @@ void TestQmllint::searchWarnings(const QJsonArray &warnings, const QString &subs const auto toDescription = [](const QJsonArray &warnings, const QString &substring, quint32 line, quint32 column, bool must = true) { - // Note: this actually produces a very poorly formatted multi-line - // description, but this is how we also do it in cleanQmlCode test case, - // so this should suffice. in any case this mainly aids the debugging - // and CI stays (or should stay) clean. - QString msg = QStringLiteral("qmllint output '%1' %2 contain '%3'") + QString msg = QStringLiteral("qmllint output:\n%1\nIt %2 contain '%3'") .arg(QString::fromUtf8( - QJsonDocument(warnings).toJson(QJsonDocument::Compact)), + QJsonDocument(warnings).toJson(QJsonDocument::Indented)), must ? u"must" : u"must NOT", substring); if (line != 0 || column != 0) msg += u" (%1:%2)"_s.arg(line).arg(column); @@ -1551,11 +1547,11 @@ void TestQmllint::searchWarnings(const QJsonArray &warnings, const QString &subs if (shouldContain == StringContained) { if (!contains) - qWarning() << toDescription(warnings, substring, line, column); + qWarning().noquote() << toDescription(warnings, substring, line, column); QVERIFY(contains); } else { if (contains) - qWarning() << toDescription(warnings, substring, line, column, false); + qWarning().noquote() << toDescription(warnings, substring, line, column, false); QVERIFY(!contains); } } -- cgit v1.2.3