diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-10-11 16:21:42 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-10-11 16:21:42 +0200 |
commit | 6a0bb9a7d6a6473920da74bb48c52a4eaed990b0 (patch) | |
tree | 3a32c56b1fe21c96d5982511e0b4815c1c07dfbb /tests/auto/qml/qmllint | |
parent | f0d23d3ff9da26a71295a6abd356c8d366d17439 (diff) | |
parent | 2746518c76e02c642ff29faf568de4de90216e58 (diff) |
Merge remote-tracking branch 'origin/wip/qt6' into wip/cmake
Change-Id: I4a91928610f79c8e21a05781953ffa41508c828a
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" |