aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@digia.com>2013-11-29 15:12:40 +0100
committerChristian Kandeler <christian.kandeler@digia.com>2013-12-05 11:23:19 +0100
commitabb499afaf5b3c2339980fefa5f82fd9239881f2 (patch)
tree8f1beff40674ba0282f409b8a743c32cd2f4ee05 /tests/auto
parenta9ad6ffc6e6e51e9c3b398818a2376ae9ecf5bda (diff)
Allow directories in "references" properties.
Such a construct will work if the given directory contains exactly one project file, identified by the ".qbs" extension. This saves annoying redundancies of the form "references: 'mysubproject/mysubproject.qbs'". Change-Id: Ief0f52f788189b7fb2e4764b692159b570fe444c Task-number: QBS-454 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/api/testdata/references/invalid1.qbs5
-rw-r--r--tests/auto/api/testdata/references/invalid2.qbs5
-rw-r--r--tests/auto/api/testdata/references/subdir-with-multiple-projects/subproject1.qbs0
-rw-r--r--tests/auto/api/testdata/references/subdir-with-multiple-projects/subproject2.qbs0
-rw-r--r--tests/auto/api/testdata/references/subdir-with-multiple-projects/subproject3.qbs0
-rw-r--r--tests/auto/api/testdata/references/subdir-with-no-project/test.txt0
-rw-r--r--tests/auto/api/testdata/references/subdir-with-one-project/p.qbs3
-rw-r--r--tests/auto/api/testdata/references/subdir-with-one-project/test.txt0
-rw-r--r--tests/auto/api/testdata/references/valid.qbs5
-rw-r--r--tests/auto/api/tst_api.cpp31
-rw-r--r--tests/auto/api/tst_api.h1
-rw-r--r--tests/auto/blackbox/testdata/subprojects/toplevelproject.qbs2
12 files changed, 51 insertions, 1 deletions
diff --git a/tests/auto/api/testdata/references/invalid1.qbs b/tests/auto/api/testdata/references/invalid1.qbs
new file mode 100644
index 000000000..4bbb26d3a
--- /dev/null
+++ b/tests/auto/api/testdata/references/invalid1.qbs
@@ -0,0 +1,5 @@
+import qbs
+
+Project {
+ references: "subdir-with-no-project"
+} \ No newline at end of file
diff --git a/tests/auto/api/testdata/references/invalid2.qbs b/tests/auto/api/testdata/references/invalid2.qbs
new file mode 100644
index 000000000..1946e2221
--- /dev/null
+++ b/tests/auto/api/testdata/references/invalid2.qbs
@@ -0,0 +1,5 @@
+import qbs
+
+Project {
+ references: "subdir-with-multiple-projects"
+} \ No newline at end of file
diff --git a/tests/auto/api/testdata/references/subdir-with-multiple-projects/subproject1.qbs b/tests/auto/api/testdata/references/subdir-with-multiple-projects/subproject1.qbs
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/auto/api/testdata/references/subdir-with-multiple-projects/subproject1.qbs
diff --git a/tests/auto/api/testdata/references/subdir-with-multiple-projects/subproject2.qbs b/tests/auto/api/testdata/references/subdir-with-multiple-projects/subproject2.qbs
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/auto/api/testdata/references/subdir-with-multiple-projects/subproject2.qbs
diff --git a/tests/auto/api/testdata/references/subdir-with-multiple-projects/subproject3.qbs b/tests/auto/api/testdata/references/subdir-with-multiple-projects/subproject3.qbs
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/auto/api/testdata/references/subdir-with-multiple-projects/subproject3.qbs
diff --git a/tests/auto/api/testdata/references/subdir-with-no-project/test.txt b/tests/auto/api/testdata/references/subdir-with-no-project/test.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/auto/api/testdata/references/subdir-with-no-project/test.txt
diff --git a/tests/auto/api/testdata/references/subdir-with-one-project/p.qbs b/tests/auto/api/testdata/references/subdir-with-one-project/p.qbs
new file mode 100644
index 000000000..7d453a671
--- /dev/null
+++ b/tests/auto/api/testdata/references/subdir-with-one-project/p.qbs
@@ -0,0 +1,3 @@
+import qbs
+
+Project { }
diff --git a/tests/auto/api/testdata/references/subdir-with-one-project/test.txt b/tests/auto/api/testdata/references/subdir-with-one-project/test.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/auto/api/testdata/references/subdir-with-one-project/test.txt
diff --git a/tests/auto/api/testdata/references/valid.qbs b/tests/auto/api/testdata/references/valid.qbs
new file mode 100644
index 000000000..43d728a4d
--- /dev/null
+++ b/tests/auto/api/testdata/references/valid.qbs
@@ -0,0 +1,5 @@
+import qbs
+
+Project {
+ references: "subdir-with-one-project"
+}
diff --git a/tests/auto/api/tst_api.cpp b/tests/auto/api/tst_api.cpp
index 61b1ebc83..775ed6ec1 100644
--- a/tests/auto/api/tst_api.cpp
+++ b/tests/auto/api/tst_api.cpp
@@ -45,6 +45,7 @@
#include <QCoreApplication>
#include <QDir>
#include <QEventLoop>
+#include <QFileInfo>
#include <QScopedPointer>
#include <QStringList>
#include <QTest>
@@ -480,6 +481,36 @@ qbs::SetupProjectParameters TestApi::defaultSetupParameters() const
return setupParams;
}
+void TestApi::references()
+{
+ qbs::SetupProjectParameters setupParams = defaultSetupParameters();
+ const QString projectDir = QDir::cleanPath(m_workingDataDir + "/references");
+ setupParams.setProjectFilePath(projectDir + QLatin1String("/invalid1.qbs"));
+ QScopedPointer<qbs::SetupProjectJob> job(qbs::Project::setupProject(setupParams,
+ m_logSink, 0));
+ waitForFinished(job.data());
+ QVERIFY(job->error().hasError());
+ QString errorString = job->error().toString();
+ QVERIFY2(errorString.contains("does not contain"), qPrintable(errorString));
+
+ setupParams.setProjectFilePath(projectDir + QLatin1String("/invalid2.qbs"));
+ job.reset(qbs::Project::setupProject(setupParams, m_logSink, 0));
+ waitForFinished(job.data());
+ QVERIFY(job->error().hasError());
+ errorString = job->error().toString();
+ QVERIFY2(errorString.contains("contains more than one"), qPrintable(errorString));
+
+ setupParams.setProjectFilePath(projectDir + QLatin1String("/valid.qbs"));
+ job.reset(qbs::Project::setupProject(setupParams, m_logSink, 0));
+ waitForFinished(job.data());
+ QVERIFY2(!job->error().hasError(), qPrintable(job->error().toString()));
+ const qbs::ProjectData topLevelProject = job->project().projectData();
+ QCOMPARE(topLevelProject.subProjects().count(), 1);
+ const QString subProjectFileName
+ = QFileInfo(topLevelProject.subProjects().first().location().fileName()).fileName();
+ QCOMPARE(subProjectFileName, QString("p.qbs"));
+}
+
QTEST_MAIN(TestApi)
#include "tst_api.moc"
diff --git a/tests/auto/api/tst_api.h b/tests/auto/api/tst_api.h
index ffeff6922..f240dca2e 100644
--- a/tests/auto/api/tst_api.h
+++ b/tests/auto/api/tst_api.h
@@ -54,6 +54,7 @@ private slots:
void listBuildSystemFiles();
void nonexistingProjectPropertyFromProduct();
void nonexistingProjectPropertyFromCommandLine();
+ void references();
private:
qbs::SetupProjectParameters defaultSetupParameters() const;
diff --git a/tests/auto/blackbox/testdata/subprojects/toplevelproject.qbs b/tests/auto/blackbox/testdata/subprojects/toplevelproject.qbs
index 84a2a211f..f167ccabc 100644
--- a/tests/auto/blackbox/testdata/subprojects/toplevelproject.qbs
+++ b/tests/auto/blackbox/testdata/subprojects/toplevelproject.qbs
@@ -2,7 +2,7 @@ import qbs
Project {
name: "top level project"
- references: ["subproject2/subproject2.qbs"]
+ references: ["subproject2"]
Project {
condition: true