diff options
Diffstat (limited to 'tests')
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 |