diff options
author | Christian Kandeler <christian.kandeler@theqtcompany.com> | 2016-05-25 11:00:10 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@theqtcompany.com> | 2016-05-25 09:18:14 +0000 |
commit | 756a296e7dd1a79af9de1206809c02e9e936f9b9 (patch) | |
tree | 529351e02cea2343505fbff24498af55825b5866 | |
parent | c5ea3e3a3d5df68790e82cee17923bb23a4997b4 (diff) |
Fix edge case in module look-up.
If a product in a project with an extra search path exports a dependency
to a module that is found using that search path, *and* a second product
that is located in a project without the extra search path depends on
the first product, *and* a third product that is located in the project
with the extra search path also depends on the first product, we
inexplicably ignored the failure to load the exported module, leading to
an assertion later on.
Change-Id: Id0e4a67e912ded679fa35ec397b51dcaabd65cce
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
5 files changed, 42 insertions, 2 deletions
diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp index 95c1092d4..c4cfac73c 100644 --- a/src/lib/corelib/language/moduleloader.cpp +++ b/src/lib/corelib/language/moduleloader.cpp @@ -1845,8 +1845,12 @@ void ModuleLoader::addTransitiveDependencies(ProductContext *ctx) Item::Module dep; dep.item = loadModule(ctx, ctx->item, ctx->item->location(), QString(), module.name, module.required, &dep.isProduct); - if (!dep.item) - continue; + if (!dep.item) { + throw ErrorInfo(Tr::tr("Module '%1' not found when setting up transitive " + "dependencies for product '%2'.").arg(module.name.toString(), + ctx->name), + ctx->item->location()); + } dep.name = module.name; dep.required = module.required; ctx->item->addModule(dep); diff --git a/tests/auto/blackbox/testdata/export-to-outside-searchpath/export-to-outside-searchpath.qbs b/tests/auto/blackbox/testdata/export-to-outside-searchpath/export-to-outside-searchpath.qbs new file mode 100644 index 000000000..72c48b75a --- /dev/null +++ b/tests/auto/blackbox/testdata/export-to-outside-searchpath/export-to-outside-searchpath.qbs @@ -0,0 +1,21 @@ +import qbs + +Project { + Project { + qbsSearchPaths: ["qbs-resources"] + Product { + name: "otherProduct" + Depends { name: "dep" } + } + Product { + name: "dep" + Export { Depends { name: "aModule" } } + } + } + Project { + Product { + name: "theProduct" + Depends { name: "dep" } + } + } +} diff --git a/tests/auto/blackbox/testdata/export-to-outside-searchpath/qbs-resources/modules/aModule/aModule.qbs b/tests/auto/blackbox/testdata/export-to-outside-searchpath/qbs-resources/modules/aModule/aModule.qbs new file mode 100644 index 000000000..3e67ba10d --- /dev/null +++ b/tests/auto/blackbox/testdata/export-to-outside-searchpath/qbs-resources/modules/aModule/aModule.qbs @@ -0,0 +1,4 @@ +import qbs + +Module { +} diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index c6e7aed51..b7c6c2440 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -2199,6 +2199,16 @@ void TestBlackbox::exportRule() QCOMPARE(runQbs(params), 0); } +void TestBlackbox::exportToOutsideSearchPath() +{ + QDir::setCurrent(testDataDir + "/export-to-outside-searchpath"); + QbsRunParameters params; + params.expectFailure = true; + QVERIFY(runQbs(params) != 0); + QVERIFY2(m_qbsStderr.contains("Module 'aModule' not found when setting up transitive " + "dependencies for product 'theProduct'"), m_qbsStderr.constData()); +} + void TestBlackbox::fileDependencies() { QDir::setCurrent(testDataDir + "/fileDependencies"); diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h index c71020a89..6b3a5bd3a 100644 --- a/tests/auto/blackbox/tst_blackbox.h +++ b/tests/auto/blackbox/tst_blackbox.h @@ -131,6 +131,7 @@ private slots: void erroneousFiles(); void errorInfo(); void exportRule(); + void exportToOutsideSearchPath(); void fileDependencies(); void frameworkStructure(); void groupsInModules(); |