diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2018-04-27 17:47:51 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2018-05-09 12:55:51 +0000 |
commit | 92d532d88d7962d4568554d3f2928fd3d1d259d7 (patch) | |
tree | c2d73ef2162f7700765a40ba04e63e29c9dfb8f0 /tests | |
parent | fb371a811d5f8de4ed78dd7b7a625b30e3e25996 (diff) |
Add new property explicitlyDependsOnFromDependencies
This change adds new Rule item property called
explicitlyDependsOnFromDependencies.
It allows specifying a list of file tags to consider in dependent
target artifacts which should be used as dependencies.
[ChangeLog] The Rule item property explicitlyDependsOn no longer
considers target artifacts of products that the processed product
depends on. The new property explicitlyDependsOnFromDependencies can
be used for that purpose.
Change-Id: I47a80699fe881d4075b292ad164dd6e776049a83
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'tests')
12 files changed, 208 insertions, 7 deletions
diff --git a/tests/auto/api/testdata/excluded-inputs/excluded-inputs.qbs b/tests/auto/api/testdata/excluded-inputs/excluded-inputs.qbs index 37c4261f4..faa51d3b9 100644 --- a/tests/auto/api/testdata/excluded-inputs/excluded-inputs.qbs +++ b/tests/auto/api/testdata/excluded-inputs/excluded-inputs.qbs @@ -92,7 +92,7 @@ Project { } Rule { multiplex: true - explicitlyDependsOn: "the_tag" + explicitlyDependsOnFromDependencies: "the_tag" excludedAuxiliaryInputs: "the_other_tag" Artifact { filePath: "dummy3.txt" diff --git a/tests/auto/api/testdata/explicitly-depends-on/explicitly-depends-on.qbs b/tests/auto/api/testdata/explicitly-depends-on/explicitly-depends-on.qbs index 0ac4a7463..17aa74697 100644 --- a/tests/auto/api/testdata/explicitly-depends-on/explicitly-depends-on.qbs +++ b/tests/auto/api/testdata/explicitly-depends-on/explicitly-depends-on.qbs @@ -20,7 +20,7 @@ Project { Rule { inputs: ["mytype.in"] - explicitlyDependsOn: ["compiler"] + explicitlyDependsOnFromDependencies: ["compiler"] Artifact { filePath: input.fileName + ".out" fileTags: product.type @@ -36,7 +36,7 @@ Project { Rule { multiplex: true - explicitlyDependsOn: ["compiler"] + explicitlyDependsOnFromDependencies: ["compiler"] Artifact { filePath: "compiler-name.txt" fileTags: product.type diff --git a/tests/auto/api/testdata/tool-in-module/use-outside-project/modules/thetool/thetool.qbs b/tests/auto/api/testdata/tool-in-module/use-outside-project/modules/thetool/thetool.qbs index d9bd47003..9521f3ae4 100644 --- a/tests/auto/api/testdata/tool-in-module/use-outside-project/modules/thetool/thetool.qbs +++ b/tests/auto/api/testdata/tool-in-module/use-outside-project/modules/thetool/thetool.qbs @@ -13,7 +13,7 @@ Module { Rule { multiplex: true - explicitlyDependsOn: ["thetool.thetool"] + explicitlyDependsOnFromDependencies: ["thetool.thetool"] Artifact { filePath: "tool-output.txt" fileTags: ["thetool.output"] diff --git a/tests/auto/api/testdata/tool-in-module/use-within-project/use-within-project.qbs b/tests/auto/api/testdata/tool-in-module/use-within-project/use-within-project.qbs index 13b2bb819..bd480fb08 100644 --- a/tests/auto/api/testdata/tool-in-module/use-within-project/use-within-project.qbs +++ b/tests/auto/api/testdata/tool-in-module/use-within-project/use-within-project.qbs @@ -15,7 +15,7 @@ Project { Depends { name: "cpp" } Rule { multiplex: true - explicitlyDependsOn: ["thetool.thetool"] + explicitlyDependsOnFromDependencies: ["thetool.thetool"] Artifact { filePath: "tool-output.txt" fileTags: ["thetool.output"] diff --git a/tests/auto/blackbox/testdata/aux-inputs-from-deps/aux-inputs-from-deps.qbs b/tests/auto/blackbox/testdata/aux-inputs-from-deps/aux-inputs-from-deps.qbs index e5be44b76..620ae2ea0 100644 --- a/tests/auto/blackbox/testdata/aux-inputs-from-deps/aux-inputs-from-deps.qbs +++ b/tests/auto/blackbox/testdata/aux-inputs-from-deps/aux-inputs-from-deps.qbs @@ -16,7 +16,7 @@ Project { Depends { name: "dep" } Rule { multiplex: true - explicitlyDependsOn: ["hpp"] + explicitlyDependsOnFromDependencies: ["hpp"] Artifact { filePath: "dummy.out" fileTags: ["p.out"] diff --git a/tests/auto/blackbox/testdata/explicitly-depends-on/explicitly-depends-on.qbs b/tests/auto/blackbox/testdata/explicitly-depends-on/explicitly-depends-on.qbs new file mode 100644 index 000000000..10cfa089b --- /dev/null +++ b/tests/auto/blackbox/testdata/explicitly-depends-on/explicitly-depends-on.qbs @@ -0,0 +1,124 @@ +import qbs +import qbs.File +import qbs.TextFile + +Project { + // Cases: + // step1 + in-product final -> step2 -> step3 -> final => rule cycle + // step1 + dependency final -> step2 -> step3 -> final => ok + // step1 + module filesAreTargets final -> step2 -> step3 -> final => ok + + name: "proj1" + property bool useModule: false + + Product { + name: "prod1" + type: "final" + property bool useExplicitlyDependsOn: false + property bool useExplicitlyDependsOnFromDependencies: false + + Depends { + condition: !project.useModule + name: "prod2" + } + Depends { + condition: project.useModule + name: "module1" + } + + Group { + files: ["step1.txt"] + fileTags: ["step1"] + } + + Rule { + inputs: ["step3"] + outputFileTags: ["final"] + Artifact { + filePath: "final.txt" + fileTags: ["final"] + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "step3 -> final"; + cmd.sourceCode = function() { + File.copy(input.filePath, output.filePath); + }; + return cmd; + } + } + + Rule { + inputs: ["step2"] + outputFileTags: ["step3"] + Artifact { + filePath: "step3.txt" + fileTags: ["step3"] + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "step2 -> step3"; + cmd.sourceCode = function() { + File.copy(input.filePath, output.filePath); + }; + return cmd; + } + } + + Rule { + inputs: ["step1"] + outputFileTags: ["step2"] + Artifact { + filePath: "step2.txt" + fileTags: ["step2"] + } + + Properties { + condition: useExplicitlyDependsOn + explicitlyDependsOn: ["final"] + } + + Properties { + condition: useExplicitlyDependsOnFromDependencies + explicitlyDependsOnFromDependencies: ["final"] + } + + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "step1 -> step2"; + cmd.sourceCode = function() { + console.info("Using explicitlyDependsOnArtifact: " + + explicitlyDependsOn["final"][0].fileName) + File.copy(input.filePath, output.filePath); + }; + return cmd; + } + } + } + + Product { + name: "prod2" + type: "final" + condition: !project.useModule + + Rule { + multiplex: true + requiresInputs: false + outputFileTags: ["final"] + Artifact { + filePath: "product-fish.txt" + fileTags: ["final"] + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "creating 'product-fish.txt' tagged with 'final'"; + cmd.sourceCode = function() { + var file = new TextFile(output.filePath, TextFile.ReadWrite); + file.write("Lots of fish."); + file.close() + }; + return cmd; + } + } + } +} diff --git a/tests/auto/blackbox/testdata/explicitly-depends-on/modules/module1/module-fish.txt b/tests/auto/blackbox/testdata/explicitly-depends-on/modules/module1/module-fish.txt new file mode 100644 index 000000000..10b4b7cbe --- /dev/null +++ b/tests/auto/blackbox/testdata/explicitly-depends-on/modules/module1/module-fish.txt @@ -0,0 +1 @@ +Module fish diff --git a/tests/auto/blackbox/testdata/explicitly-depends-on/modules/module1/module1.qbs b/tests/auto/blackbox/testdata/explicitly-depends-on/modules/module1/module1.qbs new file mode 100644 index 000000000..f1752b4ed --- /dev/null +++ b/tests/auto/blackbox/testdata/explicitly-depends-on/modules/module1/module1.qbs @@ -0,0 +1,9 @@ +import qbs + +Module { + Group { + filesAreTargets: true + fileTags: ["final"] + files: ["module-fish.txt"] + } +} diff --git a/tests/auto/blackbox/testdata/explicitly-depends-on/step1.txt b/tests/auto/blackbox/testdata/explicitly-depends-on/step1.txt new file mode 100644 index 000000000..45b983be3 --- /dev/null +++ b/tests/auto/blackbox/testdata/explicitly-depends-on/step1.txt @@ -0,0 +1 @@ +hi diff --git a/tests/auto/blackbox/testdata/exports-qbs/tool.qbs b/tests/auto/blackbox/testdata/exports-qbs/tool.qbs index 0139b7e14..b0078a75c 100644 --- a/tests/auto/blackbox/testdata/exports-qbs/tool.qbs +++ b/tests/auto/blackbox/testdata/exports-qbs/tool.qbs @@ -40,7 +40,7 @@ CppApplication { property var helper2Obj: Helper2 Rule { inputs: Helper.toolInputs() - explicitlyDependsOn: toolTags + explicitlyDependsOnFromDependencies: toolTags outputFileTags: parent.outTags outputArtifacts: [{ diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index 62930f54f..a18a735ab 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -4936,6 +4936,70 @@ void TestBlackbox::auxiliaryInputsFromDependencies() QVERIFY2(m_qbsStdout.contains("generating dummy.out"), m_qbsStdout.constData()); } +void TestBlackbox::explicitlyDependsOn() +{ + QFETCH(QString, useExplicitlyDependsOn); + QFETCH(QString, useExplicitlyDependsOnFromDependencies); + QFETCH(QString, useModule); + QFETCH(bool, expectFailure); + + QDir::setCurrent(testDataDir + "/explicitly-depends-on"); + QbsRunParameters params("", + QStringList("products.prod1.useExplicitlyDependsOn:" + useExplicitlyDependsOn) + << "products.prod1.useExplicitlyDependsOnFromDependencies:" + + useExplicitlyDependsOnFromDependencies + << "projects.proj1.useModule:" + + useModule); + params.expectFailure = expectFailure; + + rmDirR(relativeBuildDir()); + + if (params.expectFailure) { + // Build should fail because a rule cycle is created within the product when + // explicitlyDependsOn is used. + QVERIFY(runQbs(params) != 0); + QVERIFY2(m_qbsStderr.contains("Cycle detected in rule dependencies"), + m_qbsStderr.constData()); + } else { + // When explicitlyDependsOnFromDependencies is used, build should succeed due to the + // "final" tag being pulled in from dependencies. + QCOMPARE(runQbs(params), 0); + + if (useModule == QLatin1String("false")) { + QVERIFY2(m_qbsStdout.contains("creating 'product-fish.txt' tagged with 'final'"), + m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("Using explicitlyDependsOnArtifact: product-fish.txt"), + m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("step1 -> step2"), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("step2 -> step3"), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("step3 -> final"), m_qbsStdout.constData()); + } else { + QVERIFY2(!m_qbsStdout.contains("creating 'product-fish.txt' tagged with 'final'"), + m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("Using explicitlyDependsOnArtifact: module-fish.txt"), + m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("step1 -> step2"), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("step2 -> step3"), m_qbsStdout.constData()); + QVERIFY2(m_qbsStdout.contains("step3 -> final"), m_qbsStdout.constData()); + } + } +} + +void TestBlackbox::explicitlyDependsOn_data() +{ + QTest::addColumn<QString>("useExplicitlyDependsOn"); + QTest::addColumn<QString>("useExplicitlyDependsOnFromDependencies"); + QTest::addColumn<QString>("useModule"); + QTest::addColumn<bool>("expectFailure"); + + QTest::newRow("useExplicitlyDependsOn -> causes cycle") + << "true" << "false" << "false" << true; + QTest::newRow("explicitlyDependsOnFromDependencies + product") + << "false" << "true" << "false" << false; + QTest::newRow("explicitlyDependsOnFromDependencies + module + filesAreTargets") + << "false" << "true" << "true" << false; +} + static bool haveMakeNsis() { QStringList regKeys; diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h index f3fb1f90d..5a4544bbe 100644 --- a/tests/auto/blackbox/tst_blackbox.h +++ b/tests/auto/blackbox/tst_blackbox.h @@ -97,6 +97,8 @@ private slots: void erroneousFiles(); void errorInfo(); void escapedLinkerFlags(); + void explicitlyDependsOn(); + void explicitlyDependsOn_data(); void exportedDependencyInDisabledProduct(); void exportedDependencyInDisabledProduct_data(); void exportedPropertyInDisabledProduct(); |