ClangPchManager: Fix path for excluded include files

Still used the old approach but now it is using the new one.

Change-Id: I4bf4da3a5d41d46afff261f3d77bd9190737038a
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Marco Bubke
2019-07-10 15:58:23 +02:00
parent 56277de27f
commit 1841cb1fa5
6 changed files with 137 additions and 95 deletions

View File

@@ -136,20 +136,8 @@ void BuildDependencyCollector::collect()
void BuildDependencyCollector::setExcludedFilePaths(ClangBackEnd::FilePaths &&excludedFilePaths) void BuildDependencyCollector::setExcludedFilePaths(ClangBackEnd::FilePaths &&excludedFilePaths)
{ {
if (Utils::HostOsInfo::isWindowsHost()) {
m_excludedFilePaths.clear();
m_excludedFilePaths.reserve(excludedFilePaths.size());
std::transform(std::make_move_iterator(excludedFilePaths.begin()),
std::make_move_iterator(excludedFilePaths.end()),
std::back_inserter(m_excludedFilePaths),
[](auto &&path) {
path.replace("/", "\\");
return std::move(path);
});
} else {
m_excludedFilePaths = std::move(excludedFilePaths); m_excludedFilePaths = std::move(excludedFilePaths);
} }
}
void BuildDependencyCollector::addFiles(const FilePathIds &filePathIds, void BuildDependencyCollector::addFiles(const FilePathIds &filePathIds,
Utils::SmallStringVector &&arguments) Utils::SmallStringVector &&arguments)

View File

@@ -73,8 +73,10 @@ public:
std::vector<uint> fileUIDs; std::vector<uint> fileUIDs;
fileUIDs.reserve(m_excludedFilePaths.size()); fileUIDs.reserve(m_excludedFilePaths.size());
for (const ClangBackEnd::FilePath &filePath : m_excludedFilePaths) { for (const FilePath &filePath : m_excludedFilePaths) {
const clang::FileEntry *file = fileManager.getFile({filePath.data(), filePath.size()}, NativeFilePath nativeFilePath{filePath};
const clang::FileEntry *file = fileManager.getFile({nativeFilePath.path().data(),
nativeFilePath.path().size()},
true); true);
if (file) if (file)

View File

@@ -57,7 +57,7 @@ void ClangTool::addUnsavedFiles(const V2::FileContainers &unsavedFiles)
m_unsavedFileContents.reserve(m_unsavedFileContents.size() + unsavedFiles.size()); m_unsavedFileContents.reserve(m_unsavedFileContents.size() + unsavedFiles.size());
auto convertToUnsavedFileContent = [](const V2::FileContainer &unsavedFile) { auto convertToUnsavedFileContent = [](const V2::FileContainer &unsavedFile) {
return UnsavedFileContent{unsavedFile.filePath.clone(), return UnsavedFileContent{NativeFilePath{unsavedFile.filePath},
unsavedFile.unsavedFileContent.clone()}; unsavedFile.unsavedFileContent.clone()};
}; };

View File

@@ -55,12 +55,12 @@ struct FileContent
struct UnsavedFileContent struct UnsavedFileContent
{ {
UnsavedFileContent(FilePath &&filePath, Utils::SmallString &&content) UnsavedFileContent(NativeFilePath &&filePath, Utils::SmallString &&content)
: filePath(std::move(filePath)) : filePath(std::move(filePath))
, content(std::move(content)) , content(std::move(content))
{} {}
FilePath filePath; NativeFilePath filePath;
Utils::SmallString content; Utils::SmallString content;
}; };

View File

@@ -80,6 +80,13 @@ MATCHER_P3(HasSource,
&& entry.hasMissingIncludes == hasMissingIncludes; && entry.hasMissingIncludes == hasMissingIncludes;
} }
static Utils::SmallString toNativePath(Utils::SmallStringView text)
{
ClangBackEnd::FilePath path{text};
return Utils::SmallString{ClangBackEnd::NativeFilePath{path}.path()};
}
class BuildDependencyCollector : public ::testing::Test class BuildDependencyCollector : public ::testing::Test
{ {
protected: protected:
@@ -91,11 +98,11 @@ protected:
id(TESTDATA_DIR "/builddependencycollector/project/main2.cpp")}, id(TESTDATA_DIR "/builddependencycollector/project/main2.cpp")},
{"cc", {"cc",
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/external", toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/project", toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
"-isystem", "-isystem",
TESTDATA_DIR "/builddependencycollector/system"}); toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
collector.addUnsavedFiles( collector.addUnsavedFiles(
{{{TESTDATA_DIR, "BuildDependencyCollector/project/generated_file.h"}, {{{TESTDATA_DIR, "BuildDependencyCollector/project/generated_file.h"},
@@ -184,7 +191,8 @@ protected:
TESTDATA_DIR "/builddependencycollector/project/main2.cpp", TESTDATA_DIR "/builddependencycollector/project/main2.cpp",
TESTDATA_DIR "/builddependencycollector/project/header1.h", TESTDATA_DIR "/builddependencycollector/project/header1.h",
TESTDATA_DIR "/builddependencycollector/project/header2.h", TESTDATA_DIR "/builddependencycollector/project/header2.h",
TESTDATA_DIR "/builddependencycollector/project/generated_file.h"}; TESTDATA_DIR "/builddependencycollector/project/generated_file.h",
TESTDATA_DIR "/builddependencycollector/project/generated/generated_file.h"};
}; };
TEST_F(BuildDependencyCollector, IncludesExternalHeader) TEST_F(BuildDependencyCollector, IncludesExternalHeader)
@@ -245,7 +253,14 @@ TEST_F(BuildDependencyCollector, IncludesAreSorted)
TEST_F(BuildDependencyCollector, If) TEST_F(BuildDependencyCollector, If)
{ {
emptyCollector.addFile(id(TESTDATA_DIR "/builddependencycollector/project/if.cpp"), {"cc", "-I", TESTDATA_DIR "/builddependencycollector/external", "-I", TESTDATA_DIR "/builddependencycollector/project", "-isystem", TESTDATA_DIR "/builddependencycollector/system"}); emptyCollector.addFile(id(TESTDATA_DIR "/builddependencycollector/project/if.cpp"),
{"cc",
"-I",
toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
"-I",
toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
"-isystem",
toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
emptyCollector.collect(); emptyCollector.collect();
@@ -256,7 +271,14 @@ TEST_F(BuildDependencyCollector, If)
TEST_F(BuildDependencyCollector, LocalPath) TEST_F(BuildDependencyCollector, LocalPath)
{ {
emptyCollector.addFile(id(TESTDATA_DIR "/builddependencycollector/project/main.cpp"), {"cc", "-I", TESTDATA_DIR "/builddependencycollector/external", "-I", TESTDATA_DIR "/builddependencycollector/project", "-isystem", TESTDATA_DIR "/builddependencycollector/system"}); emptyCollector.addFile(id(TESTDATA_DIR "/builddependencycollector/project/main.cpp"),
{"cc",
"-I",
toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
"-I",
toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
"-isystem",
toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
emptyCollector.collect(); emptyCollector.collect();
@@ -274,7 +296,14 @@ TEST_F(BuildDependencyCollector, LocalPath)
TEST_F(BuildDependencyCollector, IgnoreMissingFile) TEST_F(BuildDependencyCollector, IgnoreMissingFile)
{ {
emptyCollector.addFile(id(TESTDATA_DIR "/builddependencycollector/project/missingfile.cpp"), {"cc", "-I", TESTDATA_DIR "/builddependencycollector/external", "-I", TESTDATA_DIR "/builddependencycollector/project", "-isystem", TESTDATA_DIR "/builddependencycollector/system"}); emptyCollector.addFile(id(TESTDATA_DIR "/builddependencycollector/project/missingfile.cpp"),
{"cc",
"-I",
toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
"-I",
toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
"-isystem",
toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
emptyCollector.collect(); emptyCollector.collect();
@@ -299,7 +328,14 @@ TEST_F(BuildDependencyCollector, IncludesOnlyTopExternalHeader)
TEST_F(BuildDependencyCollector, TopIncludeInIfMacro) TEST_F(BuildDependencyCollector, TopIncludeInIfMacro)
{ {
emptyCollector.addFile(id(TESTDATA_DIR "/builddependencycollector/project/if.cpp"), {"cc", "-I", TESTDATA_DIR "/builddependencycollector/external", "-I", TESTDATA_DIR "/builddependencycollector/project", "-isystem", TESTDATA_DIR "/builddependencycollector/system"}); emptyCollector.addFile(id(TESTDATA_DIR "/builddependencycollector/project/if.cpp"),
{"cc",
"-I",
toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
"-I",
toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
"-isystem",
toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
emptyCollector.setExcludedFilePaths({TESTDATA_DIR "/builddependencycollector/project/if.cpp"}); emptyCollector.setExcludedFilePaths({TESTDATA_DIR "/builddependencycollector/project/if.cpp"});
emptyCollector.collect(); emptyCollector.collect();
@@ -310,7 +346,14 @@ TEST_F(BuildDependencyCollector, TopIncludeInIfMacro)
TEST_F(BuildDependencyCollector, TopIncludeWithLocalPath) TEST_F(BuildDependencyCollector, TopIncludeWithLocalPath)
{ {
emptyCollector.addFile(id(TESTDATA_DIR "/builddependencycollector/project/main.cpp"), {"cc", "-I", TESTDATA_DIR "/builddependencycollector/external", "-I", TESTDATA_DIR "/builddependencycollector/project", "-isystem", TESTDATA_DIR "/builddependencycollector/system"}); emptyCollector.addFile(id(TESTDATA_DIR "/builddependencycollector/project/main.cpp"),
{"cc",
"-I",
toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
"-I",
toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
"-isystem",
toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
emptyCollector.collect(); emptyCollector.collect();
@@ -323,7 +366,14 @@ TEST_F(BuildDependencyCollector, TopIncludeWithLocalPath)
TEST_F(BuildDependencyCollector, TopIncludesIgnoreMissingFile) TEST_F(BuildDependencyCollector, TopIncludesIgnoreMissingFile)
{ {
emptyCollector.addFile(id(TESTDATA_DIR "/builddependencycollector/project/missingfile.cpp"), {"cc", "-I", TESTDATA_DIR "/builddependencycollector/external", "-I", TESTDATA_DIR "/builddependencycollector/project", "-isystem", TESTDATA_DIR "/builddependencycollector/system"}); emptyCollector.addFile(id(TESTDATA_DIR "/builddependencycollector/project/missingfile.cpp"),
{"cc",
"-I",
toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
"-I",
toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
"-isystem",
toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
emptyCollector.setExcludedFilePaths({TESTDATA_DIR "/builddependencycollector/project/missingfile.cpp"}); emptyCollector.setExcludedFilePaths({TESTDATA_DIR "/builddependencycollector/project/missingfile.cpp"});
emptyCollector.collect(); emptyCollector.collect();
@@ -338,11 +388,11 @@ TEST_F(BuildDependencyCollector, SourceFiles)
emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"), emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"),
{"cc", {"cc",
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/external", toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/project", toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
"-isystem", "-isystem",
TESTDATA_DIR "/builddependencycollector/system"}); toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
emptyCollector.collect(); emptyCollector.collect();
@@ -357,11 +407,11 @@ TEST_F(BuildDependencyCollector, MainFileInSourceFiles)
emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"), emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"),
{"cc", {"cc",
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/external", toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/project", toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
"-isystem", "-isystem",
TESTDATA_DIR "/builddependencycollector/system"}); toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
ASSERT_THAT(emptyCollector.sourceFiles(), ASSERT_THAT(emptyCollector.sourceFiles(),
ElementsAre(id(TESTDATA_DIR "/symbolscollector/main.cpp"))); ElementsAre(id(TESTDATA_DIR "/symbolscollector/main.cpp")));
@@ -372,11 +422,11 @@ TEST_F(BuildDependencyCollector, ResetMainFileInSourceFiles)
emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"), emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"),
{"cc", {"cc",
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/external", toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/project", toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
"-isystem", "-isystem",
TESTDATA_DIR "/builddependencycollector/system"}); toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
ASSERT_THAT(emptyCollector.sourceFiles(), ASSERT_THAT(emptyCollector.sourceFiles(),
ElementsAre(id(TESTDATA_DIR "/symbolscollector/main.cpp"))); ElementsAre(id(TESTDATA_DIR "/symbolscollector/main.cpp")));
@@ -387,11 +437,11 @@ TEST_F(BuildDependencyCollector, DontDuplicateSourceFiles)
emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"), emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"),
{"cc", {"cc",
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/external", toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/project", toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
"-isystem", "-isystem",
TESTDATA_DIR "/builddependencycollector/system"}); toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
emptyCollector.collect(); emptyCollector.collect();
emptyCollector.collect(); emptyCollector.collect();
@@ -407,11 +457,11 @@ TEST_F(BuildDependencyCollector, ClearSourceFiles)
emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"), emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"),
{"cc", {"cc",
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/external", toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/project", toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
"-isystem", "-isystem",
TESTDATA_DIR "/builddependencycollector/system"}); toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
emptyCollector.clear(); emptyCollector.clear();
@@ -423,11 +473,11 @@ TEST_F(BuildDependencyCollector, ClearFileStatus)
emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"), emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"),
{"cc", {"cc",
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/external", toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/project", toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
"-isystem", "-isystem",
TESTDATA_DIR "/builddependencycollector/system"}); toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
emptyCollector.collect(); emptyCollector.collect();
emptyCollector.clear(); emptyCollector.clear();
@@ -440,11 +490,11 @@ TEST_F(BuildDependencyCollector, ClearUsedMacros)
emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/defines.h"), emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/defines.h"),
{"cc", {"cc",
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/external", toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/project", toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
"-isystem", "-isystem",
TESTDATA_DIR "/builddependencycollector/system"}); toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
emptyCollector.collect(); emptyCollector.collect();
emptyCollector.clear(); emptyCollector.clear();
@@ -467,11 +517,11 @@ TEST_F(BuildDependencyCollector, DontCollectSourceFilesAfterFilesAreCleared)
emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"), emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"),
{"cc", {"cc",
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/external", toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/project", toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
"-isystem", "-isystem",
TESTDATA_DIR "/builddependencycollector/system"}); toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
emptyCollector.clear(); emptyCollector.clear();
emptyCollector.collect(); emptyCollector.collect();
@@ -484,11 +534,11 @@ TEST_F(BuildDependencyCollector, DontCollectFileStatusAfterFilesAreCleared)
emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"), emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"),
{"cc", {"cc",
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/external", toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/project", toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
"-isystem", "-isystem",
TESTDATA_DIR "/builddependencycollector/system"}); toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
emptyCollector.clear(); emptyCollector.clear();
emptyCollector.collect(); emptyCollector.collect();
@@ -501,11 +551,11 @@ TEST_F(BuildDependencyCollector, DontCollectUsedMacrosAfterFilesAreCleared)
emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"), emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"),
{"cc", {"cc",
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/external", toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/project", toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
"-isystem", "-isystem",
TESTDATA_DIR "/builddependencycollector/system"}); toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
emptyCollector.clear(); emptyCollector.clear();
emptyCollector.collect(); emptyCollector.collect();
@@ -519,11 +569,11 @@ TEST_F(BuildDependencyCollector, DontCollectSourceDependenciesAfterFilesAreClear
emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"), emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"),
{"cc", {"cc",
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/external", toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/project", toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
"-isystem", "-isystem",
TESTDATA_DIR "/builddependencycollector/system"}); toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
emptyCollector.clear(); emptyCollector.clear();
emptyCollector.collect(); emptyCollector.collect();
@@ -552,11 +602,11 @@ TEST_F(BuildDependencyCollector, CollectUsedMacrosWithoutExternalDefine)
emptyCollector.addFile(fileId, emptyCollector.addFile(fileId,
{"cc", {"cc",
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/external", toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/project", toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
"-isystem", "-isystem",
TESTDATA_DIR "/builddependencycollector/system"}); toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
emptyCollector.collect(); emptyCollector.collect();
@@ -574,11 +624,11 @@ TEST_F(BuildDependencyCollector, DontCollectHeaderGuards)
emptyCollector.addFile(fileId, emptyCollector.addFile(fileId,
{"cc", {"cc",
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/external", toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/project", toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
"-isystem", "-isystem",
TESTDATA_DIR "/builddependencycollector/system"}); toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
emptyCollector.collect(); emptyCollector.collect();
@@ -592,11 +642,11 @@ TEST_F(BuildDependencyCollector, DISABLED_DontCollectDynamicLibraryExports)
emptyCollector.addFile(fileId, emptyCollector.addFile(fileId,
{"cc", {"cc",
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/external", toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/project", toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
"-isystem", "-isystem",
TESTDATA_DIR "/builddependencycollector/system"}); toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
emptyCollector.collect(); emptyCollector.collect();
@@ -609,11 +659,11 @@ TEST_F(BuildDependencyCollector, CollectFileStatuses)
emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"), emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"),
{"cc", {"cc",
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/external", toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/project", toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
"-isystem", "-isystem",
TESTDATA_DIR "/builddependencycollector/system"}); toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
emptyCollector.collect(); emptyCollector.collect();
@@ -645,11 +695,11 @@ TEST_F(BuildDependencyCollector, MissingInclude)
emptyCollector.addFile(id(TESTDATA_DIR "/builddependencycollector/project/main5.cpp"), emptyCollector.addFile(id(TESTDATA_DIR "/builddependencycollector/project/main5.cpp"),
{"cc", {"cc",
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/external", toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/project", toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
"-isystem", "-isystem",
TESTDATA_DIR "/builddependencycollector/system"}); toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
emptyCollector.collect(); emptyCollector.collect();
@@ -690,15 +740,16 @@ TEST_F(BuildDependencyCollector, MissingInclude)
TEST_F(BuildDependencyCollector, GeneratedFile) TEST_F(BuildDependencyCollector, GeneratedFile)
{ {
generatedFiles.update( generatedFiles.update(
{{TESTDATA_DIR "/builddependencycollector/project/generated_file.h", "#pragma once"}}); {{TESTDATA_DIR "/builddependencycollector/project/generated/generated_file.h",
"#pragma once"}});
emptyCollector.addFile(id(TESTDATA_DIR "/builddependencycollector/project/main6.cpp"), emptyCollector.addFile(id(TESTDATA_DIR "/builddependencycollector/project/main6.cpp"),
{"cc", {"cc",
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/external", toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
"-I", "-I",
TESTDATA_DIR "/builddependencycollector/project", toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
"-isystem", "-isystem",
TESTDATA_DIR "/builddependencycollector/system"}); toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
emptyCollector.addUnsavedFiles(generatedFiles.fileContainers()); emptyCollector.addUnsavedFiles(generatedFiles.fileContainers());
emptyCollector.collect(); emptyCollector.collect();
@@ -707,7 +758,8 @@ TEST_F(BuildDependencyCollector, GeneratedFile)
emptyCollector.sourceEntries(), emptyCollector.sourceEntries(),
ElementsAre(HasSource(id(TESTDATA_DIR "/builddependencycollector/project/main6.cpp"), ElementsAre(HasSource(id(TESTDATA_DIR "/builddependencycollector/project/main6.cpp"),
SourceType::Source), SourceType::Source),
HasSource(id(TESTDATA_DIR "/builddependencycollector/project/generated_file.h"), HasSource(id(TESTDATA_DIR
"/builddependencycollector/project/generated/generated_file.h"),
SourceType::UserInclude))); SourceType::UserInclude)));
} }
@@ -737,14 +789,14 @@ TEST_F(BuildDependencyCollector, Create)
1, 1,
{}, {},
{}, {},
{{TESTDATA_DIR "/builddependencycollector/system", {{toNativePath(TESTDATA_DIR "/builddependencycollector/system"),
1, 1,
ClangBackEnd::IncludeSearchPathType::System}}, ClangBackEnd::IncludeSearchPathType::System}},
{ {
{TESTDATA_DIR "/builddependencycollector/project", {toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
1, 1,
ClangBackEnd::IncludeSearchPathType::User}, ClangBackEnd::IncludeSearchPathType::User},
{TESTDATA_DIR "/builddependencycollector/external", {toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
2, 2,
ClangBackEnd::IncludeSearchPathType::User}, ClangBackEnd::IncludeSearchPathType::User},
}, },
@@ -899,14 +951,14 @@ TEST_F(BuildDependencyCollector, Clear)
1, 1,
{}, {},
{}, {},
{{TESTDATA_DIR "/builddependencycollector/system", {{toNativePath(TESTDATA_DIR "/builddependencycollector/system"),
1, 1,
ClangBackEnd::IncludeSearchPathType::System}}, ClangBackEnd::IncludeSearchPathType::System}},
{ {
{TESTDATA_DIR "/builddependencycollector/project", {toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
1, 1,
ClangBackEnd::IncludeSearchPathType::User}, ClangBackEnd::IncludeSearchPathType::User},
{TESTDATA_DIR "/builddependencycollector/external", {toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
2, 2,
ClangBackEnd::IncludeSearchPathType::User}, ClangBackEnd::IncludeSearchPathType::User},
}, },
@@ -925,14 +977,14 @@ TEST_F(BuildDependencyCollector, Clear)
1, 1,
{}, {},
{}, {},
{{TESTDATA_DIR "/builddependencycollector/system", {{toNativePath(TESTDATA_DIR "/builddependencycollector/system"),
1, 1,
ClangBackEnd::IncludeSearchPathType::System}}, ClangBackEnd::IncludeSearchPathType::System}},
{ {
{TESTDATA_DIR "/builddependencycollector/project", {toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
1, 1,
ClangBackEnd::IncludeSearchPathType::User}, ClangBackEnd::IncludeSearchPathType::User},
{TESTDATA_DIR "/builddependencycollector/external", {toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
2, 2,
ClangBackEnd::IncludeSearchPathType::User}, ClangBackEnd::IncludeSearchPathType::User},
}, },
@@ -960,14 +1012,14 @@ TEST_F(BuildDependencyCollector, PreIncludes)
1, 1,
{}, {},
{}, {},
{{TESTDATA_DIR "/builddependencycollector/system", {{toNativePath(TESTDATA_DIR "/builddependencycollector/system"),
1, 1,
ClangBackEnd::IncludeSearchPathType::System}}, ClangBackEnd::IncludeSearchPathType::System}},
{ {
{TESTDATA_DIR "/builddependencycollector/project", {toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
1, 1,
ClangBackEnd::IncludeSearchPathType::User}, ClangBackEnd::IncludeSearchPathType::User},
{TESTDATA_DIR "/builddependencycollector/external", {toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
2, 2,
ClangBackEnd::IncludeSearchPathType::User}, ClangBackEnd::IncludeSearchPathType::User},
}, },

View File

@@ -1,3 +1,3 @@
#include "generated_file.h" #include "generated/generated_file.h"
#include "generated_file.h" #include "generated/generated_file.h"