From abb499afaf5b3c2339980fefa5f82fd9239881f2 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Fri, 29 Nov 2013 15:12:40 +0100 Subject: 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 --- tests/auto/api/testdata/references/invalid1.qbs | 5 ++++ tests/auto/api/testdata/references/invalid2.qbs | 5 ++++ .../subdir-with-multiple-projects/subproject1.qbs | 0 .../subdir-with-multiple-projects/subproject2.qbs | 0 .../subdir-with-multiple-projects/subproject3.qbs | 0 .../references/subdir-with-no-project/test.txt | 0 .../references/subdir-with-one-project/p.qbs | 3 +++ .../references/subdir-with-one-project/test.txt | 0 tests/auto/api/testdata/references/valid.qbs | 5 ++++ tests/auto/api/tst_api.cpp | 31 ++++++++++++++++++++++ tests/auto/api/tst_api.h | 1 + 11 files changed, 50 insertions(+) create mode 100644 tests/auto/api/testdata/references/invalid1.qbs create mode 100644 tests/auto/api/testdata/references/invalid2.qbs create mode 100644 tests/auto/api/testdata/references/subdir-with-multiple-projects/subproject1.qbs create mode 100644 tests/auto/api/testdata/references/subdir-with-multiple-projects/subproject2.qbs create mode 100644 tests/auto/api/testdata/references/subdir-with-multiple-projects/subproject3.qbs create mode 100644 tests/auto/api/testdata/references/subdir-with-no-project/test.txt create mode 100644 tests/auto/api/testdata/references/subdir-with-one-project/p.qbs create mode 100644 tests/auto/api/testdata/references/subdir-with-one-project/test.txt create mode 100644 tests/auto/api/testdata/references/valid.qbs (limited to 'tests/auto/api') 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 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 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 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 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 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 #include #include +#include #include #include #include @@ -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 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; -- cgit v1.2.3