diff options
author | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2018-05-22 10:44:44 +0200 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2018-05-24 12:33:55 +0000 |
commit | 69dec8a9f8736bcf97bec301433abb60fcefd4b9 (patch) | |
tree | d307ba766cc6888bb5e027e78bede41ce7532f72 /tests | |
parent | 8fa15892a417bd4c2af33a9dab1f394e93539c54 (diff) |
Clang: Create preamble on first parse
...now that parsing and creating the preamble is faster due to the
skipped function bodies.
As a consequence, we can remove all the extra jobs that were needed to
get an initial AST faster.
Change-Id: I79a66b8a0e8a180850af6daf353d9a679089bbb1
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'tests')
6 files changed, 3 insertions, 237 deletions
diff --git a/tests/unit/unittest/clangcreateinitialdocumentpreamblejob-test.cpp b/tests/unit/unittest/clangcreateinitialdocumentpreamblejob-test.cpp deleted file mode 100644 index 29ef7c68260..00000000000 --- a/tests/unit/unittest/clangcreateinitialdocumentpreamblejob-test.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "clangasyncjob-base.h" - -#include <clangcreateinitialdocumentpreamblejob.h> - -using namespace ClangBackEnd; - -namespace { - -class CreateInitialDocumentPreambleJob : public ClangAsyncJobTest -{ -protected: - void SetUp() override { BaseSetUp(JobRequest::Type::CreateInitialDocumentPreamble, job); } - -protected: - ClangBackEnd::CreateInitialDocumentPreambleJob job; -}; - -using CreateInitialDocumentPreambleJobSlowTest = CreateInitialDocumentPreambleJob; - -TEST_F(CreateInitialDocumentPreambleJob, PrepareAsyncRun) -{ - job.setContext(jobContext); - - ASSERT_TRUE(job.prepareAsyncRun()); -} - -TEST_F(CreateInitialDocumentPreambleJobSlowTest, RunAsync) -{ - document.parse(); - document.setDirtyIfDependencyIsMet(document.filePath()); - job.setContext(jobContext); - job.prepareAsyncRun(); - - job.runAsync(); - - ASSERT_TRUE(waitUntilJobFinished(job)); -} - -} // anonymous diff --git a/tests/unit/unittest/clangjobqueue-test.cpp b/tests/unit/unittest/clangjobqueue-test.cpp index b9c336551f4..de0161c713c 100644 --- a/tests/unit/unittest/clangjobqueue-test.cpp +++ b/tests/unit/unittest/clangjobqueue-test.cpp @@ -309,7 +309,6 @@ TEST_F(JobQueue, PrioritizeCurrentDocumentOverVisible) TEST_F(JobQueue, RunNothingForNotCurrentOrVisibleDocument) { jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateDocumentAnnotations)); - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::CreateInitialDocumentPreamble)); documents.setVisibleInEditors({}); documents.setUsedByCurrentEditor(Utf8StringLiteral("aNonExistingFilePath")); @@ -321,7 +320,7 @@ TEST_F(JobQueue, RunNothingForNotCurrentOrVisibleDocument) TEST_F(JobQueue, RunOnlyOneJobPerTranslationUnitIfMultipleAreInQueue) { jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateDocumentAnnotations)); - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::CreateInitialDocumentPreamble)); + jobQueue.add(createJobRequest(filePath1, JobRequest::Type::RequestDocumentAnnotations)); const JobRequests jobsToRun = jobQueue.processQueue(); @@ -350,7 +349,6 @@ TEST_F(JobQueue, RunJobsForDistinctTranslationUnits) TEST_F(JobQueue, DoNotRunJobForTranslationUnittThatIsBeingProcessed) { jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateDocumentAnnotations)); - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::CreateInitialDocumentPreamble)); JobRequests jobsToRun = jobQueue.processQueue(); jobQueue.setIsJobRunningForTranslationUnitHandler([](const Utf8String &) { return true; @@ -443,16 +441,6 @@ TEST_F(JobQueue, RequestCompleteCodeNotOutdatableByDocumentRevisionChange) ASSERT_THAT(jobsToStart.size(), Eq(1)); } -TEST_F(JobQueue, RequestCreateInitialDocumentPreambleOutdatableByDocumentClose) -{ - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::CreateInitialDocumentPreamble)); - removeDocument(); - - const JobRequests jobsToStart = jobQueue.processQueue(); - - ASSERT_THAT(jobsToStart.size(), Eq(0)); -} - TEST_F(JobQueue, RequestCompleteCodeOutdatableByDocumentRevisionChange) { jobQueue.add(createJobRequest(filePath1, JobRequest::Type::RequestDocumentAnnotations)); diff --git a/tests/unit/unittest/clangparsesupportivetranslationunitjob-test.cpp b/tests/unit/unittest/clangparsesupportivetranslationunitjob-test.cpp index 7a1edd4fc8d..dbb4554a41c 100644 --- a/tests/unit/unittest/clangparsesupportivetranslationunitjob-test.cpp +++ b/tests/unit/unittest/clangparsesupportivetranslationunitjob-test.cpp @@ -66,23 +66,4 @@ TEST_F(ParseSupportiveTranslationUnitJobSlowTest, RunAsync) ASSERT_TRUE(waitUntilJobFinished(job)); } -TEST_F(ParseSupportiveTranslationUnitJobSlowTest, DoNotIncorporateUpdaterResult) -{ - const TimePoint parseTimePointBefore = parseTimePointOfDocument(); - job.setContext(jobContext); - job.prepareAsyncRun(); - - job.runAsync(); - - ASSERT_TRUE(waitUntilJobFinished(job)); - ASSERT_THAT(parseTimePointOfDocument(), Eq(parseTimePointBefore)); -} - -TimePoint ParseSupportiveTranslationUnitJob::parseTimePointOfDocument() -{ - const Utf8String translationUnitId = document.translationUnit().id(); - - return document.translationUnits().parseTimePoint(translationUnitId); -} - } // anonymous diff --git a/tests/unit/unittest/clangreparsesupportivetranslationunitjob-test.cpp b/tests/unit/unittest/clangreparsesupportivetranslationunitjob-test.cpp deleted file mode 100644 index 449de4e2f32..00000000000 --- a/tests/unit/unittest/clangreparsesupportivetranslationunitjob-test.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "clangasyncjob-base.h" - -#include <clangreparsesupportivetranslationunitjob.h> -#include <clangtranslationunits.h> - -using namespace ClangBackEnd; - -using testing::Eq; -using testing::Not; -using testing::_; - -namespace { - -class ReparseSupportiveTranslationUnitJob : public ClangAsyncJobTest -{ -protected: - void SetUp() override { BaseSetUp(JobRequest::Type::ReparseSupportiveTranslationUnit, job); } - - TimePoint parseTimePointOfDocument(); - void parse(); - -protected: - ClangBackEnd::ReparseSupportiveTranslationUnitJob job; -}; - -using ReparseSupportiveTranslationUnitJobSlowTest = ReparseSupportiveTranslationUnitJob; - -TEST_F(ReparseSupportiveTranslationUnitJob, PrepareAsyncRun) -{ - job.setContext(jobContext); - - ASSERT_TRUE(job.prepareAsyncRun()); -} - -TEST_F(ReparseSupportiveTranslationUnitJobSlowTest, RunAsync) -{ - parse(); - job.setContext(jobContext); - job.prepareAsyncRun(); - - job.runAsync(); - - ASSERT_TRUE(waitUntilJobFinished(job)); -} - -TEST_F(ReparseSupportiveTranslationUnitJobSlowTest, IncorporateUpdaterResult) -{ - parse(); - const TimePoint parseTimePointBefore = parseTimePointOfDocument(); - job.setContext(jobContext); - job.prepareAsyncRun(); - - job.runAsync(); - - ASSERT_TRUE(waitUntilJobFinished(job)); - ASSERT_THAT(parseTimePointOfDocument(), Not(Eq(parseTimePointBefore))); -} - -TEST_F(ReparseSupportiveTranslationUnitJobSlowTest, DoNotIncorporateUpdaterResultIfDocumentWasClosed) -{ - parse(); - const TimePoint parseTimePointBefore = parseTimePointOfDocument(); - job.setContext(jobContext); - job.prepareAsyncRun(); - - job.runAsync(); - documents.remove({FileContainer{filePath, projectPartId}}); - - ASSERT_TRUE(waitUntilJobFinished(job)); - ASSERT_THAT(parseTimePointOfDocument(), Eq(parseTimePointBefore)); -} - -TimePoint ReparseSupportiveTranslationUnitJob::parseTimePointOfDocument() -{ - const Utf8String translationUnitId = document.translationUnit().id(); - - return document.translationUnits().parseTimePoint(translationUnitId); -} - -void ReparseSupportiveTranslationUnitJob::parse() -{ - projects.createOrUpdate({ProjectPartContainer{projectPartId, Utf8StringVector()}}); - document.parse(); -} - -} // anonymous diff --git a/tests/unit/unittest/clangsupportivetranslationunitinitializer-test.cpp b/tests/unit/unittest/clangsupportivetranslationunitinitializer-test.cpp index 65062a9d165..86aae2ee2cb 100644 --- a/tests/unit/unittest/clangsupportivetranslationunitinitializer-test.cpp +++ b/tests/unit/unittest/clangsupportivetranslationunitinitializer-test.cpp @@ -144,34 +144,8 @@ TEST_F(SupportiveTranslationUnitInitializerSlowTest, CheckIfParseJobFinishedStar initializer.checkIfParseJobFinished(runningJob); jobs.process(); - assertSingleJobRunningAndEmptyQueue(); - runningJob = jobs.runningJobs().first(); - ASSERT_THAT(runningJob.jobRequest.type, JobRequest::Type::ReparseSupportiveTranslationUnit); -} - -TEST_F(SupportiveTranslationUnitInitializer, CheckIfReparseJobFinishedAbortsIfDocumentIsClosed) -{ - documents.remove({FileContainer(filePath, projectPartId)}); - initializer.setState(ClangBackEnd::SupportiveTranslationUnitInitializer::State::WaitingForReparseJob); - const Jobs::RunningJob runningJob = createRunningJob(JobRequest::Type::ReparseSupportiveTranslationUnit); - - initializer.checkIfReparseJobFinished(runningJob); - - assertNoJobIsRunningAndEmptyQueue(); - ASSERT_THAT(initializer.state(), Eq(ClangBackEnd::SupportiveTranslationUnitInitializer::State::Aborted)); -} - -TEST_F(SupportiveTranslationUnitInitializerSlowTest, CheckIfReparseJobFinishedStartsJob) -{ - parse(); - initializer.setState(ClangBackEnd::SupportiveTranslationUnitInitializer::State::WaitingForReparseJob); - Jobs::RunningJob runningJob = createRunningJob(JobRequest::Type::ReparseSupportiveTranslationUnit); - - initializer.checkIfReparseJobFinished(runningJob); - jobs.process(); - - assertNoJobIsRunningAndEmptyQueue(); - ASSERT_THAT(initializer.state(), Eq(ClangBackEnd::SupportiveTranslationUnitInitializer::State::Initialized)); + ASSERT_THAT(jobs.runningJobs(), IsEmpty()); + ASSERT_THAT(jobs.queue(), IsEmpty()); } TEST_F(SupportiveTranslationUnitInitializerSlowTest, FullRun) diff --git a/tests/unit/unittest/unittest.pro b/tests/unit/unittest/unittest.pro index 050537e071a..622b9e00cde 100644 --- a/tests/unit/unittest/unittest.pro +++ b/tests/unit/unittest/unittest.pro @@ -104,7 +104,6 @@ SOURCES += \ clangcodemodelserver-test.cpp \ clangcompletecodejob-test.cpp \ clangcompletioncontextanalyzer-test.cpp \ - clangcreateinitialdocumentpreamblejob-test.cpp \ clangdiagnosticfilter-test.cpp \ clangdocumentprocessors-test.cpp \ clangdocumentprocessor-test.cpp \ @@ -118,7 +117,6 @@ SOURCES += \ clangjobs-test.cpp \ clangparsesupportivetranslationunitjob-test.cpp \ clangreferencescollector-test.cpp \ - clangreparsesupportivetranslationunitjob-test.cpp \ clangrequestdocumentannotationsjob-test.cpp \ clangrequestreferencesjob-test.cpp \ clangresumedocumentjob-test.cpp \ |