diff options
author | Maximilian Goldstein <max.goldstein@qt.io> | 2022-05-23 10:43:24 +0200 |
---|---|---|
committer | Maximilian Goldstein <max.goldstein@qt.io> | 2022-05-24 15:44:16 +0200 |
commit | 3d8702378ba7f8252862aac8d71995d61f4f2b69 (patch) | |
tree | ee430ae1fda7facad00685de84453aaad90806ce | |
parent | 66d80fdf2c9bfc65f6d37a873d3b6304b672aa85 (diff) |
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 <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r-- | tests/auto/qml/qmllint/tst_qmllint.cpp | 12 |
1 files 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); } } |