From bc4be3f98169d7d4ed74d7539299924b57b89bd1 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Sun, 15 Nov 2020 18:51:01 +0100 Subject: qmllint: Check qmltypes files in import path for validity Now that we have a module describing the qmltypes format, we can run qmllint on qmltypes files. Change-Id: I23339e52b5081ecb6a2c3b127078389a2b8faab0 Reviewed-by: Fabian Kosmale --- tests/auto/qml/qmllint/tst_qmllint.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'tests/auto/qml') diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index 7e21c8d437..3f674fb5cc 100644 --- a/tests/auto/qml/qmllint/tst_qmllint.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -53,6 +53,9 @@ private Q_SLOTS: void directoryPassedAsQmlTypesFile(); void oldQmltypes(); + void qmltypes_data(); + void qmltypes(); + private: QString runQmllint(const QString &fileToLint, std::function handleResult, @@ -146,6 +149,23 @@ void TestQmllint::oldQmltypes() QVERIFY(errors.contains(QStringLiteral("Revision 0 corresponds to version 0.0; it should be 1.0."))); } +void TestQmllint::qmltypes_data() +{ + QTest::addColumn("file"); + + const QString importsPath = QLibraryInfo::path(QLibraryInfo::Qml2ImportsPath); + QDirIterator it(importsPath, { "*.qmltypes" }, + QDir::Files, QDirIterator::Subdirectories); + while (it.hasNext()) + QTest::addRow("%s", qPrintable(it.next().mid(importsPath.length()))) << it.filePath(); +} + +void TestQmllint::qmltypes() +{ + QFETCH(QString, file); + runQmllint(file, true); +} + void TestQmllint::dirtyQmlCode_data() { QTest::addColumn("filename"); @@ -306,7 +326,8 @@ QString TestQmllint::runQmllint(const QString &fileToLint, { auto qmlImportDir = QLibraryInfo::path(QLibraryInfo::Qml2ImportsPath); QStringList args; - args << testFile(fileToLint) + + args << (QFileInfo(fileToLint).isAbsolute() ? fileToLint : testFile(fileToLint)) << QStringLiteral("-I") << qmlImportDir << QStringLiteral("-I") << dataDirectory(); args << extraArgs; -- cgit v1.2.3