Skip to content

Commit fe628c7

Browse files
Vladislav Kaluginladisgin
authored andcommitted
Reformat build structure
1 parent 8c7cced commit fe628c7

23 files changed

+77
-87
lines changed

server/src/KleeRunner.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@ namespace {
4242
}
4343

4444
KleeRunner::KleeRunner(utbot::ProjectContext projectContext,
45-
utbot::SettingsContext settingsContext,
46-
fs::path serverBuildDir)
47-
: projectContext(std::move(projectContext)), settingsContext(std::move(settingsContext)),
48-
projectTmpPath(std::move(serverBuildDir)) {
45+
utbot::SettingsContext settingsContext)
46+
: projectContext(std::move(projectContext)), settingsContext(std::move(settingsContext)) {
4947
}
5048

5149
void KleeRunner::runKlee(const std::vector<tests::TestMethod> &testMethods,
@@ -59,7 +57,7 @@ void KleeRunner::runKlee(const std::vector<tests::TestMethod> &testMethods,
5957
StatsUtils::TestsGenerationStatsFileMap &generationStats) {
6058
LOG_SCOPE_FUNCTION(DEBUG);
6159

62-
fs::path kleeOutDir = Paths::getKleeOutDir(projectTmpPath);
60+
fs::path kleeOutDir = Paths::getKleeOutDir(projectContext);
6361
if (fs::exists(kleeOutDir)) {
6462
FileSystemUtils::removeAll(kleeOutDir);
6563
}
@@ -105,7 +103,7 @@ void KleeRunner::runKlee(const std::vector<tests::TestMethod> &testMethods,
105103
} else {
106104
processBatchWithoutInteractive(batch, tests, ktests);
107105
}
108-
auto kleeStats = writeKleeStats(Paths::kleeOutDirForFilePath(projectContext, projectTmpPath, filePath));
106+
auto kleeStats = writeKleeStats(Paths::kleeOutDirForFilePath(projectContext, filePath));
109107
generator->parseKTestsToFinalCode(tests, methodNameToReturnTypeMap, ktests, lineInfo,
110108
settingsContext.verbose);
111109
generationStats.addFileStats(kleeStats, tests);
@@ -116,7 +114,7 @@ void KleeRunner::runKlee(const std::vector<tests::TestMethod> &testMethods,
116114
std::function<void()> prepareTotal = [&]() {
117115
testsWriter->writeReport(sarif::sarifPackResults(sarifResults),
118116
"Sarif Report was created",
119-
projectContext.projectPath / sarif::SARIF_DIR_NAME / sarif::SARIF_FILE_NAME);
117+
Paths::getUTBotReportDir(projectContext) / sarif::SARIF_FILE_NAME);
120118
};
121119

122120
testsWriter->writeTestsWithProgress(
@@ -212,7 +210,6 @@ KleeRunner::createKleeParams(const tests::TestMethod &testMethod,
212210
const tests::Tests &tests,
213211
const std::string &methodNameOrEmptyForFolder) {
214212
fs::path kleeOut = Paths::kleeOutDirForEntrypoints(projectContext,
215-
projectTmpPath,
216213
tests.sourceFilePath,
217214
methodNameOrEmptyForFolder);
218215
fs::create_directories(kleeOut.parent_path());

server/src/KleeRunner.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
class KleeRunner {
1717
public:
1818
KleeRunner(utbot::ProjectContext projectContext,
19-
utbot::SettingsContext settingsContext,
20-
fs::path serverBuildDir);
19+
utbot::SettingsContext settingsContext);
2120
/**
2221
* @brief Passes arguments to `run_klee.cpp` and executes it.
2322
*
@@ -39,7 +38,6 @@ class KleeRunner {
3938
private:
4039
const utbot::ProjectContext projectContext;
4140
const utbot::SettingsContext settingsContext;
42-
fs::path projectTmpPath;
4341

4442
void processBatchWithoutInteractive(const std::vector<tests::TestMethod> &testMethods,
4543
tests::Tests &tests,

server/src/Paths.cpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,16 @@ namespace Paths {
161161
return errFiles;
162162
}
163163

164-
fs::path kleeOutDirForFilePath(const utbot::ProjectContext &projectContext, const fs::path &projectTmpPath,
165-
const fs::path &filePath) {
166-
fs::path kleeOutDir = getKleeOutDir(projectTmpPath);
164+
fs::path kleeOutDirForFilePath(const utbot::ProjectContext &projectContext, const fs::path &filePath) {
165+
fs::path kleeOutDir = getKleeOutDir(projectContext);
167166
fs::path relative = fs::relative(addOrigExtensionAsSuffixAndAddNew(filePath, ""), projectContext.projectPath);
168167
return kleeOutDir / relative;
169168
}
170169

171170
fs::path kleeOutDirForEntrypoints(const utbot::ProjectContext &projectContext,
172-
const fs::path &projectTmpPath,
173171
const fs::path &srcFilePath,
174172
const std::string &methodNameOrEmptyForFolder) {
175-
auto kleeOutDirForFile = kleeOutDirForFilePath(projectContext, projectTmpPath, srcFilePath);
173+
auto kleeOutDirForFile = kleeOutDirForFilePath(projectContext, srcFilePath);
176174
std::string suffix = methodNameOrEmptyForFolder.empty()
177175
? addOrigExtensionAsSuffixAndAddNew(srcFilePath, "").filename().string()
178176
: methodNameOrEmptyForFolder;
@@ -218,7 +216,7 @@ namespace Paths {
218216
return getArtifactsRootDir(projectContext) / "tests";
219217
}
220218
fs::path getMakefileDir(const utbot::ProjectContext &projectContext, const fs::path &sourceFilePath) {
221-
return getPathDirRelativeToTestDir(projectContext, sourceFilePath);
219+
return getPathDirRelativeToTestDir(projectContext, sourceFilePath) / "makefiles";
222220
}
223221
fs::path getGeneratedHeaderDir(const utbot::ProjectContext &projectContext, const fs::path &sourceFilePath) {
224222
return getPathDirRelativeToTestDir(projectContext, sourceFilePath);
@@ -229,13 +227,13 @@ namespace Paths {
229227
}
230228

231229
fs::path getRecompiledDir(const utbot::ProjectContext &projectContext) {
232-
return getUtbotBuildDir(projectContext) / "recompiled";
230+
return getUTBotBuildDir(projectContext) / "recompiled";
233231
}
234232
fs::path getTestObjectDir(const utbot::ProjectContext &projectContext) {
235-
return getUtbotBuildDir(projectContext) / "test_objects";
233+
return getUTBotBuildDir(projectContext) / "test_objects";
236234
}
237235
fs::path getCoverageDir(const utbot::ProjectContext &projectContext) {
238-
return getUtbotBuildDir(projectContext) / "coverage";
236+
return getUTBotBuildDir(projectContext) / "coverage";
239237
}
240238
fs::path getClangCoverageDir(const utbot::ProjectContext &projectContext) {
241239
return getCoverageDir(projectContext) / "lcov";
@@ -278,15 +276,15 @@ namespace Paths {
278276

279277
fs::path getBuildFilePath(const utbot::ProjectContext &projectContext,
280278
const fs::path &sourceFilePath) {
281-
fs::path path = getUtbotBuildDir(projectContext) /
279+
fs::path path = getUTBotBuildDir(projectContext) /
282280
getRelativeDirPath(projectContext, sourceFilePath) /
283281
sourceFilePath.filename();
284282
return addExtension(path, ".o");
285283
}
286284

287285
fs::path getStubBuildFilePath(const utbot::ProjectContext &projectContext,
288286
const fs::path &sourceFilePath) {
289-
fs::path path = getUtbotBuildDir(projectContext) /
287+
fs::path path = getUTBotBuildDir(projectContext) /
290288
getRelativeDirPath(projectContext, sourceFilePath) /
291289
sourcePathToStubName(sourceFilePath);
292290
return addExtension(path, ".o");
@@ -410,9 +408,6 @@ namespace Paths {
410408
bool isHeadersEqual(const fs::path &srcPath, const fs::path &headerPath) {
411409
return removeSuffix(srcPath, STUB_SUFFIX).stem() == headerPath.stem();
412410
}
413-
fs::path getUtbotBuildDir(const utbot::ProjectContext &projectContext) {
414-
return projectContext.buildDir() / CompilationUtils::UTBOT_BUILD_DIR_NAME;
415-
}
416411

417412
//endregion
418413

server/src/Paths.h

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,16 @@ namespace Paths {
189189

190190
//endregion
191191

192-
fs::path getUtbotBuildDir(const utbot::ProjectContext &projectContext);
192+
static inline fs::path getUTBotFiles(const utbot::ProjectContext &projectContext) {
193+
return projectContext.buildDir() / CompilationUtils::UTBOT_FILES_DIR_NAME;
194+
}
195+
196+
static inline fs::path getUTBotBuildDir(const utbot::ProjectContext &projectContext) {
197+
return getUTBotFiles(projectContext) / CompilationUtils::UTBOT_BUILD_DIR_NAME;
198+
}
193199

194200
static inline fs::path getRelativeUtbotBuildDir(const utbot::ProjectContext &projectContext) {
195-
return fs::relative(getUtbotBuildDir(projectContext), projectContext.projectPath);
201+
return fs::relative(getUTBotBuildDir(projectContext), projectContext.projectPath);
196202
}
197203

198204
//region json
@@ -218,8 +224,8 @@ namespace Paths {
218224
return getBaseLogDir() / "klee_tmp_log.txt";
219225
}
220226

221-
static inline fs::path getKleeOutDir(const fs::path &projectTmpPath) {
222-
return projectTmpPath / "klee_out";
227+
static inline fs::path getKleeOutDir(const utbot::ProjectContext &projectContext) {
228+
return getUTBotFiles(projectContext) / "klee_out";
223229
}
224230

225231
static inline bool isKtest(fs::path const &path) {
@@ -239,11 +245,9 @@ namespace Paths {
239245

240246
std::vector<fs::path> getErrorDescriptors(fs::path const &path);
241247

242-
fs::path kleeOutDirForFilePath(const utbot::ProjectContext &projectContext, const fs::path &projectTmpPath,
243-
const fs::path &filePath);
248+
fs::path kleeOutDirForFilePath(const utbot::ProjectContext &projectContext, const fs::path &filePath);
244249

245250
fs::path kleeOutDirForEntrypoints(const utbot::ProjectContext &projectContext,
246-
const fs::path &projectTmpPath,
247251
const fs::path &srcFilePath,
248252
const std::string &methodNameOrEmptyForFolder);
249253

@@ -417,10 +421,12 @@ namespace Paths {
417421

418422
//endregion
419423

420-
//region utbot-report
424+
//region utbot_report
425+
426+
const std::string UTBOT_REPORT = "utbot_report";
421427

422428
inline fs::path getUTBotReportDir(const utbot::ProjectContext &projectContext) {
423-
return projectContext.projectPath / "utbot-report";
429+
return projectContext.projectPath / UTBOT_REPORT;
424430
}
425431

426432
inline fs::path getGenerationStatsCSVPath(const utbot::ProjectContext &projectContext) {

server/src/SARIFGenerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ namespace sarif {
7676
const fs::path &srcPath = fs::path(stack_match[3]);
7777
const fs::path &relPathInProject = getInProjectPath(projectContext.projectPath, srcPath);
7878
const fs::path &fullPathInProject = projectContext.projectPath / relPathInProject;
79-
if (Paths::isSubPathOf(Paths::getUtbotBuildDir(projectContext), fullPathInProject)) {
79+
if (Paths::isSubPathOf(Paths::getUTBotBuildDir(projectContext), fullPathInProject)) {
8080
LOG_S(WARNING) << "Full path " << fullPathInProject << " is in build - skip it";
8181
continue;
8282
}

server/src/SARIFGenerator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ namespace sarif {
99
const std::string TEST_NAME_KEY = "TestName";
1010
const std::string ERROR_ID_KEY = "ErrorId";
1111

12-
const std::string SARIF_DIR_NAME = "codeAnalysis";
1312
const std::string SARIF_FILE_NAME = "project_code_analysis.sarif";
1413

1514
void sarifAddTestsToResults(const utbot::ProjectContext &projectContext,

server/src/Server.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,7 @@ Status Server::TestsGenServiceImpl::ProcessBaseTestRequest(BaseTestGen &testGen,
265265
Linker linker{testGen, stubGen, lineInfo, generator};
266266
linker.prepareArtifacts();
267267
auto testMethods = linker.getTestMethods();
268-
KleeRunner kleeRunner{testGen.projectContext, testGen.settingsContext,
269-
testGen.serverBuildDir};
268+
KleeRunner kleeRunner{testGen.projectContext, testGen.settingsContext};
270269
bool interactiveMode = (dynamic_cast<ProjectTestGen *>(&testGen) != nullptr);
271270
auto generationStartTime = std::chrono::steady_clock::now();
272271
StatsUtils::TestsGenerationStatsFileMap generationStatsMap(testGen.projectContext,
@@ -578,7 +577,7 @@ Status Server::TestsGenServiceImpl::PrintModulesContent(ServerContext *context,
578577
MEASURE_FUNCTION_EXECUTION_TIME
579578

580579
utbot::ProjectContext projectContext{*request};
581-
fs::path serverBuildDir = Paths::getUtbotBuildDir(projectContext);
580+
fs::path serverBuildDir = Paths::getUTBotBuildDir(projectContext);
582581
std::shared_ptr<ProjectBuildDatabase> buildDatabase = std::make_shared<ProjectBuildDatabase>(projectContext);
583582
StubSourcesFinder(buildDatabase).printAllModules();
584583
return Status::OK;

server/src/Synchronizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ void Synchronizer::synchronizeStubs(StubSet &outdatedStubs,
160160
stubFetcher.fetchWithProgress(testGen->progressWriter, "Finding source files required for stubs", true);
161161

162162
fs::path ccJsonStubDirPath =
163-
Paths::getUtbotBuildDir(testGen->projectContext) / "stubs_build_files";
163+
Paths::getUTBotBuildDir(testGen->projectContext) / "stubs_build_files";
164164
auto stubsCdb = createStubsCompilationDatabase(stubFiles, ccJsonStubDirPath);
165165

166166
auto sourceToHeaderRewriter =

server/src/building/ProjectBuildDatabse.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ ProjectBuildDatabase::ProjectBuildDatabase(fs::path _buildCommandsJsonPath,
5252
}
5353

5454
ProjectBuildDatabase::ProjectBuildDatabase(utbot::ProjectContext projectContext) : ProjectBuildDatabase(
55-
CompilationUtils::substituteRemotePathToCompileCommandsJsonPath(projectContext.projectPath,
56-
projectContext.buildDirRelativePath),
57-
Paths::getUtbotBuildDir(projectContext), std::move(projectContext)) {
55+
CompilationUtils::substituteRemotePathToCompileCommandsJsonPath(projectContext),
56+
Paths::getUTBotBuildDir(projectContext), std::move(projectContext)) {
5857
}
5958

6059

@@ -80,8 +79,8 @@ void ProjectBuildDatabase::initObjects(const nlohmann::json &compileCommandsJson
8079
objectInfo->command = utbot::CompileCommand(jsonArguments, directory, sourceFile);
8180
objectInfo->command.removeWerror();
8281
fs::path outputFile = objectInfo->getOutputFile();
83-
fs::path kleeFilePathTemplate =
84-
Paths::createNewDirForFile(sourceFile, projectContext.buildDir(), serverBuildDir);
82+
fs::path kleeFilePathTemplate = Paths::createNewDirForFile(sourceFile, projectContext.projectPath,
83+
Paths::getUTBotFiles(projectContext));
8584
fs::path kleeFile = Paths::addSuffix(kleeFilePathTemplate, "_klee");
8685
objectInfo->kleeFilesInfo = std::make_shared<KleeFilesInfo>(kleeFile);
8786

server/src/building/UserProjectConfiguration.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void UserProjectConfiguration::RunProjectConfigurationCommand(const fs::path &bu
122122
const ProjectConfigWriter &writer) {
123123
auto[out, status, _] = ShellExecTask::runShellCommandTask(params, buildDirPath, projectContext.projectName, true, true);
124124
if (status != 0) {
125-
auto logFilePath = LogUtils::writeLog(out, Paths::getUtbotBuildDir(projectContext), "project-import");
125+
auto logFilePath = LogUtils::writeLog(out, Paths::getUTBotBuildDir(projectContext), "project-import");
126126
std::string message = StringUtils::stringFormat(
127127
"Running command \"%s\" failed. See more info in logs.", params.toString());
128128
throw std::runtime_error(message);

0 commit comments

Comments
 (0)