diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2016-10-11 09:51:52 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2016-10-11 09:05:11 +0000 |
commit | 1e60fab274e722efa01bce67c9acc56627fcc801 (patch) | |
tree | c7f769a47429689da86d40225e369d191047bb1d | |
parent | 16597049dccbe22da92616387a57f7e00bccbb3a (diff) |
Extend the autotest for module property assignments in Groups
So that we won't accidentally fix only one special case.
Task-number: QBS-1005
Change-Id: I2093fd1569880f1ad683118cdd8df2576039f5f2
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
4 files changed, 94 insertions, 13 deletions
diff --git a/src/lib/corelib/language/testdata/modulepropertiesingroups.qbs b/src/lib/corelib/language/testdata/modulepropertiesingroups.qbs index 6bfbf42d3..22fb750e4 100644 --- a/src/lib/corelib/language/testdata/modulepropertiesingroups.qbs +++ b/src/lib/corelib/language/testdata/modulepropertiesingroups.qbs @@ -3,11 +3,34 @@ import qbs 1.0 Project { Product { name: "grouptest" + + Depends { name: "gmod1" } Depends { name: "dummyqt.core" } + + gmod1.listProp2: ["product", gmod1.stringProp] + gmod1.p1: 1 + + // TODO: Also test nested groups in >= 1.7 Group { - name: "thegroup" + name: "g1" files: ["Banana"] + + gmod1.stringProp: "g1" + gmod1.listProp2: ["g1"] + gmod1.p2: 2 + gmod2.prop: 1 dummyqt.core.zort: "X" } + + Group { + name: "g2" + files: ["zort"] + + gmod1.stringProp: "g2" + gmod1.listProp2: ["g2"] + gmod1.p1: 2 + gmod1.p2: 4 + gmod2.prop: 2 + } } } diff --git a/src/lib/corelib/language/testdata/modules/gmod1/gmod1.qbs b/src/lib/corelib/language/testdata/modules/gmod1/gmod1.qbs new file mode 100644 index 000000000..416372e3d --- /dev/null +++ b/src/lib/corelib/language/testdata/modules/gmod1/gmod1.qbs @@ -0,0 +1,12 @@ +import qbs + +Module { + Depends { name: "gmod2" } + property stringList listProp1: ["prototype", stringProp] + property stringList listProp2: ["prototype"] + property string stringProp: "prototype" + property int depProp: gmod2.prop + property int p0: p1 + p2 + property int p1: 0 + property int p2: 0 +} diff --git a/src/lib/corelib/language/testdata/modules/gmod2/gmod2.qbs b/src/lib/corelib/language/testdata/modules/gmod2/gmod2.qbs new file mode 100644 index 000000000..208f7330d --- /dev/null +++ b/src/lib/corelib/language/testdata/modules/gmod2/gmod2.qbs @@ -0,0 +1,5 @@ +import qbs + +Module { + property int prop: 0 +} diff --git a/src/lib/corelib/language/tst_language.cpp b/src/lib/corelib/language/tst_language.cpp index 6e5d78a14..4dec7dbde 100644 --- a/src/lib/corelib/language/tst_language.cpp +++ b/src/lib/corelib/language/tst_language.cpp @@ -1120,21 +1120,62 @@ void TestLanguage::modulePropertiesInGroups() const QHash<QString, ResolvedProductPtr> products = productsFromProject(project); const ResolvedProductPtr product = products.value("grouptest"); QVERIFY(product); - GroupConstPtr group; + GroupConstPtr g1; + GroupConstPtr g2; foreach (const GroupConstPtr &g, product->groups) { - if (g->name == "thegroup") { - group = g; - break; - } + if (g->name == "g1") + g1= g; + else if (g->name == "g2") + g2 = g; } - QVERIFY(group); - QVariantList values = PropertyFinder().propertyValues(group->properties->value(), - "dummy", "cFlags"); - QStringList valueStrings; - foreach (const QVariant &v, values) - valueStrings += v.toString(); + QVERIFY(g1); + QVERIFY(g2); + + const QVariantMap productProps = product->moduleProperties->value(); + PropertyFinder pf; + + const auto &productListProp1 = pf.propertyValue(productProps, "gmod1", "listProp1") + .toStringList(); + QCOMPARE(productListProp1, QStringList() << "prototype" << "prototype"); + const auto &productListProp2 = pf.propertyValue(productProps, "gmod1", "listProp2") + .toStringList(); + QCOMPARE(productListProp2, QStringList() << "product" << "prototype" << "prototype"); + const int productP0 = pf.propertyValue(productProps, "gmod1", "p0").toInt(); + QCOMPARE(productP0, 1); + const int productDepProp = pf.propertyValue(productProps, "gmod1", "depProp").toInt(); + QCOMPARE(productDepProp, 0); + + const QVariantMap g1Props = g1->properties->value(); + const auto &g1ListProp1 = pf.propertyValue(g1Props, "gmod1", "listProp1") + .toStringList(); + QCOMPARE(g1ListProp1, QStringList() << "prototype" << "g1"); + const auto &g1ListProp2 = pf.propertyValue(g1Props, "gmod1", "listProp2") + .toStringList(); + QEXPECT_FAIL(0, "QBS-1005", Continue); + QCOMPARE(g1ListProp2, QStringList() << "product" << "g1" << "prototype"); + const int g1P0 = pf.propertyValue(g1Props, "gmod1", "p0").toInt(); + QCOMPARE(g1P0, 3); + const int g1DepProp = pf.propertyValue(g1Props, "gmod1", "depProp").toInt(); + QEXPECT_FAIL(0, "QBS-1005", Continue); + QCOMPARE(g1DepProp, 1); + const auto &g1DummyCFlags = pf.propertyValue(g1Props, "dummy", "cFlags") + .toStringList(); + QEXPECT_FAIL(0, "QBS-1005", Continue); + QCOMPARE(g1DummyCFlags, QStringList("X")); + + const QVariantMap g2Props = g2->properties->value(); + const auto &g2ListProp1 = pf.propertyValue(g2Props, "gmod1", "listProp1") + .toStringList(); + QCOMPARE(g2ListProp1, QStringList() << "prototype" << "g2"); + const auto &g2ListProp2 = pf.propertyValue(g2Props, "gmod1", "listProp2") + .toStringList(); + QEXPECT_FAIL(0, "QBS-1005", Continue); + QCOMPARE(g2ListProp2, QStringList() << "product" << "g2" << "prototype"); + const int g2P0 = pf.propertyValue(g2Props, "gmod1", "p0").toInt(); + QCOMPARE(g2P0, 6); + const int g2DepProp = pf.propertyValue(g2Props, "gmod1", "depProp").toInt(); QEXPECT_FAIL(0, "QBS-1005", Continue); - QCOMPARE(valueStrings, QStringList("X")); + QCOMPARE(g2DepProp, 2); } catch (const ErrorInfo &e) { exceptionCaught = true; qDebug() << e.toString(); |