From 9c560689cf8e8401e460f867fdc398f1cbc5449f Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 8 Jan 2015 14:15:15 +0100 Subject: Add failing autotest for newly discovered bug. Task-number: QBS-723 Reviewed-by: Jake Petroules (cherry picked from commit 49f4c6114c80d77ba9e16c17e6eae46eeae52bf5) Conflicts: tests/auto/blackbox/tst_blackbox.h Change-Id: I6cf98fac6c32a297e409bf4916761d3b7c6a9828 Reviewed-by: Christian Kandeler --- .../testdata/wildcards-and-rules/input1.inp | 0 .../testdata/wildcards-and-rules/project.qbs | 37 ++++++++++++++++++++++ tests/auto/blackbox/tst_blackbox.cpp | 31 ++++++++++++++++++ tests/auto/blackbox/tst_blackbox.h | 1 + 4 files changed, 69 insertions(+) create mode 100644 tests/auto/blackbox/testdata/wildcards-and-rules/input1.inp create mode 100644 tests/auto/blackbox/testdata/wildcards-and-rules/project.qbs diff --git a/tests/auto/blackbox/testdata/wildcards-and-rules/input1.inp b/tests/auto/blackbox/testdata/wildcards-and-rules/input1.inp new file mode 100644 index 000000000..e69de29bb diff --git a/tests/auto/blackbox/testdata/wildcards-and-rules/project.qbs b/tests/auto/blackbox/testdata/wildcards-and-rules/project.qbs new file mode 100644 index 000000000..88fadd3a5 --- /dev/null +++ b/tests/auto/blackbox/testdata/wildcards-and-rules/project.qbs @@ -0,0 +1,37 @@ +import qbs +import qbs.TextFile + +Product { + name: "wildcards-and-rules" + type: "mytype" + files: ["*.inp", "*.dep"] + FileTagger { + patterns: "*.inp" + fileTags: ["inp"] + } + FileTagger { + patterns: "*.dep" + fileTags: ["dep"] + } + Rule { + multiplex: true + inputs: ["inp"] + explicitlyDependsOn: ["dep"] + Artifact { + filePath: "test.mytype" + fileTags: product.type + } + prepare: { + var cmd = new JavaScriptCommand(); + cmd.description = "Creating output artifact"; + cmd.highlight = "codegen"; + cmd.sourceCode = function() { + var file = new TextFile(output.filePath, TextFile.WriteOnly); + for (var i = 0; i < inputs.inp.length; ++i) + file.writeLine(inputs.inp[i].fileName); + file.close(); + } + return cmd; + } + } +} diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index 200e4a099..3f4c39248 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -2470,4 +2470,35 @@ QString TestBlackbox::executableFilePath(const QString &productName) const return productBuildDir(productName) + '/' + HostOsInfo::appendExecutableSuffix(productName); } +void TestBlackbox::wildCardsAndRules() +{ + QDir::setCurrent(testDataDir + "/wildcards-and-rules"); + QCOMPARE(runQbs(), 0); + QVERIFY(m_qbsStdout.contains("Creating output artifact")); + QFile output(productBuildDir("wildcards-and-rules") + "/test.mytype"); + QVERIFY2(output.open(QIODevice::ReadOnly), qPrintable(output.errorString())); + QCOMPARE(output.readAll().count('\n'), 1); + output.close(); + + // Add input. + touch("input2.inp"); + QEXPECT_FAIL(0, "QBS-723", Abort); + QbsRunParameters params; + params.expectFailure = true; + QCOMPARE(runQbs(params), 0); + QVERIFY(m_qbsStdout.contains("Creating output artifact")); + QVERIFY2(output.open(QIODevice::ReadOnly), qPrintable(output.errorString())); + QCOMPARE(output.readAll().count('\n'), 2); + output.close(); + + // Add "explicitlyDependsOn". + touch("dep.dep"); + QCOMPARE(runQbs(), 0); + QVERIFY(m_qbsStdout.contains("Creating output artifact")); + + // Add nothing. + QCOMPARE(runQbs(), 0); + QVERIFY(!m_qbsStdout.contains("Creating output artifact")); +} + QTEST_MAIN(TestBlackbox) diff --git a/tests/auto/blackbox/tst_blackbox.h b/tests/auto/blackbox/tst_blackbox.h index 5457225cd..5c9c6fe8a 100644 --- a/tests/auto/blackbox/tst_blackbox.h +++ b/tests/auto/blackbox/tst_blackbox.h @@ -193,6 +193,7 @@ private slots: void testIconset(); void testIconsetApp(); void testAssetCatalog(); + void wildCardsAndRules(); private: QString uniqueProductName(const QString &productName) const; -- cgit v1.2.3 From ab4dc4c45d9580d579044f80ca1a0bec0fca2cea Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 12 Jan 2015 17:50:29 +0100 Subject: update leaves for invalidated artifacts Artifacts that get invalidated by rules must be considered as source for new leaves in the executor. Task-number: QBS-723 Change-Id: I6a6f40725103f1f4a917d3e71f968dc355f8a763 Reviewed-by: Christian Kandeler --- src/lib/corelib/buildgraph/executor.cpp | 1 + src/lib/corelib/buildgraph/rulenode.cpp | 4 +++- src/lib/corelib/buildgraph/rulenode.h | 1 + src/lib/corelib/buildgraph/rulesapplicator.cpp | 5 +++-- src/lib/corelib/buildgraph/rulesapplicator.h | 7 ++++++- tests/auto/blackbox/tst_blackbox.cpp | 2 +- 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/lib/corelib/buildgraph/executor.cpp b/src/lib/corelib/buildgraph/executor.cpp index 775674862..a4341d18f 100644 --- a/src/lib/corelib/buildgraph/executor.cpp +++ b/src/lib/corelib/buildgraph/executor.cpp @@ -476,6 +476,7 @@ void Executor::executeRuleNode(RuleNode *ruleNode) loggedConnect(parentRule, outputArtifact, m_logger); } updateLeaves(result.createdNodes); + updateLeaves(result.invalidatedNodes); } finishNode(ruleNode); if (m_progressObserver) diff --git a/src/lib/corelib/buildgraph/rulenode.cpp b/src/lib/corelib/buildgraph/rulenode.cpp index 0c50b4422..576ee5572 100644 --- a/src/lib/corelib/buildgraph/rulenode.cpp +++ b/src/lib/corelib/buildgraph/rulenode.cpp @@ -121,7 +121,9 @@ void RuleNode::apply(const Logger &logger, const ArtifactSet &changedInputs, } if (!inputs.isEmpty()) { RulesApplicator applicator(product, logger); - result->createdNodes = applicator.applyRuleInEvaluationContext(m_rule, inputs); + applicator.applyRuleInEvaluationContext(m_rule, inputs); + result->createdNodes = applicator.createdArtifacts(); + result->invalidatedNodes = applicator.invalidatedArtifacts(); m_oldInputArtifacts.unite(inputs); } } diff --git a/src/lib/corelib/buildgraph/rulenode.h b/src/lib/corelib/buildgraph/rulenode.h index b5ccabe00..415b90f75 100644 --- a/src/lib/corelib/buildgraph/rulenode.h +++ b/src/lib/corelib/buildgraph/rulenode.h @@ -58,6 +58,7 @@ public: { bool upToDate; NodeSet createdNodes; + NodeSet invalidatedNodes; }; void apply(const Logger &logger, const ArtifactSet &changedInputs, ApplicationResult *result); diff --git a/src/lib/corelib/buildgraph/rulesapplicator.cpp b/src/lib/corelib/buildgraph/rulesapplicator.cpp index 0756ac8c7..aa08f992b 100644 --- a/src/lib/corelib/buildgraph/rulesapplicator.cpp +++ b/src/lib/corelib/buildgraph/rulesapplicator.cpp @@ -66,13 +66,13 @@ RulesApplicator::~RulesApplicator() delete m_mocScanner; } -NodeSet RulesApplicator::applyRuleInEvaluationContext(const RuleConstPtr &rule, +void RulesApplicator::applyRuleInEvaluationContext(const RuleConstPtr &rule, const ArtifactSet &inputArtifacts) { m_createdArtifacts.clear(); + m_invalidatedArtifacts.clear(); RulesEvaluationContext::Scope s(m_product->topLevelProject()->buildData->evaluationContext.data()); applyRule(rule, inputArtifacts); - return m_createdArtifacts; } void RulesApplicator::applyRule(const RuleConstPtr &rule, const ArtifactSet &inputArtifacts) @@ -320,6 +320,7 @@ Artifact *RulesApplicator::createOutputArtifact(const QString &filePath, const F throw ErrorInfo(e); } outputArtifact->clearTimestamp(); + m_invalidatedArtifacts += outputArtifact; } else { outputArtifact = new Artifact; outputArtifact->artifactType = Artifact::Generated; diff --git a/src/lib/corelib/buildgraph/rulesapplicator.h b/src/lib/corelib/buildgraph/rulesapplicator.h index 76d63ac96..ec5261b2b 100644 --- a/src/lib/corelib/buildgraph/rulesapplicator.h +++ b/src/lib/corelib/buildgraph/rulesapplicator.h @@ -52,8 +52,12 @@ class RulesApplicator public: RulesApplicator(const ResolvedProductPtr &product, const Logger &logger); ~RulesApplicator(); - NodeSet applyRuleInEvaluationContext(const RuleConstPtr &rule, + + void applyRuleInEvaluationContext(const RuleConstPtr &rule, const ArtifactSet &inputArtifacts); + const NodeSet &createdArtifacts() const { return m_createdArtifacts; } + const NodeSet &invalidatedArtifacts() const { return m_invalidatedArtifacts; } + void applyRule(const RuleConstPtr &rule, const ArtifactSet &inputArtifacts); static void handleRemovedRuleOutputs(const ArtifactSet &inputArtifacts, ArtifactSet artifactsToRemove, const Logger &logger); @@ -76,6 +80,7 @@ private: const ResolvedProductPtr m_product; NodeSet m_createdArtifacts; + NodeSet m_invalidatedArtifacts; RuleConstPtr m_rule; ArtifactSet m_completeInputSet; TransformerPtr m_transformer; diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index 3f4c39248..49012c9d8 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -2482,7 +2482,6 @@ void TestBlackbox::wildCardsAndRules() // Add input. touch("input2.inp"); - QEXPECT_FAIL(0, "QBS-723", Abort); QbsRunParameters params; params.expectFailure = true; QCOMPARE(runQbs(params), 0); @@ -2494,6 +2493,7 @@ void TestBlackbox::wildCardsAndRules() // Add "explicitlyDependsOn". touch("dep.dep"); QCOMPARE(runQbs(), 0); + QEXPECT_FAIL(0, "QBS-724", Abort); QVERIFY(m_qbsStdout.contains("Creating output artifact")); // Add nothing. -- cgit v1.2.3 From d8a90f254e37cd40cc2a684e584a579689a4fb16 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 13 Jan 2015 12:28:07 +0100 Subject: remove superfluous project variable There's no project variable directly beneath the Project item. Change-Id: I31d158a6d291200b2bb4d739617752a6ab88dd2a Reviewed-by: Christian Kandeler --- qbs.qbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qbs.qbs b/qbs.qbs index 7d084c955..6eb2f35c4 100644 --- a/qbs.qbs +++ b/qbs.qbs @@ -13,7 +13,7 @@ Project { property string relativePluginsPath: "../" + libDirName property string relativeSearchPath: ".." property stringList libRPaths: { - if (!project.enableRPath) + if (!enableRPath) return undefined; if (qbs.targetOS.contains("linux")) return ["$ORIGIN/../" + libDirName]; -- cgit v1.2.3