summaryrefslogtreecommitdiff
path: root/tests/auto
diff options
context:
space:
mode:
authorOlivier De Cannière <olivier.decanniere@qt.io>2023-05-11 09:52:24 +0200
committerOlivier De Cannière <olivier.decanniere@qt.io>2023-05-12 15:06:42 +0200
commit5860c9c12c1c948ce1498da30581bfd5b9c05988 (patch)
tree46be2f41ebc66900ad8259a809cdb1327bc9c5b7 /tests/auto
parent825d23a84687e67818dfff0485d08cd6d7186de3 (diff)
downloadqtdeclarative-5860c9c12c1c948ce1498da30581bfd5b9c05988.tar.gz
qmllint: Separate logic by import type in QQmlJSImportVisitor::visit
This patch reorganizes the logic of the import visitor to deal with each import type (paths, qrc: urls, file: urls) separately. This reorganisation fixes QTBUG-108803 which happened because "qrc:" imports were being treated as paths leading to things like ":/untitled/qrc:/untitled/components". Fixes: QTBUG-108803 Pick-to: 6.5 Change-Id: I5af20d10c533455215895be66b5cd98a977fd18a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qml/qmllint/data/untitled/components/Foo.qml5
-rw-r--r--tests/auto/qml/qmllint/data/untitled/main.qml9
-rw-r--r--tests/auto/qml/qmllint/data/untitled/qrcUrlImport.qrc6
-rw-r--r--tests/auto/qml/qmllint/tst_qmllint.cpp11
4 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/qml/qmllint/data/untitled/components/Foo.qml b/tests/auto/qml/qmllint/data/untitled/components/Foo.qml
new file mode 100644
index 0000000000..10e5741900
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/untitled/components/Foo.qml
@@ -0,0 +1,5 @@
+import QtQuick
+
+Text {
+ text: "Here I am!"
+}
diff --git a/tests/auto/qml/qmllint/data/untitled/main.qml b/tests/auto/qml/qmllint/data/untitled/main.qml
new file mode 100644
index 0000000000..cf8980ab55
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/untitled/main.qml
@@ -0,0 +1,9 @@
+pragma Strict
+
+import QtQuick
+import 'qrc:/untitled/components' as C
+
+Window {
+ id: root
+ C.Foo {}
+}
diff --git a/tests/auto/qml/qmllint/data/untitled/qrcUrlImport.qrc b/tests/auto/qml/qmllint/data/untitled/qrcUrlImport.qrc
new file mode 100644
index 0000000000..0ad0d57fbb
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/untitled/qrcUrlImport.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/untitled/">
+ <file alias="main.qml">main.qml</file>
+ <file alias="components/Foo.qml">components/Foo.qml</file>
+ </qresource>
+</RCC>
diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp
index 56705712d0..110017b371 100644
--- a/tests/auto/qml/qmllint/tst_qmllint.cpp
+++ b/tests/auto/qml/qmllint/tst_qmllint.cpp
@@ -79,6 +79,8 @@ private Q_SLOTS:
void additionalImplicitImport();
+ void qrcUrlImport();
+
void attachedPropertyReuse();
void missingBuiltinsNoCrash();
@@ -1654,7 +1656,16 @@ void TestQmllint::additionalImplicitImport()
const auto guard = qScopeGuard([this]() {m_linter.clearCache(); });
runTest("additionalImplicitImport.qml", Result::clean(), {}, {},
{ testFile("implicitImportResource.qrc") });
+}
+void TestQmllint::qrcUrlImport()
+{
+ const auto guard = qScopeGuard([this]() { m_linter.clearCache(); });
+
+ QJsonArray warnings;
+ callQmllint(testFile("untitled/main.qml"), true, &warnings, {}, {},
+ { testFile("untitled/qrcUrlImport.qrc") });
+ checkResult(warnings, Result::clean());
}
void TestQmllint::attachedPropertyReuse()