2018-11-12 19:27:51 +01:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
|
|
|
** 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 "googletest.h"
|
|
|
|
|
2019-02-06 17:18:15 +01:00
|
|
|
#include "testenvironment.h"
|
|
|
|
|
2018-11-12 19:27:51 +01:00
|
|
|
#include <refactoringdatabaseinitializer.h>
|
|
|
|
#include <filepathcaching.h>
|
2019-01-22 14:38:02 +01:00
|
|
|
#include <generatedfiles.h>
|
2018-11-12 19:27:51 +01:00
|
|
|
#include <builddependencycollector.h>
|
|
|
|
|
|
|
|
#include <sqlitedatabase.h>
|
|
|
|
|
|
|
|
#include <QDateTime>
|
|
|
|
#include <QDir>
|
|
|
|
|
|
|
|
using testing::AllOf;
|
|
|
|
using testing::Contains;
|
|
|
|
using testing::Not;
|
|
|
|
using testing::ElementsAre;
|
|
|
|
using testing::UnorderedElementsAre;
|
|
|
|
|
|
|
|
using ClangBackEnd::BuildDependency;
|
|
|
|
using ClangBackEnd::FilePathId;
|
|
|
|
using ClangBackEnd::FilePathIds;
|
|
|
|
using ClangBackEnd::FilePathView;
|
2019-02-28 17:52:34 +01:00
|
|
|
using ClangBackEnd::HasMissingIncludes;
|
2018-11-12 19:27:51 +01:00
|
|
|
using ClangBackEnd::SourceDependency;
|
|
|
|
using ClangBackEnd::SourceType;
|
|
|
|
using ClangBackEnd::UsedMacro;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2019-02-25 19:07:19 +01:00
|
|
|
MATCHER_P2(HasSource,
|
|
|
|
sourceId,
|
|
|
|
sourceType,
|
2018-11-12 19:27:51 +01:00
|
|
|
std::string(negation ? "hasn't " : "has ")
|
2019-02-28 17:52:34 +01:00
|
|
|
+ PrintToString(ClangBackEnd::SourceEntry(
|
|
|
|
sourceId, sourceType, -1, ClangBackEnd::HasMissingIncludes::No)))
|
2018-11-12 19:27:51 +01:00
|
|
|
{
|
|
|
|
const ClangBackEnd::SourceEntry &entry = arg;
|
|
|
|
|
2019-02-28 17:52:34 +01:00
|
|
|
return entry.sourceId == sourceId && entry.sourceType == sourceType
|
|
|
|
&& entry.hasMissingIncludes == ClangBackEnd::HasMissingIncludes::No;
|
|
|
|
}
|
|
|
|
|
|
|
|
MATCHER_P3(HasSource,
|
|
|
|
sourceId,
|
|
|
|
sourceType,
|
|
|
|
hasMissingIncludes,
|
|
|
|
std::string(negation ? "hasn't " : "has ")
|
|
|
|
+ PrintToString(ClangBackEnd::SourceEntry(sourceId, sourceType, -1, hasMissingIncludes)))
|
|
|
|
{
|
|
|
|
const ClangBackEnd::SourceEntry &entry = arg;
|
|
|
|
|
|
|
|
return entry.sourceId == sourceId && entry.sourceType == sourceType
|
|
|
|
&& entry.hasMissingIncludes == hasMissingIncludes;
|
2018-11-12 19:27:51 +01:00
|
|
|
}
|
|
|
|
|
2019-07-10 15:58:23 +02:00
|
|
|
static Utils::SmallString toNativePath(Utils::SmallStringView text)
|
|
|
|
{
|
|
|
|
ClangBackEnd::FilePath path{text};
|
|
|
|
|
|
|
|
return Utils::SmallString{ClangBackEnd::NativeFilePath{path}.path()};
|
|
|
|
}
|
|
|
|
|
2018-11-12 19:27:51 +01:00
|
|
|
class BuildDependencyCollector : public ::testing::Test
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
BuildDependencyCollector()
|
|
|
|
{
|
|
|
|
setFilePathCache(&filePathCache);
|
|
|
|
|
2019-02-06 17:18:15 +01:00
|
|
|
collector.addFiles({id(TESTDATA_DIR "/builddependencycollector/project/main.cpp"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/main2.cpp")},
|
|
|
|
{"cc",
|
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
|
2019-02-06 17:18:15 +01:00
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
|
2019-02-06 17:18:15 +01:00
|
|
|
"-isystem",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
|
2018-11-21 20:11:07 +01:00
|
|
|
|
|
|
|
collector.addUnsavedFiles(
|
|
|
|
{{{TESTDATA_DIR, "BuildDependencyCollector/project/generated_file.h"},
|
2019-08-20 14:45:01 +02:00
|
|
|
id(TESTDATA_DIR "/BuildDependencyCollector/project/generated_file.h"),
|
2018-11-21 20:11:07 +01:00
|
|
|
"#pragma once",
|
|
|
|
{}}});
|
2018-11-12 19:27:51 +01:00
|
|
|
|
|
|
|
collector.setExcludedFilePaths(Utils::clone(excludePaths));
|
|
|
|
emptyCollector.setExcludedFilePaths(Utils::clone(excludePaths));
|
|
|
|
}
|
|
|
|
|
2018-11-21 20:11:07 +01:00
|
|
|
~BuildDependencyCollector() { setFilePathCache(nullptr); }
|
2018-11-12 19:27:51 +01:00
|
|
|
|
|
|
|
FilePathId id(const Utils::SmallStringView &path) const
|
|
|
|
{
|
|
|
|
return filePathCache.filePathId(FilePathView{path});
|
|
|
|
}
|
|
|
|
|
|
|
|
static off_t fileSize(Utils::SmallStringView filePath)
|
|
|
|
{
|
|
|
|
return QFileInfo(QString(filePath)).size();
|
|
|
|
}
|
|
|
|
|
2018-11-21 20:11:07 +01:00
|
|
|
static std::time_t lastModified(Utils::SmallStringView filePath)
|
2018-11-12 19:27:51 +01:00
|
|
|
{
|
2019-09-10 13:13:30 +02:00
|
|
|
return QFileInfo(QString(filePath)).lastModified().toSecsSinceEpoch();
|
2018-11-12 19:27:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ClangBackEnd::FileStatus fileStatus(Utils::SmallStringView filePath) const
|
|
|
|
{
|
2019-02-25 19:07:19 +01:00
|
|
|
return {id(filePath), fileSize(filePath), lastModified(filePath)};
|
2018-11-12 19:27:51 +01:00
|
|
|
}
|
|
|
|
|
2019-02-25 19:07:19 +01:00
|
|
|
static FilePathIds filteredSources(const ClangBackEnd::SourceEntries &sources,
|
|
|
|
ClangBackEnd::SourceType sourceType)
|
2018-11-12 19:27:51 +01:00
|
|
|
{
|
2019-02-25 19:07:19 +01:00
|
|
|
FilePathIds filteredSources;
|
2018-11-12 19:27:51 +01:00
|
|
|
|
2019-02-25 19:07:19 +01:00
|
|
|
for (const ClangBackEnd::SourceEntry &source : sources) {
|
|
|
|
if (source.sourceType == sourceType)
|
|
|
|
filteredSources.push_back(source.sourceId);
|
2018-11-12 19:27:51 +01:00
|
|
|
}
|
|
|
|
|
2019-02-25 19:07:19 +01:00
|
|
|
return filteredSources;
|
2018-11-12 19:27:51 +01:00
|
|
|
}
|
|
|
|
|
2019-02-25 19:07:19 +01:00
|
|
|
static FilePathIds topSources(const ClangBackEnd::SourceEntries &sources)
|
2018-11-12 19:27:51 +01:00
|
|
|
{
|
2019-02-25 19:07:19 +01:00
|
|
|
return filteredSources(sources, ClangBackEnd::SourceType::TopProjectInclude);
|
2018-11-12 19:27:51 +01:00
|
|
|
}
|
|
|
|
|
2019-02-25 19:07:19 +01:00
|
|
|
static FilePathIds systemTopSources(const ClangBackEnd::SourceEntries &sources)
|
2018-11-12 19:27:51 +01:00
|
|
|
{
|
2019-02-25 19:07:19 +01:00
|
|
|
return filteredSources(sources, ClangBackEnd::SourceType::TopSystemInclude);
|
2018-11-12 19:27:51 +01:00
|
|
|
}
|
|
|
|
|
2019-02-25 19:07:19 +01:00
|
|
|
static FilePathIds userSources(const ClangBackEnd::SourceEntries &sources)
|
2018-11-12 19:27:51 +01:00
|
|
|
{
|
2019-02-25 19:07:19 +01:00
|
|
|
return filteredSources(sources, ClangBackEnd::SourceType::UserInclude);
|
2018-11-12 19:27:51 +01:00
|
|
|
}
|
|
|
|
|
2019-02-25 19:07:19 +01:00
|
|
|
static FilePathIds projectPartSources(const ClangBackEnd::SourceEntries &sources)
|
2018-11-21 20:11:07 +01:00
|
|
|
{
|
2019-02-25 19:07:19 +01:00
|
|
|
return filteredSources(sources, ClangBackEnd::SourceType::ProjectInclude);
|
2018-11-21 20:11:07 +01:00
|
|
|
}
|
|
|
|
|
2019-02-25 19:07:19 +01:00
|
|
|
static FilePathIds sources(const ClangBackEnd::SourceEntries &sources)
|
2018-11-12 19:27:51 +01:00
|
|
|
{
|
2019-02-25 19:07:19 +01:00
|
|
|
FilePathIds filteredSources;
|
2018-11-12 19:27:51 +01:00
|
|
|
|
2019-02-25 19:07:19 +01:00
|
|
|
for (const ClangBackEnd::SourceEntry &source : sources)
|
|
|
|
filteredSources.push_back(source.sourceId);
|
2018-11-12 19:27:51 +01:00
|
|
|
|
2019-02-25 19:07:19 +01:00
|
|
|
return filteredSources;
|
2018-11-12 19:27:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory};
|
2019-02-06 17:18:15 +01:00
|
|
|
TestEnvironment environment;
|
2018-11-12 19:27:51 +01:00
|
|
|
ClangBackEnd::RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database};
|
|
|
|
ClangBackEnd::FilePathCaching filePathCache{database};
|
2019-01-22 14:38:02 +01:00
|
|
|
ClangBackEnd::GeneratedFiles generatedFiles;
|
2019-02-06 17:18:15 +01:00
|
|
|
ClangBackEnd::BuildDependencyCollector collector{filePathCache, generatedFiles, environment};
|
|
|
|
ClangBackEnd::BuildDependencyCollector emptyCollector{filePathCache, generatedFiles, environment};
|
|
|
|
ClangBackEnd::FilePaths excludePaths = {
|
|
|
|
TESTDATA_DIR "/builddependencycollector/project/main.cpp",
|
|
|
|
TESTDATA_DIR "/builddependencycollector/project/main2.cpp",
|
|
|
|
TESTDATA_DIR "/builddependencycollector/project/header1.h",
|
|
|
|
TESTDATA_DIR "/builddependencycollector/project/header2.h",
|
2019-07-10 15:58:23 +02:00
|
|
|
TESTDATA_DIR "/builddependencycollector/project/generated_file.h",
|
|
|
|
TESTDATA_DIR "/builddependencycollector/project/generated/generated_file.h"};
|
2018-11-12 19:27:51 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, IncludesExternalHeader)
|
|
|
|
{
|
|
|
|
collector.collect();
|
|
|
|
|
2019-02-25 19:07:19 +01:00
|
|
|
ASSERT_THAT(sources(collector.sourceEntries()),
|
2018-11-12 19:27:51 +01:00
|
|
|
AllOf(Contains(id(TESTDATA_DIR "/builddependencycollector/external/external1.h")),
|
|
|
|
Contains(id(TESTDATA_DIR "/builddependencycollector/external/external2.h")),
|
2019-02-25 19:07:19 +01:00
|
|
|
Contains(id(TESTDATA_DIR
|
|
|
|
"/builddependencycollector/external/indirect_external.h")),
|
|
|
|
Contains(id(TESTDATA_DIR
|
|
|
|
"/builddependencycollector/external/indirect_external2.h"))));
|
2018-11-12 19:27:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, InternalHeaderAreUserIncludes)
|
|
|
|
{
|
|
|
|
collector.collect();
|
|
|
|
|
2019-02-25 19:07:19 +01:00
|
|
|
ASSERT_THAT(userSources(collector.sourceEntries()),
|
|
|
|
Contains(id(TESTDATA_DIR "/builddependencycollector/project/header1.h")));
|
2018-11-12 19:27:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, NoDuplicate)
|
|
|
|
{
|
|
|
|
collector.collect();
|
|
|
|
|
2019-02-25 19:07:19 +01:00
|
|
|
ASSERT_THAT(sources(collector.sourceEntries()),
|
2018-11-12 19:27:51 +01:00
|
|
|
UnorderedElementsAre(
|
2019-02-25 19:07:19 +01:00
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/main.cpp"),
|
2019-02-28 17:52:34 +01:00
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/main2.cpp"),
|
2018-11-12 19:27:51 +01:00
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/header1.h"),
|
|
|
|
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/external/external3.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/external/indirect_external.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/external/indirect_external2.h")));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, IncludesAreSorted)
|
|
|
|
{
|
|
|
|
collector.collect();
|
|
|
|
|
2019-02-25 19:07:19 +01:00
|
|
|
ASSERT_THAT(sources(collector.sourceEntries()),
|
|
|
|
ElementsAre(id(TESTDATA_DIR "/builddependencycollector/project/main.cpp"),
|
2019-02-28 17:52:34 +01:00
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/main2.cpp"),
|
2019-02-25 19:07:19 +01:00
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/header1.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/header2.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/external/external3.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/external/external1.h"),
|
|
|
|
id(TESTDATA_DIR
|
|
|
|
"/builddependencycollector/external/indirect_external.h"),
|
|
|
|
id(TESTDATA_DIR
|
|
|
|
"/builddependencycollector/external/indirect_external2.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/external/external2.h")));
|
2018-11-12 19:27:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, If)
|
|
|
|
{
|
2019-07-10 15:58:23 +02:00
|
|
|
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")});
|
2018-11-12 19:27:51 +01:00
|
|
|
|
|
|
|
emptyCollector.collect();
|
|
|
|
|
2019-02-25 19:07:19 +01:00
|
|
|
ASSERT_THAT(sources(emptyCollector.sourceEntries()),
|
|
|
|
ElementsAre(id(TESTDATA_DIR "/builddependencycollector/project/if.cpp"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/true.h")));
|
2018-11-12 19:27:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, LocalPath)
|
|
|
|
{
|
2019-07-10 15:58:23 +02:00
|
|
|
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")});
|
2018-11-12 19:27:51 +01:00
|
|
|
|
|
|
|
emptyCollector.collect();
|
|
|
|
|
2019-02-25 19:07:19 +01:00
|
|
|
ASSERT_THAT(sources(emptyCollector.sourceEntries()),
|
2018-11-12 19:27:51 +01:00
|
|
|
UnorderedElementsAre(
|
2019-02-25 19:07:19 +01:00
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/main.cpp"),
|
2018-11-12 19:27:51 +01:00
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/header1.h"),
|
|
|
|
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/external/external3.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/external/indirect_external.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/external/indirect_external2.h")));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, IgnoreMissingFile)
|
|
|
|
{
|
2019-07-10 15:58:23 +02:00
|
|
|
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")});
|
2018-11-12 19:27:51 +01:00
|
|
|
|
|
|
|
emptyCollector.collect();
|
|
|
|
|
2019-02-25 19:07:19 +01:00
|
|
|
ASSERT_THAT(sources(emptyCollector.sourceEntries()),
|
|
|
|
UnorderedElementsAre(
|
2019-02-28 17:52:34 +01:00
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/missingfile.cpp"),
|
2019-02-25 19:07:19 +01:00
|
|
|
id(TESTDATA_DIR "/builddependencycollector/external/external1.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/external/indirect_external.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/external/indirect_external2.h")));
|
2018-11-12 19:27:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, IncludesOnlyTopExternalHeader)
|
|
|
|
{
|
|
|
|
collector.collect();
|
|
|
|
|
2019-02-25 19:07:19 +01:00
|
|
|
ASSERT_THAT(
|
|
|
|
topSources(collector.sourceEntries()),
|
|
|
|
UnorderedElementsAre(id(TESTDATA_DIR "/builddependencycollector/external/external1.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/external/external2.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/external/external3.h")));
|
2018-11-12 19:27:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, TopIncludeInIfMacro)
|
|
|
|
{
|
2019-07-10 15:58:23 +02:00
|
|
|
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")});
|
2018-11-12 19:27:51 +01:00
|
|
|
emptyCollector.setExcludedFilePaths({TESTDATA_DIR "/builddependencycollector/project/if.cpp"});
|
|
|
|
|
|
|
|
emptyCollector.collect();
|
|
|
|
|
2019-02-25 19:07:19 +01:00
|
|
|
ASSERT_THAT(topSources(emptyCollector.sourceEntries()),
|
2018-11-12 19:27:51 +01:00
|
|
|
ElementsAre(id(TESTDATA_DIR "/builddependencycollector/project/true.h")));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, TopIncludeWithLocalPath)
|
|
|
|
{
|
2019-07-10 15:58:23 +02:00
|
|
|
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")});
|
2018-11-12 19:27:51 +01:00
|
|
|
|
|
|
|
emptyCollector.collect();
|
|
|
|
|
2019-02-25 19:07:19 +01:00
|
|
|
ASSERT_THAT(
|
|
|
|
topSources(emptyCollector.sourceEntries()),
|
|
|
|
UnorderedElementsAre(id(TESTDATA_DIR "/builddependencycollector/external/external1.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/external/external2.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/external/external3.h")));
|
2018-11-12 19:27:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, TopIncludesIgnoreMissingFile)
|
|
|
|
{
|
2019-07-10 15:58:23 +02:00
|
|
|
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")});
|
2018-11-12 19:27:51 +01:00
|
|
|
emptyCollector.setExcludedFilePaths({TESTDATA_DIR "/builddependencycollector/project/missingfile.cpp"});
|
|
|
|
|
|
|
|
emptyCollector.collect();
|
|
|
|
|
2019-02-25 19:07:19 +01:00
|
|
|
ASSERT_THAT(topSources(emptyCollector.sourceEntries()),
|
|
|
|
UnorderedElementsAre(
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/external/external1.h")));
|
2018-11-12 19:27:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, SourceFiles)
|
|
|
|
{
|
2019-02-07 12:20:39 +01:00
|
|
|
emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"),
|
|
|
|
{"cc",
|
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-isystem",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
|
2018-11-12 19:27:51 +01:00
|
|
|
|
|
|
|
emptyCollector.collect();
|
|
|
|
|
|
|
|
ASSERT_THAT(emptyCollector.sourceFiles(),
|
2019-02-07 12:20:39 +01:00
|
|
|
UnorderedElementsAre(id(TESTDATA_DIR "/symbolscollector/main.cpp"),
|
|
|
|
id(TESTDATA_DIR "/symbolscollector/header1.h"),
|
|
|
|
id(TESTDATA_DIR "/symbolscollector/header2.h")));
|
2018-11-12 19:27:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, MainFileInSourceFiles)
|
|
|
|
{
|
2019-02-07 12:20:39 +01:00
|
|
|
emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"),
|
|
|
|
{"cc",
|
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-isystem",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
|
2018-11-12 19:27:51 +01:00
|
|
|
|
|
|
|
ASSERT_THAT(emptyCollector.sourceFiles(),
|
2019-02-07 12:20:39 +01:00
|
|
|
ElementsAre(id(TESTDATA_DIR "/symbolscollector/main.cpp")));
|
2018-11-12 19:27:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, ResetMainFileInSourceFiles)
|
|
|
|
{
|
2019-02-07 12:20:39 +01:00
|
|
|
emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"),
|
|
|
|
{"cc",
|
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-isystem",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
|
2018-11-12 19:27:51 +01:00
|
|
|
|
|
|
|
ASSERT_THAT(emptyCollector.sourceFiles(),
|
2019-02-07 12:20:39 +01:00
|
|
|
ElementsAre(id(TESTDATA_DIR "/symbolscollector/main.cpp")));
|
2018-11-12 19:27:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, DontDuplicateSourceFiles)
|
|
|
|
{
|
2019-02-07 12:20:39 +01:00
|
|
|
emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"),
|
|
|
|
{"cc",
|
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-isystem",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
|
2018-11-12 19:27:51 +01:00
|
|
|
emptyCollector.collect();
|
|
|
|
|
|
|
|
emptyCollector.collect();
|
|
|
|
|
|
|
|
ASSERT_THAT(emptyCollector.sourceFiles(),
|
2019-02-07 12:20:39 +01:00
|
|
|
UnorderedElementsAre(id(TESTDATA_DIR "/symbolscollector/main.cpp"),
|
|
|
|
id(TESTDATA_DIR "/symbolscollector/header1.h"),
|
|
|
|
id(TESTDATA_DIR "/symbolscollector/header2.h")));
|
2018-11-12 19:27:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, ClearSourceFiles)
|
|
|
|
{
|
2019-02-07 12:20:39 +01:00
|
|
|
emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"),
|
|
|
|
{"cc",
|
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-isystem",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
|
2018-11-12 19:27:51 +01:00
|
|
|
|
|
|
|
emptyCollector.clear();
|
|
|
|
|
|
|
|
ASSERT_THAT(emptyCollector.sourceFiles(), IsEmpty());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, ClearFileStatus)
|
|
|
|
{
|
2019-02-07 12:20:39 +01:00
|
|
|
emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"),
|
|
|
|
{"cc",
|
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-isystem",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
|
2018-11-12 19:27:51 +01:00
|
|
|
emptyCollector.collect();
|
|
|
|
|
|
|
|
emptyCollector.clear();
|
|
|
|
|
|
|
|
ASSERT_THAT(emptyCollector.fileStatuses(), IsEmpty());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, ClearUsedMacros)
|
|
|
|
{
|
2019-02-07 12:20:39 +01:00
|
|
|
emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/defines.h"),
|
|
|
|
{"cc",
|
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-isystem",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
|
2018-11-12 19:27:51 +01:00
|
|
|
emptyCollector.collect();
|
|
|
|
|
|
|
|
emptyCollector.clear();
|
|
|
|
|
|
|
|
ASSERT_THAT(emptyCollector.usedMacros(), IsEmpty());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, ClearSourceDependencies)
|
|
|
|
{
|
2019-02-07 12:20:39 +01:00
|
|
|
emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main2.cpp"), {"cc", "-I" TESTDATA_DIR});
|
2018-11-12 19:27:51 +01:00
|
|
|
emptyCollector.collect();
|
|
|
|
|
|
|
|
emptyCollector.clear();
|
|
|
|
|
|
|
|
ASSERT_THAT(emptyCollector.sourceDependencies(), IsEmpty());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, DontCollectSourceFilesAfterFilesAreCleared)
|
|
|
|
{
|
2019-02-07 12:20:39 +01:00
|
|
|
emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"),
|
|
|
|
{"cc",
|
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-isystem",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
|
2018-11-12 19:27:51 +01:00
|
|
|
|
|
|
|
emptyCollector.clear();
|
|
|
|
emptyCollector.collect();
|
|
|
|
|
|
|
|
ASSERT_THAT(emptyCollector.sourceFiles(), IsEmpty());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, DontCollectFileStatusAfterFilesAreCleared)
|
|
|
|
{
|
2019-02-07 12:20:39 +01:00
|
|
|
emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"),
|
|
|
|
{"cc",
|
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-isystem",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
|
2018-11-12 19:27:51 +01:00
|
|
|
|
|
|
|
emptyCollector.clear();
|
|
|
|
emptyCollector.collect();
|
|
|
|
|
|
|
|
ASSERT_THAT(emptyCollector.fileStatuses(), IsEmpty());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, DontCollectUsedMacrosAfterFilesAreCleared)
|
|
|
|
{
|
2019-02-07 12:20:39 +01:00
|
|
|
emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"),
|
|
|
|
{"cc",
|
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-isystem",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
|
2018-11-12 19:27:51 +01:00
|
|
|
|
|
|
|
emptyCollector.clear();
|
|
|
|
emptyCollector.collect();
|
|
|
|
|
|
|
|
ASSERT_THAT(emptyCollector.usedMacros(), IsEmpty());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, DontCollectSourceDependenciesAfterFilesAreCleared)
|
|
|
|
{
|
2019-02-07 12:20:39 +01:00
|
|
|
emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"),
|
|
|
|
{"cc",
|
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-isystem",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
|
2018-11-12 19:27:51 +01:00
|
|
|
|
|
|
|
emptyCollector.clear();
|
|
|
|
emptyCollector.collect();
|
|
|
|
|
|
|
|
ASSERT_THAT(emptyCollector.sourceDependencies(), IsEmpty());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, CollectUsedMacrosWithExternalDefine)
|
|
|
|
{
|
2019-02-07 12:20:39 +01:00
|
|
|
auto fileId = id(TESTDATA_DIR "/symbolscollector/defines.h");
|
2018-11-12 19:27:51 +01:00
|
|
|
emptyCollector.addFile(fileId, {"cc", "-DCOMPILER_ARGUMENT"});
|
|
|
|
|
|
|
|
emptyCollector.collect();
|
|
|
|
|
|
|
|
ASSERT_THAT(emptyCollector.usedMacros(),
|
|
|
|
ElementsAre(Eq(UsedMacro{"DEFINED", fileId}),
|
|
|
|
Eq(UsedMacro{"IF_DEFINE", fileId}),
|
|
|
|
Eq(UsedMacro{"__clang__", fileId}),
|
|
|
|
Eq(UsedMacro{"IF_NOT_DEFINE", fileId}),
|
|
|
|
Eq(UsedMacro{"COMPILER_ARGUMENT", fileId})));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, CollectUsedMacrosWithoutExternalDefine)
|
|
|
|
{
|
2019-02-07 12:20:39 +01:00
|
|
|
auto fileId = id(TESTDATA_DIR "/symbolscollector/defines.h");
|
|
|
|
emptyCollector.addFile(fileId,
|
|
|
|
{"cc",
|
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-isystem",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
|
2018-11-12 19:27:51 +01:00
|
|
|
|
|
|
|
emptyCollector.collect();
|
|
|
|
|
|
|
|
ASSERT_THAT(emptyCollector.usedMacros(),
|
|
|
|
ElementsAre(Eq(UsedMacro{"DEFINED", fileId}),
|
|
|
|
Eq(UsedMacro{"IF_DEFINE", fileId}),
|
|
|
|
Eq(UsedMacro{"__clang__", fileId}),
|
|
|
|
Eq(UsedMacro{"IF_NOT_DEFINE", fileId}),
|
|
|
|
Eq(UsedMacro{"COMPILER_ARGUMENT", fileId})));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, DontCollectHeaderGuards)
|
|
|
|
{
|
2019-02-07 12:20:39 +01:00
|
|
|
auto fileId = id(TESTDATA_DIR "/symbolscollector/defines.h");
|
|
|
|
emptyCollector.addFile(fileId,
|
|
|
|
{"cc",
|
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-isystem",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
|
2018-11-12 19:27:51 +01:00
|
|
|
|
|
|
|
emptyCollector.collect();
|
|
|
|
|
|
|
|
ASSERT_THAT(emptyCollector.usedMacros(),
|
|
|
|
Not(Contains(Eq(UsedMacro{"SYMBOLSCOLLECTOR_DEFINES_H", fileId}))));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, DISABLED_DontCollectDynamicLibraryExports)
|
|
|
|
{
|
2019-02-07 12:20:39 +01:00
|
|
|
auto fileId = id(TESTDATA_DIR "/symbolscollector/defines.h");
|
|
|
|
emptyCollector.addFile(fileId,
|
|
|
|
{"cc",
|
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-isystem",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
|
2018-11-12 19:27:51 +01:00
|
|
|
|
|
|
|
emptyCollector.collect();
|
|
|
|
|
|
|
|
ASSERT_THAT(emptyCollector.usedMacros(),
|
|
|
|
Not(Contains(Eq(UsedMacro{"CLASS_EXPORT", fileId}))));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, CollectFileStatuses)
|
|
|
|
{
|
2019-02-07 12:20:39 +01:00
|
|
|
emptyCollector.addFile(id(TESTDATA_DIR "/symbolscollector/main.cpp"),
|
|
|
|
{"cc",
|
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
|
2019-02-07 12:20:39 +01:00
|
|
|
"-isystem",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
|
2018-11-12 19:27:51 +01:00
|
|
|
|
|
|
|
emptyCollector.collect();
|
|
|
|
|
|
|
|
ASSERT_THAT(emptyCollector.fileStatuses(),
|
2019-02-07 12:20:39 +01:00
|
|
|
ElementsAre(fileStatus(TESTDATA_DIR "/symbolscollector/main.cpp"),
|
|
|
|
fileStatus(TESTDATA_DIR "/symbolscollector/header1.h"),
|
|
|
|
fileStatus(TESTDATA_DIR "/symbolscollector/header2.h")));
|
2018-11-12 19:27:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, CollectSourceDependencies)
|
|
|
|
{
|
2019-02-07 12:20:39 +01:00
|
|
|
auto mainFileId = id(TESTDATA_DIR "/symbolscollector/main2.cpp");
|
|
|
|
auto header1FileId = id(TESTDATA_DIR "/symbolscollector/header1.h");
|
|
|
|
auto header2FileId = id(TESTDATA_DIR "/symbolscollector/header2.h");
|
|
|
|
auto header3FileId = id(TESTDATA_DIR "/symbolscollector/header3.h");
|
2018-11-12 19:27:51 +01:00
|
|
|
emptyCollector.addFile(mainFileId, {"cc", "-I" TESTDATA_DIR});
|
|
|
|
|
|
|
|
emptyCollector.collect();
|
|
|
|
|
|
|
|
ASSERT_THAT(emptyCollector.sourceDependencies(),
|
|
|
|
UnorderedElementsAre(SourceDependency(mainFileId, header1FileId),
|
|
|
|
SourceDependency(mainFileId, header3FileId),
|
|
|
|
SourceDependency(header3FileId, header2FileId),
|
|
|
|
SourceDependency(header1FileId, header2FileId)));
|
|
|
|
}
|
|
|
|
|
2018-11-19 19:56:58 +01:00
|
|
|
TEST_F(BuildDependencyCollector, MissingInclude)
|
|
|
|
{
|
|
|
|
emptyCollector.addFile(id(TESTDATA_DIR "/builddependencycollector/project/main5.cpp"),
|
|
|
|
{"cc",
|
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
|
2018-11-19 19:56:58 +01:00
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
|
2018-11-19 19:56:58 +01:00
|
|
|
"-isystem",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
|
2018-11-19 19:56:58 +01:00
|
|
|
|
|
|
|
emptyCollector.collect();
|
|
|
|
|
2019-02-28 17:52:34 +01:00
|
|
|
ASSERT_THAT(
|
|
|
|
emptyCollector.sourceEntries(),
|
|
|
|
UnorderedElementsAre(
|
|
|
|
HasSource(id(TESTDATA_DIR "/builddependencycollector/project/main5.cpp"),
|
|
|
|
SourceType::Source,
|
|
|
|
HasMissingIncludes::Yes),
|
|
|
|
HasSource(id(TESTDATA_DIR "/builddependencycollector/project/missinginclude2.h"),
|
|
|
|
SourceType::ProjectInclude,
|
|
|
|
HasMissingIncludes::Yes),
|
|
|
|
HasSource(id(TESTDATA_DIR
|
|
|
|
"/builddependencycollector/project/indirect_missinginclude.h"),
|
|
|
|
SourceType::ProjectInclude,
|
|
|
|
HasMissingIncludes::Yes),
|
|
|
|
HasSource(id(TESTDATA_DIR
|
|
|
|
"/builddependencycollector/project/indirect_missinginclude3.h"),
|
|
|
|
SourceType::ProjectInclude,
|
|
|
|
HasMissingIncludes::Yes),
|
|
|
|
HasSource(id(TESTDATA_DIR
|
|
|
|
"/builddependencycollector/project/indirect_missinginclude4.h"),
|
|
|
|
SourceType::ProjectInclude,
|
|
|
|
HasMissingIncludes::Yes),
|
|
|
|
HasSource(id(TESTDATA_DIR "/builddependencycollector/project/missinginclude3.h"),
|
|
|
|
SourceType::ProjectInclude,
|
|
|
|
HasMissingIncludes::Yes),
|
|
|
|
HasSource(id(TESTDATA_DIR
|
|
|
|
"/builddependencycollector/project/indirect_missinginclude2.h"),
|
|
|
|
SourceType::ProjectInclude,
|
|
|
|
HasMissingIncludes::Yes),
|
|
|
|
HasSource(id(TESTDATA_DIR "/builddependencycollector/project/header1.h"),
|
|
|
|
SourceType::UserInclude,
|
|
|
|
HasMissingIncludes::No)));
|
2018-11-19 19:56:58 +01:00
|
|
|
}
|
|
|
|
|
2019-01-22 14:38:02 +01:00
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, GeneratedFile)
|
|
|
|
{
|
|
|
|
generatedFiles.update(
|
2019-07-10 15:58:23 +02:00
|
|
|
{{TESTDATA_DIR "/builddependencycollector/project/generated/generated_file.h",
|
2019-08-20 14:45:01 +02:00
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/generated/generated_file.h"),
|
2019-07-10 15:58:23 +02:00
|
|
|
"#pragma once"}});
|
2019-01-22 14:38:02 +01:00
|
|
|
emptyCollector.addFile(id(TESTDATA_DIR "/builddependencycollector/project/main6.cpp"),
|
|
|
|
{"cc",
|
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
|
2019-01-22 14:38:02 +01:00
|
|
|
"-I",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
|
2019-01-22 14:38:02 +01:00
|
|
|
"-isystem",
|
2019-07-10 15:58:23 +02:00
|
|
|
toNativePath(TESTDATA_DIR "/builddependencycollector/system")});
|
2019-01-22 14:38:02 +01:00
|
|
|
emptyCollector.addUnsavedFiles(generatedFiles.fileContainers());
|
|
|
|
|
|
|
|
emptyCollector.collect();
|
|
|
|
|
2019-08-20 14:45:01 +02:00
|
|
|
ASSERT_THAT(emptyCollector.sourceEntries(),
|
|
|
|
UnorderedElementsAre(
|
|
|
|
HasSource(id(TESTDATA_DIR "/builddependencycollector/project/main6.cpp"),
|
2019-02-25 19:07:19 +01:00
|
|
|
SourceType::Source),
|
2019-07-10 15:58:23 +02:00
|
|
|
HasSource(id(TESTDATA_DIR
|
|
|
|
"/builddependencycollector/project/generated/generated_file.h"),
|
2019-02-25 19:07:19 +01:00
|
|
|
SourceType::UserInclude)));
|
2019-01-22 14:38:02 +01:00
|
|
|
}
|
|
|
|
|
2019-02-06 17:18:15 +01:00
|
|
|
TEST_F(BuildDependencyCollector, CreateFakeFileContent)
|
|
|
|
{
|
|
|
|
auto content = collector.generateFakeFileContent(
|
|
|
|
{id(TESTDATA_DIR "/builddependencycollector/project/header2.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/external/external1.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/external/external2.h")});
|
|
|
|
|
|
|
|
ASSERT_THAT(std::string(content),
|
|
|
|
AllOf(HasSubstr("#include \"" TESTDATA_DIR
|
|
|
|
"/builddependencycollector/project/header2.h\"\n"),
|
|
|
|
HasSubstr("#include \"" TESTDATA_DIR
|
|
|
|
"/builddependencycollector/external/external1.h\"\n"),
|
|
|
|
HasSubstr("#include \"" TESTDATA_DIR
|
|
|
|
"/builddependencycollector/external/external2.h\"\n")));
|
|
|
|
}
|
|
|
|
|
2018-11-12 19:27:51 +01:00
|
|
|
TEST_F(BuildDependencyCollector, Create)
|
|
|
|
{
|
2018-12-17 12:06:57 +01:00
|
|
|
using ClangBackEnd::IncludeSearchPathType;
|
2019-02-06 17:18:15 +01:00
|
|
|
ClangBackEnd::BuildDependencyCollector collector{filePathCache, generatedFiles, environment};
|
2019-08-20 14:45:01 +02:00
|
|
|
generatedFiles.update({{TESTDATA_DIR "/builddependencycollector/project/generated_file.h",
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/generated_file.h"),
|
|
|
|
"#pragma once"}});
|
2018-12-17 12:06:57 +01:00
|
|
|
ClangBackEnd::ProjectPartContainer projectPart{
|
2019-03-13 15:09:30 +01:00
|
|
|
1,
|
2018-12-17 12:06:57 +01:00
|
|
|
{},
|
|
|
|
{},
|
2019-07-10 15:58:23 +02:00
|
|
|
{{toNativePath(TESTDATA_DIR "/builddependencycollector/system"),
|
2019-04-24 14:07:39 +02:00
|
|
|
1,
|
|
|
|
ClangBackEnd::IncludeSearchPathType::System}},
|
2018-12-17 12:06:57 +01:00
|
|
|
{
|
2019-07-10 15:58:23 +02:00
|
|
|
{toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
|
2019-04-24 14:07:39 +02:00
|
|
|
1,
|
|
|
|
ClangBackEnd::IncludeSearchPathType::User},
|
2019-07-10 15:58:23 +02:00
|
|
|
{toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
|
2019-04-24 14:07:39 +02:00
|
|
|
2,
|
|
|
|
ClangBackEnd::IncludeSearchPathType::User},
|
2018-12-17 12:06:57 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/header1.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/header2.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/missingfile.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/macros.h"),
|
|
|
|
},
|
|
|
|
{id(TESTDATA_DIR "/builddependencycollector/project/main4.cpp")},
|
|
|
|
Utils::Language::Cxx,
|
|
|
|
Utils::LanguageVersion::CXX11,
|
|
|
|
Utils::LanguageExtension::None};
|
2018-11-12 19:27:51 +01:00
|
|
|
|
|
|
|
auto buildDependency = collector.create(projectPart);
|
|
|
|
|
|
|
|
ASSERT_THAT(
|
|
|
|
buildDependency,
|
|
|
|
AllOf(
|
|
|
|
Field(&BuildDependency::fileStatuses,
|
|
|
|
UnorderedElementsAre(
|
|
|
|
fileStatus(TESTDATA_DIR "/builddependencycollector/project/main4.cpp"),
|
|
|
|
fileStatus(TESTDATA_DIR "/builddependencycollector/project/header1.h"),
|
|
|
|
fileStatus(TESTDATA_DIR "/builddependencycollector/project/header2.h"),
|
|
|
|
fileStatus(TESTDATA_DIR "/builddependencycollector/external/external3.h"),
|
|
|
|
fileStatus(TESTDATA_DIR "/builddependencycollector/external/external1.h"),
|
|
|
|
fileStatus(TESTDATA_DIR
|
|
|
|
"/builddependencycollector/external/indirect_external.h"),
|
|
|
|
fileStatus(TESTDATA_DIR
|
|
|
|
"/builddependencycollector/external/indirect_external2.h"),
|
|
|
|
fileStatus(TESTDATA_DIR "/builddependencycollector/external/external2.h"),
|
|
|
|
fileStatus(TESTDATA_DIR "/builddependencycollector/system/system1.h"),
|
2019-04-24 14:07:39 +02:00
|
|
|
fileStatus(TESTDATA_DIR "/preincludes/system1.h"),
|
2018-11-12 19:27:51 +01:00
|
|
|
fileStatus(TESTDATA_DIR "/builddependencycollector/system/indirect_system.h"),
|
2019-01-22 14:38:02 +01:00
|
|
|
fileStatus(TESTDATA_DIR
|
|
|
|
"/builddependencycollector/system/indirect_system2.h"),
|
2018-11-12 19:27:51 +01:00
|
|
|
fileStatus(TESTDATA_DIR "/builddependencycollector/project/missingfile.h"),
|
2019-01-22 14:38:02 +01:00
|
|
|
fileStatus(TESTDATA_DIR "/builddependencycollector/project/macros.h"),
|
|
|
|
ClangBackEnd::FileStatus(
|
2019-02-25 19:07:19 +01:00
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/generated_file.h"), 12, 0))),
|
|
|
|
Field(
|
|
|
|
&BuildDependency::sources,
|
|
|
|
UnorderedElementsAre(
|
2019-02-28 17:52:34 +01:00
|
|
|
HasSource(id(TESTDATA_DIR "/builddependencycollector/project/main4.cpp"),
|
|
|
|
SourceType::Source,
|
|
|
|
HasMissingIncludes::Yes),
|
|
|
|
HasSource(id(TESTDATA_DIR "/builddependencycollector/project/missingfile.h"),
|
|
|
|
SourceType::UserInclude,
|
|
|
|
HasMissingIncludes::Yes),
|
2019-02-25 19:07:19 +01:00
|
|
|
HasSource(id(TESTDATA_DIR "/builddependencycollector/project/header1.h"),
|
|
|
|
SourceType::UserInclude),
|
|
|
|
HasSource(id(TESTDATA_DIR "/builddependencycollector/project/header2.h"),
|
|
|
|
SourceType::UserInclude),
|
|
|
|
HasSource(id(TESTDATA_DIR "/builddependencycollector/external/external3.h"),
|
|
|
|
SourceType::TopProjectInclude),
|
|
|
|
HasSource(id(TESTDATA_DIR "/builddependencycollector/external/external1.h"),
|
|
|
|
SourceType::TopProjectInclude),
|
|
|
|
HasSource(id(TESTDATA_DIR
|
|
|
|
"/builddependencycollector/external/indirect_external.h"),
|
|
|
|
SourceType::ProjectInclude),
|
|
|
|
HasSource(id(TESTDATA_DIR
|
|
|
|
"/builddependencycollector/external/indirect_external2.h"),
|
|
|
|
SourceType::ProjectInclude),
|
|
|
|
HasSource(id(TESTDATA_DIR "/builddependencycollector/external/external2.h"),
|
|
|
|
SourceType::TopProjectInclude),
|
|
|
|
HasSource(id(TESTDATA_DIR "/builddependencycollector/system/system1.h"),
|
2019-04-24 14:07:39 +02:00
|
|
|
SourceType::SystemInclude),
|
2019-02-25 19:07:19 +01:00
|
|
|
HasSource(id(TESTDATA_DIR "/builddependencycollector/system/indirect_system.h"),
|
|
|
|
SourceType::SystemInclude),
|
|
|
|
HasSource(id(TESTDATA_DIR
|
|
|
|
"/builddependencycollector/system/indirect_system2.h"),
|
|
|
|
SourceType::SystemInclude),
|
|
|
|
HasSource(id(TESTDATA_DIR "/builddependencycollector/project/macros.h"),
|
|
|
|
SourceType::UserInclude),
|
|
|
|
HasSource(id(TESTDATA_DIR "/builddependencycollector/project/generated_file.h"),
|
2019-04-24 14:07:39 +02:00
|
|
|
SourceType::UserInclude),
|
|
|
|
HasSource(id(TESTDATA_DIR "/preincludes/system1.h"), SourceType::TopSystemInclude))),
|
2018-11-12 19:27:51 +01:00
|
|
|
Field(&BuildDependency::usedMacros,
|
|
|
|
UnorderedElementsAre(
|
2019-01-22 14:38:02 +01:00
|
|
|
UsedMacro{"IFDEF", id(TESTDATA_DIR "/builddependencycollector/project/macros.h")},
|
2018-11-12 19:27:51 +01:00
|
|
|
UsedMacro{"DEFINED",
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/macros.h")})),
|
|
|
|
Field(&BuildDependency::sourceFiles,
|
|
|
|
UnorderedElementsAre(
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/main4.cpp"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/header1.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/header2.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/external/external3.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/external/external1.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/external/indirect_external.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/external/indirect_external2.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/external/external2.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/system/system1.h"),
|
2019-04-24 14:07:39 +02:00
|
|
|
id(TESTDATA_DIR "/preincludes/system1.h"),
|
2018-11-12 19:27:51 +01:00
|
|
|
id(TESTDATA_DIR "/builddependencycollector/system/indirect_system.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/system/indirect_system2.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/missingfile.h"),
|
2019-01-22 14:38:02 +01:00
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/macros.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/generated_file.h"))),
|
2018-11-12 19:27:51 +01:00
|
|
|
Field(
|
|
|
|
&BuildDependency::sourceDependencies,
|
|
|
|
UnorderedElementsAre(
|
|
|
|
SourceDependency(id(TESTDATA_DIR "/builddependencycollector/project/main4.cpp"),
|
2019-01-22 14:38:02 +01:00
|
|
|
id(TESTDATA_DIR
|
|
|
|
"/builddependencycollector/project/header1.h")),
|
2018-11-12 19:27:51 +01:00
|
|
|
SourceDependency(id(TESTDATA_DIR "/builddependencycollector/project/main4.cpp"),
|
2019-01-22 14:38:02 +01:00
|
|
|
id(TESTDATA_DIR
|
|
|
|
"/builddependencycollector/project/header2.h")),
|
2018-11-12 19:27:51 +01:00
|
|
|
SourceDependency(id(TESTDATA_DIR "/builddependencycollector/project/main4.cpp"),
|
|
|
|
id(TESTDATA_DIR
|
|
|
|
"/builddependencycollector/project/missingfile.h")),
|
|
|
|
SourceDependency(id(TESTDATA_DIR "/builddependencycollector/project/main4.cpp"),
|
|
|
|
id(TESTDATA_DIR
|
|
|
|
"/builddependencycollector/external/external1.h")),
|
|
|
|
SourceDependency(id(TESTDATA_DIR "/builddependencycollector/project/main4.cpp"),
|
|
|
|
id(TESTDATA_DIR
|
|
|
|
"/builddependencycollector/external/external2.h")),
|
|
|
|
SourceDependency(id(TESTDATA_DIR "/builddependencycollector/project/main4.cpp"),
|
2019-04-24 14:07:39 +02:00
|
|
|
id(TESTDATA_DIR "/preincludes/system1.h")),
|
|
|
|
SourceDependency(id(TESTDATA_DIR "/preincludes/system1.h"),
|
2018-11-12 19:27:51 +01:00
|
|
|
id(TESTDATA_DIR "/builddependencycollector/system/system1.h")),
|
|
|
|
SourceDependency(id(TESTDATA_DIR "/builddependencycollector/project/main4.cpp"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/macros.h")),
|
2019-01-22 14:38:02 +01:00
|
|
|
SourceDependency(id(TESTDATA_DIR "/builddependencycollector/project/main4.cpp"),
|
|
|
|
id(TESTDATA_DIR
|
|
|
|
"/builddependencycollector/project/generated_file.h")),
|
2018-11-12 19:27:51 +01:00
|
|
|
SourceDependency(id(TESTDATA_DIR "/builddependencycollector/project/header2.h"),
|
|
|
|
id(TESTDATA_DIR
|
|
|
|
"/builddependencycollector/external/external3.h")),
|
2019-01-22 14:38:02 +01:00
|
|
|
SourceDependency(
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/missingfile.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/external/external1.h")),
|
|
|
|
SourceDependency(
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/external/external1.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/external/indirect_external.h")),
|
|
|
|
SourceDependency(
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/external/indirect_external.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/external/indirect_external2.h")),
|
2018-11-12 19:27:51 +01:00
|
|
|
SourceDependency(id(TESTDATA_DIR "/builddependencycollector/system/system1.h"),
|
|
|
|
id(TESTDATA_DIR
|
|
|
|
"/builddependencycollector/system/indirect_system.h")),
|
2019-01-22 14:38:02 +01:00
|
|
|
SourceDependency(
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/system/indirect_system.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/system/indirect_system2.h"))))));
|
2018-11-12 19:27:51 +01:00
|
|
|
}
|
2019-01-21 17:37:16 +01:00
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, Clear)
|
|
|
|
{
|
|
|
|
using ClangBackEnd::IncludeSearchPathType;
|
2019-02-06 17:18:15 +01:00
|
|
|
ClangBackEnd::BuildDependencyCollector collector{filePathCache, generatedFiles, environment};
|
2019-01-21 17:37:16 +01:00
|
|
|
ClangBackEnd::ProjectPartContainer projectPart{
|
2019-03-13 15:09:30 +01:00
|
|
|
1,
|
2019-01-21 17:37:16 +01:00
|
|
|
{},
|
|
|
|
{},
|
2019-07-10 15:58:23 +02:00
|
|
|
{{toNativePath(TESTDATA_DIR "/builddependencycollector/system"),
|
2019-04-24 14:07:39 +02:00
|
|
|
1,
|
|
|
|
ClangBackEnd::IncludeSearchPathType::System}},
|
2019-01-21 17:37:16 +01:00
|
|
|
{
|
2019-07-10 15:58:23 +02:00
|
|
|
{toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
|
2019-04-24 14:07:39 +02:00
|
|
|
1,
|
|
|
|
ClangBackEnd::IncludeSearchPathType::User},
|
2019-07-10 15:58:23 +02:00
|
|
|
{toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
|
2019-04-24 14:07:39 +02:00
|
|
|
2,
|
|
|
|
ClangBackEnd::IncludeSearchPathType::User},
|
2019-01-21 17:37:16 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/header1.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/header2.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/missingfile.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/macros.h"),
|
|
|
|
},
|
2019-04-24 14:07:39 +02:00
|
|
|
{id(TESTDATA_DIR "/builddependencycollector/project/main4.cpp")},
|
2019-01-21 17:37:16 +01:00
|
|
|
Utils::Language::Cxx,
|
|
|
|
Utils::LanguageVersion::CXX11,
|
|
|
|
Utils::LanguageExtension::None};
|
|
|
|
collector.create(projectPart);
|
2019-04-24 14:07:39 +02:00
|
|
|
ClangBackEnd::ProjectPartContainer emptyProjectPart{
|
|
|
|
1,
|
|
|
|
{},
|
|
|
|
{},
|
2019-07-10 15:58:23 +02:00
|
|
|
{{toNativePath(TESTDATA_DIR "/builddependencycollector/system"),
|
2019-04-24 14:07:39 +02:00
|
|
|
1,
|
|
|
|
ClangBackEnd::IncludeSearchPathType::System}},
|
|
|
|
{
|
2019-07-10 15:58:23 +02:00
|
|
|
{toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
|
2019-04-24 14:07:39 +02:00
|
|
|
1,
|
|
|
|
ClangBackEnd::IncludeSearchPathType::User},
|
2019-07-10 15:58:23 +02:00
|
|
|
{toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
|
2019-04-24 14:07:39 +02:00
|
|
|
2,
|
|
|
|
ClangBackEnd::IncludeSearchPathType::User},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/header1.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/header2.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/missingfile.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/macros.h"),
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
Utils::Language::Cxx,
|
|
|
|
Utils::LanguageVersion::CXX11,
|
|
|
|
Utils::LanguageExtension::None};
|
2019-01-21 17:37:16 +01:00
|
|
|
|
2019-04-24 14:07:39 +02:00
|
|
|
auto buildDependency = collector.create(emptyProjectPart);
|
2019-01-21 17:37:16 +01:00
|
|
|
|
2019-02-25 19:07:19 +01:00
|
|
|
ASSERT_THAT(buildDependency.sources, IsEmpty());
|
2019-01-21 17:37:16 +01:00
|
|
|
}
|
2019-04-24 14:07:39 +02:00
|
|
|
|
|
|
|
TEST_F(BuildDependencyCollector, PreIncludes)
|
|
|
|
{
|
|
|
|
using ClangBackEnd::IncludeSearchPathType;
|
|
|
|
ClangBackEnd::BuildDependencyCollector collector{filePathCache, generatedFiles, environment};
|
|
|
|
ClangBackEnd::ProjectPartContainer projectPart{
|
|
|
|
1,
|
|
|
|
{},
|
|
|
|
{},
|
2019-07-10 15:58:23 +02:00
|
|
|
{{toNativePath(TESTDATA_DIR "/builddependencycollector/system"),
|
2019-04-24 14:07:39 +02:00
|
|
|
1,
|
|
|
|
ClangBackEnd::IncludeSearchPathType::System}},
|
|
|
|
{
|
2019-07-10 15:58:23 +02:00
|
|
|
{toNativePath(TESTDATA_DIR "/builddependencycollector/project"),
|
2019-04-24 14:07:39 +02:00
|
|
|
1,
|
|
|
|
ClangBackEnd::IncludeSearchPathType::User},
|
2019-07-10 15:58:23 +02:00
|
|
|
{toNativePath(TESTDATA_DIR "/builddependencycollector/external"),
|
2019-04-24 14:07:39 +02:00
|
|
|
2,
|
|
|
|
ClangBackEnd::IncludeSearchPathType::User},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/header1.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/header2.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/missingfile.h"),
|
|
|
|
id(TESTDATA_DIR "/builddependencycollector/project/macros.h"),
|
|
|
|
},
|
|
|
|
{id(TESTDATA_DIR "/builddependencycollector/project/main4.cpp")},
|
|
|
|
Utils::Language::Cxx,
|
|
|
|
Utils::LanguageVersion::CXX11,
|
|
|
|
Utils::LanguageExtension::None};
|
|
|
|
|
|
|
|
auto buildDependency = collector.create(projectPart);
|
|
|
|
|
|
|
|
ASSERT_THAT(buildDependency.sources,
|
|
|
|
Contains(HasSource(id(TESTDATA_DIR "/preincludes/system1.h"),
|
|
|
|
SourceType::TopSystemInclude)));
|
|
|
|
}
|
2018-11-12 19:27:51 +01:00
|
|
|
} // namespace
|