aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@qt.io>2019-06-18 18:26:27 +0200
committerMarco Bubke <marco.bubke@qt.io>2019-06-27 12:32:12 +0000
commite031ada154ba94e13af104a1e32be0f94754ba12 (patch)
treebf91a4c733dcb3c321f3cf5d80cd75fcc0762bae /tests
parentcbfd9dc16b41176ce5a79bd9e11a336e853573a0 (diff)
Clang: Watch only PCH sources
We watched all sources but we do not want to watch the sources of the project part because they are not used to build a PCH. Change-Id: I700cd6077fc54230c9be94d620043cf3f10cf9ea Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/unittest/builddependenciesstorage-test.cpp4
-rw-r--r--tests/unit/unittest/mockbuilddependenciesstorage.h2
-rw-r--r--tests/unit/unittest/pchcreator-test.cpp24
-rw-r--r--tests/unit/unittest/pchtaskgenerator-test.cpp2
-rw-r--r--tests/unit/unittest/refactoringdatabaseinitializer-test.cpp12
-rw-r--r--tests/unit/unittest/symbolindexer-test.cpp2
-rw-r--r--tests/unit/unittest/usedmacrofilter-test.cpp7
7 files changed, 31 insertions, 22 deletions
diff --git a/tests/unit/unittest/builddependenciesstorage-test.cpp b/tests/unit/unittest/builddependenciesstorage-test.cpp
index 052ed452f0..d14b94fe30 100644
--- a/tests/unit/unittest/builddependenciesstorage-test.cpp
+++ b/tests/unit/unittest/builddependenciesstorage-test.cpp
@@ -70,7 +70,7 @@ protected:
MockSqliteWriteStatement &updatePchCreationTimeStampStatement = storage.updatePchCreationTimeStampStatement;
MockSqliteWriteStatement &deleteAllProjectPartsFilesWithProjectPartNameStatement
= storage.deleteAllProjectPartsFilesWithProjectPartNameStatement;
- MockSqliteReadStatement &fetchProjectPartsFilesStatement = storage.fetchProjectPartsFilesStatement;
+ MockSqliteReadStatement &fetchProjectPartsFilesStatement = storage.fetchPchSourcesStatement;
};
TEST_F(BuildDependenciesStorage, ConvertStringsToJson)
@@ -238,7 +238,7 @@ TEST_F(BuildDependenciesStorage, FetchSources)
ClangBackEnd::FilePathIds result{3, 5, 7};
EXPECT_CALL(fetchProjectPartsFilesStatement, valuesReturnFilePathIds(_, 22)).WillOnce(Return(result));
- auto sources = storage.fetchSources(22);
+ auto sources = storage.fetchPchSources(22);
ASSERT_THAT(sources, result);
}
diff --git a/tests/unit/unittest/mockbuilddependenciesstorage.h b/tests/unit/unittest/mockbuilddependenciesstorage.h
index a4d34e481d..dd2850d88c 100644
--- a/tests/unit/unittest/mockbuilddependenciesstorage.h
+++ b/tests/unit/unittest/mockbuilddependenciesstorage.h
@@ -51,7 +51,7 @@ public:
ClangBackEnd::ProjectPartId(Utils::SmallStringView projectPartName));
MOCK_METHOD2(updatePchCreationTimeStamp,
void(long long pchCreationTimeStamp, ClangBackEnd::ProjectPartId projectPartId));
- MOCK_CONST_METHOD1(fetchSources,
+ MOCK_CONST_METHOD1(fetchPchSources,
ClangBackEnd::FilePathIds(ClangBackEnd::ProjectPartId projectPartId));
};
diff --git a/tests/unit/unittest/pchcreator-test.cpp b/tests/unit/unittest/pchcreator-test.cpp
index 0cf84a983d..04e198eec7 100644
--- a/tests/unit/unittest/pchcreator-test.cpp
+++ b/tests/unit/unittest/pchcreator-test.cpp
@@ -226,16 +226,21 @@ TEST_F(PchCreatorVerySlowTest, SourcesAreWatchedAfterSucess)
creator.doInMainThreadAfterFinished();
}
-TEST_F(PchCreatorVerySlowTest, SourcesAreNotWatchedAfterFail)
+TEST_F(PchCreatorVerySlowTest, SourcesAreWatchedAfterFail)
{
pchTask1.systemIncludeSearchPaths = {};
pchTask1.projectIncludeSearchPaths = {};
creator.generatePch(std::move(pchTask1));
EXPECT_CALL(mockClangPathWatcher,
- updateIdPaths(
- ElementsAre(AllOf(Field(&ClangBackEnd::IdPaths::id, 1),
- Field(&ClangBackEnd::IdPaths::filePathIds, IsEmpty())))));
+ updateIdPaths(ElementsAre(AllOf(
+ Field(&ClangBackEnd::IdPaths::id, 1),
+ Field(&ClangBackEnd::IdPaths::filePathIds,
+ UnorderedElementsAre(
+ id(TESTDATA_DIR "/builddependencycollector/project/header2.h"),
+ id(TESTDATA_DIR "/builddependencycollector/external/external1.h"),
+ id(TESTDATA_DIR "/builddependencycollector/external/external2.h"),
+ id(TESTDATA_DIR "/builddependencycollector/project/main2.cpp")))))));
creator.doInMainThreadAfterFinished();
}
@@ -337,9 +342,14 @@ TEST_F(PchCreatorSlowTest, NoIncludesInTheMainThreadCalls)
Field(&ClangBackEnd::PrecompiledHeadersUpdatedMessage::projectPartIds,
ElementsAre(Eq(creator.projectPartPch().projectPartId)))));
EXPECT_CALL(mockClangPathWatcher,
- updateIdPaths(
- ElementsAre(AllOf(Field(&ClangBackEnd::IdPaths::id, 1),
- Field(&ClangBackEnd::IdPaths::filePathIds, IsEmpty())))));
+ updateIdPaths(ElementsAre(AllOf(
+ Field(&ClangBackEnd::IdPaths::id, 1),
+ Field(&ClangBackEnd::IdPaths::filePathIds,
+ UnorderedElementsAre(
+ id(TESTDATA_DIR "/builddependencycollector/project/header2.h"),
+ id(TESTDATA_DIR "/builddependencycollector/external/external1.h"),
+ id(TESTDATA_DIR "/builddependencycollector/external/external2.h"),
+ id(TESTDATA_DIR "/builddependencycollector/project/main2.cpp")))))));
EXPECT_CALL(mockBuildDependenciesStorage, updatePchCreationTimeStamp(Gt(0), Eq(1)));
creator.doInMainThreadAfterFinished();
diff --git a/tests/unit/unittest/pchtaskgenerator-test.cpp b/tests/unit/unittest/pchtaskgenerator-test.cpp
index 8f5f0754af..cb9df32235 100644
--- a/tests/unit/unittest/pchtaskgenerator-test.cpp
+++ b/tests/unit/unittest/pchtaskgenerator-test.cpp
@@ -117,7 +117,7 @@ TEST_F(PchTaskGenerator, AddProjectParts)
&PchTaskSet::project,
AllOf(Field(&PchTask::projectPartIds, ElementsAre(ProjectPartId{1})),
Field(&PchTask::includes, ElementsAre(3)),
- Field(&PchTask::sources, ElementsAre(1, 2, 3, 4, 5)),
+ Field(&PchTask::sources, ElementsAre(1, 3, 4, 5)),
Field(&PchTask::compilerMacros,
ElementsAre(CompilerMacro{"YI", "1", 1}, CompilerMacro{"SAN", "3", 3})),
Field(&PchTask::systemIncludeSearchPaths,
diff --git a/tests/unit/unittest/refactoringdatabaseinitializer-test.cpp b/tests/unit/unittest/refactoringdatabaseinitializer-test.cpp
index 7177060311..3af0fc8cfe 100644
--- a/tests/unit/unittest/refactoringdatabaseinitializer-test.cpp
+++ b/tests/unit/unittest/refactoringdatabaseinitializer-test.cpp
@@ -107,7 +107,10 @@ TEST_F(RefactoringDatabaseInitializer, AddProjectPartsFilesTable)
"sourceId INTEGER, sourceType INTEGER, pchCreationTimeStamp INTEGER, "
"hasMissingIncludes INTEGER)")));
EXPECT_CALL(mockDatabase, execute(Eq("CREATE UNIQUE INDEX IF NOT EXISTS index_projectPartsFiles_sourceId_projectPartId ON projectPartsFiles(sourceId, projectPartId)")));
- EXPECT_CALL(mockDatabase, execute(Eq("CREATE INDEX IF NOT EXISTS index_projectPartsFiles_projectPartId ON projectPartsFiles(projectPartId)")));
+ EXPECT_CALL(mockDatabase,
+ execute(Eq(
+ "CREATE INDEX IF NOT EXISTS index_projectPartsFiles_projectPartId_sourceType "
+ "ON projectPartsFiles(projectPartId, sourceType)")));
initializer.createProjectPartsFilesTable();
}
@@ -247,9 +250,10 @@ TEST_F(RefactoringDatabaseInitializer, CreateInTheContructor)
execute(
Eq("CREATE UNIQUE INDEX IF NOT EXISTS index_projectPartsFiles_sourceId_projectPartId "
"ON projectPartsFiles(sourceId, projectPartId)")));
- EXPECT_CALL(mockDatabase,
- execute(Eq("CREATE INDEX IF NOT EXISTS index_projectPartsFiles_projectPartId ON "
- "projectPartsFiles(projectPartId)")));
+ EXPECT_CALL(
+ mockDatabase,
+ execute(Eq("CREATE INDEX IF NOT EXISTS index_projectPartsFiles_projectPartId_sourceType ON "
+ "projectPartsFiles(projectPartId, sourceType)")));
EXPECT_CALL(mockDatabase,
execute(Eq("CREATE TABLE IF NOT EXISTS usedMacros(usedMacroId INTEGER PRIMARY KEY, "
"sourceId INTEGER, macroName TEXT)")));
diff --git a/tests/unit/unittest/symbolindexer-test.cpp b/tests/unit/unittest/symbolindexer-test.cpp
index c7831d099f..16e0fc81b0 100644
--- a/tests/unit/unittest/symbolindexer-test.cpp
+++ b/tests/unit/unittest/symbolindexer-test.cpp
@@ -923,7 +923,7 @@ TEST_F(SymbolIndexer, SourcesAreWatched)
InSequence s;
FilePathIds sourcePathIds{4, 6, 8};
- EXPECT_CALL(mockBuildDependenciesStorage, fetchSources(projectPart1.projectPartId))
+ EXPECT_CALL(mockBuildDependenciesStorage, fetchPchSources(projectPart1.projectPartId))
.WillOnce(Return(sourcePathIds));
EXPECT_CALL(mockPathWatcher,
updateIdPaths(ElementsAre(AllOf(Field(&IdPaths::id, projectPart1.projectPartId),
diff --git a/tests/unit/unittest/usedmacrofilter-test.cpp b/tests/unit/unittest/usedmacrofilter-test.cpp
index 788a443eee..85e1bb59b5 100644
--- a/tests/unit/unittest/usedmacrofilter-test.cpp
+++ b/tests/unit/unittest/usedmacrofilter-test.cpp
@@ -98,12 +98,7 @@ TEST_F(UsedMacroFilter, Sources)
ClangBackEnd::UsedMacroFilter filter(sources, usedMacros, compileMacros);
ASSERT_THAT(filter.sources,
- ElementsAre(FilePathId{1},
- FilePathId{2},
- FilePathId{3},
- FilePathId{4},
- FilePathId{5},
- FilePathId{6}));
+ ElementsAre(FilePathId{2}, FilePathId{3}, FilePathId{4}, FilePathId{5}));
}
TEST_F(UsedMacroFilter, SystemUsedMacros)