2017-08-02 16:00:55 +02:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
|
|
|
** Copyright (C) 2017 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.
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
2019-01-31 10:30:58 +01:00
|
|
|
#include "filesystem-utilities.h"
|
2019-03-13 15:09:30 +01:00
|
|
|
#include "googletest.h"
|
|
|
|
#include "mockbuilddependenciesstorage.h"
|
2017-10-26 13:23:27 +02:00
|
|
|
#include "mockclangpathwatcher.h"
|
2019-03-13 15:09:30 +01:00
|
|
|
#include "mockfilepathcaching.h"
|
2019-06-06 10:57:55 +02:00
|
|
|
#include "mockfilesystem.h"
|
2019-03-21 17:55:24 +01:00
|
|
|
#include "mockmodifiedtimechecker.h"
|
2019-02-22 16:44:40 +01:00
|
|
|
#include "mockprecompiledheaderstorage.h"
|
2019-03-13 15:09:30 +01:00
|
|
|
#include "mockprojectpartsstorage.h"
|
|
|
|
#include "mocksqlitetransactionbackend.h"
|
2017-08-02 16:00:55 +02:00
|
|
|
#include "mocksymbolscollector.h"
|
|
|
|
#include "mocksymbolstorage.h"
|
2019-04-24 14:07:39 +02:00
|
|
|
#include "testenvironment.h"
|
2017-08-02 16:00:55 +02:00
|
|
|
|
2018-02-08 17:49:02 +01:00
|
|
|
#include <filepathcaching.h>
|
|
|
|
#include <filestatuscache.h>
|
2019-07-10 14:03:38 +02:00
|
|
|
#include <processormanager.h>
|
2018-12-17 12:06:57 +01:00
|
|
|
#include <projectpartcontainer.h>
|
2018-02-08 17:49:02 +01:00
|
|
|
#include <refactoringdatabaseinitializer.h>
|
2019-07-10 14:03:38 +02:00
|
|
|
#include <sqliteexception.h>
|
2017-08-02 16:00:55 +02:00
|
|
|
#include <symbolindexer.h>
|
2018-08-28 12:08:37 +02:00
|
|
|
#include <symbolindexertaskqueue.h>
|
2018-09-11 17:02:45 +02:00
|
|
|
#include <taskscheduler.h>
|
2018-02-20 12:43:05 +01:00
|
|
|
#include <updateprojectpartsmessage.h>
|
2018-02-08 17:49:02 +01:00
|
|
|
|
2018-08-28 12:08:37 +02:00
|
|
|
#include <QCoreApplication>
|
2018-02-08 17:49:02 +01:00
|
|
|
#include <QDateTime>
|
|
|
|
|
|
|
|
#include <fstream>
|
2017-08-02 16:00:55 +02:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2018-02-06 19:03:14 +01:00
|
|
|
using ClangBackEnd::CompilerMacro;
|
2018-02-07 16:18:16 +01:00
|
|
|
using ClangBackEnd::FilePathId;
|
2018-01-22 14:21:01 +01:00
|
|
|
using ClangBackEnd::FilePathIds;
|
|
|
|
using ClangBackEnd::FilePathView;
|
2019-03-13 15:09:30 +01:00
|
|
|
using ClangBackEnd::FileStatuses;
|
|
|
|
using ClangBackEnd::ProcessorManager;
|
2018-12-17 12:06:57 +01:00
|
|
|
using ClangBackEnd::ProjectPartContainer;
|
|
|
|
using ClangBackEnd::ProjectPartContainers;
|
2019-03-13 15:09:30 +01:00
|
|
|
using ClangBackEnd::ProjectPartId;
|
|
|
|
using ClangBackEnd::ProjectPartIds;
|
|
|
|
using ClangBackEnd::SourceDependencies;
|
|
|
|
using ClangBackEnd::SourceLocationEntries;
|
|
|
|
using ClangBackEnd::SourceLocationEntry;
|
|
|
|
using ClangBackEnd::SourceLocationKind;
|
2017-08-02 16:00:55 +02:00
|
|
|
using ClangBackEnd::SymbolEntries;
|
|
|
|
using ClangBackEnd::SymbolEntry;
|
2018-08-28 12:08:37 +02:00
|
|
|
using ClangBackEnd::SymbolIndexerTask;
|
|
|
|
using ClangBackEnd::SymbolIndexerTaskQueue;
|
2018-03-22 17:46:43 +01:00
|
|
|
using ClangBackEnd::SymbolKind;
|
2019-03-13 15:09:30 +01:00
|
|
|
using ClangBackEnd::TaskScheduler;
|
2018-01-25 15:20:47 +01:00
|
|
|
using ClangBackEnd::UsedMacros;
|
2019-03-13 15:09:30 +01:00
|
|
|
using ClangBackEnd::V2::FileContainers;
|
|
|
|
using Utils::PathString;
|
2018-02-20 12:43:05 +01:00
|
|
|
using OptionalProjectPartArtefact = Utils::optional<ClangBackEnd::ProjectPartArtefact>;
|
2017-08-02 16:00:55 +02:00
|
|
|
|
2018-02-08 17:49:02 +01:00
|
|
|
struct Data
|
|
|
|
{
|
|
|
|
Sqlite::Database database{":memory:", Sqlite::JournalMode::Memory};
|
|
|
|
ClangBackEnd::RefactoringDatabaseInitializer<Sqlite::Database> databaseInitializer{database};
|
|
|
|
ClangBackEnd::FilePathCaching filePathCache{database};
|
|
|
|
};
|
|
|
|
|
2018-09-11 17:02:45 +02:00
|
|
|
class Manager final : public ProcessorManager<NiceMock<MockSymbolsCollector>>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
using Processor = NiceMock<MockSymbolsCollector>;
|
|
|
|
Manager(const ClangBackEnd::GeneratedFiles &generatedFiles)
|
|
|
|
: ProcessorManager(generatedFiles)
|
|
|
|
{}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
std::unique_ptr<NiceMock<MockSymbolsCollector>> createProcessor() const
|
|
|
|
{
|
|
|
|
return std::make_unique<NiceMock<MockSymbolsCollector>>();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-08-02 16:00:55 +02:00
|
|
|
class SymbolIndexer : public testing::Test
|
|
|
|
{
|
|
|
|
protected:
|
2017-12-27 13:19:21 +01:00
|
|
|
void SetUp()
|
|
|
|
{
|
|
|
|
ON_CALL(mockCollector, symbols()).WillByDefault(ReturnRef(symbolEntries));
|
|
|
|
ON_CALL(mockCollector, sourceLocations()).WillByDefault(ReturnRef(sourceLocations));
|
2018-01-22 14:21:01 +01:00
|
|
|
ON_CALL(mockCollector, sourceFiles()).WillByDefault(ReturnRef(sourceFileIds));
|
2018-01-25 15:20:47 +01:00
|
|
|
ON_CALL(mockCollector, usedMacros()).WillByDefault(ReturnRef(usedMacros));
|
2018-01-31 14:14:34 +01:00
|
|
|
ON_CALL(mockCollector, sourceDependencies()).WillByDefault(ReturnRef(sourceDependencies));
|
2019-03-13 15:09:30 +01:00
|
|
|
ON_CALL(mockProjectPartsStorage, fetchProjectPartArtefact(A<FilePathId>()))
|
|
|
|
.WillByDefault(Return(artefact));
|
2018-11-07 17:48:25 +01:00
|
|
|
ON_CALL(mockBuildDependenciesStorage, fetchLowestLastModifiedTime(A<FilePathId>())).WillByDefault(Return(-1));
|
2019-02-07 12:20:51 +01:00
|
|
|
ON_CALL(mockCollector, collectSymbols()).WillByDefault(Return(true));
|
2019-06-20 18:34:02 +02:00
|
|
|
ON_CALL(mockBuildDependenciesStorage, fetchDependentSourceIds(sourceFileIds))
|
2019-03-21 17:55:24 +01:00
|
|
|
.WillByDefault(Return(sourceFileIds));
|
2019-06-20 18:34:02 +02:00
|
|
|
ON_CALL(mockBuildDependenciesStorage, fetchDependentSourceIds(ElementsAre(sourceFileIds[0])))
|
2019-03-21 17:55:24 +01:00
|
|
|
.WillByDefault(Return(FilePathIds{sourceFileIds[0]}));
|
2019-06-20 18:34:02 +02:00
|
|
|
ON_CALL(mockBuildDependenciesStorage, fetchDependentSourceIds(ElementsAre(main1PathId)))
|
2019-03-21 17:55:24 +01:00
|
|
|
.WillByDefault(Return(FilePathIds{main1PathId}));
|
2018-08-28 12:08:37 +02:00
|
|
|
mockCollector.setIsUsed(false);
|
2018-09-03 14:38:01 +02:00
|
|
|
|
|
|
|
generatedFiles.update(unsaved);
|
2018-08-28 12:08:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TearDown()
|
|
|
|
{
|
|
|
|
syncTasks();
|
|
|
|
}
|
|
|
|
|
|
|
|
void syncTasks()
|
|
|
|
{
|
|
|
|
while (!indexerQueue.tasks().empty() || !indexerScheduler.futures().empty()) {
|
|
|
|
indexerScheduler.syncTasks();
|
|
|
|
QCoreApplication::processEvents();
|
|
|
|
}
|
2018-02-08 17:49:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void SetUpTestCase()
|
|
|
|
{
|
|
|
|
data = std::make_unique<Data>();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void TearDownTestCase()
|
|
|
|
{
|
|
|
|
data.reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
FilePathId filePathId(Utils::SmallStringView path) const
|
|
|
|
{
|
|
|
|
return filePathCache.filePathId(ClangBackEnd::FilePathView(path));
|
2017-12-27 13:19:21 +01:00
|
|
|
}
|
2017-08-02 16:00:55 +02:00
|
|
|
|
|
|
|
protected:
|
2018-02-08 17:49:02 +01:00
|
|
|
static std::unique_ptr<Data> data; // it can be non const because data holds no tested classes
|
2018-09-11 17:02:45 +02:00
|
|
|
using Scheduler = TaskScheduler<Manager, ClangBackEnd::SymbolIndexerTask::Callable>;
|
2018-02-08 17:49:02 +01:00
|
|
|
ClangBackEnd::FilePathCaching &filePathCache = data->filePathCache;
|
|
|
|
ClangBackEnd::FilePathId main1PathId{filePathId(TESTDATA_DIR "/symbolindexer_main1.cpp")};
|
|
|
|
ClangBackEnd::FilePathId main2PathId{filePathId(TESTDATA_DIR "/symbolindexer_main2.cpp")};
|
|
|
|
ClangBackEnd::FilePathId header2PathId{filePathId(TESTDATA_DIR "/symbolindexer_header1.h")};
|
|
|
|
ClangBackEnd::FilePathId header1PathId{filePathId(TESTDATA_DIR "/symbolindexer_header2.h")};
|
2018-11-12 19:27:51 +01:00
|
|
|
PathString generatedFileName = "BuildDependencyCollector_generated_file.h";
|
2018-11-06 19:02:00 +01:00
|
|
|
ClangBackEnd::FilePathId generatedFilePathId21;
|
2018-12-17 12:06:57 +01:00
|
|
|
ClangBackEnd::IncludeSearchPaths systemIncludeSearchPaths{
|
|
|
|
{"/includes", 1, ClangBackEnd::IncludeSearchPathType::BuiltIn},
|
|
|
|
{TESTDATA_DIR, 2, ClangBackEnd::IncludeSearchPathType::System},
|
|
|
|
{"/other/includes", 3, ClangBackEnd::IncludeSearchPathType::System}};
|
|
|
|
ClangBackEnd::IncludeSearchPaths projectIncludeSearchPaths{
|
|
|
|
{"/project/includes", 1, ClangBackEnd::IncludeSearchPathType::User},
|
|
|
|
{"/other/project/includes", 2, ClangBackEnd::IncludeSearchPathType::User}};
|
2019-03-13 15:09:30 +01:00
|
|
|
ProjectPartContainer projectPart1{1,
|
2018-12-17 12:06:57 +01:00
|
|
|
{"-Wno-pragma-once-outside-header"},
|
2018-11-21 20:11:07 +01:00
|
|
|
{{"BAR", "1", 1}, {"FOO", "1", 2}},
|
2018-12-17 12:06:57 +01:00
|
|
|
Utils::clone(systemIncludeSearchPaths),
|
|
|
|
Utils::clone(projectIncludeSearchPaths),
|
2018-01-22 14:21:01 +01:00
|
|
|
{header1PathId},
|
2018-12-17 12:06:57 +01:00
|
|
|
{main1PathId},
|
|
|
|
Utils::Language::Cxx,
|
|
|
|
Utils::LanguageVersion::CXX14,
|
|
|
|
Utils::LanguageExtension::None};
|
2019-03-13 15:09:30 +01:00
|
|
|
ProjectPartContainer projectPart2{2,
|
2018-12-17 12:06:57 +01:00
|
|
|
{"-Wno-pragma-once-outside-header"},
|
2018-11-21 20:11:07 +01:00
|
|
|
{{"BAR", "1", 1}, {"FOO", "0", 2}},
|
2018-12-17 12:06:57 +01:00
|
|
|
Utils::clone(systemIncludeSearchPaths),
|
|
|
|
Utils::clone(projectIncludeSearchPaths),
|
2018-01-22 14:21:01 +01:00
|
|
|
{header2PathId},
|
2018-12-17 12:06:57 +01:00
|
|
|
{main2PathId},
|
|
|
|
Utils::Language::Cxx,
|
|
|
|
Utils::LanguageVersion::CXX14,
|
|
|
|
Utils::LanguageExtension::None};
|
2019-03-13 15:09:30 +01:00
|
|
|
ProjectPartContainer projectPart3{3,
|
2018-12-17 12:06:57 +01:00
|
|
|
{"-Wno-pragma-once-outside-header"},
|
2018-11-21 20:11:07 +01:00
|
|
|
{{"BAR", "1", 1}, {"FOO", "1", 2}},
|
2018-12-17 12:06:57 +01:00
|
|
|
Utils::clone(systemIncludeSearchPaths),
|
|
|
|
Utils::clone(projectIncludeSearchPaths),
|
2018-02-08 17:49:02 +01:00
|
|
|
{header1PathId},
|
2018-12-17 12:06:57 +01:00
|
|
|
{main1PathId},
|
|
|
|
Utils::Language::Cxx,
|
|
|
|
Utils::LanguageVersion::CXX14,
|
|
|
|
Utils::LanguageExtension::None};
|
2017-08-17 12:44:52 +02:00
|
|
|
FileContainers unsaved{{{TESTDATA_DIR, "query_simplefunction.h"},
|
2019-08-20 14:45:01 +02:00
|
|
|
filePathId(TESTDATA_DIR "/query_simplefunction.h"),
|
2017-08-17 12:44:52 +02:00
|
|
|
"void f();",
|
|
|
|
{}}};
|
2018-03-22 17:46:43 +01:00
|
|
|
SymbolEntries symbolEntries{{1, {"function", "function", SymbolKind::Function}}};
|
2018-11-06 19:02:00 +01:00
|
|
|
SourceLocationEntries sourceLocations{{1, 1, {42, 23}, SourceLocationKind::Declaration}};
|
|
|
|
FilePathIds sourceFileIds{1, 23};
|
|
|
|
UsedMacros usedMacros{{"Foo", 1}};
|
2019-02-25 19:07:19 +01:00
|
|
|
FileStatuses fileStatus{{2, 3, 4}};
|
2018-11-06 19:02:00 +01:00
|
|
|
SourceDependencies sourceDependencies{{1, 2}, {1, 3}};
|
2018-12-17 12:06:57 +01:00
|
|
|
Utils::SmallString systemIncludeSearchPathsText{
|
|
|
|
R"([["/includes", 1, 2], [")" TESTDATA_DIR R"(" ,2 , 3], ["/other/includes", 3, 3]])"};
|
|
|
|
Utils::SmallString projectIncludeSearchPathsText{
|
|
|
|
R"([["/project/includes", 1, 1], ["/other/project/includes", 2, 1]])"};
|
|
|
|
ClangBackEnd::ProjectPartArtefact artefact{R"(["-DFOO"])",
|
|
|
|
R"([["FOO","1", 2],["BAR","1", 1]])",
|
|
|
|
systemIncludeSearchPathsText,
|
|
|
|
projectIncludeSearchPathsText,
|
2019-01-23 14:10:58 +01:00
|
|
|
74,
|
|
|
|
Utils::Language::Cxx,
|
|
|
|
Utils::LanguageVersion::CXX14,
|
|
|
|
Utils::LanguageExtension::None};
|
|
|
|
ClangBackEnd::ProjectPartArtefact emptyArtefact{"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
2019-03-13 15:09:30 +01:00
|
|
|
1,
|
2019-01-23 14:10:58 +01:00
|
|
|
Utils::Language::Cxx,
|
|
|
|
Utils::LanguageVersion::CXX14,
|
|
|
|
Utils::LanguageExtension::None};
|
2019-03-21 17:55:24 +01:00
|
|
|
ClangBackEnd::SourceTimeStamps dependentSourceTimeStamps1{{1, 32}};
|
|
|
|
ClangBackEnd::SourceTimeStamps dependentSourceTimeStamps2{{2, 35}};
|
|
|
|
ClangBackEnd::FileStatuses fileStatuses1{{1, 0, 32}};
|
|
|
|
ClangBackEnd::FileStatuses fileStatuses2{{2, 0, 35}};
|
2018-09-04 14:24:42 +02:00
|
|
|
Utils::optional<ClangBackEnd::ProjectPartArtefact > nullArtefact;
|
2019-04-10 19:24:36 +02:00
|
|
|
ClangBackEnd::PchPaths pchPaths{"/project/pch", "/system/pch"};
|
2018-01-22 14:21:01 +01:00
|
|
|
NiceMock<MockSqliteTransactionBackend> mockSqliteTransactionBackend;
|
2018-10-11 18:09:55 +02:00
|
|
|
NiceMock<MockSymbolStorage> mockSymbolStorage;
|
2018-11-07 17:48:25 +01:00
|
|
|
NiceMock<MockBuildDependenciesStorage> mockBuildDependenciesStorage;
|
2019-02-22 16:44:40 +01:00
|
|
|
NiceMock<MockPrecompiledHeaderStorage> mockPrecompiledHeaderStorage;
|
2019-03-13 15:09:30 +01:00
|
|
|
NiceMock<MockProjectPartsStorage> mockProjectPartsStorage;
|
2017-10-26 13:23:27 +02:00
|
|
|
NiceMock<MockClangPathWatcher> mockPathWatcher;
|
2019-06-06 10:57:55 +02:00
|
|
|
NiceMock<MockFileSystem> mockFileSystem;
|
|
|
|
ClangBackEnd::FileStatusCache fileStatusCache{mockFileSystem};
|
2018-09-03 14:38:01 +02:00
|
|
|
ClangBackEnd::GeneratedFiles generatedFiles;
|
2018-09-11 17:02:45 +02:00
|
|
|
Manager collectorManger{generatedFiles};
|
2018-09-27 17:52:44 +02:00
|
|
|
NiceMock<MockFunction<void(int, int)>> mockSetProgressCallback;
|
|
|
|
ClangBackEnd::ProgressCounter progressCounter{mockSetProgressCallback.AsStdFunction()};
|
2019-03-21 17:55:24 +01:00
|
|
|
NiceMock<MockSourceTimeStampsModifiedTimeChecker> mockModifiedTimeChecker;
|
2019-04-24 14:07:39 +02:00
|
|
|
TestEnvironment testEnvironment;
|
2018-08-28 12:08:37 +02:00
|
|
|
ClangBackEnd::SymbolIndexer indexer{indexerQueue,
|
2018-10-11 18:09:55 +02:00
|
|
|
mockSymbolStorage,
|
2018-11-07 17:48:25 +01:00
|
|
|
mockBuildDependenciesStorage,
|
2019-02-22 16:44:40 +01:00
|
|
|
mockPrecompiledHeaderStorage,
|
2018-02-08 17:49:02 +01:00
|
|
|
mockPathWatcher,
|
|
|
|
filePathCache,
|
|
|
|
fileStatusCache,
|
2019-03-13 15:09:30 +01:00
|
|
|
mockSqliteTransactionBackend,
|
2019-03-21 17:55:24 +01:00
|
|
|
mockProjectPartsStorage,
|
2019-04-24 14:07:39 +02:00
|
|
|
mockModifiedTimeChecker,
|
|
|
|
testEnvironment};
|
2021-03-24 18:10:55 +01:00
|
|
|
NiceMock<SqliteDatabaseMock> mockSqliteDatabase;
|
2019-05-20 16:46:22 +02:00
|
|
|
SymbolIndexerTaskQueue indexerQueue{indexerScheduler, progressCounter, mockSqliteDatabase};
|
2019-01-24 15:01:30 +01:00
|
|
|
Scheduler indexerScheduler{collectorManger,
|
|
|
|
indexerQueue,
|
|
|
|
progressCounter,
|
|
|
|
1,
|
|
|
|
ClangBackEnd::CallDoInMainThreadAfterFinished::Yes};
|
2018-09-11 17:02:45 +02:00
|
|
|
MockSymbolsCollector &mockCollector{static_cast<MockSymbolsCollector&>(collectorManger.unusedProcessor())};
|
2017-08-02 16:00:55 +02:00
|
|
|
};
|
|
|
|
|
2018-02-08 17:49:02 +01:00
|
|
|
std::unique_ptr<Data> SymbolIndexer::data;
|
|
|
|
|
2017-08-02 16:00:55 +02:00
|
|
|
TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesInCollector)
|
|
|
|
{
|
2018-12-17 12:06:57 +01:00
|
|
|
EXPECT_CALL(mockCollector,
|
|
|
|
setFile(main1PathId,
|
|
|
|
ElementsAre("clang++",
|
2019-02-28 19:22:22 +01:00
|
|
|
"-w",
|
2018-12-17 12:06:57 +01:00
|
|
|
"-Wno-pragma-once-outside-header",
|
2019-02-13 13:37:24 +01:00
|
|
|
"-DNOMINMAX",
|
2018-12-17 12:06:57 +01:00
|
|
|
"-x",
|
2019-01-30 13:59:30 +01:00
|
|
|
"c++",
|
2018-12-17 12:06:57 +01:00
|
|
|
"-std=c++14",
|
|
|
|
"-nostdinc",
|
2019-01-30 09:07:45 +01:00
|
|
|
"-nostdinc++",
|
2019-01-23 18:54:48 +01:00
|
|
|
"-DBAR=1",
|
|
|
|
"-DFOO=1",
|
2019-04-24 14:07:39 +02:00
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR "/preincludes"),
|
2019-04-07 15:57:42 +02:00
|
|
|
"-I",
|
2019-03-13 15:09:30 +01:00
|
|
|
toNativePath("/project/includes"),
|
2018-12-17 12:06:57 +01:00
|
|
|
"-I",
|
2019-03-13 15:09:30 +01:00
|
|
|
toNativePath("/other/project/includes"),
|
2018-12-17 12:06:57 +01:00
|
|
|
"-isystem",
|
2019-03-13 15:09:30 +01:00
|
|
|
toNativePath(TESTDATA_DIR),
|
2018-12-17 12:06:57 +01:00
|
|
|
"-isystem",
|
2019-03-13 15:09:30 +01:00
|
|
|
toNativePath("/other/includes"),
|
2018-12-17 12:06:57 +01:00
|
|
|
"-isystem",
|
2019-03-13 15:09:30 +01:00
|
|
|
toNativePath("/includes"))));
|
2017-08-02 16:00:55 +02:00
|
|
|
|
2018-09-03 14:38:01 +02:00
|
|
|
indexer.updateProjectParts({projectPart1});
|
2017-08-02 16:00:55 +02:00
|
|
|
}
|
|
|
|
|
2018-02-20 12:43:05 +01:00
|
|
|
TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesWithPrecompiledHeaderInCollector)
|
|
|
|
{
|
2019-04-10 19:24:36 +02:00
|
|
|
ON_CALL(mockPrecompiledHeaderStorage, fetchPrecompiledHeaders(Eq(projectPart1.projectPartId)))
|
|
|
|
.WillByDefault(Return(pchPaths));
|
2018-02-20 12:43:05 +01:00
|
|
|
|
2018-12-17 12:06:57 +01:00
|
|
|
EXPECT_CALL(mockCollector,
|
|
|
|
setFile(main1PathId,
|
|
|
|
ElementsAre("clang++",
|
2019-02-28 19:22:22 +01:00
|
|
|
"-w",
|
2018-12-17 12:06:57 +01:00
|
|
|
"-Wno-pragma-once-outside-header",
|
2019-02-13 13:37:24 +01:00
|
|
|
"-DNOMINMAX",
|
2018-12-17 12:06:57 +01:00
|
|
|
"-x",
|
2019-01-30 13:59:30 +01:00
|
|
|
"c++",
|
2018-12-17 12:06:57 +01:00
|
|
|
"-std=c++14",
|
|
|
|
"-nostdinc",
|
2019-01-30 09:07:45 +01:00
|
|
|
"-nostdinc++",
|
2019-01-23 18:54:48 +01:00
|
|
|
"-DBAR=1",
|
|
|
|
"-DFOO=1",
|
2019-04-24 14:07:39 +02:00
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR "/preincludes"),
|
2019-04-07 15:57:42 +02:00
|
|
|
"-I",
|
2019-03-13 15:09:30 +01:00
|
|
|
toNativePath("/project/includes"),
|
2018-12-17 12:06:57 +01:00
|
|
|
"-I",
|
2019-03-13 15:09:30 +01:00
|
|
|
toNativePath("/other/project/includes"),
|
2018-12-17 12:06:57 +01:00
|
|
|
"-isystem",
|
2019-03-13 15:09:30 +01:00
|
|
|
toNativePath(TESTDATA_DIR),
|
2018-12-17 12:06:57 +01:00
|
|
|
"-isystem",
|
2019-03-13 15:09:30 +01:00
|
|
|
toNativePath("/other/includes"),
|
2018-12-17 12:06:57 +01:00
|
|
|
"-isystem",
|
2019-03-13 15:09:30 +01:00
|
|
|
toNativePath("/includes"),
|
2018-12-17 12:06:57 +01:00
|
|
|
"-Xclang",
|
|
|
|
"-include-pch",
|
|
|
|
"-Xclang",
|
2019-04-10 19:24:36 +02:00
|
|
|
toNativePath("/project/pch"))));
|
2018-02-20 12:43:05 +01:00
|
|
|
|
2018-09-03 14:38:01 +02:00
|
|
|
indexer.updateProjectParts({projectPart1});
|
2018-02-20 12:43:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesWithoutPrecompiledHeaderInCollector)
|
|
|
|
{
|
2019-03-13 15:09:30 +01:00
|
|
|
ON_CALL(mockProjectPartsStorage, fetchProjectPartArtefact(TypedEq<ProjectPartId>(1)))
|
|
|
|
.WillByDefault(Return(emptyArtefact));
|
2018-02-20 12:43:05 +01:00
|
|
|
|
2018-12-17 12:06:57 +01:00
|
|
|
EXPECT_CALL(mockCollector,
|
|
|
|
setFile(main1PathId,
|
|
|
|
ElementsAre("clang++",
|
2019-02-28 19:22:22 +01:00
|
|
|
"-w",
|
2018-12-17 12:06:57 +01:00
|
|
|
"-Wno-pragma-once-outside-header",
|
2019-02-13 13:37:24 +01:00
|
|
|
"-DNOMINMAX",
|
2018-12-17 12:06:57 +01:00
|
|
|
"-x",
|
2019-01-30 13:59:30 +01:00
|
|
|
"c++",
|
2018-12-17 12:06:57 +01:00
|
|
|
"-std=c++14",
|
|
|
|
"-nostdinc",
|
2019-01-30 09:07:45 +01:00
|
|
|
"-nostdinc++",
|
2019-01-23 18:54:48 +01:00
|
|
|
"-DBAR=1",
|
|
|
|
"-DFOO=1",
|
2019-04-24 14:07:39 +02:00
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR "/preincludes"),
|
2019-04-07 15:57:42 +02:00
|
|
|
"-I",
|
2019-03-13 15:09:30 +01:00
|
|
|
toNativePath("/project/includes"),
|
2018-12-17 12:06:57 +01:00
|
|
|
"-I",
|
2019-03-13 15:09:30 +01:00
|
|
|
toNativePath("/other/project/includes"),
|
2018-12-17 12:06:57 +01:00
|
|
|
"-isystem",
|
2019-03-13 15:09:30 +01:00
|
|
|
toNativePath(TESTDATA_DIR),
|
2018-12-17 12:06:57 +01:00
|
|
|
"-isystem",
|
2019-03-13 15:09:30 +01:00
|
|
|
toNativePath("/other/includes"),
|
2018-12-17 12:06:57 +01:00
|
|
|
"-isystem",
|
2019-03-13 15:09:30 +01:00
|
|
|
toNativePath("/includes"))));
|
2018-02-20 12:43:05 +01:00
|
|
|
|
2018-09-03 14:38:01 +02:00
|
|
|
indexer.updateProjectParts({projectPart1});
|
2018-02-20 12:43:05 +01:00
|
|
|
}
|
|
|
|
|
2017-12-13 12:04:19 +01:00
|
|
|
TEST_F(SymbolIndexer, UpdateProjectPartsCallsClearInCollector)
|
|
|
|
{
|
2018-01-22 14:21:01 +01:00
|
|
|
EXPECT_CALL(mockCollector, clear()).Times(2);
|
2017-12-13 12:04:19 +01:00
|
|
|
|
2018-09-03 14:38:01 +02:00
|
|
|
indexer.updateProjectParts({projectPart1, projectPart2});
|
2017-12-13 12:04:19 +01:00
|
|
|
}
|
|
|
|
|
2017-08-02 16:00:55 +02:00
|
|
|
TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesInCollectorForEveryProjectPart)
|
|
|
|
{
|
2018-09-03 14:38:01 +02:00
|
|
|
EXPECT_CALL(mockCollector, setFile(_, _)).Times(2);
|
2017-08-02 16:00:55 +02:00
|
|
|
|
2018-09-03 14:38:01 +02:00
|
|
|
indexer.updateProjectParts({projectPart1, projectPart2});
|
2017-08-02 16:00:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SymbolIndexer, UpdateProjectPartsDoesNotCallAddFilesInCollectorForEmptyEveryProjectParts)
|
|
|
|
{
|
2018-09-03 14:38:01 +02:00
|
|
|
EXPECT_CALL(mockCollector, setFile(_, _))
|
2017-08-02 16:00:55 +02:00
|
|
|
.Times(0);
|
|
|
|
|
2018-09-03 14:38:01 +02:00
|
|
|
indexer.updateProjectParts({});
|
2017-08-02 16:00:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SymbolIndexer, UpdateProjectPartsCallscollectSymbolsInCollector)
|
|
|
|
{
|
2019-04-24 14:07:39 +02:00
|
|
|
EXPECT_CALL(mockCollector, collectSymbols()).Times(2);
|
2017-08-02 16:00:55 +02:00
|
|
|
|
2018-09-03 14:38:01 +02:00
|
|
|
indexer.updateProjectParts({projectPart1, projectPart2});
|
2017-08-02 16:00:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SymbolIndexer, UpdateProjectPartsCallsSymbolsInCollector)
|
|
|
|
{
|
2018-01-22 14:21:01 +01:00
|
|
|
EXPECT_CALL(mockCollector, symbols()).Times(2);
|
2017-08-02 16:00:55 +02:00
|
|
|
|
2018-09-03 14:38:01 +02:00
|
|
|
indexer.updateProjectParts({projectPart1, projectPart2});
|
2017-08-02 16:00:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SymbolIndexer, UpdateProjectPartsCallsSourceLocationsInCollector)
|
|
|
|
{
|
2018-01-22 14:21:01 +01:00
|
|
|
EXPECT_CALL(mockCollector, sourceLocations()).Times(2);
|
2017-08-02 16:00:55 +02:00
|
|
|
|
2018-09-03 14:38:01 +02:00
|
|
|
indexer.updateProjectParts({projectPart1, projectPart2});
|
2017-08-17 12:44:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddUnsavedFilesInCollector)
|
|
|
|
{
|
2018-09-03 14:38:01 +02:00
|
|
|
EXPECT_CALL(mockCollector, setUnsavedFiles(unsaved)).Times(2);
|
2017-08-17 12:44:52 +02:00
|
|
|
|
2018-09-03 14:38:01 +02:00
|
|
|
indexer.updateProjectParts({projectPart1, projectPart2});
|
2017-08-02 16:00:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddSymbolsAndSourceLocationsInStorage)
|
|
|
|
{
|
2018-10-11 18:09:55 +02:00
|
|
|
EXPECT_CALL(mockSymbolStorage, addSymbolsAndSourceLocations(symbolEntries, sourceLocations)).Times(2);
|
2017-08-02 16:00:55 +02:00
|
|
|
|
2018-09-03 14:38:01 +02:00
|
|
|
indexer.updateProjectParts({projectPart1, projectPart2});
|
2018-01-22 14:21:01 +01:00
|
|
|
}
|
|
|
|
|
2019-03-13 15:09:30 +01:00
|
|
|
TEST_F(SymbolIndexer, UpdateProjectPartsCallsInOrder)
|
2017-08-02 16:00:55 +02:00
|
|
|
{
|
2017-12-13 12:04:19 +01:00
|
|
|
InSequence s;
|
|
|
|
|
2019-04-10 19:24:36 +02:00
|
|
|
EXPECT_CALL(mockPrecompiledHeaderStorage, fetchPrecompiledHeaders(Eq(projectPart1.projectPartId)));
|
2018-12-17 12:06:57 +01:00
|
|
|
EXPECT_CALL(mockCollector,
|
|
|
|
setFile(main1PathId,
|
|
|
|
ElementsAre("clang++",
|
2019-02-28 19:22:22 +01:00
|
|
|
"-w",
|
2018-12-17 12:06:57 +01:00
|
|
|
"-Wno-pragma-once-outside-header",
|
2019-02-13 13:37:24 +01:00
|
|
|
"-DNOMINMAX",
|
2018-12-17 12:06:57 +01:00
|
|
|
"-x",
|
2019-01-30 13:59:30 +01:00
|
|
|
"c++",
|
2018-12-17 12:06:57 +01:00
|
|
|
"-std=c++14",
|
|
|
|
"-nostdinc",
|
2019-01-30 09:07:45 +01:00
|
|
|
"-nostdinc++",
|
2019-01-23 18:54:48 +01:00
|
|
|
"-DBAR=1",
|
|
|
|
"-DFOO=1",
|
2019-04-24 14:07:39 +02:00
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR "/preincludes"),
|
2019-04-07 15:57:42 +02:00
|
|
|
"-I",
|
2019-03-13 15:09:30 +01:00
|
|
|
toNativePath("/project/includes"),
|
2018-12-17 12:06:57 +01:00
|
|
|
"-I",
|
2019-03-13 15:09:30 +01:00
|
|
|
toNativePath("/other/project/includes"),
|
2018-12-17 12:06:57 +01:00
|
|
|
"-isystem",
|
2019-03-13 15:09:30 +01:00
|
|
|
toNativePath(TESTDATA_DIR),
|
2018-12-17 12:06:57 +01:00
|
|
|
"-isystem",
|
2019-03-13 15:09:30 +01:00
|
|
|
toNativePath("/other/includes"),
|
2018-12-17 12:06:57 +01:00
|
|
|
"-isystem",
|
2019-03-13 15:09:30 +01:00
|
|
|
toNativePath("/includes"))));
|
2017-08-02 16:00:55 +02:00
|
|
|
EXPECT_CALL(mockCollector, collectSymbols());
|
2018-01-22 14:21:01 +01:00
|
|
|
EXPECT_CALL(mockSqliteTransactionBackend, immediateBegin());
|
2018-10-11 18:09:55 +02:00
|
|
|
EXPECT_CALL(mockSymbolStorage, addSymbolsAndSourceLocations(symbolEntries, sourceLocations));
|
2018-01-22 14:21:01 +01:00
|
|
|
EXPECT_CALL(mockSqliteTransactionBackend, commit());
|
2017-08-02 16:00:55 +02:00
|
|
|
|
2018-09-03 14:38:01 +02:00
|
|
|
indexer.updateProjectParts({projectPart1});
|
2017-08-02 16:00:55 +02:00
|
|
|
}
|
|
|
|
|
2019-04-10 19:24:36 +02:00
|
|
|
TEST_F(SymbolIndexer, UpdateProjectPartsCallsGetsProjectAndSystemPchPathsAndHasNoError)
|
2019-02-07 12:20:51 +01:00
|
|
|
{
|
|
|
|
InSequence s;
|
|
|
|
|
2019-04-10 19:24:36 +02:00
|
|
|
EXPECT_CALL(mockPrecompiledHeaderStorage, fetchPrecompiledHeaders(Eq(projectPart1.projectPartId)))
|
|
|
|
.WillOnce(Return(ClangBackEnd::PchPaths{"/project/pch", "/system/pch"}));
|
|
|
|
EXPECT_CALL(mockCollector,
|
|
|
|
setFile(main1PathId,
|
|
|
|
ElementsAre("clang++",
|
|
|
|
"-w",
|
|
|
|
"-Wno-pragma-once-outside-header",
|
|
|
|
"-DNOMINMAX",
|
|
|
|
"-x",
|
|
|
|
"c++",
|
|
|
|
"-std=c++14",
|
|
|
|
"-nostdinc",
|
|
|
|
"-nostdinc++",
|
|
|
|
"-DBAR=1",
|
|
|
|
"-DFOO=1",
|
2019-04-24 14:07:39 +02:00
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR "/preincludes"),
|
2019-04-10 19:24:36 +02:00
|
|
|
"-I",
|
|
|
|
toNativePath("/project/includes"),
|
|
|
|
"-I",
|
|
|
|
toNativePath("/other/project/includes"),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath("/other/includes"),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath("/includes"),
|
|
|
|
"-Xclang",
|
|
|
|
"-include-pch",
|
|
|
|
"-Xclang",
|
|
|
|
toNativePath("/project/pch"))));
|
|
|
|
EXPECT_CALL(mockCollector, collectSymbols()).WillOnce(Return(true));
|
|
|
|
EXPECT_CALL(mockSymbolStorage, addSymbolsAndSourceLocations(symbolEntries, sourceLocations));
|
|
|
|
EXPECT_CALL(mockCollector, collectSymbols()).Times(0);
|
|
|
|
|
|
|
|
indexer.updateProjectParts({projectPart1});
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SymbolIndexer, UpdateProjectPartsCallsGetsProjectAndSystemPchPathsAndHasErrorWithProjectPch)
|
|
|
|
{
|
|
|
|
InSequence s;
|
|
|
|
|
|
|
|
EXPECT_CALL(mockPrecompiledHeaderStorage, fetchPrecompiledHeaders(Eq(projectPart1.projectPartId)))
|
|
|
|
.WillOnce(Return(ClangBackEnd::PchPaths{"/project/pch", "/system/pch"}));
|
|
|
|
EXPECT_CALL(mockCollector,
|
|
|
|
setFile(main1PathId,
|
|
|
|
ElementsAre("clang++",
|
|
|
|
"-w",
|
|
|
|
"-Wno-pragma-once-outside-header",
|
|
|
|
"-DNOMINMAX",
|
|
|
|
"-x",
|
|
|
|
"c++",
|
|
|
|
"-std=c++14",
|
|
|
|
"-nostdinc",
|
|
|
|
"-nostdinc++",
|
|
|
|
"-DBAR=1",
|
|
|
|
"-DFOO=1",
|
2019-04-24 14:07:39 +02:00
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR "/preincludes"),
|
2019-04-10 19:24:36 +02:00
|
|
|
"-I",
|
|
|
|
toNativePath("/project/includes"),
|
|
|
|
"-I",
|
|
|
|
toNativePath("/other/project/includes"),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath("/other/includes"),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath("/includes"),
|
|
|
|
"-Xclang",
|
|
|
|
"-include-pch",
|
|
|
|
"-Xclang",
|
|
|
|
toNativePath("/project/pch"))));
|
|
|
|
EXPECT_CALL(mockCollector, collectSymbols()).WillOnce(Return(false));
|
|
|
|
EXPECT_CALL(mockSymbolStorage, addSymbolsAndSourceLocations(symbolEntries, sourceLocations)).Times(0);
|
|
|
|
EXPECT_CALL(mockCollector,
|
|
|
|
setFile(main1PathId,
|
|
|
|
ElementsAre("clang++",
|
|
|
|
"-w",
|
|
|
|
"-Wno-pragma-once-outside-header",
|
|
|
|
"-DNOMINMAX",
|
|
|
|
"-x",
|
|
|
|
"c++",
|
|
|
|
"-std=c++14",
|
|
|
|
"-nostdinc",
|
|
|
|
"-nostdinc++",
|
|
|
|
"-DBAR=1",
|
|
|
|
"-DFOO=1",
|
2019-04-24 14:07:39 +02:00
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR "/preincludes"),
|
2019-04-10 19:24:36 +02:00
|
|
|
"-I",
|
|
|
|
toNativePath("/project/includes"),
|
|
|
|
"-I",
|
|
|
|
toNativePath("/other/project/includes"),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath("/other/includes"),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath("/includes"),
|
|
|
|
"-Xclang",
|
|
|
|
"-include-pch",
|
|
|
|
"-Xclang",
|
|
|
|
toNativePath("/system/pch"))));
|
|
|
|
EXPECT_CALL(mockCollector, collectSymbols()).WillOnce(Return(true));
|
|
|
|
EXPECT_CALL(mockSymbolStorage, addSymbolsAndSourceLocations(symbolEntries, sourceLocations));
|
|
|
|
EXPECT_CALL(mockCollector, collectSymbols()).Times(0);
|
|
|
|
|
|
|
|
indexer.updateProjectParts({projectPart1});
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SymbolIndexer,
|
|
|
|
UpdateProjectPartsCallsGetsProjectAndSystemPchPathsAndHasErrorWithProjectAndSystemPch)
|
|
|
|
{
|
|
|
|
InSequence s;
|
|
|
|
|
|
|
|
EXPECT_CALL(mockPrecompiledHeaderStorage, fetchPrecompiledHeaders(Eq(projectPart1.projectPartId)))
|
|
|
|
.WillOnce(Return(ClangBackEnd::PchPaths{"/project/pch", "/system/pch"}));
|
|
|
|
EXPECT_CALL(mockCollector,
|
|
|
|
setFile(main1PathId,
|
|
|
|
ElementsAre("clang++",
|
|
|
|
"-w",
|
|
|
|
"-Wno-pragma-once-outside-header",
|
|
|
|
"-DNOMINMAX",
|
|
|
|
"-x",
|
|
|
|
"c++",
|
|
|
|
"-std=c++14",
|
|
|
|
"-nostdinc",
|
|
|
|
"-nostdinc++",
|
|
|
|
"-DBAR=1",
|
|
|
|
"-DFOO=1",
|
2019-04-24 14:07:39 +02:00
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR "/preincludes"),
|
2019-04-10 19:24:36 +02:00
|
|
|
"-I",
|
|
|
|
toNativePath("/project/includes"),
|
|
|
|
"-I",
|
|
|
|
toNativePath("/other/project/includes"),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath("/other/includes"),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath("/includes"),
|
|
|
|
"-Xclang",
|
|
|
|
"-include-pch",
|
|
|
|
"-Xclang",
|
|
|
|
toNativePath("/project/pch"))));
|
|
|
|
EXPECT_CALL(mockCollector, collectSymbols()).WillOnce(Return(false));
|
|
|
|
EXPECT_CALL(mockSymbolStorage, addSymbolsAndSourceLocations(symbolEntries, sourceLocations)).Times(0);
|
|
|
|
EXPECT_CALL(mockCollector,
|
|
|
|
setFile(main1PathId,
|
|
|
|
ElementsAre("clang++",
|
|
|
|
"-w",
|
|
|
|
"-Wno-pragma-once-outside-header",
|
|
|
|
"-DNOMINMAX",
|
|
|
|
"-x",
|
|
|
|
"c++",
|
|
|
|
"-std=c++14",
|
|
|
|
"-nostdinc",
|
|
|
|
"-nostdinc++",
|
|
|
|
"-DBAR=1",
|
|
|
|
"-DFOO=1",
|
2019-04-24 14:07:39 +02:00
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR "/preincludes"),
|
2019-04-10 19:24:36 +02:00
|
|
|
"-I",
|
|
|
|
toNativePath("/project/includes"),
|
|
|
|
"-I",
|
|
|
|
toNativePath("/other/project/includes"),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath("/other/includes"),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath("/includes"),
|
|
|
|
"-Xclang",
|
|
|
|
"-include-pch",
|
|
|
|
"-Xclang",
|
|
|
|
toNativePath("/system/pch"))));
|
|
|
|
EXPECT_CALL(mockCollector, collectSymbols()).WillOnce(Return(false));
|
|
|
|
EXPECT_CALL(mockSymbolStorage, addSymbolsAndSourceLocations(symbolEntries, sourceLocations)).Times(0);
|
|
|
|
EXPECT_CALL(mockCollector,
|
|
|
|
setFile(main1PathId,
|
|
|
|
ElementsAre("clang++",
|
|
|
|
"-w",
|
|
|
|
"-Wno-pragma-once-outside-header",
|
|
|
|
"-DNOMINMAX",
|
|
|
|
"-x",
|
|
|
|
"c++",
|
|
|
|
"-std=c++14",
|
|
|
|
"-nostdinc",
|
|
|
|
"-nostdinc++",
|
|
|
|
"-DBAR=1",
|
|
|
|
"-DFOO=1",
|
2019-04-24 14:07:39 +02:00
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR "/preincludes"),
|
2019-04-10 19:24:36 +02:00
|
|
|
"-I",
|
|
|
|
toNativePath("/project/includes"),
|
|
|
|
"-I",
|
|
|
|
toNativePath("/other/project/includes"),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath("/other/includes"),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath("/includes"))));
|
|
|
|
EXPECT_CALL(mockCollector, collectSymbols()).WillOnce(Return(true));
|
|
|
|
EXPECT_CALL(mockSymbolStorage, addSymbolsAndSourceLocations(symbolEntries, sourceLocations));
|
|
|
|
|
|
|
|
indexer.updateProjectParts({projectPart1});
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SymbolIndexer, UpdateProjectPartsCallsGetsProjectAndSystemPchPathsAndHasOnlyError)
|
|
|
|
{
|
|
|
|
InSequence s;
|
|
|
|
|
|
|
|
EXPECT_CALL(mockPrecompiledHeaderStorage, fetchPrecompiledHeaders(Eq(projectPart1.projectPartId)))
|
|
|
|
.WillOnce(Return(ClangBackEnd::PchPaths{"/project/pch", "/system/pch"}));
|
|
|
|
EXPECT_CALL(mockCollector,
|
|
|
|
setFile(main1PathId,
|
|
|
|
ElementsAre("clang++",
|
|
|
|
"-w",
|
|
|
|
"-Wno-pragma-once-outside-header",
|
|
|
|
"-DNOMINMAX",
|
|
|
|
"-x",
|
|
|
|
"c++",
|
|
|
|
"-std=c++14",
|
|
|
|
"-nostdinc",
|
|
|
|
"-nostdinc++",
|
|
|
|
"-DBAR=1",
|
|
|
|
"-DFOO=1",
|
2019-04-24 14:07:39 +02:00
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR "/preincludes"),
|
2019-04-10 19:24:36 +02:00
|
|
|
"-I",
|
|
|
|
toNativePath("/project/includes"),
|
|
|
|
"-I",
|
|
|
|
toNativePath("/other/project/includes"),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath("/other/includes"),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath("/includes"),
|
|
|
|
"-Xclang",
|
|
|
|
"-include-pch",
|
|
|
|
"-Xclang",
|
|
|
|
toNativePath("/project/pch"))));
|
|
|
|
EXPECT_CALL(mockCollector, collectSymbols()).WillOnce(Return(false));
|
|
|
|
EXPECT_CALL(mockSymbolStorage, addSymbolsAndSourceLocations(symbolEntries, sourceLocations)).Times(0);
|
|
|
|
EXPECT_CALL(mockCollector,
|
|
|
|
setFile(main1PathId,
|
|
|
|
ElementsAre("clang++",
|
|
|
|
"-w",
|
|
|
|
"-Wno-pragma-once-outside-header",
|
|
|
|
"-DNOMINMAX",
|
|
|
|
"-x",
|
|
|
|
"c++",
|
|
|
|
"-std=c++14",
|
|
|
|
"-nostdinc",
|
|
|
|
"-nostdinc++",
|
|
|
|
"-DBAR=1",
|
|
|
|
"-DFOO=1",
|
2019-04-24 14:07:39 +02:00
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR "/preincludes"),
|
2019-04-10 19:24:36 +02:00
|
|
|
"-I",
|
|
|
|
toNativePath("/project/includes"),
|
|
|
|
"-I",
|
|
|
|
toNativePath("/other/project/includes"),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath("/other/includes"),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath("/includes"),
|
|
|
|
"-Xclang",
|
|
|
|
"-include-pch",
|
|
|
|
"-Xclang",
|
|
|
|
toNativePath("/system/pch"))));
|
|
|
|
EXPECT_CALL(mockCollector, collectSymbols()).WillOnce(Return(false));
|
|
|
|
EXPECT_CALL(mockSymbolStorage, addSymbolsAndSourceLocations(symbolEntries, sourceLocations)).Times(0);
|
|
|
|
EXPECT_CALL(mockCollector,
|
|
|
|
setFile(main1PathId,
|
|
|
|
ElementsAre("clang++",
|
|
|
|
"-w",
|
|
|
|
"-Wno-pragma-once-outside-header",
|
|
|
|
"-DNOMINMAX",
|
|
|
|
"-x",
|
|
|
|
"c++",
|
|
|
|
"-std=c++14",
|
|
|
|
"-nostdinc",
|
|
|
|
"-nostdinc++",
|
|
|
|
"-DBAR=1",
|
|
|
|
"-DFOO=1",
|
2019-04-24 14:07:39 +02:00
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR "/preincludes"),
|
2019-04-10 19:24:36 +02:00
|
|
|
"-I",
|
|
|
|
toNativePath("/project/includes"),
|
|
|
|
"-I",
|
|
|
|
toNativePath("/other/project/includes"),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath("/other/includes"),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath("/includes"))));
|
|
|
|
EXPECT_CALL(mockCollector, collectSymbols()).WillOnce(Return(false));
|
|
|
|
EXPECT_CALL(mockSymbolStorage, addSymbolsAndSourceLocations(symbolEntries, sourceLocations)).Times(0);
|
|
|
|
|
|
|
|
indexer.updateProjectParts({projectPart1});
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SymbolIndexer, UpdateProjectPartsCallsGetsSystemPchPathsAndHasErrorWithProjectPch)
|
|
|
|
{
|
|
|
|
InSequence s;
|
|
|
|
|
|
|
|
EXPECT_CALL(mockPrecompiledHeaderStorage, fetchPrecompiledHeaders(Eq(projectPart1.projectPartId)))
|
|
|
|
.WillOnce(Return(ClangBackEnd::PchPaths{{}, "/system/pch"}));
|
|
|
|
EXPECT_CALL(mockCollector,
|
|
|
|
setFile(main1PathId,
|
|
|
|
ElementsAre("clang++",
|
|
|
|
"-w",
|
|
|
|
"-Wno-pragma-once-outside-header",
|
|
|
|
"-DNOMINMAX",
|
|
|
|
"-x",
|
|
|
|
"c++",
|
|
|
|
"-std=c++14",
|
|
|
|
"-nostdinc",
|
|
|
|
"-nostdinc++",
|
|
|
|
"-DBAR=1",
|
|
|
|
"-DFOO=1",
|
2019-04-24 14:07:39 +02:00
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR "/preincludes"),
|
2019-04-10 19:24:36 +02:00
|
|
|
"-I",
|
|
|
|
toNativePath("/project/includes"),
|
|
|
|
"-I",
|
|
|
|
toNativePath("/other/project/includes"),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath("/other/includes"),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath("/includes"),
|
|
|
|
"-Xclang",
|
|
|
|
"-include-pch",
|
|
|
|
"-Xclang",
|
|
|
|
toNativePath("/system/pch"))));
|
|
|
|
EXPECT_CALL(mockCollector, collectSymbols()).WillOnce(Return(true));
|
|
|
|
EXPECT_CALL(mockSymbolStorage, addSymbolsAndSourceLocations(symbolEntries, sourceLocations));
|
|
|
|
EXPECT_CALL(mockCollector, collectSymbols()).Times(0);
|
|
|
|
|
|
|
|
indexer.updateProjectParts({projectPart1});
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SymbolIndexer, UpdateProjectPartsCallsGetsNoPchPathsAndHasErrors)
|
|
|
|
{
|
|
|
|
InSequence s;
|
|
|
|
|
|
|
|
EXPECT_CALL(mockPrecompiledHeaderStorage, fetchPrecompiledHeaders(Eq(projectPart1.projectPartId)));
|
2019-02-07 12:20:51 +01:00
|
|
|
EXPECT_CALL(mockCollector,
|
|
|
|
setFile(main1PathId,
|
|
|
|
ElementsAre("clang++",
|
2019-02-28 19:22:22 +01:00
|
|
|
"-w",
|
2019-02-07 12:20:51 +01:00
|
|
|
"-Wno-pragma-once-outside-header",
|
2019-02-13 13:37:24 +01:00
|
|
|
"-DNOMINMAX",
|
2019-02-07 12:20:51 +01:00
|
|
|
"-x",
|
|
|
|
"c++",
|
|
|
|
"-std=c++14",
|
|
|
|
"-nostdinc",
|
|
|
|
"-nostdinc++",
|
|
|
|
"-DBAR=1",
|
|
|
|
"-DFOO=1",
|
2019-04-24 14:07:39 +02:00
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR "/preincludes"),
|
2019-04-07 15:57:42 +02:00
|
|
|
"-I",
|
2019-03-13 15:09:30 +01:00
|
|
|
toNativePath("/project/includes"),
|
2019-02-07 12:20:51 +01:00
|
|
|
"-I",
|
2019-03-13 15:09:30 +01:00
|
|
|
toNativePath("/other/project/includes"),
|
2019-02-07 12:20:51 +01:00
|
|
|
"-isystem",
|
2019-03-13 15:09:30 +01:00
|
|
|
toNativePath(TESTDATA_DIR),
|
2019-02-07 12:20:51 +01:00
|
|
|
"-isystem",
|
2019-03-13 15:09:30 +01:00
|
|
|
toNativePath("/other/includes"),
|
2019-02-07 12:20:51 +01:00
|
|
|
"-isystem",
|
2019-03-13 15:09:30 +01:00
|
|
|
toNativePath("/includes"))));
|
2019-04-10 19:24:36 +02:00
|
|
|
EXPECT_CALL(mockCollector, collectSymbols()).WillOnce(Return(true));
|
|
|
|
EXPECT_CALL(mockSymbolStorage, addSymbolsAndSourceLocations(symbolEntries, sourceLocations));
|
|
|
|
EXPECT_CALL(mockCollector, collectSymbols()).Times(0);
|
2019-02-07 12:20:51 +01:00
|
|
|
|
|
|
|
indexer.updateProjectParts({projectPart1});
|
|
|
|
}
|
|
|
|
|
2019-03-21 17:55:24 +01:00
|
|
|
TEST_F(SymbolIndexer, UpdateProjectPartsFetchIncludedIndexingTimeStamps)
|
|
|
|
{
|
|
|
|
InSequence s;
|
2019-07-10 14:03:38 +02:00
|
|
|
|
|
|
|
EXPECT_CALL(mockSqliteTransactionBackend, immediateBegin());
|
2019-07-24 16:13:10 +02:00
|
|
|
EXPECT_CALL(mockBuildDependenciesStorage,
|
|
|
|
insertOrUpdateIndexingTimeStampsWithoutTransaction(_, _));
|
2019-07-10 14:03:38 +02:00
|
|
|
EXPECT_CALL(mockSymbolStorage, addSymbolsAndSourceLocations(_, _));
|
|
|
|
EXPECT_CALL(mockSqliteTransactionBackend, commit());
|
|
|
|
|
|
|
|
indexer.updateProjectParts({projectPart1});
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SymbolIndexer, UpdateProjectPartsIsBusyInStoringData)
|
|
|
|
{
|
|
|
|
InSequence s;
|
|
|
|
|
|
|
|
EXPECT_CALL(mockSqliteTransactionBackend, immediateBegin())
|
|
|
|
.WillOnce(Throw(Sqlite::StatementIsBusy{""}));
|
|
|
|
EXPECT_CALL(mockSqliteTransactionBackend, immediateBegin());
|
2019-07-24 16:13:10 +02:00
|
|
|
EXPECT_CALL(mockBuildDependenciesStorage,
|
|
|
|
insertOrUpdateIndexingTimeStampsWithoutTransaction(_, _));
|
2019-07-10 14:03:38 +02:00
|
|
|
EXPECT_CALL(mockSymbolStorage, addSymbolsAndSourceLocations(_, _));
|
|
|
|
EXPECT_CALL(mockSqliteTransactionBackend, commit());
|
2019-03-21 17:55:24 +01:00
|
|
|
|
2019-07-10 14:03:38 +02:00
|
|
|
indexer.updateProjectParts({projectPart1});
|
2019-03-21 17:55:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SymbolIndexer, DependentSourceAreNotUpToDate)
|
|
|
|
{
|
|
|
|
InSequence s;
|
|
|
|
|
|
|
|
EXPECT_CALL(mockModifiedTimeChecker, isUpToDate(_)).WillOnce(Return(false));
|
|
|
|
EXPECT_CALL(mockCollector, setFile(main1PathId, _));
|
|
|
|
EXPECT_CALL(mockCollector, collectSymbols()).WillOnce(Return(true));
|
|
|
|
EXPECT_CALL(mockSymbolStorage, addSymbolsAndSourceLocations(symbolEntries, sourceLocations));
|
|
|
|
|
|
|
|
indexer.updateProjectParts({projectPart1});
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SymbolIndexer, DependentSourceAreUpToDate)
|
|
|
|
{
|
|
|
|
InSequence s;
|
|
|
|
|
|
|
|
EXPECT_CALL(mockModifiedTimeChecker, isUpToDate(_)).WillOnce(Return(true));
|
|
|
|
EXPECT_CALL(mockCollector, setFile(main1PathId, _)).Times(0);
|
|
|
|
EXPECT_CALL(mockCollector, collectSymbols()).Times(0);
|
|
|
|
EXPECT_CALL(mockSymbolStorage, addSymbolsAndSourceLocations(symbolEntries, sourceLocations)).Times(0);
|
|
|
|
|
|
|
|
indexer.updateProjectParts({projectPart1});
|
|
|
|
}
|
|
|
|
|
2018-02-08 12:48:46 +01:00
|
|
|
TEST_F(SymbolIndexer, CompilerMacrosAndIncludeSearchPathsAreNotDifferent)
|
2018-02-07 16:18:16 +01:00
|
|
|
{
|
2019-03-13 15:09:30 +01:00
|
|
|
ON_CALL(mockProjectPartsStorage, fetchProjectPartArtefact(A<ProjectPartId>()))
|
|
|
|
.WillByDefault(Return(artefact));
|
2018-02-07 16:18:16 +01:00
|
|
|
|
2018-02-20 12:43:05 +01:00
|
|
|
auto areDifferent = indexer.compilerMacrosOrIncludeSearchPathsAreDifferent(projectPart1,
|
|
|
|
artefact);
|
2018-02-07 16:18:16 +01:00
|
|
|
|
|
|
|
ASSERT_FALSE(areDifferent);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SymbolIndexer, CompilerMacrosAreDifferent)
|
|
|
|
{
|
2019-03-13 15:09:30 +01:00
|
|
|
ON_CALL(mockProjectPartsStorage, fetchProjectPartArtefact(A<ProjectPartId>()))
|
|
|
|
.WillByDefault(Return(artefact));
|
2018-02-07 16:18:16 +01:00
|
|
|
|
2018-02-20 12:43:05 +01:00
|
|
|
auto areDifferent = indexer.compilerMacrosOrIncludeSearchPathsAreDifferent(projectPart2,
|
|
|
|
artefact);
|
2018-02-08 12:48:46 +01:00
|
|
|
|
|
|
|
ASSERT_TRUE(areDifferent);
|
|
|
|
}
|
|
|
|
|
2018-12-17 12:06:57 +01:00
|
|
|
TEST_F(SymbolIndexer, SystemIncludeSearchPathsAreDifferent)
|
|
|
|
{
|
|
|
|
ClangBackEnd::IncludeSearchPaths newSystemIncludeSearchPaths{
|
|
|
|
{"/includes", 1, ClangBackEnd::IncludeSearchPathType::BuiltIn},
|
|
|
|
{"/other/includes2", 2, ClangBackEnd::IncludeSearchPathType::System}};
|
|
|
|
ClangBackEnd::IncludeSearchPaths newProjectIncludeSearchPaths{
|
|
|
|
{"/project/includes", 1, ClangBackEnd::IncludeSearchPathType::User},
|
|
|
|
{"/other/project/includes2", 2, ClangBackEnd::IncludeSearchPathType::User}};
|
2019-03-13 15:09:30 +01:00
|
|
|
ProjectPartContainer projectPart3{3,
|
|
|
|
{"-I", TESTDATA_DIR, "-Wno-pragma-once-outside-header"},
|
|
|
|
{{"BAR", "1", 1}, {"FOO", "1", 2}},
|
|
|
|
{{"/includes", 1, ClangBackEnd::IncludeSearchPathType::BuiltIn},
|
|
|
|
{"/other/includes2",
|
|
|
|
2,
|
|
|
|
ClangBackEnd::IncludeSearchPathType::System}},
|
|
|
|
Utils::clone(projectIncludeSearchPaths),
|
|
|
|
{header1PathId},
|
|
|
|
{main1PathId},
|
|
|
|
Utils::Language::C,
|
|
|
|
Utils::LanguageVersion::C11,
|
|
|
|
Utils::LanguageExtension::All};
|
|
|
|
ON_CALL(mockProjectPartsStorage, fetchProjectPartArtefact(A<ProjectPartId>()))
|
2018-12-17 12:06:57 +01:00
|
|
|
.WillByDefault(Return(artefact));
|
|
|
|
|
|
|
|
auto areDifferent = indexer.compilerMacrosOrIncludeSearchPathsAreDifferent(
|
|
|
|
projectPart3, artefact);
|
|
|
|
|
|
|
|
ASSERT_TRUE(areDifferent);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SymbolIndexer, ProjectIncludeSearchPathsAreDifferent)
|
2018-02-08 12:48:46 +01:00
|
|
|
{
|
2018-12-17 12:06:57 +01:00
|
|
|
ProjectPartContainer projectPart3{
|
2019-03-13 15:09:30 +01:00
|
|
|
3,
|
2018-12-17 12:06:57 +01:00
|
|
|
{"-I", TESTDATA_DIR, "-Wno-pragma-once-outside-header"},
|
|
|
|
{{"BAR", "1", 1}, {"FOO", "1", 2}},
|
|
|
|
Utils::clone(systemIncludeSearchPaths),
|
|
|
|
{{"/project/includes", 1, ClangBackEnd::IncludeSearchPathType::User},
|
|
|
|
{"/other/project/includes2", 2, ClangBackEnd::IncludeSearchPathType::User}},
|
|
|
|
{header1PathId},
|
|
|
|
{main1PathId},
|
|
|
|
Utils::Language::C,
|
|
|
|
Utils::LanguageVersion::C11,
|
|
|
|
Utils::LanguageExtension::All};
|
2019-03-13 15:09:30 +01:00
|
|
|
ON_CALL(mockProjectPartsStorage, fetchProjectPartArtefact(A<ProjectPartId>()))
|
2018-12-17 12:06:57 +01:00
|
|
|
.WillByDefault(Return(artefact));
|
2018-02-08 12:48:46 +01:00
|
|
|
|
2018-12-17 12:06:57 +01:00
|
|
|
auto areDifferent = indexer.compilerMacrosOrIncludeSearchPathsAreDifferent(
|
|
|
|
projectPart3, artefact);
|
2018-02-07 16:18:16 +01:00
|
|
|
|
|
|
|
ASSERT_TRUE(areDifferent);
|
|
|
|
}
|
2019-03-13 15:09:30 +01:00
|
|
|
|
|
|
|
TEST_F(SymbolIndexer, DISABLED_DontReparseInUpdateProjectPartsIfDefinesAreTheSame)
|
2018-02-07 16:18:16 +01:00
|
|
|
{
|
2018-08-28 12:08:37 +02:00
|
|
|
InSequence s;
|
2018-11-07 17:48:25 +01:00
|
|
|
ON_CALL(mockBuildDependenciesStorage, fetchLowestLastModifiedTime(A<FilePathId>())).WillByDefault(Return(QDateTime::currentSecsSinceEpoch()));
|
2018-02-07 16:18:16 +01:00
|
|
|
|
2018-08-28 12:08:37 +02:00
|
|
|
EXPECT_CALL(mockSqliteTransactionBackend, immediateBegin());
|
2019-03-13 15:09:30 +01:00
|
|
|
EXPECT_CALL(mockProjectPartsStorage, fetchProjectPartArtefact(TypedEq<ProjectPartId>(1)))
|
|
|
|
.WillRepeatedly(Return(artefact));
|
|
|
|
EXPECT_CALL(mockProjectPartsStorage,
|
|
|
|
updateProjectPart(Eq(projectPart1.projectPartId),
|
|
|
|
Eq(projectPart1.toolChainArguments),
|
|
|
|
Eq(projectPart1.compilerMacros),
|
|
|
|
Eq(projectPart1.systemIncludeSearchPaths),
|
|
|
|
Eq(projectPart1.projectIncludeSearchPaths),
|
|
|
|
Eq(Utils::Language::Cxx),
|
|
|
|
Eq(Utils::LanguageVersion::CXX14),
|
|
|
|
Eq(Utils::LanguageExtension::None)));
|
2018-11-07 17:48:25 +01:00
|
|
|
EXPECT_CALL(mockBuildDependenciesStorage, fetchLowestLastModifiedTime(A<FilePathId>())).WillRepeatedly(Return(QDateTime::currentSecsSinceEpoch()));
|
2018-08-28 12:08:37 +02:00
|
|
|
EXPECT_CALL(mockSqliteTransactionBackend, commit());
|
2018-09-03 14:38:01 +02:00
|
|
|
EXPECT_CALL(mockCollector, setFile(_, _)).Times(0);
|
2018-02-07 16:18:16 +01:00
|
|
|
EXPECT_CALL(mockCollector, collectSymbols()).Times(0);
|
|
|
|
EXPECT_CALL(mockSqliteTransactionBackend, immediateBegin()).Times(0);
|
2018-10-11 18:09:55 +02:00
|
|
|
EXPECT_CALL(mockSymbolStorage, addSymbolsAndSourceLocations(_, _)).Times(0);
|
2018-02-07 16:18:16 +01:00
|
|
|
EXPECT_CALL(mockSqliteTransactionBackend, commit()).Times(0);
|
|
|
|
|
2018-09-03 14:38:01 +02:00
|
|
|
indexer.updateProjectPart(std::move(projectPart1));
|
2018-02-07 16:18:16 +01:00
|
|
|
}
|
|
|
|
|
2018-02-08 17:49:02 +01:00
|
|
|
TEST_F(SymbolIndexer, PathsChangedUpdatesFileStatusCache)
|
|
|
|
{
|
|
|
|
auto sourceId = filePathId(TESTDATA_DIR "/symbolindexer_pathChanged.cpp");
|
2019-06-06 10:57:55 +02:00
|
|
|
ON_CALL(mockFileSystem, lastModified(Eq(sourceId))).WillByDefault(Return(65));
|
2019-06-20 18:34:02 +02:00
|
|
|
ON_CALL(mockBuildDependenciesStorage, fetchDependentSourceIds(_))
|
|
|
|
.WillByDefault(Return(FilePathIds{sourceId}));
|
2018-02-08 17:49:02 +01:00
|
|
|
|
|
|
|
indexer.pathsChanged({sourceId});
|
|
|
|
|
2019-06-06 10:57:55 +02:00
|
|
|
ASSERT_THAT(fileStatusCache.lastModifiedTime(sourceId), 65);
|
2018-02-08 17:49:02 +01:00
|
|
|
}
|
|
|
|
|
2019-06-17 18:17:49 +02:00
|
|
|
TEST_F(SymbolIndexer, PathsChangedCallsModifiedTimeChecker)
|
|
|
|
{
|
|
|
|
auto sourceId = filePathId(TESTDATA_DIR "/symbolindexer_pathChanged.cpp");
|
|
|
|
|
|
|
|
EXPECT_CALL(mockModifiedTimeChecker, pathsChanged(ElementsAre(sourceId)));
|
|
|
|
|
|
|
|
indexer.pathsChanged({sourceId});
|
|
|
|
}
|
|
|
|
|
2018-02-08 17:49:02 +01:00
|
|
|
TEST_F(SymbolIndexer, GetUpdatableFilePathIdsIfCompilerMacrosAreDifferent)
|
|
|
|
{
|
2019-03-13 15:09:30 +01:00
|
|
|
ON_CALL(mockProjectPartsStorage, fetchProjectPartArtefact(A<ProjectPartId>()))
|
|
|
|
.WillByDefault(Return(artefact));
|
2018-02-08 17:49:02 +01:00
|
|
|
|
2018-02-20 12:43:05 +01:00
|
|
|
auto filePathIds = indexer.updatableFilePathIds(projectPart2, artefact);
|
2018-02-08 17:49:02 +01:00
|
|
|
|
2018-04-04 18:25:23 +02:00
|
|
|
ASSERT_THAT(filePathIds, projectPart2.sourcePathIds);
|
2018-02-08 17:49:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SymbolIndexer, GetUpdatableFilePathIdsIfIncludeSearchPathsAreDifferent)
|
|
|
|
{
|
2019-03-13 15:09:30 +01:00
|
|
|
ON_CALL(mockProjectPartsStorage, fetchProjectPartArtefact(A<ProjectPartId>()))
|
|
|
|
.WillByDefault(Return(artefact));
|
2018-02-08 17:49:02 +01:00
|
|
|
|
2018-02-20 12:43:05 +01:00
|
|
|
auto filePathIds = indexer.updatableFilePathIds(projectPart3, artefact);
|
2018-02-08 17:49:02 +01:00
|
|
|
|
2018-04-04 18:25:23 +02:00
|
|
|
ASSERT_THAT(filePathIds, projectPart3.sourcePathIds);
|
2018-02-08 17:49:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SymbolIndexer, GetNoUpdatableFilePathIdsIfArtefactsAreTheSame)
|
|
|
|
{
|
2019-03-13 15:09:30 +01:00
|
|
|
ON_CALL(mockProjectPartsStorage, fetchProjectPartArtefact(A<ProjectPartId>()))
|
|
|
|
.WillByDefault(Return(artefact));
|
2018-11-07 17:48:25 +01:00
|
|
|
ON_CALL(mockBuildDependenciesStorage, fetchLowestLastModifiedTime(A<FilePathId>())).WillByDefault(Return(QDateTime::currentSecsSinceEpoch()));
|
2018-02-08 17:49:02 +01:00
|
|
|
|
2018-02-20 12:43:05 +01:00
|
|
|
auto filePathIds = indexer.updatableFilePathIds(projectPart1, artefact);
|
2018-02-08 17:49:02 +01:00
|
|
|
|
|
|
|
ASSERT_THAT(filePathIds, IsEmpty());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SymbolIndexer, OutdatedFilesPassUpdatableFilePathIds)
|
|
|
|
{
|
2019-06-06 10:57:55 +02:00
|
|
|
ON_CALL(mockFileSystem, lastModified(Eq(main1PathId))).WillByDefault(Return(65));
|
2018-02-08 17:49:02 +01:00
|
|
|
indexer.pathsChanged({main1PathId});
|
2019-03-13 15:09:30 +01:00
|
|
|
ON_CALL(mockProjectPartsStorage, fetchProjectPartArtefact(A<ProjectPartId>()))
|
|
|
|
.WillByDefault(Return(artefact));
|
2018-11-07 17:48:25 +01:00
|
|
|
ON_CALL(mockBuildDependenciesStorage, fetchLowestLastModifiedTime(A<FilePathId>()))
|
2018-02-08 17:49:02 +01:00
|
|
|
.WillByDefault(Return(0));
|
|
|
|
|
2018-02-20 12:43:05 +01:00
|
|
|
auto filePathIds = indexer.updatableFilePathIds(projectPart1, artefact);
|
2018-02-08 17:49:02 +01:00
|
|
|
|
|
|
|
ASSERT_THAT(filePathIds, ElementsAre(main1PathId));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SymbolIndexer, UpToDateFilesDontPassFilteredUpdatableFilePathIds)
|
|
|
|
{
|
|
|
|
indexer.pathsChanged({main1PathId});
|
2019-03-13 15:09:30 +01:00
|
|
|
ON_CALL(mockProjectPartsStorage, fetchProjectPartArtefact(A<ProjectPartId>()))
|
|
|
|
.WillByDefault(Return(artefact));
|
2018-11-07 17:48:25 +01:00
|
|
|
ON_CALL(mockBuildDependenciesStorage, fetchLowestLastModifiedTime(A<FilePathId>()))
|
2018-02-08 17:49:02 +01:00
|
|
|
.WillByDefault(Return(QDateTime::currentSecsSinceEpoch()));
|
|
|
|
|
2018-02-20 12:43:05 +01:00
|
|
|
auto filePathIds = indexer.updatableFilePathIds(projectPart1, artefact);
|
2018-02-08 17:49:02 +01:00
|
|
|
|
|
|
|
ASSERT_THAT(filePathIds, IsEmpty());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(SymbolIndexer, OutdatedFilesAreParsedInUpdateProjectParts)
|
|
|
|
{
|
|
|
|
indexer.pathsChanged({main1PathId});
|
2018-08-28 12:08:37 +02:00
|
|
|
indexerScheduler.syncTasks();
|
2019-03-13 15:09:30 +01:00
|
|
|
ON_CALL(mockProjectPartsStorage, fetchProjectPartArtefact(A<ProjectPartId>()))
|
|
|
|
.WillByDefault(Return(artefact));
|
2018-11-07 17:48:25 +01:00
|
|
|
ON_CALL(mockBuildDependenciesStorage, fetchLowestLastModifiedTime(A<FilePathId>()))
|
2018-02-08 17:49:02 +01:00
|
|
|
.WillByDefault(Return(0));
|
|
|
|
|
2018-09-03 14:38:01 +02:00
|
|
|
EXPECT_CALL(mockCollector, setFile(Eq(main1PathId), _));
|
2018-02-08 17:49:02 +01:00
|
|
|
|
2018-09-03 14:38:01 +02:00
|
|
|
indexer.updateProjectParts({projectPart1});
|
2018-02-08 17:49:02 +01:00
|
|
|
}
|
|
|
|
|
2019-03-13 15:09:30 +01:00
|
|
|
TEST_F(SymbolIndexer, DISABLED_UpToDateFilesAreNotParsedInUpdateProjectParts)
|
2018-02-08 17:49:02 +01:00
|
|
|
{
|
|
|
|
indexer.pathsChanged({main1PathId});
|
2018-12-17 12:06:57 +01:00
|
|
|
|
2018-08-28 12:08:37 +02:00
|
|
|
indexerScheduler.syncTasks();
|
2019-03-13 15:09:30 +01:00
|
|
|
ON_CALL(mockProjectPartsStorage, fetchProjectPartArtefact(A<ProjectPartId>()))
|
|
|
|
.WillByDefault(Return(artefact));
|
2018-11-07 17:48:25 +01:00
|
|
|
ON_CALL(mockBuildDependenciesStorage, fetchLowestLastModifiedTime(A<FilePathId>()))
|
2018-02-08 17:49:02 +01:00
|
|
|
.WillByDefault(Return(QDateTime::currentSecsSinceEpoch()));
|
|
|
|
|
2018-09-03 14:38:01 +02:00
|
|
|
EXPECT_CALL(mockCollector, setFile(_, _)).Times(0);
|
2018-02-08 17:49:02 +01:00
|
|
|
|
2018-09-03 14:38:01 +02:00
|
|
|
indexer.updateProjectParts({projectPart1});
|
2018-02-08 17:49:02 +01:00
|
|
|
}
|
|
|
|
|
2019-04-25 17:58:15 +02:00
|
|
|
TEST_F(SymbolIndexer, MultipleSourceFiles)
|
|
|
|
{
|
|
|
|
ProjectPartContainer projectPart{0,
|
|
|
|
{},
|
|
|
|
{{"BAR", "1", 1}, {"FOO", "1", 2}},
|
|
|
|
Utils::clone(systemIncludeSearchPaths),
|
|
|
|
Utils::clone(projectIncludeSearchPaths),
|
|
|
|
{header1PathId, header2PathId},
|
|
|
|
{main1PathId, main2PathId},
|
|
|
|
Utils::Language::Cxx,
|
|
|
|
Utils::LanguageVersion::CXX14,
|
|
|
|
Utils::LanguageExtension::None};
|
|
|
|
|
|
|
|
EXPECT_CALL(mockCollector,
|
|
|
|
setFile(main1PathId,
|
|
|
|
ElementsAre("clang++",
|
|
|
|
"-w",
|
|
|
|
"-DNOMINMAX",
|
|
|
|
"-x",
|
|
|
|
"c++",
|
|
|
|
"-std=c++14",
|
|
|
|
"-nostdinc",
|
|
|
|
"-nostdinc++",
|
|
|
|
"-DBAR=1",
|
|
|
|
"-DFOO=1",
|
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR "/preincludes"),
|
|
|
|
"-I",
|
|
|
|
toNativePath("/project/includes"),
|
|
|
|
"-I",
|
|
|
|
toNativePath("/other/project/includes"),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath("/other/includes"),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath("/includes"))));
|
|
|
|
EXPECT_CALL(mockCollector,
|
|
|
|
setFile(main2PathId,
|
|
|
|
ElementsAre("clang++",
|
|
|
|
"-w",
|
|
|
|
"-DNOMINMAX",
|
|
|
|
"-x",
|
|
|
|
"c++",
|
|
|
|
"-std=c++14",
|
|
|
|
"-nostdinc",
|
|
|
|
"-nostdinc++",
|
|
|
|
"-DBAR=1",
|
|
|
|
"-DFOO=1",
|
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR "/preincludes"),
|
|
|
|
"-I",
|
|
|
|
toNativePath("/project/includes"),
|
|
|
|
"-I",
|
|
|
|
toNativePath("/other/project/includes"),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath(TESTDATA_DIR),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath("/other/includes"),
|
|
|
|
"-isystem",
|
|
|
|
toNativePath("/includes"))));
|
|
|
|
|
|
|
|
indexer.updateProjectParts({projectPart});
|
2017-08-02 16:00:55 +02:00
|
|
|
}
|
2019-04-25 17:58:15 +02:00
|
|
|
} // namespace
|