diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-09-05 11:08:59 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-09-05 11:08:59 +0200 |
commit | 2746518c76e02c642ff29faf568de4de90216e58 (patch) | |
tree | 822a6d979c13b6450c221b2a45ccfb6674bcb8e4 /tests/auto/qml/qmllint | |
parent | 9e32b23a1514f367921b4a9ee25bc864a008463c (diff) | |
parent | bdf0a46c289298f7378796d62ae5fb283e08657d (diff) |
Merge remote-tracking branch 'origin/dev' into wip/qt6
Conflicts:
.qmake.conf
src/qml/qml/qqmlengine.cpp
src/qmlmodels/qqmlmodelsmodule.cpp
Change-Id: Id60420f8250a9c97fcfe56d4eea19b62c6870404
Diffstat (limited to 'tests/auto/qml/qmllint')
-rw-r--r-- | tests/auto/qml/qmllint/data/CatchStatement.qml | 8 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/data/catchIdentifierNoWarning.qml | 7 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/qmllint.pro | 13 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/tst_qmllint.cpp (renamed from tests/auto/qml/qmllint/main.cpp) | 39 |
4 files changed, 51 insertions, 16 deletions
diff --git a/tests/auto/qml/qmllint/data/CatchStatement.qml b/tests/auto/qml/qmllint/data/CatchStatement.qml new file mode 100644 index 0000000000..e0f70fce7e --- /dev/null +++ b/tests/auto/qml/qmllint/data/CatchStatement.qml @@ -0,0 +1,8 @@ +import QtQml 2.12 + +QtObject { + function f() { + try {} catch(err) {} + console.log(err); + } +} diff --git a/tests/auto/qml/qmllint/data/catchIdentifierNoWarning.qml b/tests/auto/qml/qmllint/data/catchIdentifierNoWarning.qml new file mode 100644 index 0000000000..097baa6fcf --- /dev/null +++ b/tests/auto/qml/qmllint/data/catchIdentifierNoWarning.qml @@ -0,0 +1,7 @@ +import QtQml 2.12 + +QtObject { + function f() { + try {} catch(err) {console.log(err);} + } +} diff --git a/tests/auto/qml/qmllint/qmllint.pro b/tests/auto/qml/qmllint/qmllint.pro index b53a6f6877..95470b4085 100644 --- a/tests/auto/qml/qmllint/qmllint.pro +++ b/tests/auto/qml/qmllint/qmllint.pro @@ -1,6 +1,11 @@ -TEMPLATE = app -TARGET = testqmllint -INCLUDEPATH += . +CONFIG += testcase +TARGET = tst_qmllint +macos:CONFIG -= app_bundle + +SOURCES += tst_qmllint.cpp + +include (../../shared/util.pri) + +TESTDATA = data/* -SOURCES += main.cpp QT += testlib diff --git a/tests/auto/qml/qmllint/main.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index 928575bc82..582f146dca 100644 --- a/tests/auto/qml/qmllint/main.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -30,23 +30,27 @@ #include <QProcess> #include <QString> -class TestQmllint: public QObject +#include <util.h> + +class TestQmllint: public QQmlDataTest { Q_OBJECT private Q_SLOTS: - void initTestCase(); + void initTestCase() override; void test(); void test_data(); void testUnqualified(); void testUnqualified_data(); void testUnqualifiedNoSpuriousParentWarning(); + void catchIdentifierNoFalsePositive(); private: QString m_qmllintPath; }; void TestQmllint::initTestCase() { + QQmlDataTest::initTestCase(); m_qmllintPath = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QLatin1String("/qmllint"); #ifdef Q_OS_WIN m_qmllintPath += QLatin1String(".exe"); @@ -79,9 +83,8 @@ void TestQmllint::testUnqualified() QFETCH(QString, warningMessage); QFETCH(int, warningLine); QFETCH(int, warningColumn); - filename.prepend(QStringLiteral("data/")); QStringList args; - args << QStringLiteral("-U") << filename << QStringLiteral("-I") << qmlImportDir; + args << QStringLiteral("-U") << testFile(filename) << QStringLiteral("-I") << qmlImportDir; QProcess process; process.start(m_qmllintPath, args); @@ -113,15 +116,15 @@ void TestQmllint::testUnqualified_data() QTest::newRow("SignalHandler2") << QStringLiteral("SignalHandler.qml") << QStringLiteral("onPositionChanged: function(mouse) {...") << 10 << 21; QTest::newRow("SignalHandlerShort1") << QStringLiteral("SignalHandler.qml") << QStringLiteral("onClicked: (mouse) => {...") << 8 << 29; QTest::newRow("SignalHandlerShort2") << QStringLiteral("SignalHandler.qml") << QStringLiteral("onPressAndHold: (mouse) => {...") << 12 << 34; - + // access catch identifier outside catch block + QTest::newRow("CatchStatement") << QStringLiteral("CatchStatement.qml") << QStringLiteral("err") << 6 << 21; } void TestQmllint::testUnqualifiedNoSpuriousParentWarning() { auto qmlImportDir = QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath); { - QString filename = QLatin1String("spuriousParentWarning.qml"); - filename.prepend(QStringLiteral("data/")); + QString filename = testFile("spuriousParentWarning.qml"); QStringList args; args << QStringLiteral("-U") << filename << QStringLiteral("-I") << qmlImportDir; QProcess process; @@ -131,8 +134,7 @@ void TestQmllint::testUnqualifiedNoSpuriousParentWarning() QVERIFY(process.exitCode() == 0); } { - QString filename = QLatin1String("nonSpuriousParentWarning.qml"); - filename.prepend(QStringLiteral("data/")); + QString filename = testFile("nonSpuriousParentWarning.qml"); QStringList args; args << QStringLiteral("-U") << filename << QStringLiteral("-I") << qmlImportDir; QProcess process; @@ -143,17 +145,30 @@ void TestQmllint::testUnqualifiedNoSpuriousParentWarning() } } +void TestQmllint::catchIdentifierNoFalsePositive() +{ + auto qmlImportDir = QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath); + QString filename = QLatin1String("catchIdentifierNoWarning.qml"); + filename.prepend(QStringLiteral("data/")); + QStringList args; + args << QStringLiteral("-U") << filename << QStringLiteral("-I") << qmlImportDir; + QProcess process; + process.start(m_qmllintPath, args); + QVERIFY(process.waitForFinished()); + QVERIFY(process.exitStatus() == QProcess::NormalExit); + QVERIFY(process.exitCode() == 0); +} + void TestQmllint::test() { QFETCH(QString, filename); QFETCH(bool, isValid); - filename = QStringLiteral("data/") + filename; QStringList args; - args << QStringLiteral("--silent") << filename; + args << QStringLiteral("--silent") << testFile(filename); bool success = QProcess::execute(m_qmllintPath, args) == 0; QCOMPARE(success, isValid); } QTEST_MAIN(TestQmllint) -#include "main.moc" +#include "tst_qmllint.moc" |