From 5c1973d4b74e0823b4f4fedc896ac342520ae852 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Tue, 16 May 2023 10:47:26 +0200 Subject: Loader: Do not error out when encountering duplicate multiplex values In qbs, values of list properties specified in a project file are merged with those from the profile. As of fb52fed84a1510a7de0172e643d6fd66a780e2e8, this is also true for the special multiplexing properties ("qbs.architectures", "qbs.buildVariants" etc). This means it can now happen that we end up with duplicate entries in these lists implicitly. Therefore, it no longer makes sense to throw an error when such duplicates are encountered, as they were not necessarily specified verbatim. Instead, we simply ignore the duplicate value and carry on normally. Change-Id: Ie4fed2081bebd2b0dd62aa873cafed769b308e97 Reviewed-by: Ivan Komissarov --- tests/auto/language/tst_language.cpp | 41 +++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) (limited to 'tests/auto/language/tst_language.cpp') diff --git a/tests/auto/language/tst_language.cpp b/tests/auto/language/tst_language.cpp index eda7bf566..c97b83cc1 100644 --- a/tests/auto/language/tst_language.cpp +++ b/tests/auto/language/tst_language.cpp @@ -626,6 +626,42 @@ void TestLanguage::dottedNames() } } +void TestLanguage::duplicateMultiplexValues_data() +{ + QTest::addColumn("dummy"); + QTest::newRow("duplicate-multiplex-value") << true; + QTest::newRow("duplicate-multiplex-value2") << true; +} + +void TestLanguage::duplicateMultiplexValues() +{ + bool exceptionCaught = false; + try { + SetupProjectParameters params = defaultParameters; + const QString filePath = testDataDir() + QLatin1Char('/') + + QString::fromLocal8Bit(QTest::currentDataTag()) + QLatin1String(".qbs"); + params.setProjectFilePath(filePath); + TopLevelProjectPtr project = m_resolver->resolve(params); + QVERIFY(project); + const std::vector products = project->allProducts(); + QCOMPARE(products.size(), 2); + bool x86 = false; + bool arm = false; + for (const ResolvedProductPtr &p : products) { + if (p->moduleProperties->moduleProperty("qbs", "architecture").toString() == "x86") + x86 = true; + else if (p->moduleProperties->moduleProperty("qbs", "architecture").toString() == "arm") + arm = true; + } + QVERIFY(x86); + QVERIFY(arm); + } catch (const ErrorInfo &e) { + exceptionCaught = true; + qDebug() << e.toString(); + } + QVERIFY(!exceptionCaught); +} + void TestLanguage::emptyJsFile() { bool exceptionCaught = false; @@ -937,11 +973,6 @@ void TestLanguage::erroneousFiles_data() QTest::newRow("dependency-profile-mismatch-2") << "dependency-profile-mismatch-2.qbs:15:9 Dependency from product 'main' to " "product 'dep' not fulfilled. There are no eligible multiplex candidates."; - QTest::newRow("duplicate-multiplex-value") - << "duplicate-multiplex-value.qbs:1:1.*Duplicate entry 'x86' in qbs.architectures."; - QTest::newRow("duplicate-multiplex-value2") - << "duplicate-multiplex-value2.qbs:1:1.*Duplicate entry 'architecture' in " - "Product.multiplexByQbsProperties."; QTest::newRow("invalid-references") << "invalid-references.qbs:2:17.*Cannot open '.*nosuchproject.qbs'"; QTest::newRow("missing-js-file") -- cgit v1.2.1