aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/api
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2018-03-15 17:48:36 +0100
committerChristian Kandeler <christian.kandeler@qt.io>2018-04-05 10:43:36 +0000
commitbaa09164ae14c58ec11a925a1f0fa57117e8ff1d (patch)
tree3d3d64f3801050eee244e02f273e21a312bcb69b /tests/auto/api
parent8884edef3ce886748a5fcc10f0c452b0a1a9a411 (diff)
Fix and rename the excludedAuxiliaryInputs property
This property did not only exclude auxiliary inputs, but all kinds of inputs ("inputs", "auxiliaryInputs", "explicitlyDependsOn"), which happens to be what we want, as it does not appear to make any sense to exclude only tags from one of the relevant "input-like" properties. But the behavior was inconsistent: When building the (product-local) rule graph, the property was considered, but not when collecting artifacts from other products during rule application. This is now fixed. [ChangeLog] The excludedAuxiliaryInputs property of the Rule item has been renamed to excludedInputs. The old name is deprecated. Change-Id: Id7eae3461a6e85f53b3d47750d296c3e47a18a95 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Diffstat (limited to 'tests/auto/api')
-rw-r--r--tests/auto/api/testdata/excluded-inputs/excluded-inputs.qbs114
-rw-r--r--tests/auto/api/tst_api.cpp46
-rw-r--r--tests/auto/api/tst_api.h1
3 files changed, 161 insertions, 0 deletions
diff --git a/tests/auto/api/testdata/excluded-inputs/excluded-inputs.qbs b/tests/auto/api/testdata/excluded-inputs/excluded-inputs.qbs
new file mode 100644
index 000000000..37c4261f4
--- /dev/null
+++ b/tests/auto/api/testdata/excluded-inputs/excluded-inputs.qbs
@@ -0,0 +1,114 @@
+import qbs
+import qbs.File
+import qbs.TextFile
+
+Project {
+ Product {
+ name: "dep"
+ type: "the_tag"
+ Rule {
+ multiplex: true
+ Artifact {
+ filePath: "file1.txt"
+ fileTags: "the_tag"
+ }
+ prepare: {
+ var cmd = new JavaScriptCommand();
+ cmd.description = "creating " + output.fileName;
+ cmd.sourceCode = function() {
+ var f = new TextFile(output.filePath, TextFile.WriteOnly);
+ f.writeLine("the_content");
+ f.close();
+ };
+ return cmd;
+ }
+ }
+ Rule {
+ inputs: "the_tag"
+ excludedInputs: "the_other_tag"
+ Artifact {
+ filePath: "file2.txt"
+ fileTags: "the_other_tag"
+ }
+ prepare: {
+ var cmd = new JavaScriptCommand();
+ cmd.description = "creating " + output.fileName;
+ cmd.sourceCode = function() {
+ File.copy(input.filePath, output.filePath);
+ var f = new TextFile(output.filePath, TextFile.Append);
+ f.writeLine("the_other_content");
+ f.close();
+ };
+ return cmd;
+ }
+ }
+ Group {
+ fileTagsFilter: "the_other_tag"
+ fileTags: "the_tag"
+ }
+ }
+ Product {
+ name: "p"
+ type: "p_type"
+ Depends { name: "dep" }
+ Rule {
+ multiplex: true
+ inputsFromDependencies: "the_tag"
+ Artifact {
+ filePath: "dummy1.txt"
+ fileTags: "p_type"
+ }
+ prepare: {
+ var cmd = new JavaScriptCommand();
+ cmd.description = "creating " + output.fileName;;
+ if (!inputs["the_tag"] || inputs["the_tag"].length != 2)
+ throw "Huch?";
+ cmd.sourceCode = function() {
+ var f = new TextFile(output.filePath, TextFile.WriteOnly);
+ f.close();
+ };
+ return cmd;
+ }
+ }
+ Rule {
+ multiplex: true
+ inputsFromDependencies: "the_tag"
+ excludedInputs: "the_other_tag"
+ Artifact {
+ filePath: "dummy2.txt"
+ fileTags: "p_type"
+ }
+ prepare: {
+ var cmd = new JavaScriptCommand();
+ cmd.description = "creating " + output.fileName;;
+ if (!inputs["the_tag"] || inputs["the_tag"].length != 1)
+ throw "Huch?";
+ cmd.sourceCode = function() {
+ var f = new TextFile(output.filePath, TextFile.WriteOnly);
+ f.close();
+ };
+ return cmd;
+ }
+ }
+ Rule {
+ multiplex: true
+ explicitlyDependsOn: "the_tag"
+ excludedAuxiliaryInputs: "the_other_tag"
+ Artifact {
+ filePath: "dummy3.txt"
+ fileTags: "p_type"
+ }
+ prepare: {
+ var cmd = new JavaScriptCommand();
+ cmd.description = "creating " + output.fileName;
+ if (!explicitlyDependsOn["the_tag"] || explicitlyDependsOn["the_tag"].length != 1)
+ throw "Huch?";
+ cmd.sourceCode = function() {
+ var f = new TextFile(output.filePath, TextFile.WriteOnly);
+ f.close();
+ };
+ return cmd;
+ }
+ }
+ }
+}
diff --git a/tests/auto/api/tst_api.cpp b/tests/auto/api/tst_api.cpp
index 750ac988f..4fb2d8a3a 100644
--- a/tests/auto/api/tst_api.cpp
+++ b/tests/auto/api/tst_api.cpp
@@ -1039,6 +1039,52 @@ void TestApi::errorInSetupRunEnvironment()
QVERIFY(!exceptionCaught);
}
+void TestApi::excludedInputs()
+{
+ qbs::SetupProjectParameters setupParams = defaultSetupParameters("excluded-inputs");
+ std::unique_ptr<qbs::SetupProjectJob> job(qbs::Project().setupProject(setupParams,
+ m_logSink, 0));
+ waitForFinished(job.get());
+ QVERIFY2(!job->error().hasError(), qPrintable(job->error().toString()));
+ const qbs::Project project = job->project();
+ std::unique_ptr<qbs::BuildJob> buildJob(project.buildAllProducts(qbs::BuildOptions()));
+ waitForFinished(buildJob.get());
+ QVERIFY2(!buildJob->error().hasError(), qPrintable(job->error().toString()));
+ QVERIFY(project.isValid());
+ QCOMPARE(project.projectData().products().size(), 2);
+ qbs::ProductData depProduct;
+ qbs::ProductData pProduct;
+ for (qbs::ProductData &p : project.projectData().products()) {
+ if (p.name() == "dep")
+ depProduct = p;
+ else if (p.name() == "p")
+ pProduct = p;
+ }
+ QVERIFY(depProduct.isValid());
+ QVERIFY(pProduct.isValid());
+ int theTagCount = 0;
+ for (const qbs::ArtifactData &artifact : depProduct.targetArtifacts()) {
+ if (!artifact.fileTags().contains("the_tag"))
+ continue;
+ ++theTagCount;
+ QFile f(artifact.filePath());
+ QVERIFY2(f.open(QIODevice::ReadOnly), qPrintable(f.errorString()));
+ const QByteArray content = f.readAll();
+ QVERIFY2(content.contains("the_content"), content.constData());
+ QCOMPARE(artifact.fileTags().contains("the_other_tag"),
+ content.contains("the_other_content"));
+ }
+ QCOMPARE(theTagCount, 2);
+ int dummyCount = 0;
+ for (const qbs::ArtifactData &artifact : pProduct.targetArtifacts()) {
+ QFileInfo fi(artifact.filePath());
+ QVERIFY2(fi.exists(), qPrintable(fi.filePath()));
+ if (fi.fileName().startsWith("dummy"))
+ ++dummyCount;
+ }
+ QCOMPARE(dummyCount, 3);
+}
+
static qbs::ErrorInfo forceRuleEvaluation(const qbs::Project project)
{
qbs::BuildOptions buildOptions;
diff --git a/tests/auto/api/tst_api.h b/tests/auto/api/tst_api.h
index c8852acdf..3f5b88715 100644
--- a/tests/auto/api/tst_api.h
+++ b/tests/auto/api/tst_api.h
@@ -84,6 +84,7 @@ private slots:
void emptySubmodulesList();
void enableAndDisableProduct();
void errorInSetupRunEnvironment();
+ void excludedInputs();
void explicitlyDependsOn();
void exportSimple();
void exportWithRecursiveDepends();