aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorFawzi Mohamed <fawzi.mohamed@qt.io>2021-02-03 09:06:09 +0100
committerFawzi Mohamed <fawzi.mohamed@qt.io>2021-02-15 18:22:27 +0100
commit6d51f997df14f2b22c265c5b2fda679ece9edef3 (patch)
tree551889cb0b96998d87c234c6cce657242c4ce954 /tests/auto
parenta8685fdb4d57c0ba36d80c395c2ae878595f04da (diff)
Uniformly support shebang
The "qml" tool was the only way of loading QML files that would respect a shebang line. This is problematic as this way you cannot load such files programatically using QQmlComponent, limiting their re-use. Common tools like Qt Creator, but also qmllint, qmlformat, qmlcachegen, etc would not recognize files with shebangs. By moving she-bang support directly in the lexer all tools implicitly support it. Note that we could just as easily support '#' as extra comment character along with //, but here we narrowly add support for in the first line only, as node does (this means that javascript files using she-bang accepted by node, are now accepted also by qml). The only tool needing some adjustments is qmlformat, that has to emit the she-bang again as she-bang and as first line. Add tests for qmlformat, and sprinkle some she-bangs in the other tests just to be sure it doesn't affect anything. Change-Id: I1f6d881c7438bdb23163b5dbe829d59a35d11132 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qml/qmlcachegen/data/Enums.qml1
-rw-r--r--tests/auto/qml/qmlformat/data/Annotations.formatted.qml1
-rw-r--r--tests/auto/qml/qmlformat/data/Annotations.qml1
-rw-r--r--tests/auto/qml/qmlformat/data/IfBlocks.formatted.qml1
-rw-r--r--tests/auto/qml/qmlformat/data/IfBlocks.qml1
-rw-r--r--tests/auto/qml/qmlformat/data/QtBug85003.formatted.qml2
-rw-r--r--tests/auto/qml/qmlformat/data/QtBug85003.qml2
-rw-r--r--tests/auto/qml/qmlimportscanner/data/ListProperty.qml1
-rw-r--r--tests/auto/qml/qqmlcomponent/data/SpecificComponent/SpecificComponent.qml1
-rw-r--r--tests/auto/qml/qqmlcomponent/data/callingQmlContextComponent.qml1
10 files changed, 12 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcachegen/data/Enums.qml b/tests/auto/qml/qmlcachegen/data/Enums.qml
index 830babb73e..5207ef03f0 100644
--- a/tests/auto/qml/qmlcachegen/data/Enums.qml
+++ b/tests/auto/qml/qmlcachegen/data/Enums.qml
@@ -1,3 +1,4 @@
+#!/she-bang
import QtQml 2.0
QtObject {
enum Test {
diff --git a/tests/auto/qml/qmlformat/data/Annotations.formatted.qml b/tests/auto/qml/qmlformat/data/Annotations.formatted.qml
index a05c2125dc..ab56b5ce00 100644
--- a/tests/auto/qml/qmlformat/data/Annotations.formatted.qml
+++ b/tests/auto/qml/qmlformat/data/Annotations.formatted.qml
@@ -1,3 +1,4 @@
+#!/she-bang
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
diff --git a/tests/auto/qml/qmlformat/data/Annotations.qml b/tests/auto/qml/qmlformat/data/Annotations.qml
index 2d3d7d2cfd..4638d4f7e9 100644
--- a/tests/auto/qml/qmlformat/data/Annotations.qml
+++ b/tests/auto/qml/qmlformat/data/Annotations.qml
@@ -1,3 +1,4 @@
+#!/she-bang
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
diff --git a/tests/auto/qml/qmlformat/data/IfBlocks.formatted.qml b/tests/auto/qml/qmlformat/data/IfBlocks.formatted.qml
index ddba82c312..d89260df5d 100644
--- a/tests/auto/qml/qmlformat/data/IfBlocks.formatted.qml
+++ b/tests/auto/qml/qmlformat/data/IfBlocks.formatted.qml
@@ -1,3 +1,4 @@
+#!/she-bang
Item {
function test() {
//// The following if blocks should NOT HAVE braces
diff --git a/tests/auto/qml/qmlformat/data/IfBlocks.qml b/tests/auto/qml/qmlformat/data/IfBlocks.qml
index 505988b238..2140c8246f 100644
--- a/tests/auto/qml/qmlformat/data/IfBlocks.qml
+++ b/tests/auto/qml/qmlformat/data/IfBlocks.qml
@@ -1,3 +1,4 @@
+#!/she-bang
Item {
function test() {
//// The following if blocks should NOT HAVE braces
diff --git a/tests/auto/qml/qmlformat/data/QtBug85003.formatted.qml b/tests/auto/qml/qmlformat/data/QtBug85003.formatted.qml
index ee42b39571..53e278ab9c 100644
--- a/tests/auto/qml/qmlformat/data/QtBug85003.formatted.qml
+++ b/tests/auto/qml/qmlformat/data/QtBug85003.formatted.qml
@@ -1,3 +1,5 @@
+#!/she-bang
+// extra comment
Item {
Component.onCompleted: {
if (3 < 2)
diff --git a/tests/auto/qml/qmlformat/data/QtBug85003.qml b/tests/auto/qml/qmlformat/data/QtBug85003.qml
index 5d039cb9ca..9bbec07ed4 100644
--- a/tests/auto/qml/qmlformat/data/QtBug85003.qml
+++ b/tests/auto/qml/qmlformat/data/QtBug85003.qml
@@ -1,3 +1,5 @@
+#!/she-bang
+// extra comment
Item {
Component.onCompleted:
{
diff --git a/tests/auto/qml/qmlimportscanner/data/ListProperty.qml b/tests/auto/qml/qmlimportscanner/data/ListProperty.qml
index d2bbc58cc5..faeb1bfe5e 100644
--- a/tests/auto/qml/qmlimportscanner/data/ListProperty.qml
+++ b/tests/auto/qml/qmlimportscanner/data/ListProperty.qml
@@ -1,3 +1,4 @@
+#!/she-bang
import QtQuick 2.12
import Things 1.0
diff --git a/tests/auto/qml/qqmlcomponent/data/SpecificComponent/SpecificComponent.qml b/tests/auto/qml/qqmlcomponent/data/SpecificComponent/SpecificComponent.qml
index 0086737970..46f4542df8 100644
--- a/tests/auto/qml/qqmlcomponent/data/SpecificComponent/SpecificComponent.qml
+++ b/tests/auto/qml/qqmlcomponent/data/SpecificComponent/SpecificComponent.qml
@@ -1,3 +1,4 @@
+#!/she-bang
import QtQuick 2.0
Item {
diff --git a/tests/auto/qml/qqmlcomponent/data/callingQmlContextComponent.qml b/tests/auto/qml/qqmlcomponent/data/callingQmlContextComponent.qml
index adf491c87e..1b413bec36 100644
--- a/tests/auto/qml/qqmlcomponent/data/callingQmlContextComponent.qml
+++ b/tests/auto/qml/qqmlcomponent/data/callingQmlContextComponent.qml
@@ -1,3 +1,4 @@
+#!/she-bang
import qqmlcomponenttest 1.0
CallingContextCheckingClass {
}