summaryrefslogtreecommitdiff
path: root/tests/auto/language/tst_language.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2018-05-14 10:26:58 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2018-05-15 07:37:15 +0000
commit979b2524818fa0b618ac8308c608c6a593e5f521 (patch)
treedc794a877864ca39df6a1a76e502ec8fc1fc4876 /tests/auto/language/tst_language.cpp
parent20d261df437c9c08462735909e9c62c2b7615a55 (diff)
downloadqbs-979b2524818fa0b618ac8308c608c6a593e5f521.tar.gz
Allow module instances with the same priority in different search paths
The search path order provides additional prioritization. Conflicts can now only occur between candidates in the same directory. This is needed e.g. to allow distributions to provide global search paths. Change-Id: I698a96e8943041fb0c4536901f75394bacd7fb40 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'tests/auto/language/tst_language.cpp')
-rw-r--r--tests/auto/language/tst_language.cpp40
1 files changed, 37 insertions, 3 deletions
diff --git a/tests/auto/language/tst_language.cpp b/tests/auto/language/tst_language.cpp
index e19eef7c0..ef549da21 100644
--- a/tests/auto/language/tst_language.cpp
+++ b/tests/auto/language/tst_language.cpp
@@ -819,9 +819,6 @@ void TestLanguage::erroneousFiles_data()
QTest::newRow("conflicting-module-instances")
<< "There is more than one equally prioritized candidate for module "
"'conflicting-instances'.";
- QTest::newRow("conflicting-module-instances-in-search-paths/project")
- << "There is more than one equally prioritized candidate for module "
- "'conflicting-instances'.";
QTest::newRow("module-depends-on-product")
<< "module-with-product-dependency.qbs:4:5.*Modules cannot depend on products.";
QTest::newRow("overwrite-inherited-readonly-property")
@@ -1492,6 +1489,43 @@ void TestLanguage::jsImportUsedInMultipleScopes()
QVERIFY(!exceptionCaught);
}
+void TestLanguage::modulePrioritizationBySearchPath_data()
+{
+ QTest::addColumn<QStringList>("searchPaths");
+ QTest::addColumn<QString>("expectedVariant");
+ QTest::newRow("foo has priority") << QStringList{"./foo", "./bar"} << "foo";
+ QTest::newRow("bar has priority") << QStringList{"./bar", "./foo"} << "bar";
+}
+
+void TestLanguage::modulePrioritizationBySearchPath()
+{
+ QFETCH(QStringList, searchPaths);
+ QFETCH(QString, expectedVariant);
+
+ bool exceptionCaught = false;
+ try {
+ SetupProjectParameters params = defaultParameters;
+ params.setProjectFilePath(testProject("module-prioritization-by-search-path/project.qbs"));
+ params.setOverriddenValues({std::make_pair(QLatin1String("project.qbsSearchPaths"),
+ searchPaths)});
+ params.expandBuildConfiguration();
+ TopLevelProjectPtr project = loader->loadProject(params);
+ QVERIFY(!!project);
+ QHash<QString, ResolvedProductPtr> products = productsFromProject(project);
+ QCOMPARE(products.size(), 1);
+ ResolvedProductPtr product = products.values().front();
+ QVERIFY(!!product);
+ const QString actualVariant = product->moduleProperties->moduleProperty
+ ("conflicting-instances", "moduleVariant").toString();
+ QCOMPARE(actualVariant, expectedVariant);
+ }
+ catch (const ErrorInfo &e) {
+ exceptionCaught = true;
+ qDebug() << e.toString();
+ }
+ QVERIFY(!exceptionCaught);
+}
+
void TestLanguage::moduleProperties_data()
{
QTest::addColumn<QString>("propertyName");