Skip to content

Commit 131140e

Browse files
author
Vladislav Kalugin
committed
not end
1 parent 7bb4175 commit 131140e

File tree

13 files changed

+27
-26
lines changed

13 files changed

+27
-26
lines changed

server/src/ReturnTypesFetcher.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ void ReturnTypesFetcher::fetch(ProgressWriter *const progressWriter,
1010
testsMap[filePath];
1111
}
1212
Fetcher(Fetcher::Options::Value::RETURN_TYPE_NAMES_ONLY,
13-
testGen->compilationDatabase, testsMap, nullptr, nullptr, nullptr,
13+
testGen->buildDatabase->compilationDatabase, testsMap, nullptr, nullptr, nullptr,
1414
testGen->compileCommandsJsonPath, false)
1515
.fetchWithProgress(progressWriter, "Fetching return types for functions", true);
1616
for (auto const &[sourceFilePath, test] : testsMap) {

server/src/Server.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,11 @@ Status Server::TestsGenServiceImpl::ProcessBaseTestRequest(BaseTestGen &testGen,
198198
static std::string logMessage = "Traversing sources AST tree and fetching declarations.";
199199
LOG_S(DEBUG) << logMessage;
200200
Fetcher fetcher(Fetcher::Options::Value::ALL,
201-
testGen.compilationDatabase, testGen.tests, &testGen.types,
201+
testGen.buildDatabase->compilationDatabase, testGen.tests, &testGen.types,
202202
&sizeContext.pointerSize, &sizeContext.maximumAlignment,
203203
testGen.compileCommandsJsonPath, false);
204204
fetcher.fetchWithProgress(testGen.progressWriter, logMessage);
205-
SourceToHeaderRewriter(testGen.projectContext, testGen.compilationDatabase,
205+
SourceToHeaderRewriter(testGen.projectContext, testGen.buildDatabase->compilationDatabase,
206206
fetcher.getStructsToDeclare(), testGen.serverBuildDir)
207207
.generateTestHeaders(testGen.tests, testGen.progressWriter);
208208
types::TypesHandler typesHandler{ testGen.types, sizeContext };
@@ -218,7 +218,7 @@ Status Server::TestsGenServiceImpl::ProcessBaseTestRequest(BaseTestGen &testGen,
218218
if (lineTestGen != nullptr) {
219219
if (isSameType<ClassTestGen>(testGen) && Paths::isHeaderFile(lineTestGen->filePath)) {
220220
BordersFinder classFinder(lineTestGen->filePath, lineTestGen->line,
221-
lineTestGen->compilationDatabase,
221+
lineTestGen->buildDatabase->compilationDatabase,
222222
lineTestGen->compileCommandsJsonPath);
223223
classFinder.findClass();
224224
lineInfo = std::make_shared<LineInfo>(classFinder.getLineInfo());
@@ -255,7 +255,7 @@ Status Server::TestsGenServiceImpl::ProcessBaseTestRequest(BaseTestGen &testGen,
255255
}
256256
auto generator = std::make_shared<KleeGenerator>(
257257
testGen.projectContext, testGen.settingsContext,
258-
testGen.serverBuildDir, testGen.compilationDatabase, typesHandler,
258+
testGen.serverBuildDir, testGen.buildDatabase->compilationDatabase, typesHandler,
259259
pathSubstitution, testGen.buildDatabase, testGen.progressWriter);
260260

261261
ReturnTypesFetcher returnTypesFetcher{ &testGen };
@@ -311,7 +311,7 @@ Status Server::TestsGenServiceImpl::ProcessBaseTestRequest(BaseTestGen &testGen,
311311

312312
std::shared_ptr<LineInfo> Server::TestsGenServiceImpl::getLineInfo(LineTestGen &lineTestGen) {
313313
BordersFinder stmtFinder(lineTestGen.filePath, lineTestGen.line,
314-
lineTestGen.compilationDatabase,
314+
lineTestGen.buildDatabase->compilationDatabase,
315315
lineTestGen.compileCommandsJsonPath);
316316
stmtFinder.findFunction();
317317
if (!stmtFinder.getLineInfo().initialized) {
@@ -550,7 +550,7 @@ Status Server::TestsGenServiceImpl::ProcessProjectStubsRequest(BaseTestGen *test
550550
static std::string logMessage = "Traversing sources AST tree and fetching declarations.";
551551
LOG_S(DEBUG) << logMessage;
552552
Fetcher fetcher(Fetcher::Options::Value::TYPE | Fetcher::Options::Value::FUNCTION,
553-
testGen->compilationDatabase, testGen->tests, &testGen->types,
553+
testGen->buildDatabase->compilationDatabase, testGen->tests, &testGen->types,
554554
&sizeContext.pointerSize, &sizeContext.maximumAlignment,
555555
testGen->compileCommandsJsonPath, false);
556556

server/src/Synchronizer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ void Synchronizer::synchronizeStubs(StubSet &outdatedStubs,
145145
auto options = Fetcher::Options::Value::FUNCTION | Fetcher::Options::Value::INCLUDE | Fetcher::Options::Value::TYPE;
146146

147147
auto stubFetcher =
148-
Fetcher(options, testGen->compilationDatabase, sourceFilesMap, &testGen->types,
148+
Fetcher(options, testGen->buildDatabase->compilationDatabase, sourceFilesMap, &testGen->types,
149149
&sizeContext->pointerSize, &sizeContext->maximumAlignment,
150150
testGen->compileCommandsJsonPath, false);
151151

@@ -157,7 +157,7 @@ void Synchronizer::synchronizeStubs(StubSet &outdatedStubs,
157157
auto stubsCdb = createStubsCompilationDatabase(stubFiles, ccJsonStubDirPath);
158158

159159
auto sourceToHeaderRewriter =
160-
SourceToHeaderRewriter(testGen->projectContext, testGen->compilationDatabase,
160+
SourceToHeaderRewriter(testGen->projectContext, testGen->buildDatabase->compilationDatabase,
161161
stubFetcher.getStructsToDeclare(), testGen->serverBuildDir);
162162

163163
for (const StubOperator &outdatedStub : outdatedStubs) {
@@ -203,14 +203,14 @@ void Synchronizer::synchronizeWrappers(const CollectionUtils::FileSet &outdatedS
203203
sourceFilesNeedToRegenerateWrappers, testGen->progressWriter,
204204
"Generating wrappers", [this](fs::path const &sourceFilePath) {
205205
SourceToHeaderRewriter sourceToHeaderRewriter(testGen->projectContext,
206-
testGen->compilationDatabase, nullptr,
206+
testGen->buildDatabase->compilationDatabase, nullptr,
207207
testGen->serverBuildDir);
208208
std::string wrapper = sourceToHeaderRewriter.generateWrapper(sourceFilePath);
209209
printer::SourceWrapperPrinter(Paths::getSourceLanguage(sourceFilePath)).print(testGen->projectContext, sourceFilePath, wrapper);
210210
});
211211
}
212212
const CollectionUtils::FileSet &Synchronizer::getAllFiles() const {
213-
return testGen->compilationDatabase->getAllFiles();
213+
return testGen->baseBuildDatabase->compilationDatabase->getAllFiles();
214214
}
215215

216216
void Synchronizer::prepareDirectory(const fs::path &stubDirectory) {

server/src/building/BuildDatabase.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ void BuildDatabase::createClangCompileCommandsJson() {
289289

290290
fs::path clangCompileCommandsJsonPath = CompilationUtils::getClangCompileCommandsJsonPath(buildCommandsJsonPath);
291291
JsonUtils::writeJsonToFile(clangCompileCommandsJsonPath, compileCommandsSingleFilesJson);
292+
compilationDatabase = CompilationUtils::getCompilationDatabase(compileCommandsJsonPath);
292293
}
293294

294295
//void BuildDatabase::updateTarget(const fs::path &_target) {

server/src/building/BuildDatabase.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ class BuildDatabase {
233233
bool hasAutoTarget() const;
234234

235235
fs::path getTargetPath() const;
236+
237+
std::shared_ptr<CompilationDatabase> compilationDatabase;
236238
private:
237239
BuildDatabase(BuildDatabase& baseBuildDatabase,
238240
const std::string &_target);
@@ -249,6 +251,7 @@ class BuildDatabase {
249251
CollectionUtils::MapFileTo<std::vector<fs::path>> objectFileTargets;
250252
CollectionUtils::MapFileTo<CollectionUtils::FileSet> linkUnitToStubFiles;
251253

254+
252255
std::vector<std::pair<nlohmann::json, std::shared_ptr<ObjectFileInfo>>> compileCommands_temp;
253256

254257
static bool conflictPriorityMore(const std::shared_ptr<ObjectFileInfo> &left,

server/src/building/Linker.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void Linker::linkForOneFile(const fs::path &sourceFilePath) {
114114
if (result.isSuccess()) {
115115
auto [targetBitcode, stubsSet, _] = result.getOpt().value();
116116
addToGenerated({ objectFile }, targetBitcode);
117-
auto&& targetUnitInfo = testGen.baseBuildDatabase->getClientLinkUnitInfo(target);
117+
auto&& targetUnitInfo = testGen.buildDatabase->getClientLinkUnitInfo(target);
118118
testGen.buildDatabase->assignStubFilesToLinkUnit(targetUnitInfo, stubsSet);
119119
return;
120120
} else {
@@ -202,7 +202,7 @@ void Linker::linkForProject() {
202202
return compilationUnitInfo->getOutputFile();
203203
});
204204
addToGenerated(objectFiles, linkres.bitcodeOutput);
205-
auto &&targetUnitInfo = testGen.baseBuildDatabase->getClientLinkUnitInfo(target);
205+
auto &&targetUnitInfo = testGen.buildDatabase->getClientLinkUnitInfo(target);
206206
testGen.buildDatabase->assignStubFilesToLinkUnit(targetUnitInfo, linkres.stubsSet);
207207
break;
208208
} else {

server/src/printers/TestMakefilesPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace printer {
3737
testGen.buildDatabase,
3838
testGen.buildDatabase->getTargetPath(),
3939
CompilationUtils::getBundledCompilerPath(CompilationUtils::getCompilerName(
40-
testGen.compilationDatabase->getBuildCompilerPath())),
40+
testGen.buildDatabase->compilationDatabase->getBuildCompilerPath())),
4141
stubSources) {
4242
}
4343

server/src/stubs/StubGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ CollectionUtils::FileSet StubGen::getStubSources(const fs::path &target) {
2020
return {};
2121
}
2222
fs::path testedFilePath = *testGen.testingMethodsSourcePaths.begin();
23-
auto stubSources = StubSourcesFinder(testGen.baseBuildDatabase).excludeFind(testedFilePath, target);
23+
auto stubSources = StubSourcesFinder(testGen.buildDatabase).excludeFind(testedFilePath, target);
2424
return { stubSources.begin(), stubSources.end() };
2525
}
2626

server/src/testgens/BaseTestGen.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ BaseTestGen::BaseTestGen(const testsgen::ProjectContext &projectContext,
1717
}
1818

1919
bool BaseTestGen::needToBeMocked() const {
20-
LOG_S(ERROR) << "?????? " << TypeUtils::isSameType<LineTestGen>(*this)
21-
<< " " << TypeUtils::isSameType<FileTestGen>(*this)
22-
<< " " << TypeUtils::isSameType<FolderTestGen>(*this);
2320
return TypeUtils::isSameType<LineTestGen>(*this) ||
2421
TypeUtils::isSameType<FileTestGen>(*this) ||
2522
TypeUtils::isSameType<FolderTestGen>(*this);

server/src/testgens/BaseTestGen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class BaseTestGen {
2323
fs::path serverBuildDir;
2424

2525
fs::path compileCommandsJsonPath;
26-
std::shared_ptr<CompilationDatabase> compilationDatabase;
26+
// std::shared_ptr<CompilationDatabase> compilationDatabase;
2727
std::shared_ptr<BuildDatabase> baseBuildDatabase;
2828
std::shared_ptr<BuildDatabase> buildDatabase;
2929

server/src/testgens/ProjectTestGen.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ ProjectTestGen::ProjectTestGen(const testsgen::ProjectRequest &request,
1818
projectContext.projectPath, projectContext.buildDirRelativePath);
1919
baseBuildDatabase = std::make_shared<BuildDatabase>(compileCommandsJsonPath, serverBuildDir, projectContext, false);
2020
buildDatabase = baseBuildDatabase->createBaseForTarget(request.targetpath());
21-
compilationDatabase = CompilationUtils::getCompilationDatabase(compileCommandsJsonPath);
21+
// compilationDatabase = CompilationUtils::getCompilationDatabase(compileCommandsJsonPath);
2222
if (autoSrcPaths) {
2323
autoDetectSourcePathsIfNotEmpty();
2424
} else {
25-
sourcePaths = compilationDatabase->getAllFiles();
25+
sourcePaths = buildDatabase->compilationDatabase->getAllFiles();
2626
}
2727
testingMethodsSourcePaths = sourcePaths;
2828
setInitializedTestsMap();
@@ -54,7 +54,7 @@ void ProjectTestGen::autoDetectSourcePathsIfNotEmpty() {
5454
// requestSourcePaths are from settings.json
5555
auto requestSourcePaths = getRequestSourcePaths();
5656
// sourcePathsCandidates are from compile_commands.json
57-
auto sourcePathsCandidates = compilationDatabase->getAllFiles();
57+
auto sourcePathsCandidates = buildDatabase->compilationDatabase->getAllFiles();
5858
if (!requestSourcePaths.empty()) {
5959
sourcePaths =
6060
Paths::filterPathsByDirNames(sourcePathsCandidates, requestSourcePaths, Paths::isSourceFile);

server/src/testgens/SnippetTestGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ SnippetTestGen::SnippetTestGen(const testsgen::SnippetRequest &request,
2020
utbot::ProjectContext projectContext{request, serverBuildDir};
2121
baseBuildDatabase = std::make_shared<BuildDatabase>(compileCommandsJsonPath, serverBuildDir, projectContext, false);
2222
buildDatabase = baseBuildDatabase->createBaseForTarget(serverBuildDir / SNIPPET_TARGET);
23-
compilationDatabase = CompilationUtils::getCompilationDatabase(serverBuildDir);
23+
// compilationDatabase = CompilationUtils::getCompilationDatabase(serverBuildDir);
2424
setTargetForSource(filePath);
2525
setInitializedTestsMap();
2626
}

server/test/framework/Stub_Tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,9 @@ namespace {
167167
ASSERT_TRUE(status.ok()) << status.error_message();
168168
EXPECT_EQ(testUtils::getNumberOfTests(testGen.tests), 2);
169169

170-
auto root = testGen.baseBuildDatabase->getRootForSource(foreign_bar_c);
171-
auto linkUnitInfo = testGen.baseBuildDatabase->getClientLinkUnitInfo(root);
172-
auto stubFiles = testGen.baseBuildDatabase->getStubFiles(linkUnitInfo);
170+
auto root = testGen.buildDatabase->getRootForSource(foreign_bar_c);
171+
auto linkUnitInfo = testGen.buildDatabase->getClientLinkUnitInfo(root);
172+
auto stubFiles = testGen.buildDatabase->getStubFiles(linkUnitInfo);
173173
auto stubCandidates = { calc_sum_c };
174174
auto expectedStubFiles = CollectionUtils::transformTo<decltype(stubFiles)>(
175175
stubCandidates, [&testGen](fs::path const &path) {

0 commit comments

Comments
 (0)