diff options
author | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2018-01-05 09:35:00 +0100 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2018-01-19 13:16:07 +0000 |
commit | 2d7f1d6c8cf5c9be01d12bd71dbf05da6ce7c3d6 (patch) | |
tree | 1d35fd890828c8051ae63c48d7275ee0439151b1 /tests | |
parent | dd06a4188d375f990d7ef391b5b626d169a1d196 (diff) |
Clang: Take over jobs if document's project changes
On registerProjectPartsForEditor() we recreated the affected
DocumentProcessors, but did not take care of the jobs that were in the
queue, which effectively could led to lost jobs. Catch up on this.
Task-number: QTCREATORBUG-18856
Change-Id: I4184e5dc6480667953f2d2081ccf39a28c092186
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'tests')
3 files changed, 37 insertions, 0 deletions
diff --git a/tests/unit/unittest/clangcodemodelserver-test.cpp b/tests/unit/unittest/clangcodemodelserver-test.cpp index 36efb1597a..edcbcff7ad 100644 --- a/tests/unit/unittest/clangcodemodelserver-test.cpp +++ b/tests/unit/unittest/clangcodemodelserver-test.cpp @@ -406,6 +406,18 @@ TEST_F(ClangCodeModelServerSlowTest, TranslationUnitAfterUpdateNeedsReparse) ASSERT_THAT(clangServer, HasDirtyDocument(filePathA, projectPartId, 1U, true, true)); } +TEST_F(ClangCodeModelServerSlowTest, TakeOverJobsOnProjectPartChange) +{ + registerProjectAndFileAndWaitForFinished(filePathC, 2); + updateVisibilty(filePathB, filePathB); // Disable processing jobs + requestReferences(); + + expectReferences(); + + changeProjectPartArguments(); // Here we do not want to loose the RequestReferences job + updateVisibilty(filePathC, filePathC); // Enable processing jobs +} + void ClangCodeModelServer::SetUp() { clangServer.setClient(&mockClangCodeModelClient); diff --git a/tests/unit/unittest/clangdocumentprocessors-test.cpp b/tests/unit/unittest/clangdocumentprocessors-test.cpp index 87990bca11..0e16ab1f4e 100644 --- a/tests/unit/unittest/clangdocumentprocessors-test.cpp +++ b/tests/unit/unittest/clangdocumentprocessors-test.cpp @@ -126,6 +126,19 @@ TEST_F(DocumentProcessors, Remove) ASSERT_TRUE(documentProcessors.processors().empty()); } +TEST_F(DocumentProcessors, ResetTakesOverJobsInQueue) +{ + documentProcessors.create(document); + documentProcessors.processor(document).addJob(JobRequest::Type::RequestReferences); + documents.remove({document.fileContainer()}); + const auto newDocument = *documents.create({document.fileContainer()}).begin(); + + documentProcessors.reset(document, newDocument); + + ASSERT_THAT(documentProcessors.processor(document).queue().first().type, + JobRequest::Type::RequestReferences); +} + TEST_F(DocumentProcessors, RemoveThrowsForNotExisting) { ASSERT_THROW(documentProcessors.remove(document), diff --git a/tests/unit/unittest/clangsupportivetranslationunitinitializer-test.cpp b/tests/unit/unittest/clangsupportivetranslationunitinitializer-test.cpp index 540fcf7fdc..65062a9d16 100644 --- a/tests/unit/unittest/clangsupportivetranslationunitinitializer-test.cpp +++ b/tests/unit/unittest/clangsupportivetranslationunitinitializer-test.cpp @@ -111,6 +111,18 @@ TEST_F(SupportiveTranslationUnitInitializerSlowTest, StartInitializingStartsJob) ASSERT_THAT(runningJob.jobRequest.type, JobRequest::Type::ParseSupportiveTranslationUnit); } +TEST_F(SupportiveTranslationUnitInitializerSlowTest, Abort) +{ + initializer.startInitializing(); + assertSingleJobRunningAndEmptyQueue(); + + initializer.abort(); + + ASSERT_THAT(initializer.state(), + Eq(ClangBackEnd::SupportiveTranslationUnitInitializer::State::Aborted)); + ASSERT_FALSE(jobs.jobFinishedCallback()); +} + TEST_F(SupportiveTranslationUnitInitializer, CheckIfParseJobFinishedAbortsIfDocumentIsClosed) { documents.remove({FileContainer(filePath, projectPartId)}); |