aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmllint
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2020-04-29 10:47:19 +0200
committerMitch Curtis <mitch.curtis@qt.io>2020-05-06 13:46:27 +0200
commitaa470fa92d8139ea849c00e01db5ffc537fe6981 (patch)
tree66e90018b1caed54b2413d986e776ddc9b4d50d0 /tests/auto/qml/qmllint
parentafd6c6b905820529b1b46767970bf090d04973a9 (diff)
qmllint: warn when passing a directory to -i option
It should be a file. Change-Id: I52f4ebcf8bdd8ddd1fedd66ceffe9a060139c1d9 Fixes: QTBUG-83861 Pick-to: 5.15 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmllint')
-rw-r--r--tests/auto/qml/qmllint/tst_qmllint.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp
index 235748f55e..0f6fac4ddf 100644
--- a/tests/auto/qml/qmllint/tst_qmllint.cpp
+++ b/tests/auto/qml/qmllint/tst_qmllint.cpp
@@ -50,8 +50,10 @@ private Q_SLOTS:
void testUnknownCausesFail();
+ void directoryPassedAsQmlTypesFile();
+
private:
- QString runQmllint(const QString &fileToLint, bool shouldSucceed);
+ QString runQmllint(const QString &fileToLint, bool shouldSucceed, const QStringList &extraArgs = QStringList());
QString m_qmllintPath;
};
@@ -114,6 +116,15 @@ void TestQmllint::testUnknownCausesFail()
QStringLiteral("warning: Unknown was not found. Did you add all import paths?")));
}
+void TestQmllint::directoryPassedAsQmlTypesFile()
+{
+ const QStringList iArg = QStringList() << QStringLiteral("-i") << dataDirectory();
+ const QString errorMessages = runQmllint("unknownElement.qml", false, iArg);
+ const QString expectedError = QStringLiteral("warning: QML types file cannot be a directory: ") + dataDirectory();
+ QVERIFY2(errorMessages.contains(expectedError), qPrintable(QString::fromLatin1(
+ "Expected error to contain \"%1\", but it didn't: %2").arg(expectedError, errorMessages)));
+}
+
void TestQmllint::dirtyQmlCode_data()
{
QTest::addColumn<QString>("filename");
@@ -214,14 +225,15 @@ void TestQmllint::cleanQmlCode()
QVERIFY(warnings.isEmpty());
}
-QString TestQmllint::runQmllint(const QString &fileToLint, bool shouldSucceed)
+QString TestQmllint::runQmllint(const QString &fileToLint, bool shouldSucceed, const QStringList &extraArgs)
{
auto qmlImportDir = QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath);
QStringList args;
args << testFile(fileToLint)
<< QStringLiteral("-I") << qmlImportDir
- << QStringLiteral("-I") << dataDirectory()
- << QStringLiteral("--silent");
+ << QStringLiteral("-I") << dataDirectory();
+ args << extraArgs;
+ args << QStringLiteral("--silent");
QString errors;
auto verify = [&](bool isSilent) {
QProcess process;