diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-10-02 10:27:38 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-10-02 13:21:09 +0200 |
commit | b1afde8ada7959b29acb4ac0fae87d7a8ae8aa08 (patch) | |
tree | 32fb1e8916d28e0c03f16b71b312cf774959394b /tests/auto/qml/qmllint/tst_qmllint.cpp | |
parent | 45594322fe91eadcd9b2d7b1d76c1a6662bc1472 (diff) |
qmllint: Ignore grouped properties again
We cannot handle those, yet. Add tests that prove correct grouped
properties pass and incorrect ones are expected to fail at causing
qmllint to fail for now.
Task-number: QTBUG-87116
Change-Id: I0aeed15d262e2c6226e27d5d92890c5385a38936
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmllint/tst_qmllint.cpp')
-rw-r--r-- | tests/auto/qml/qmllint/tst_qmllint.cpp | 48 |
1 files changed, 39 insertions, 9 deletions
diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index 1a36986663..cd0042d291 100644 --- a/tests/auto/qml/qmllint/tst_qmllint.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -53,7 +53,11 @@ private Q_SLOTS: void directoryPassedAsQmlTypesFile(); private: - QString runQmllint(const QString &fileToLint, bool shouldSucceed, const QStringList &extraArgs = QStringList()); + QString runQmllint(const QString &fileToLint, + std::function<void(QProcess &)> handleResult, + const QStringList &extraArgs = QStringList()); + QString runQmllint(const QString &fileToLint, bool shouldSucceed, + const QStringList &extraArgs = QStringList()); QString m_qmllintPath; }; @@ -195,6 +199,14 @@ void TestQmllint::dirtyQmlCode_data() << QStringLiteral("badEnumFromQtQml.qml") << QString("Warning: Property \"Linear123\" not found on type \"QQmlEasingEnums\"") << QString(); + QTest::newRow("nanchors1") + << QStringLiteral("nanchors1.qml") + << QString() + << QString(); + QTest::newRow("nanchors3") + << QStringLiteral("nanchors3.qml") + << QString() + << QString(); } void TestQmllint::dirtyQmlCode() @@ -205,7 +217,14 @@ void TestQmllint::dirtyQmlCode() if (warningMessage.contains(QLatin1String("%1"))) warningMessage = warningMessage.arg(testFile(filename)); - const QString output = runQmllint(filename, false); + const QString output = runQmllint(filename, [&](QProcess &process) { + QVERIFY(process.waitForFinished()); + QCOMPARE(process.exitStatus(), QProcess::NormalExit); + QEXPECT_FAIL("nanchors1", "Invalid grouped properties are not detected", Abort); + QEXPECT_FAIL("nanchors3", "Invalid grouped properties are not detected", Abort); + QVERIFY(process.exitCode() != 0); + }); + QVERIFY(output.contains(warningMessage)); if (!notContained.isEmpty()) QVERIFY(!output.contains(notContained)); @@ -242,6 +261,8 @@ void TestQmllint::cleanQmlCode_data() QTest::newRow("javascriptMethodsInModule") << QStringLiteral("javascriptMethodsInModuleGood.qml"); QTest::newRow("enumFromQtQml") << QStringLiteral("enumFromQtQml.qml"); + QTest::newRow("anchors1") << QStringLiteral("anchors1.qml"); + QTest::newRow("anchors3") << QStringLiteral("anchors3.qml"); } void TestQmllint::cleanQmlCode() @@ -251,7 +272,9 @@ void TestQmllint::cleanQmlCode() QVERIFY(warnings.isEmpty()); } -QString TestQmllint::runQmllint(const QString &fileToLint, bool shouldSucceed, const QStringList &extraArgs) +QString TestQmllint::runQmllint(const QString &fileToLint, + std::function<void(QProcess &)> handleResult, + const QStringList &extraArgs) { auto qmlImportDir = QLibraryInfo::path(QLibraryInfo::Qml2ImportsPath); QStringList args; @@ -264,12 +287,7 @@ QString TestQmllint::runQmllint(const QString &fileToLint, bool shouldSucceed, c auto verify = [&](bool isSilent) { QProcess process; process.start(m_qmllintPath, args); - QVERIFY(process.waitForFinished()); - QCOMPARE(process.exitStatus(), QProcess::NormalExit); - if (shouldSucceed) - QCOMPARE(process.exitCode(), 0); - else - QVERIFY(process.exitCode() != 0); + handleResult(process); errors = process.readAllStandardError(); if (isSilent) @@ -281,5 +299,17 @@ QString TestQmllint::runQmllint(const QString &fileToLint, bool shouldSucceed, c return errors; } +QString TestQmllint::runQmllint(const QString &fileToLint, bool shouldSucceed, const QStringList &extraArgs) +{ + return runQmllint(fileToLint, [&](QProcess &process) { + QVERIFY(process.waitForFinished()); + QCOMPARE(process.exitStatus(), QProcess::NormalExit); + if (shouldSucceed) + QCOMPARE(process.exitCode(), 0); + else + QVERIFY(process.exitCode() != 0); + }, extraArgs); +} + QTEST_MAIN(TestQmllint) #include "tst_qmllint.moc" |