diff options
author | Christian Kandeler <christian.kandeler@digia.com> | 2013-11-22 12:24:27 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@digia.com> | 2013-11-25 13:21:51 +0100 |
commit | d7656eef2decad018759cae7f18c4e66c3a688bf (patch) | |
tree | c655d6b323900ff7a3d52818028498a6d8b293aa /tests/auto | |
parent | b46a9a08fd48872cffb622ed1dd596087a6e7a4c (diff) |
Lock the build graph while jobs are running.
All jobs except setting up the project are mutually exclusive, and it is
also forbidden to change the project internally while they are going on.
Currently, ignoring this requirement leads to undefined behavior. Since
we can detect such a condition and react in a defined way, we should do
it.
Note: This is about the API and the in-memory build graph, not about
competing accesses to the stored build graph from different processes.
That's a different (and more difficult) problem.
Change-Id: I2d8a715334b2b73b4f4d32781d0b4f83b1612d40
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/api/tst_api.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/auto/api/tst_api.cpp b/tests/auto/api/tst_api.cpp index a148f5052..61b1ebc83 100644 --- a/tests/auto/api/tst_api.cpp +++ b/tests/auto/api/tst_api.cpp @@ -295,7 +295,8 @@ void TestApi::changeContent() job.reset(qbs::Project::setupProject(setupParams, m_logSink, 0)); waitForFinished(job.data()); QVERIFY2(!job->error().hasError(), qPrintable(job->error().toString())); - const qbs::ProjectData newProjectData = job->project().projectData(); + project = job->project(); + const qbs::ProjectData newProjectData = project.projectData(); const bool projectDataMatches = newProjectData == projectData; if (!projectDataMatches) { qDebug("This is the assumed project:"); @@ -306,13 +307,22 @@ void TestApi::changeContent() QVERIFY(projectDataMatches); // Will fail if e.g. code locations don't match. // Now try building again and check if the newly resolved product behaves the same way. - buildJob.reset(job->project().buildAllProducts(buildOptions, this)); + buildJob.reset(project.buildAllProducts(buildOptions, this)); connect(buildJob.data(), SIGNAL(reportCommandDescription(QString, QString)), &rcvr, SLOT(handleDescription(QString,QString))); waitForFinished(buildJob.data()); QVERIFY2(!buildJob->error().hasError(), qPrintable(buildJob->error().toString())); QVERIFY(rcvr.descriptions.contains("compiling file.cpp")); QVERIFY(!rcvr.descriptions.contains("compiling main.cpp")); + + // Error handling: Try to change the project during a build. + buildJob.reset(project.buildAllProducts(buildOptions, this)); + errorInfo = project.addGroup(newProjectData.products().first(), "blubb"); + QVERIFY(errorInfo.hasError()); + QVERIFY2(errorInfo.toString().contains("in process"), qPrintable(errorInfo.toString())); + waitForFinished(buildJob.data()); + errorInfo = project.addGroup(newProjectData.products().first(), "blubb"); + QVERIFY2(!errorInfo.hasError(), qPrintable(errorInfo.toString())); } void TestApi::disabledInstallGroup() |