diff --git a/src/qmllint/qqmllinter.cpp b/src/qmllint/qqmllinter.cpp index 1268f00a61..be7eeb516c 100644 --- a/src/qmllint/qqmllinter.cpp +++ b/src/qmllint/qqmllinter.cpp @@ -121,7 +121,11 @@ bool QQmlLinter::lintFile(const QString &filename, const QString *fileContents, QFile file(filename); if (!file.open(QFile::ReadOnly)) { if (json) { - result[u"openFailed"] = true; + addJsonWarning(QQmlJS::DiagnosticMessage { + QStringLiteral("Failed to open file %1: %2").arg(filename, file.errorString()), + QtCriticalMsg, + QQmlJS::SourceLocation() + }); success = false; } else if (!silent) { qWarning() << "Failed to open file" << filename << file.error(); diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index efa2e4ff08..e53074de5c 100644 --- a/tests/auto/qml/qmllint/tst_qmllint.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -1048,14 +1048,14 @@ void TestQmllint::callQmllint(const QString &fileToLint, bool shouldSucceed, QJs bool success = m_linter.lintFile(QFileInfo(fileToLint).isAbsolute() ? fileToLint : testFile(fileToLint), - nullptr, true, warnings ? &jsonOutput : nullptr, + nullptr, false, warnings ? &jsonOutput : nullptr, m_defaultImportPaths, QStringList(), QStringList(), {}); - QCOMPARE(success, shouldSucceed); - if (warnings) { - Q_ASSERT(jsonOutput.size() == 1); + QVERIFY2(jsonOutput.size() == 1, QJsonDocument(jsonOutput).toJson()); *warnings = jsonOutput.at(0)[u"warnings"_qs].toArray(); } + + QCOMPARE(success, shouldSucceed); } void TestQmllint::requiredProperty() diff --git a/tools/qmllint/main.cpp b/tools/qmllint/main.cpp index 652f6ea83a..0d2ebafc51 100644 --- a/tools/qmllint/main.cpp +++ b/tools/qmllint/main.cpp @@ -51,7 +51,7 @@ #include -constexpr int JSON_LOGGING_FORMAT_REVISION = 1; +constexpr int JSON_LOGGING_FORMAT_REVISION = 2; int main(int argv, char *argc[]) {