summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@qt.io>2018-09-03 14:38:01 +0200
committerMarco Bubke <marco.bubke@qt.io>2018-09-06 11:26:00 +0000
commit2a30f0e5d6f8d57f65ce21f2344049d050dc8d9e (patch)
treec74c252907a921696bdda24c5776877094274d73 /tests
parent461d5b5d152168f87f36a4d5d2aacce46bfa8500 (diff)
downloadqt-creator-2a30f0e5d6f8d57f65ce21f2344049d050dc8d9e.tar.gz
Clang: Improve generated files handling
Generated files are referenced by the system collector directly to set the unsaved files. Change-Id: I24be3ee544b7824b8b0e518eafd409f32bd002ab Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/unittest/gtest-creator-printing.cpp6
-rw-r--r--tests/unit/unittest/mocksymbolindexertaskqueue.h2
-rw-r--r--tests/unit/unittest/mocksymbolindexing.h10
-rw-r--r--tests/unit/unittest/mocksymbolscollector.h11
-rw-r--r--tests/unit/unittest/refactoringserver-test.cpp20
-rw-r--r--tests/unit/unittest/symbolindexer-test.cpp80
-rw-r--r--tests/unit/unittest/symbolindexing-test.cpp9
-rw-r--r--tests/unit/unittest/symbolscollector-test.cpp106
-rw-r--r--tests/unit/unittest/symbolscollectormanager-test.cpp20
-rw-r--r--tests/unit/unittest/unittest.pro3
10 files changed, 153 insertions, 114 deletions
diff --git a/tests/unit/unittest/gtest-creator-printing.cpp b/tests/unit/unittest/gtest-creator-printing.cpp
index 0a6b3a7134..5e078d5b71 100644
--- a/tests/unit/unittest/gtest-creator-printing.cpp
+++ b/tests/unit/unittest/gtest-creator-printing.cpp
@@ -149,17 +149,17 @@ std::ostream &operator<<(std::ostream &out, const LineColumn &lineColumn)
void PrintTo(Utils::SmallStringView text, ::std::ostream *os)
{
- *os << text;
+ *os << "\"" << text << "\"";
}
void PrintTo(const Utils::SmallString &text, ::std::ostream *os)
{
- *os << text;
+ *os << "\"" << text << "\"";
}
void PrintTo(const Utils::PathString &text, ::std::ostream *os)
{
- *os << text;
+ *os << "\"" << text << "\"";
}
} // namespace Utils
diff --git a/tests/unit/unittest/mocksymbolindexertaskqueue.h b/tests/unit/unittest/mocksymbolindexertaskqueue.h
index b17fecd516..52be4cb942 100644
--- a/tests/unit/unittest/mocksymbolindexertaskqueue.h
+++ b/tests/unit/unittest/mocksymbolindexertaskqueue.h
@@ -33,7 +33,7 @@ class MockSymbolIndexerTaskQueue : public ClangBackEnd::SymbolIndexerTaskQueueIn
{
public:
MOCK_METHOD1(addOrUpdateTasks,
- void (std::vector< ClangBackEnd::SymbolIndexerTask> &&tasks));
+ void (std::vector<ClangBackEnd::SymbolIndexerTask> &&tasks));
MOCK_METHOD1(removeTasks,
void (const std::vector<int> &projectPartIds));
MOCK_METHOD0(processTasks, void());
diff --git a/tests/unit/unittest/mocksymbolindexing.h b/tests/unit/unittest/mocksymbolindexing.h
index 967a5f6aab..048840d976 100644
--- a/tests/unit/unittest/mocksymbolindexing.h
+++ b/tests/unit/unittest/mocksymbolindexing.h
@@ -32,14 +32,12 @@
class MockSymbolIndexing : public ClangBackEnd::SymbolIndexingInterface
{
public:
- MOCK_METHOD2(updateProjectParts,
- void(const ClangBackEnd::V2::ProjectPartContainers &projectParts,
- const ClangBackEnd::V2::FileContainers &generatedFiles));
+ MOCK_METHOD1(updateProjectParts,
+ void(const ClangBackEnd::V2::ProjectPartContainers &projectParts));
- void updateProjectParts(ClangBackEnd::V2::ProjectPartContainers &&projectParts,
- const ClangBackEnd::V2::FileContainers &generatedFiles) override
+ void updateProjectParts(ClangBackEnd::V2::ProjectPartContainers &&projectParts) override
{
- updateProjectParts(projectParts, generatedFiles);
+ updateProjectParts(projectParts);
}
};
diff --git a/tests/unit/unittest/mocksymbolscollector.h b/tests/unit/unittest/mocksymbolscollector.h
index bf82f538ae..1bced44da9 100644
--- a/tests/unit/unittest/mocksymbolscollector.h
+++ b/tests/unit/unittest/mocksymbolscollector.h
@@ -44,16 +44,17 @@ public:
{
ON_CALL(*this, setIsUsed(_)).WillByDefault(Invoke(this, &MockSymbolsCollector::setIsUsed2));
ON_CALL(*this, isUsed()).WillByDefault(Invoke(this, &MockSymbolsCollector::isUsed2));
+ ON_CALL(*this, setUnsavedFiles(_)).WillByDefault(Invoke(this, &MockSymbolsCollector::setHasUnsavedFiles));
}
MOCK_METHOD0(collectSymbols,
void());
- MOCK_METHOD2(addFile,
+ MOCK_METHOD2(setFile,
void(ClangBackEnd::FilePathId filePathId,
const Utils::SmallStringVector &arguments));
- MOCK_METHOD1(addUnsavedFiles,
+ MOCK_METHOD1(setUnsavedFiles,
void(const ClangBackEnd::V2::FileContainers &unsavedFiles));
MOCK_METHOD0(clear,
@@ -93,6 +94,12 @@ public:
return used;
}
+ void setHasUnsavedFiles(const ClangBackEnd::V2::FileContainers &unsavedFiles)
+ {
+ hasUnsavedFiles = true;
+ }
+
public:
bool used = false;
+ bool hasUnsavedFiles = false;
};
diff --git a/tests/unit/unittest/refactoringserver-test.cpp b/tests/unit/unittest/refactoringserver-test.cpp
index 51cae8697e..82fff5ce2f 100644
--- a/tests/unit/unittest/refactoringserver-test.cpp
+++ b/tests/unit/unittest/refactoringserver-test.cpp
@@ -94,7 +94,8 @@ protected:
Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory};
ClangBackEnd::RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database};
ClangBackEnd::FilePathCaching filePathCache{database};
- ClangBackEnd::RefactoringServer refactoringServer{mockSymbolIndexing, filePathCache};
+ ClangBackEnd::GeneratedFiles generatedFiles;
+ ClangBackEnd::RefactoringServer refactoringServer{mockSymbolIndexing, filePathCache, generatedFiles};
Utils::SmallString sourceContent{"void f()\n {}"};
FileContainer source{{TESTDATA_DIR, "query_simplefunction.cpp"},
sourceContent.clone(),
@@ -304,12 +305,21 @@ TEST_F(RefactoringServer, UpdateGeneratedFilesSetMemberWhichIsUsedForSymbolIndex
"void f();",
{}}};
+ refactoringServer.updateGeneratedFiles(Utils::clone(unsaved));
- EXPECT_CALL(mockSymbolIndexing,
- updateProjectParts(_, unsaved));
+ ASSERT_THAT(generatedFiles.fileContainers(), ElementsAre(unsaved.front()));
+}
+TEST_F(RefactoringServer, RemoveGeneratedFilesSetMemberWhichIsUsedForSymbolIndexing)
+{
+ FileContainers unsaved{{{TESTDATA_DIR, "query_simplefunction.h"},
+ "void f();",
+ {}}};
refactoringServer.updateGeneratedFiles(Utils::clone(unsaved));
- refactoringServer.updateProjectParts({});
+
+ refactoringServer.removeGeneratedFiles({{{TESTDATA_DIR, "query_simplefunction.h"}}});
+
+ ASSERT_THAT(generatedFiles.fileContainers(), IsEmpty());
}
TEST_F(RefactoringServer, UpdateProjectPartsCallsSymbolIndexingUpdateProjectParts)
@@ -323,7 +333,7 @@ TEST_F(RefactoringServer, UpdateProjectPartsCallsSymbolIndexingUpdateProjectPart
EXPECT_CALL(mockSymbolIndexing,
- updateProjectParts(projectParts, _));
+ updateProjectParts(projectParts));
refactoringServer.updateProjectParts({Utils::clone(projectParts)});
}
diff --git a/tests/unit/unittest/symbolindexer-test.cpp b/tests/unit/unittest/symbolindexer-test.cpp
index 8ce8e40c7a..69e8927c5a 100644
--- a/tests/unit/unittest/symbolindexer-test.cpp
+++ b/tests/unit/unittest/symbolindexer-test.cpp
@@ -99,6 +99,8 @@ protected:
ON_CALL(mockStorage, fetchLowestLastModifiedTime(A<FilePathId>())).WillByDefault(Return(QDateTime::currentSecsSinceEpoch()));
mockCollector.setIsUsed(false);
+
+ generatedFiles.update(unsaved);
}
void TearDown()
@@ -179,7 +181,8 @@ protected:
NiceMock<MockSymbolStorage> mockStorage;
NiceMock<MockClangPathWatcher> mockPathWatcher;
ClangBackEnd::FileStatusCache fileStatusCache{filePathCache};
- SymbolsCollectorManager<NiceMock<MockSymbolsCollector>> collectorManger{data->database};
+ ClangBackEnd::GeneratedFiles generatedFiles;
+ SymbolsCollectorManager<NiceMock<MockSymbolsCollector>> collectorManger{data->database, generatedFiles};
SymbolIndexerTaskScheduler indexerScheduler{collectorManger, mockStorage, mockSqliteTransactionBackend, indexerQueue, 1};
SymbolIndexerTaskQueue indexerQueue{indexerScheduler};
ClangBackEnd::SymbolIndexer indexer{indexerQueue,
@@ -195,9 +198,9 @@ std::unique_ptr<Data> SymbolIndexer::data;
TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesInCollector)
{
- EXPECT_CALL(mockCollector, addFile(main1PathId, projectPart1.arguments));
+ EXPECT_CALL(mockCollector, setFile(main1PathId, projectPart1.arguments));
- indexer.updateProjectParts({projectPart1}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesWithPrecompiledHeaderInCollector)
@@ -205,7 +208,7 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesWithPrecompiledHeaderInColl
ON_CALL(mockStorage, fetchProjectPartArtefact(TypedEq<Utils::SmallStringView>(projectPart1.projectPartId))).WillByDefault(Return(emptyArtefact));
ON_CALL(mockStorage, fetchPrecompiledHeader(Eq(artefact.projectPartId))).WillByDefault(Return(projectPartPch));
- EXPECT_CALL(mockCollector, addFile(main1PathId,
+ EXPECT_CALL(mockCollector, setFile(main1PathId,
ElementsAre(Eq("-I"),
Eq(TESTDATA_DIR),
Eq("-Wno-pragma-once-outside-header"),
@@ -214,76 +217,76 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesWithPrecompiledHeaderInColl
Eq("-Xclang"),
Eq("/path/to/pch"))));
- indexer.updateProjectParts({projectPart1}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesWithoutPrecompiledHeaderInCollector)
{
ON_CALL(mockStorage, fetchProjectPartArtefact(TypedEq<Utils::SmallStringView>(projectPart1.projectPartId))).WillByDefault(Return(emptyArtefact));
- EXPECT_CALL(mockCollector, addFile(main1PathId,
+ EXPECT_CALL(mockCollector, setFile(main1PathId,
ElementsAre(Eq("-I"),
Eq(TESTDATA_DIR),
Eq("-Wno-pragma-once-outside-header"))));
- indexer.updateProjectParts({projectPart1}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsClearInCollector)
{
EXPECT_CALL(mockCollector, clear()).Times(2);
- indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1, projectPart2});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesInCollectorForEveryProjectPart)
{
- EXPECT_CALL(mockCollector, addFile(_, _)).Times(2);
+ EXPECT_CALL(mockCollector, setFile(_, _)).Times(2);
- indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1, projectPart2});
}
TEST_F(SymbolIndexer, UpdateProjectPartsDoesNotCallAddFilesInCollectorForEmptyEveryProjectParts)
{
- EXPECT_CALL(mockCollector, addFile(_, _))
+ EXPECT_CALL(mockCollector, setFile(_, _))
.Times(0);
- indexer.updateProjectParts({}, {});
+ indexer.updateProjectParts({});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallscollectSymbolsInCollector)
{
EXPECT_CALL(mockCollector, collectSymbols()).Times(2);;
- indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1, projectPart2});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsSymbolsInCollector)
{
EXPECT_CALL(mockCollector, symbols()).Times(2);
- indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1, projectPart2});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsSourceLocationsInCollector)
{
EXPECT_CALL(mockCollector, sourceLocations()).Times(2);
- indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1, projectPart2});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddUnsavedFilesInCollector)
{
- EXPECT_CALL(mockCollector, addUnsavedFiles(unsaved)).Times(2);
+ EXPECT_CALL(mockCollector, setUnsavedFiles(unsaved)).Times(2);
- indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1, projectPart2});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddSymbolsAndSourceLocationsInStorage)
{
EXPECT_CALL(mockStorage, addSymbolsAndSourceLocations(symbolEntries, sourceLocations)).Times(2);
- indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1, projectPart2});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsUpdateProjectPartsInStorage)
@@ -297,7 +300,7 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsUpdateProjectPartsInStorage)
ElementsAre(CompilerMacro{"BAR", "1"}, CompilerMacro{"FOO", "0"}),
ElementsAre("/includes")));
- indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1, projectPart2});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsUpdateProjectPartSources)
@@ -305,7 +308,7 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsUpdateProjectPartSources)
EXPECT_CALL(mockStorage, updateProjectPartSources(TypedEq<Utils::SmallStringView>("project1"), ElementsAre(IsFileId(1, 1), IsFileId(42, 23))));
EXPECT_CALL(mockStorage, updateProjectPartSources(TypedEq<Utils::SmallStringView>("project2"), ElementsAre(IsFileId(1, 1), IsFileId(42, 23))));
- indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1, projectPart2});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsInsertOrUpdateUsedMacros)
@@ -313,7 +316,7 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsInsertOrUpdateUsedMacros)
EXPECT_CALL(mockStorage, insertOrUpdateUsedMacros(Eq(usedMacros)))
.Times(2);
- indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1, projectPart2});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsInsertFileStatuses)
@@ -321,7 +324,7 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsInsertFileStatuses)
EXPECT_CALL(mockStorage, insertFileStatuses(Eq(fileStatus)))
.Times(2);
- indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1, projectPart2});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsInsertOrUpdateSourceDependencies)
@@ -329,7 +332,7 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsInsertOrUpdateSourceDependencies)
EXPECT_CALL(mockStorage, insertOrUpdateSourceDependencies(Eq(sourceDependencies)))
.Times(2);
- indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1, projectPart2});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsFetchProjectPartArtefacts)
@@ -337,7 +340,7 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsFetchProjectPartArtefacts)
EXPECT_CALL(mockStorage, fetchProjectPartArtefact(TypedEq<Utils::SmallStringView>(projectPart1.projectPartId)));
EXPECT_CALL(mockStorage, fetchProjectPartArtefact(TypedEq<Utils::SmallStringView>(projectPart2.projectPartId)));
- indexer.updateProjectParts({projectPart1, projectPart2}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1, projectPart2});
}
TEST_F(SymbolIndexer, UpdateProjectPartsCallsInOrder)
@@ -348,8 +351,7 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsInOrder)
EXPECT_CALL(mockStorage, fetchProjectPartArtefact(TypedEq<Utils::SmallStringView>(projectPart1.projectPartId)));
EXPECT_CALL(mockStorage, insertOrUpdateProjectPart(Eq(projectPart1.projectPartId), Eq(projectPart1.arguments), Eq(projectPart1.compilerMacros), Eq(projectPart1.includeSearchPaths)));
EXPECT_CALL(mockSqliteTransactionBackend, commit());
- EXPECT_CALL(mockCollector, addFile(main1PathId, projectPart1.arguments));
- EXPECT_CALL(mockCollector, addUnsavedFiles(unsaved));
+ EXPECT_CALL(mockCollector, setFile(main1PathId, projectPart1.arguments));
EXPECT_CALL(mockCollector, collectSymbols());
EXPECT_CALL(mockSqliteTransactionBackend, immediateBegin());
EXPECT_CALL(mockStorage, addSymbolsAndSourceLocations(symbolEntries, sourceLocations));
@@ -359,7 +361,7 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsInOrder)
EXPECT_CALL(mockStorage, insertOrUpdateSourceDependencies(Eq(sourceDependencies)));
EXPECT_CALL(mockSqliteTransactionBackend, commit());
- indexer.updateProjectParts({projectPart1}, Utils::clone(unsaved));
+ indexer.updateProjectParts({projectPart1});
}
TEST_F(SymbolIndexer, CallSetNotifier)
@@ -381,10 +383,10 @@ TEST_F(SymbolIndexer, UpdateChangedPathCallsInOrder)
{
InSequence s;
- EXPECT_CALL(mockSqliteTransactionBackend, immediateBegin()).Times(0);
+ EXPECT_CALL(mockSqliteTransactionBackend, deferredBegin());
EXPECT_CALL(mockStorage, fetchProjectPartArtefact(sourceFileIds[0])).WillOnce(Return(artefact));
EXPECT_CALL(mockSqliteTransactionBackend, commit());
- EXPECT_CALL(mockCollector, addFile(Eq(sourceFileIds[0]), Eq(artefact.compilerArguments)));
+ EXPECT_CALL(mockCollector, setFile(Eq(sourceFileIds[0]), Eq(artefact.compilerArguments)));
EXPECT_CALL(mockCollector, collectSymbols());
EXPECT_CALL(mockSqliteTransactionBackend, immediateBegin());
EXPECT_CALL(mockStorage, addSymbolsAndSourceLocations(symbolEntries, sourceLocations));
@@ -401,10 +403,10 @@ TEST_F(SymbolIndexer, HandleEmptyOptionalArtifactInUpdateChangedPath)
{
InSequence s;
- EXPECT_CALL(mockSqliteTransactionBackend, immediateBegin()).Times(0);
+ EXPECT_CALL(mockSqliteTransactionBackend, deferredBegin());
EXPECT_CALL(mockStorage, fetchProjectPartArtefact(sourceFileIds[0])).WillOnce(Return(emptyArtefact));
EXPECT_CALL(mockSqliteTransactionBackend, commit());
- EXPECT_CALL(mockCollector, addFile(_, _)).Times(0);
+ EXPECT_CALL(mockCollector, setFile(_, _)).Times(0);
EXPECT_CALL(mockCollector, collectSymbols()).Times(0);
EXPECT_CALL(mockSqliteTransactionBackend, immediateBegin()).Times(0);
EXPECT_CALL(mockStorage, addSymbolsAndSourceLocations(_, _)).Times(0);
@@ -425,7 +427,7 @@ TEST_F(SymbolIndexer, UpdateChangedPathIsUsingPrecompiledHeader)
.WillByDefault(Return(projectPartPch));
std::vector<SymbolIndexerTask> symbolIndexerTask;
- EXPECT_CALL(mockCollector, addFile(Eq(sourceFileIds[0]),
+ EXPECT_CALL(mockCollector, setFile(Eq(sourceFileIds[0]),
ElementsAre(Eq("-DFOO"),
Eq("-Xclang"),
Eq("-include-pch"),
@@ -441,7 +443,7 @@ TEST_F(SymbolIndexer, UpdateChangedPathIsNotUsingPrecompiledHeaderIfItNotExists)
.WillByDefault(Return(artefact));
std::vector<SymbolIndexerTask> symbolIndexerTask;
- EXPECT_CALL(mockCollector, addFile(Eq(sourceFileIds[0]),
+ EXPECT_CALL(mockCollector, setFile(Eq(sourceFileIds[0]),
ElementsAre(Eq("-DFOO"))));
indexer.pathsChanged({sourceFileIds[0]});
@@ -492,7 +494,7 @@ TEST_F(SymbolIndexer, DontReparseInUpdateProjectPartsIfDefinesAreTheSame)
EXPECT_CALL(mockStorage, fetchProjectPartArtefact(TypedEq<Utils::SmallStringView>(projectPart1.projectPartId))).WillRepeatedly(Return(artefact));
EXPECT_CALL(mockStorage, insertOrUpdateProjectPart(Eq(projectPart1.projectPartId), Eq(projectPart1.arguments), Eq(projectPart1.compilerMacros), Eq(projectPart1.includeSearchPaths)));
EXPECT_CALL(mockSqliteTransactionBackend, commit());
- EXPECT_CALL(mockCollector, addFile(_, _)).Times(0);
+ EXPECT_CALL(mockCollector, setFile(_, _)).Times(0);
EXPECT_CALL(mockCollector, collectSymbols()).Times(0);
EXPECT_CALL(mockSqliteTransactionBackend, immediateBegin()).Times(0);
EXPECT_CALL(mockStorage, addSymbolsAndSourceLocations(_, _)).Times(0);
@@ -502,7 +504,7 @@ TEST_F(SymbolIndexer, DontReparseInUpdateProjectPartsIfDefinesAreTheSame)
EXPECT_CALL(mockStorage, insertOrUpdateSourceDependencies(_)).Times(0);
EXPECT_CALL(mockSqliteTransactionBackend, commit()).Times(0);
- indexer.updateProjectPart(std::move(projectPart1), {});
+ indexer.updateProjectPart(std::move(projectPart1));
}
TEST_F(SymbolIndexer, PathsChangedUpdatesFileStatusCache)
@@ -575,9 +577,9 @@ TEST_F(SymbolIndexer, OutdatedFilesAreParsedInUpdateProjectParts)
ON_CALL(mockStorage, fetchLowestLastModifiedTime(A<FilePathId>()))
.WillByDefault(Return(0));
- EXPECT_CALL(mockCollector, addFile(Eq(main1PathId), _));
+ EXPECT_CALL(mockCollector, setFile(Eq(main1PathId), _));
- indexer.updateProjectParts({projectPart1}, {});
+ indexer.updateProjectParts({projectPart1});
}
TEST_F(SymbolIndexer, UpToDateFilesAreNotParsedInUpdateProjectParts)
@@ -588,9 +590,9 @@ TEST_F(SymbolIndexer, UpToDateFilesAreNotParsedInUpdateProjectParts)
ON_CALL(mockStorage, fetchLowestLastModifiedTime(A<FilePathId>()))
.WillByDefault(Return(QDateTime::currentSecsSinceEpoch()));
- EXPECT_CALL(mockCollector, addFile(_, _)).Times(0);
+ EXPECT_CALL(mockCollector, setFile(_, _)).Times(0);
- indexer.updateProjectParts({projectPart1}, {});
+ indexer.updateProjectParts({projectPart1});
}
}
diff --git a/tests/unit/unittest/symbolindexing-test.cpp b/tests/unit/unittest/symbolindexing-test.cpp
index 916867e4b3..5df58bff4b 100644
--- a/tests/unit/unittest/symbolindexing-test.cpp
+++ b/tests/unit/unittest/symbolindexing-test.cpp
@@ -81,7 +81,8 @@ protected:
Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory};
RefactoringDatabaseInitializer<Sqlite::Database> initializer{database};
FilePathCaching filePathCache{database};
- ClangBackEnd::SymbolIndexing indexing{database, filePathCache};
+ ClangBackEnd::GeneratedFiles generatedFiles;
+ ClangBackEnd::SymbolIndexing indexing{database, filePathCache, generatedFiles};
StatementFactory queryFactory{database};
Query query{queryFactory};
PathString main1Path = TESTDATA_DIR "/symbolindexing_main1.cpp";
@@ -95,7 +96,7 @@ protected:
TEST_F(SymbolIndexing, Locations)
{
- indexing.indexer().updateProjectParts({projectPart1}, {});
+ indexing.indexer().updateProjectParts({projectPart1});
indexing.syncTasks();
auto locations = query.locationsAt(filePathId(TESTDATA_DIR "/symbolindexing_main1.cpp"), 1, 6);
@@ -108,7 +109,7 @@ TEST_F(SymbolIndexing, Locations)
TEST_F(SymbolIndexing, DISABLED_TemplateFunction)
{
- indexing.indexer().updateProjectParts({projectPart1}, {});
+ indexing.indexer().updateProjectParts({projectPart1});
indexing.syncTasks();
auto locations = query.locationsAt(filePathId(TESTDATA_DIR "/symbolindexing_main1.cpp"), 21, 24);
@@ -120,7 +121,7 @@ TEST_F(SymbolIndexing, DISABLED_TemplateFunction)
TEST_F(SymbolIndexing, PathsAreUpdated)
{
- indexing.indexer().updateProjectParts({projectPart1}, {});
+ indexing.indexer().updateProjectParts({projectPart1});
indexing.indexer().pathsChanged({filePathId(main1Path)});
indexing.indexer().pathsChanged({filePathId(main1Path)});
diff --git a/tests/unit/unittest/symbolscollector-test.cpp b/tests/unit/unittest/symbolscollector-test.cpp
index f20e26b7f5..99ce331e94 100644
--- a/tests/unit/unittest/symbolscollector-test.cpp
+++ b/tests/unit/unittest/symbolscollector-test.cpp
@@ -178,7 +178,7 @@ protected:
TEST_F(SymbolsCollector, CollectSymbolName)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp"), {"cc"});
collector.collectSymbols();
@@ -188,7 +188,7 @@ TEST_F(SymbolsCollector, CollectSymbolName)
TEST_F(SymbolsCollector, SymbolMatchesLocation)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp"), {"cc"});
collector.collectSymbols();
@@ -200,7 +200,7 @@ TEST_F(SymbolsCollector, SymbolMatchesLocation)
TEST_F(SymbolsCollector, OtherSymboldMatchesLocation)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp"), {"cc"});
collector.collectSymbols();
@@ -212,7 +212,7 @@ TEST_F(SymbolsCollector, OtherSymboldMatchesLocation)
TEST_F(SymbolsCollector, CollectFilePath)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp"), {"cc"});
collector.collectSymbols();
@@ -225,7 +225,7 @@ TEST_F(SymbolsCollector, CollectFilePath)
TEST_F(SymbolsCollector, CollectLineColumn)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp"), {"cc"});
collector.collectSymbols();
@@ -237,7 +237,7 @@ TEST_F(SymbolsCollector, CollectLineColumn)
TEST_F(SymbolsCollector, CollectReference)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp"), {"cc"});
collector.collectSymbols();
@@ -249,7 +249,7 @@ TEST_F(SymbolsCollector, CollectReference)
TEST_F(SymbolsCollector, ReferencedSymboldMatchesLocation)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_simple.cpp"), {"cc"});
collector.collectSymbols();
@@ -264,8 +264,8 @@ TEST_F(SymbolsCollector, DISABLED_ON_WINDOWS(CollectInUnsavedFile))
FileContainers unsaved{{{TESTDATA_DIR, "symbolscollector_generated_file.h"},
"void function();",
{}}};
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_unsaved.cpp")}, {"cc"});
- collector.addUnsavedFiles(std::move(unsaved));
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_unsaved.cpp"), {"cc"});
+ collector.setUnsavedFiles(std::move(unsaved));
collector.collectSymbols();
@@ -275,7 +275,7 @@ TEST_F(SymbolsCollector, DISABLED_ON_WINDOWS(CollectInUnsavedFile))
TEST_F(SymbolsCollector, SourceFiles)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp"), {"cc"});
collector.collectSymbols();
@@ -287,7 +287,7 @@ TEST_F(SymbolsCollector, SourceFiles)
TEST_F(SymbolsCollector, MainFileInSourceFiles)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp"), {"cc"});
ASSERT_THAT(collector.sourceFiles(),
ElementsAre(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")));
@@ -295,7 +295,7 @@ TEST_F(SymbolsCollector, MainFileInSourceFiles)
TEST_F(SymbolsCollector, ResetMainFileInSourceFiles)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp"), {"cc"});
ASSERT_THAT(collector.sourceFiles(),
ElementsAre(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")));
@@ -303,7 +303,7 @@ TEST_F(SymbolsCollector, ResetMainFileInSourceFiles)
TEST_F(SymbolsCollector, DontDuplicateSourceFiles)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp"), {"cc"});
collector.collectSymbols();
collector.collectSymbols();
@@ -316,7 +316,7 @@ TEST_F(SymbolsCollector, DontDuplicateSourceFiles)
TEST_F(SymbolsCollector, ClearSourceFiles)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp"), {"cc"});
collector.clear();
@@ -325,7 +325,7 @@ TEST_F(SymbolsCollector, ClearSourceFiles)
TEST_F(SymbolsCollector, ClearSymbols)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp"), {"cc"});
collector.collectSymbols();
collector.clear();
@@ -335,7 +335,7 @@ TEST_F(SymbolsCollector, ClearSymbols)
TEST_F(SymbolsCollector, ClearSourceLocations)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp"), {"cc"});
collector.collectSymbols();
collector.clear();
@@ -345,7 +345,7 @@ TEST_F(SymbolsCollector, ClearSourceLocations)
TEST_F(SymbolsCollector, ClearFileStatus)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp"), {"cc"});
collector.collectSymbols();
collector.clear();
@@ -355,7 +355,7 @@ TEST_F(SymbolsCollector, ClearFileStatus)
TEST_F(SymbolsCollector, ClearUsedMacros)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_defines.h")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_defines.h"), {"cc"});
collector.collectSymbols();
collector.clear();
@@ -365,7 +365,7 @@ TEST_F(SymbolsCollector, ClearUsedMacros)
TEST_F(SymbolsCollector, DontCollectSymbolsAfterFilesAreCleared)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp"), {"cc"});
collector.clear();
collector.collectSymbols();
@@ -375,7 +375,7 @@ TEST_F(SymbolsCollector, DontCollectSymbolsAfterFilesAreCleared)
TEST_F(SymbolsCollector, DontCollectSourceFilesAfterFilesAreCleared)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp"), {"cc"});
collector.clear();
collector.collectSymbols();
@@ -385,7 +385,7 @@ TEST_F(SymbolsCollector, DontCollectSourceFilesAfterFilesAreCleared)
TEST_F(SymbolsCollector, DontCollectFileStatusAfterFilesAreCleared)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp"), {"cc"});
collector.clear();
collector.collectSymbols();
@@ -395,7 +395,7 @@ TEST_F(SymbolsCollector, DontCollectFileStatusAfterFilesAreCleared)
TEST_F(SymbolsCollector, DontCollectUsedMacrosAfterFilesAreCleared)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_main.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_main.cpp"), {"cc"});
collector.clear();
collector.collectSymbols();
@@ -406,7 +406,7 @@ TEST_F(SymbolsCollector, DontCollectUsedMacrosAfterFilesAreCleared)
TEST_F(SymbolsCollector, CollectUsedMacrosWithExternalDefine)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc", "-DCOMPILER_ARGUMENT"});
+ collector.setFile(fileId, {"cc", "-DCOMPILER_ARGUMENT"});
collector.collectSymbols();
@@ -423,7 +423,7 @@ TEST_F(SymbolsCollector, CollectUsedMacrosWithExternalDefine)
TEST_F(SymbolsCollector, CollectUsedMacrosWithoutExternalDefine)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc"});
+ collector.setFile(fileId, {"cc"});
collector.collectSymbols();
@@ -440,7 +440,7 @@ TEST_F(SymbolsCollector, CollectUsedMacrosWithoutExternalDefine)
TEST_F(SymbolsCollector, DontCollectHeaderGuards)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc"});
+ collector.setFile(fileId, {"cc"});
collector.collectSymbols();
@@ -451,7 +451,7 @@ TEST_F(SymbolsCollector, DontCollectHeaderGuards)
TEST_F(SymbolsCollector, DISABLED_DontCollectDynamicLibraryExports)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc"});
+ collector.setFile(fileId, {"cc"});
collector.collectSymbols();
@@ -462,7 +462,7 @@ TEST_F(SymbolsCollector, DISABLED_DontCollectDynamicLibraryExports)
TEST_F(SymbolsCollector, CollectMacroDefinitionSourceLocation)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc", "-DCOMPILER_ARGUMENT"});
+ collector.setFile(fileId, {"cc", "-DCOMPILER_ARGUMENT"});
collector.collectSymbols();
@@ -473,7 +473,7 @@ TEST_F(SymbolsCollector, CollectMacroDefinitionSourceLocation)
TEST_F(SymbolsCollector, CollectMacroUsageInIfNotDefSourceLocation)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc", "-DCOMPILER_ARGUMENT"});
+ collector.setFile(fileId, {"cc", "-DCOMPILER_ARGUMENT"});
collector.collectSymbols();
@@ -484,7 +484,7 @@ TEST_F(SymbolsCollector, CollectMacroUsageInIfNotDefSourceLocation)
TEST_F(SymbolsCollector, CollectSecondMacroUsageInIfNotDefSourceLocation)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc", "-DCOMPILER_ARGUMENT"});
+ collector.setFile(fileId, {"cc", "-DCOMPILER_ARGUMENT"});
collector.collectSymbols();
@@ -495,7 +495,7 @@ TEST_F(SymbolsCollector, CollectSecondMacroUsageInIfNotDefSourceLocation)
TEST_F(SymbolsCollector, CollectMacroUsageCompilerArgumentSourceLocation)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc", "-DCOMPILER_ARGUMENT"});
+ collector.setFile(fileId, {"cc", "-DCOMPILER_ARGUMENT"});
collector.collectSymbols();
@@ -506,7 +506,7 @@ TEST_F(SymbolsCollector, CollectMacroUsageCompilerArgumentSourceLocation)
TEST_F(SymbolsCollector, CollectMacroUsageInIfDefSourceLocation)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc", "-DCOMPILER_ARGUMENT"});
+ collector.setFile(fileId, {"cc", "-DCOMPILER_ARGUMENT"});
collector.collectSymbols();
@@ -517,7 +517,7 @@ TEST_F(SymbolsCollector, CollectMacroUsageInIfDefSourceLocation)
TEST_F(SymbolsCollector, CollectMacroUsageInDefinedSourceLocation)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc", "-DCOMPILER_ARGUMENT"});
+ collector.setFile(fileId, {"cc", "-DCOMPILER_ARGUMENT"});
collector.collectSymbols();
@@ -528,7 +528,7 @@ TEST_F(SymbolsCollector, CollectMacroUsageInDefinedSourceLocation)
TEST_F(SymbolsCollector, CollectMacroUsageExpansionSourceLocation)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc", "-DCOMPILER_ARGUMENT"});
+ collector.setFile(fileId, {"cc", "-DCOMPILER_ARGUMENT"});
collector.collectSymbols();
@@ -539,7 +539,7 @@ TEST_F(SymbolsCollector, CollectMacroUsageExpansionSourceLocation)
TEST_F(SymbolsCollector, CollectMacroUsageUndefSourceLocation)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc", "-DCOMPILER_ARGUMENT"});
+ collector.setFile(fileId, {"cc", "-DCOMPILER_ARGUMENT"});
collector.collectSymbols();
@@ -550,7 +550,7 @@ TEST_F(SymbolsCollector, CollectMacroUsageUndefSourceLocation)
TEST_F(SymbolsCollector, CollectMacroUsageBuiltInSourceLocation)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc", "-DCOMPILER_ARGUMENT"});
+ collector.setFile(fileId, {"cc", "-DCOMPILER_ARGUMENT"});
collector.collectSymbols();
@@ -561,7 +561,7 @@ TEST_F(SymbolsCollector, CollectMacroUsageBuiltInSourceLocation)
TEST_F(SymbolsCollector, CollectMacroDefinitionSymbols)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc"});
+ collector.setFile(fileId, {"cc"});
collector.collectSymbols();
@@ -572,7 +572,7 @@ TEST_F(SymbolsCollector, CollectMacroDefinitionSymbols)
TEST_F(SymbolsCollector, CollectMacroBuiltInSymbols)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc"});
+ collector.setFile(fileId, {"cc"});
collector.collectSymbols();
@@ -583,7 +583,7 @@ TEST_F(SymbolsCollector, CollectMacroBuiltInSymbols)
TEST_F(SymbolsCollector, CollectMacroCompilerArgumentSymbols)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_defines.h");
- collector.addFiles({fileId}, {"cc", "-DCOMPILER_ARGUMENT"});
+ collector.setFile(fileId, {"cc", "-DCOMPILER_ARGUMENT"});
collector.collectSymbols();
@@ -594,7 +594,7 @@ TEST_F(SymbolsCollector, CollectMacroCompilerArgumentSymbols)
TEST_F(SymbolsCollector, CollectFileStatuses)
{
auto fileId = filePathId(TESTDATA_DIR "/symbolscollector_main.cpp");
- collector.addFiles({fileId}, {"cc"});
+ collector.setFile(fileId, {"cc"});
collector.collectSymbols();
@@ -611,7 +611,7 @@ TEST_F(SymbolsCollector, CollectSourceDependencies)
auto header1FileId = filePathId(TESTDATA_DIR "/symbolscollector_header1.h");
auto header2FileId = filePathId(TESTDATA_DIR "/symbolscollector_header2.h");
auto header3FileId = filePathId(TESTDATA_DIR "/symbolscollector_header3.h");
- collector.addFiles({mainFileId}, {"cc", "-I" TESTDATA_DIR});
+ collector.setFile(mainFileId, {"cc", "-I" TESTDATA_DIR});
collector.collectSymbols();
@@ -624,7 +624,7 @@ TEST_F(SymbolsCollector, CollectSourceDependencies)
TEST_F(SymbolsCollector, IsClassSymbol)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp"), {"cc"});
collector.collectSymbols();
@@ -638,7 +638,7 @@ TEST_F(SymbolsCollector, IsClassSymbol)
TEST_F(SymbolsCollector, IsStructSymbol)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp"), {"cc"});
collector.collectSymbols();
@@ -652,7 +652,7 @@ TEST_F(SymbolsCollector, IsStructSymbol)
TEST_F(SymbolsCollector, IsEnumerationSymbol)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp"), {"cc"});
collector.collectSymbols();
@@ -670,7 +670,7 @@ TEST_F(SymbolsCollector, IsEnumerationSymbol)
TEST_F(SymbolsCollector, IsUnionSymbol)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp"), {"cc"});
collector.collectSymbols();
@@ -684,7 +684,7 @@ TEST_F(SymbolsCollector, IsUnionSymbol)
TEST_F(SymbolsCollector, DISABLED_ON_NON_WINDOWS(IsMsvcInterfaceSymbol))
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp"), {"cc"});
collector.collectSymbols();
@@ -698,7 +698,7 @@ TEST_F(SymbolsCollector, DISABLED_ON_NON_WINDOWS(IsMsvcInterfaceSymbol))
TEST_F(SymbolsCollector, IsFunctionSymbol)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp"), {"cc"});
collector.collectSymbols();
@@ -711,7 +711,7 @@ TEST_F(SymbolsCollector, IsFunctionSymbol)
TEST_F(SymbolsCollector, IsVariableSymbol)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp")}, {"cc"});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_symbolkind.cpp"), {"cc"});
collector.collectSymbols();
@@ -724,7 +724,7 @@ TEST_F(SymbolsCollector, IsVariableSymbol)
TEST_F(SymbolsCollector, IndexUnmodifiedHeaderFilesAtFirstRun)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_unmodified.cpp")}, {"cc", "-I", {TESTDATA_DIR, "/include"}});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_unmodified.cpp"), {"cc", "-I", {TESTDATA_DIR, "/include"}});
collector.collectSymbols();
@@ -741,10 +741,10 @@ TEST_F(SymbolsCollector, IndexUnmodifiedHeaderFilesAtFirstRun)
TEST_F(SymbolsCollector, DontIndexUnmodifiedHeaderFilesAtSecondRun)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_unmodified.cpp")}, {"cc", "-I", {TESTDATA_DIR, "/include"}});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_unmodified.cpp"), {"cc", "-I", {TESTDATA_DIR, "/include"}});
collector.collectSymbols();
collector.clear();
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_unmodified2.cpp")}, {"cc", "-I", {TESTDATA_DIR, "/include"}});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_unmodified2.cpp"), {"cc", "-I", {TESTDATA_DIR, "/include"}});
collector.collectSymbols();
@@ -760,11 +760,11 @@ TEST_F(SymbolsCollector, DontIndexUnmodifiedHeaderFilesAtSecondRun)
TEST_F(SymbolsCollector, DontIndexUnmodifiedHeaderFilesAtTouchHeader)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_unmodified3.cpp")}, {"cc", "-I", {TESTDATA_DIR, "/include"}});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_unmodified3.cpp"), {"cc", "-I", {TESTDATA_DIR, "/include"}});
collector.collectSymbols();
collector.clear();
touchFile(TESTDATA_DIR "/include/symbolscollector_unmodified_header2.h");
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_unmodified3.cpp")}, {"cc", "-I", {TESTDATA_DIR, "/include"}});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_unmodified3.cpp"), {"cc", "-I", {TESTDATA_DIR, "/include"}});
collector.collectSymbols();
@@ -780,7 +780,7 @@ TEST_F(SymbolsCollector, DontIndexUnmodifiedHeaderFilesAtTouchHeader)
TEST_F(SymbolsCollector, DontIndexSystemIncudes)
{
- collector.addFiles({filePathId(TESTDATA_DIR "/symbolscollector_unmodified.cpp")}, {"cc", "-isystem", {TESTDATA_DIR, "/include"}});
+ collector.setFile(filePathId(TESTDATA_DIR "/symbolscollector_unmodified.cpp"), {"cc", "-isystem", {TESTDATA_DIR, "/include"}});
collector.collectSymbols();
diff --git a/tests/unit/unittest/symbolscollectormanager-test.cpp b/tests/unit/unittest/symbolscollectormanager-test.cpp
index 18b210b80a..3a740b1e89 100644
--- a/tests/unit/unittest/symbolscollectormanager-test.cpp
+++ b/tests/unit/unittest/symbolscollectormanager-test.cpp
@@ -38,7 +38,8 @@ class SymbolsCollectorManager : public testing::Test
protected:
Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory};
ClangBackEnd::RefactoringDatabaseInitializer<Sqlite::Database> initializer{database};
- ClangBackEnd::SymbolsCollectorManager<NiceMock<MockSymbolsCollector>> manager{database};
+ ClangBackEnd::GeneratedFiles generatedFiles;
+ ClangBackEnd::SymbolsCollectorManager<NiceMock<MockSymbolsCollector>> manager{database, generatedFiles};
};
TEST_F(SymbolsCollectorManager, CreateUnsedSystemCollector)
@@ -77,4 +78,21 @@ TEST_F(SymbolsCollectorManager, AsGetReusedUnusedSymbolsCollectorItIsSetUsed)
ASSERT_TRUE(collector2.isUsed());
}
+TEST_F(SymbolsCollectorManager, UnusedSystemCollectorIsInitializedWithUnsavedFiles)
+{
+ auto &collector = manager.unusedSymbolsCollector();
+
+ ASSERT_TRUE(collector.hasUnsavedFiles);
+}
+
+TEST_F(SymbolsCollectorManager, ReusedSystemCollectorIsInitializedWithUnsavedFiles)
+{
+ auto &collector = manager.unusedSymbolsCollector();
+ collector.setIsUsed(false);
+
+ auto &collector2 = manager.unusedSymbolsCollector();
+
+ ASSERT_TRUE(collector2.hasUnsavedFiles);
+}
+
}
diff --git a/tests/unit/unittest/unittest.pro b/tests/unit/unittest/unittest.pro
index c0ae7bd230..4ca129f0df 100644
--- a/tests/unit/unittest/unittest.pro
+++ b/tests/unit/unittest/unittest.pro
@@ -14,7 +14,10 @@ OBJECTS_DIR = $$OUT_PWD/obj # workaround for qmake bug in object_parallel_to_sou
!msvc:force_debug_info:QMAKE_CXXFLAGS += -fno-omit-frame-pointer
DEFINES += \
+ QT_NO_CAST_TO_ASCII \
QT_RESTRICTED_CAST_FROM_ASCII \
+ QT_USE_FAST_OPERATOR_PLUS \
+ QT_USE_FAST_CONCATENATION \
UNIT_TESTS \
DONT_CHECK_MESSAGE_COUNTER \
TESTDATA_DIR=\"R\\\"xxx($$PWD/data)xxx\\\"\"