diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2016-07-27 13:52:52 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2016-11-24 09:33:50 +0000 |
commit | d94ba7080d32050d7c5d12d9cf03ecb7b9b7ff46 (patch) | |
tree | 3db66e14f3349fd4cf6680da7a27770e42cb4718 /tests/auto | |
parent | 37e722e9d879bbabc714046d24005b173300557f (diff) |
Separate file scope and imports scope
When evaluating, imported names need to have a higher precedence than
names in the item scope, as otherwise they can clash with dependencies
of the product (see bug report and autotest). We cannot simply move the
file scope's precedence up, because in addition to imports and the
"file" and "filePath" properties, it also potentially contains ids from
e.g. a module prototype, which would then override the respective entry
in the module scope.
Task-number: QBS-930
Change-Id: Ifb8b7c933225f872ccc3e878b2bf01b7b0ac0f99
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'tests/auto')
5 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/blackbox/testdata/imports-conflict/imports-conflict.qbs b/tests/auto/blackbox/testdata/imports-conflict/imports-conflict.qbs new file mode 100644 index 000000000..1c6be24bd --- /dev/null +++ b/tests/auto/blackbox/testdata/imports-conflict/imports-conflict.qbs @@ -0,0 +1,11 @@ +import qbs + +Project { + Product { + name: "Utils" + } + Product { + Depends { name: "Utils" } + Depends { name: "themodule" } + } +} diff --git a/tests/auto/blackbox/testdata/imports-conflict/modules/themodule/m.qbs b/tests/auto/blackbox/testdata/imports-conflict/modules/themodule/m.qbs new file mode 100644 index 000000000..48145d380 --- /dev/null +++ b/tests/auto/blackbox/testdata/imports-conflict/modules/themodule/m.qbs @@ -0,0 +1,5 @@ +import "utils.js" as Utils + +Module { + validate: { Utils.helper(); } +} diff --git a/tests/auto/blackbox/testdata/imports-conflict/modules/themodule/utils.js b/tests/auto/blackbox/testdata/imports-conflict/modules/themodule/utils.js new file mode 100644 index 000000000..ad54d4d0f --- /dev/null +++ b/tests/auto/blackbox/testdata/imports-conflict/modules/themodule/utils.js @@ -0,0 +1 @@ +function helper() { console.info("helper"); } diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index c885bec4f..454644de3 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -3978,6 +3978,12 @@ void TestBlackbox::importingProduct() QCOMPARE(runQbs(), 0); } +void TestBlackbox::importsConflict() +{ + QDir::setCurrent(testDataDir + "/imports-conflict"); + QCOMPARE(runQbs(), 0); +} + void TestBlackbox::infoPlist() { if (!HostOsInfo::isMacosHost()) diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h index 06df7f53c..4b5c410ac 100644 --- a/tests/auto/blackbox/tst_blackbox.h +++ b/tests/auto/blackbox/tst_blackbox.h @@ -85,6 +85,7 @@ private slots: void iconsetApp(); void importInPropertiesCondition(); void importingProduct(); + void importsConflict(); void infoPlist(); void inputsFromDependencies(); void installable(); |