From 84a35fe7a05126d71bad2255758afe0f969d4691 Mon Sep 17 00:00:00 2001 From: Vladislav Kalugin Date: Thu, 28 Mar 2024 16:48:51 +0300 Subject: [PATCH] Name refactoring --- .../plugin/grpc/GrpcRequestBuilderFactory.kt | 2 +- .../plugin/grpc/GrpcRequestBuildersImpl.kt | 4 +- .../settings/UTBotAllProjectSettings.kt | 8 +- .../plugin/settings/UTBotConfigurable.kt | 2 +- .../settings/UTBotProjectStoredSettings.kt | 10 +- .../ui/wizard/steps/BuildOptionsStep.kt | 2 +- .../buildingRequestsTests/BaseBuildingTest.kt | 8 +- .../BaseGenerationTestCase.kt | 4 +- server/proto/testgen.proto | 9 +- server/src/KleeRunner.cpp | 2 +- server/src/Paths.cpp | 119 +++++----- server/src/Paths.h | 25 ++- server/src/ProjectContext.cpp | 53 +++-- server/src/ProjectContext.h | 57 +++-- server/src/Server.cpp | 11 +- server/src/Synchronizer.cpp | 2 +- server/src/building/BuildDatabase.cpp | 2 +- server/src/commands/Commands.cpp | 6 +- server/src/commands/Commands.h | 4 +- server/src/coverage/TestRunner.cpp | 14 +- server/src/printers/NativeMakefilePrinter.cpp | 4 +- server/src/streams/stubs/CLIStubsWriter.cpp | 4 +- server/src/streams/stubs/CLIStubsWriter.h | 2 +- .../src/streams/stubs/ServerStubsWriter.cpp | 4 +- server/src/streams/stubs/ServerStubsWriter.h | 2 +- server/src/streams/stubs/StubsWriter.cpp | 2 +- server/src/streams/stubs/StubsWriter.h | 4 +- server/src/streams/tests/CLITestsWriter.cpp | 8 +- server/src/streams/tests/CLITestsWriter.h | 4 +- .../src/streams/tests/ServerTestsWriter.cpp | 8 +- server/src/streams/tests/ServerTestsWriter.h | 4 +- server/src/streams/tests/TestsWriter.h | 2 +- server/src/testgens/ProjectTestGen.cpp | 2 +- server/src/utils/CLIUtils.cpp | 2 +- server/src/utils/CompilationUtils.cpp | 2 +- server/src/utils/GrpcUtils.cpp | 16 +- server/src/utils/GrpcUtils.h | 6 +- server/test/framework/BaseTest.cpp | 4 +- server/test/framework/BaseTest.h | 4 +- server/test/framework/KleeGen_Tests.cpp | 4 +- server/test/framework/Library_Test.cpp | 2 +- server/test/framework/Regression_Tests.cpp | 6 +- server/test/framework/Server_Tests.cpp | 203 +++++++++--------- server/test/framework/Stub_Tests.cpp | 44 ++-- server/test/framework/Syntax_Tests.cpp | 2 +- server/test/framework/Targets_Test.cpp | 18 +- server/test/framework/TestUtils.cpp | 30 +-- server/test/framework/TestUtils.h | 20 +- vscode-plugin/src/client/client.ts | 20 +- vscode-plugin/src/config/prefs.ts | 25 +-- vscode-plugin/src/config/projectConfig.ts | 12 +- vscode-plugin/src/requests/params.ts | 6 +- vscode-plugin/src/requests/protos.ts | 10 +- 53 files changed, 436 insertions(+), 394 deletions(-) diff --git a/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/grpc/GrpcRequestBuilderFactory.kt b/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/grpc/GrpcRequestBuilderFactory.kt index a28da1301..4399b27f7 100644 --- a/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/grpc/GrpcRequestBuilderFactory.kt +++ b/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/grpc/GrpcRequestBuilderFactory.kt @@ -21,7 +21,7 @@ class GrpcRequestBuilderFactory( project.name, project.path, project.settings.storedSettings.testDirRelativePath, - project.settings.storedSettings.buildDirRelativePath + project.settings.storedSettings.buildDirRelPath ) } diff --git a/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/grpc/GrpcRequestBuildersImpl.kt b/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/grpc/GrpcRequestBuildersImpl.kt index 4e2c68fef..577cc3ee6 100644 --- a/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/grpc/GrpcRequestBuildersImpl.kt +++ b/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/grpc/GrpcRequestBuildersImpl.kt @@ -12,7 +12,7 @@ internal data class ProjectContextBuilder( val projectName: String, val projectPath: String, val testDirRelativePath: String, - val buildDirRelativePath: String + val buildDirRelPath: String ) : GrpcRequestBuilder { override fun build(remoteMapping: RemoteMapping): Testgen.ProjectContext { val projectNioPath = Paths.get(projectPath) // project path is not set by user, assuming it is valid @@ -29,7 +29,7 @@ internal data class ProjectContextBuilder( UTBot.message("settings.project.testsDir.wrong") ) ) - .setBuildDirRelativePath(buildDirRelativePath) + .setBuildDirRelPath(buildDirRelPath) .setProjectName(projectName) .setProjectPath(remoteMapping.convertToRemote(projectPath, UTBot.message("projectPath.wrong.conversion"))) .build() diff --git a/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/settings/UTBotAllProjectSettings.kt b/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/settings/UTBotAllProjectSettings.kt index f348a000c..14986f9f3 100644 --- a/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/settings/UTBotAllProjectSettings.kt +++ b/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/settings/UTBotAllProjectSettings.kt @@ -24,15 +24,15 @@ class UTBotAllProjectSettings(val project: Project) { val buildDirPath: Path get() { try { - return Paths.get(project.path).resolve(storedSettings.buildDirRelativePath) + return Paths.get(project.path).resolve(storedSettings.buildDirRelPath) } catch (e: InvalidPathException) { throw IllegalPathException( UTBot.message( "paths.invalid", "relative path to build dir", - storedSettings.buildDirRelativePath + storedSettings.buildDirRelPath ), - storedSettings.buildDirRelativePath + storedSettings.buildDirRelPath ) } } @@ -82,7 +82,7 @@ class UTBotAllProjectSettings(val project: Project) { fun predictPaths() { storedSettings.remotePath = UTBotProjectStoredSettings.REMOTE_PATH_VALUE_FOR_LOCAL_SCENARIO - storedSettings.buildDirRelativePath = UTBotProjectStoredSettings.DEFAULT_RELATIVE_PATH_TO_BUILD_DIR + storedSettings.buildDirRelPath = UTBotProjectStoredSettings.DEFAULT_RELATIVE_PATH_TO_BUILD_DIR storedSettings.targetPath = UTBotTarget.autoTarget.path } diff --git a/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/settings/UTBotConfigurable.kt b/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/settings/UTBotConfigurable.kt index 78359062a..6fa90b079 100644 --- a/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/settings/UTBotConfigurable.kt +++ b/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/settings/UTBotConfigurable.kt @@ -135,7 +135,7 @@ class UTBotConfigurable(private val myProject: Project) : BoundConfigurable( private fun Panel.createPathsSettings() { row(UTBot.message("settings.project.buildDir")) { - textField().bindText(settings::buildDirRelativePath).columns(COLUMNS_LARGE) + textField().bindText(settings::buildDirRelPath).columns(COLUMNS_LARGE) .validateInput(ValidationCondition(UTBot.message("validation.not.empty")) { it.text.stripLeadingSlashes().isNotEmpty() }) diff --git a/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/settings/UTBotProjectStoredSettings.kt b/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/settings/UTBotProjectStoredSettings.kt index ca2c9e596..9cbf1df52 100644 --- a/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/settings/UTBotProjectStoredSettings.kt +++ b/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/settings/UTBotProjectStoredSettings.kt @@ -29,7 +29,7 @@ class UTBotProjectStoredSettings(val project: Project) : PersistentStateComponen // serialized by the ide data class State( - var buildDirRelativePath: String = DEFAULT_RELATIVE_PATH_TO_BUILD_DIR, + var buildDirRelPath: String = DEFAULT_RELATIVE_PATH_TO_BUILD_DIR, var testsDirRelativePath: String = DEFAULT_TESTS_DIR_RELATIVE_PATH, var targetPath: String = UTBotTarget.autoTarget.path, var remotePath: String = REMOTE_PATH_VALUE_FOR_LOCAL_SCENARIO, @@ -44,7 +44,7 @@ class UTBotProjectStoredSettings(val project: Project) : PersistentStateComponen var isPluginEnabled: Boolean = false ) { fun fromSettingsModel(model: UTBotSettingsModel) { - buildDirRelativePath = model.projectSettings.buildDirRelativePath + buildDirRelPath = model.projectSettings.buildDirRelPath testsDirRelativePath = model.projectSettings.testsDirRelativePath targetPath = model.projectSettings.targetPath remotePath = model.projectSettings.remotePath @@ -129,10 +129,10 @@ class UTBotProjectStoredSettings(val project: Project) : PersistentStateComponen else Paths.get(project.path).relativize(Paths.get(targetPath)).toString() - var buildDirRelativePath: String - get() = myState.buildDirRelativePath.stripLeadingSlashes() + var buildDirRelPath: String + get() = myState.buildDirRelPath.stripLeadingSlashes() set(value) { - myState.buildDirRelativePath = value + myState.buildDirRelPath = value } var isPluginEnabled: Boolean diff --git a/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/ui/wizard/steps/BuildOptionsStep.kt b/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/ui/wizard/steps/BuildOptionsStep.kt index 205429089..6f9dd087d 100644 --- a/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/ui/wizard/steps/BuildOptionsStep.kt +++ b/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/ui/wizard/steps/BuildOptionsStep.kt @@ -18,7 +18,7 @@ class BuildOptionsStep(parentDisposable: Disposable, private val settingsModel: addHtml("media/options_wizard_text.html") panel { row("Relative path to Build directory") { - textField().bindText(settingsModel.projectSettings::buildDirRelativePath).columns(COLUMNS_LARGE) + textField().bindText(settingsModel.projectSettings::buildDirRelPath).columns(COLUMNS_LARGE) .validateWith(ValidationCondition(UTBot.message("validation.not.empty")) { it.text.isNotEmpty() }) } diff --git a/clion-plugin/src/test/kotlin/org/utbot/cpp/clion/plugin/tests/buildingRequestsTests/BaseBuildingTest.kt b/clion-plugin/src/test/kotlin/org/utbot/cpp/clion/plugin/tests/buildingRequestsTests/BaseBuildingTest.kt index 2883face7..9985d0886 100644 --- a/clion-plugin/src/test/kotlin/org/utbot/cpp/clion/plugin/tests/buildingRequestsTests/BaseBuildingTest.kt +++ b/clion-plugin/src/test/kotlin/org/utbot/cpp/clion/plugin/tests/buildingRequestsTests/BaseBuildingTest.kt @@ -26,14 +26,14 @@ open class BaseBuildingTest { Paths.get(File(".").canonicalPath).resolve("../integration-tests/c-example-mini").normalize() protected val testsDirRelativePath = "cl-plugin-test-tests" protected val testsDirectoryPath: Path = projectPath.resolve(testsDirRelativePath) - protected val buildDirRelativePath = "build" + protected val buildDirRelPath = "build" protected val fixture: CodeInsightTestFixture = createFixture(projectPath) protected val project: Project get() = fixture.project val settings = project.settings.storedSettings init { - settings.buildDirRelativePath = buildDirRelativePath + settings.buildDirRelPath = buildDirRelPath settings.testDirRelativePath = projectPath.relativize(testsDirectoryPath).toString() settings.isPluginEnabled = true project.logger.logWriters.let { @@ -56,7 +56,7 @@ open class BaseBuildingTest { projectName = project.name testDirPath = if (isRemote) "$remotePath/$testsDirRelativePath" else this@BaseBuildingTest.testsDirectoryPath.toString() - buildDirRelativePath = this@BaseBuildingTest.buildDirRelativePath + buildDirRelPath = this@BaseBuildingTest.buildDirRelPath }.build() } @@ -89,4 +89,4 @@ open class BaseBuildingTest { return event } -} \ No newline at end of file +} diff --git a/clion-plugin/src/test/kotlin/org/utbot/cpp/clion/plugin/tests/integrationTests/BaseGenerationTestCase.kt b/clion-plugin/src/test/kotlin/org/utbot/cpp/clion/plugin/tests/integrationTests/BaseGenerationTestCase.kt index 3db3cee0a..a5bea2c2c 100644 --- a/clion-plugin/src/test/kotlin/org/utbot/cpp/clion/plugin/tests/integrationTests/BaseGenerationTestCase.kt +++ b/clion-plugin/src/test/kotlin/org/utbot/cpp/clion/plugin/tests/integrationTests/BaseGenerationTestCase.kt @@ -41,7 +41,7 @@ abstract class BaseGenerationTestCase { get() = project.client init { - project.settings.storedSettings.buildDirRelativePath = buildDirName + project.settings.storedSettings.buildDirRelPath = buildDirName project.settings.storedSettings.testDirRelativePath = projectPath.relativize(testsDirectoryPath).toString() project.settings.storedSettings.isPluginEnabled = true project.logger.logWriters.let { @@ -102,4 +102,4 @@ abstract class BaseGenerationTestCase { fixture.tearDown() Logger.info("tearDownAll of BaseGenerationTest has finished!") } -} \ No newline at end of file +} diff --git a/server/proto/testgen.proto b/server/proto/testgen.proto index de9554456..e70d3f30b 100644 --- a/server/proto/testgen.proto +++ b/server/proto/testgen.proto @@ -86,10 +86,11 @@ message LogEntry { message ProjectContext { string projectName = 1; string projectPath = 2; - string testDirPath = 3; - string buildDirRelativePath = 4; - string clientProjectPath = 5; - string itfPath = 6; + string clientProjectPath = 3; + string testDirRelPath = 4; + string reportDirRelPath = 5; + string buildDirRelPath = 6; + string itfRelPath = 7; } enum ErrorMode { diff --git a/server/src/KleeRunner.cpp b/server/src/KleeRunner.cpp index f2da7d8b7..1d78cf564 100644 --- a/server/src/KleeRunner.cpp +++ b/server/src/KleeRunner.cpp @@ -122,7 +122,7 @@ void KleeRunner::runKlee(const std::vector &testMethods, testsWriter->writeTestsWithProgress( testsMap, "Running klee", - projectContext.testDirPath, + projectContext.getTestDirAbsPath(), std::move(prepareTests), std::move(prepareTotal)); } diff --git a/server/src/Paths.cpp b/server/src/Paths.cpp index f698fb23b..d77e9e548 100644 --- a/server/src/Paths.cpp +++ b/server/src/Paths.cpp @@ -29,17 +29,17 @@ namespace Paths { const std::vector &dirPaths, const std::function &filter) { CollectionUtils::FileSet filtered = - CollectionUtils::filterOut(paths, [&dirPaths, &filter](const fs::path &path) { - return !std::any_of(dirPaths.begin(), dirPaths.end(), [&](const fs::path &dirPath) { - return isSubPathOf(dirPath, path) && fs::exists(path) && filter(path); + CollectionUtils::filterOut(paths, [&dirPaths, &filter](const fs::path &path) { + return !std::any_of(dirPaths.begin(), dirPaths.end(), [&](const fs::path &dirPath) { + return isSubPathOf(dirPath, path) && fs::exists(path) && filter(path); + }); }); - }); return filtered; } CollectionUtils::FileSet pathsToSet(const std::vector &paths) { CollectionUtils::FileSet pathSet; - for (const auto &p : paths) { + for (const auto &p: paths) { pathSet.insert(p); } return pathSet; @@ -57,8 +57,8 @@ namespace Paths { } auto const &[mismatchA, mismatchB] = std::mismatch(a.begin(), a.end(), b.begin(), b.end()); fs::path result = - std::accumulate(a.begin(), mismatchA, fs::path{}, - [](fs::path const &a, fs::path const &b) { return a / b; }); + std::accumulate(a.begin(), mismatchA, fs::path{}, + [](fs::path const &a, fs::path const &b) { return a / b; }); return result; } @@ -68,7 +68,7 @@ namespace Paths { return {}; } CollectionUtils::FileSet moduleFiles; - for (const auto &entry : fs::recursive_directory_iterator(folder)) { + for (const auto &entry: fs::recursive_directory_iterator(folder)) { if (entry.is_regular_file()) { moduleFiles.insert(entry.path()); } @@ -78,7 +78,7 @@ namespace Paths { std::vector findFilesInFolder(const fs::path &folder, const CollectionUtils::FileSet &sourcePaths) { std::vector moduleFiles; - for (const auto &entry : fs::recursive_directory_iterator(folder)) { + for (const auto &entry: fs::recursive_directory_iterator(folder)) { if (entry.is_regular_file() && CollectionUtils::contains(sourcePaths, entry.path())) { moduleFiles.push_back(entry.path()); } @@ -86,7 +86,7 @@ namespace Paths { return moduleFiles; } - std::string mangle(const fs::path& path) { + std::string mangle(const fs::path &path) { std::string result = path.string(); StringUtils::replaceAll(result, '.', '_'); StringUtils::replaceAll(result, '/', '_'); @@ -94,7 +94,7 @@ namespace Paths { return result; } - std::string mangleExtensions(const fs::path& path) { + std::string mangleExtensions(const fs::path &path) { if (!path.has_extension()) { return path.string(); } @@ -129,19 +129,19 @@ namespace Paths { //region klee - static fs::path errorFile(const fs::path &path, std::string const& suffix) { + static fs::path errorFile(const fs::path &path, std::string const &suffix) { return replaceExtension(path, StringUtils::stringFormat(".%s.err", suffix)); } - bool errorFileExists(const fs::path &path, std::string const& suffix) { + bool errorFileExists(const fs::path &path, std::string const &suffix) { return fs::exists(errorFile(path, suffix)); } bool hasInternalError(const fs::path &path) { static const auto internalErrorSuffixes = { - "exec", - "external", - "xxx" + "exec", + "external", + "xxx" }; return std::any_of(internalErrorSuffixes.begin(), internalErrorSuffixes.end(), [&path](auto const &suffix) { return errorFileExists(path, suffix); }); @@ -149,21 +149,21 @@ namespace Paths { std::vector getErrorDescriptors(const fs::path &path) { static const auto internalErrorSuffixes = { - "abort", - "assert", - "bad_vector_access", - "free", - "overflow", - "undefined_behavior", - "ptr", - "readonly", - "reporterror", - "uncaught_exception", - "unexpected_exception" + "abort", + "assert", + "bad_vector_access", + "free", + "overflow", + "undefined_behavior", + "ptr", + "readonly", + "reporterror", + "uncaught_exception", + "unexpected_exception" }; std::vector errFiles; - for (const auto &suffix : internalErrorSuffixes) { + for (const auto &suffix: internalErrorSuffixes) { if (errorFileExists(path, suffix)) { errFiles.emplace_back(errorFile(path, suffix)); } @@ -192,14 +192,14 @@ namespace Paths { //region extensions utbot::Language getSourceLanguage(const fs::path &path) { - if(isHFile(path)) { + if (isHFile(path)) { LOG_S(WARNING) << "C language detected by .h file: " << path.string(); return utbot::Language::C; } - if(isCFile(path)) { + if (isCFile(path)) { return utbot::Language::C; } - if(isCXXFile(path) || isHppFile(path)) { + if (isCXXFile(path) || isHppFile(path)) { return utbot::Language::CXX; } LOG_S(WARNING) << "Unknown source language of " << path.string(); @@ -214,26 +214,36 @@ namespace Paths { } fs::path getArtifactsRootDir(const utbot::ProjectContext &projectContext) { - return projectContext.buildDir() / "utbot"; + return projectContext.getBuildDirAbsPath() / "utbot"; } + fs::path getGTestResultsJsonPath(const utbot::ProjectContext &projectContext) { return getArtifactsRootDir(projectContext) / "gtest-results.json"; } + fs::path getFlagsDir(const utbot::ProjectContext &projectContext) { return getArtifactsRootDir(projectContext) / "flags"; } + fs::path getTestExecDir(const utbot::ProjectContext &projectContext) { return getArtifactsRootDir(projectContext) / "tests"; } + fs::path getMakefileDir(const utbot::ProjectContext &projectContext, const fs::path &sourceFilePath) { - return projectContext.testDirPath / "makefiles" / getRelativeDirPath(projectContext, sourceFilePath); + return projectContext.getTestDirAbsPath() / "makefiles" / getRelativeDirPath(projectContext, sourceFilePath); } + fs::path getGeneratedHeaderDir(const utbot::ProjectContext &projectContext, const fs::path &sourceFilePath) { return getPathDirRelativeToTestDir(projectContext, sourceFilePath); } fs::path getPathDirRelativeToTestDir(const utbot::ProjectContext &projectContext, const fs::path &sourceFilePath) { - return projectContext.testDirPath / getRelativeDirPath(projectContext, sourceFilePath); + return projectContext.getTestDirAbsPath() / getRelativeDirPath(projectContext, sourceFilePath); + } + + fs::path getPathDirRelativeToReportDir(const utbot::ProjectContext &projectContext, + const fs::path &sourceFilePath) { + return projectContext.getReportDirAbsPath() / getRelativeDirPath(projectContext, sourceFilePath); } fs::path getPathDirRelativeToBuildDir(const utbot::ProjectContext &projectContext, @@ -244,26 +254,33 @@ namespace Paths { fs::path getRecompiledDir(const utbot::ProjectContext &projectContext) { return getUTBotBuildDir(projectContext) / "recompiled"; } + fs::path getTestObjectDir(const utbot::ProjectContext &projectContext) { return getUTBotBuildDir(projectContext) / "test_objects"; } + fs::path getCoverageDir(const utbot::ProjectContext &projectContext) { return getUTBotBuildDir(projectContext) / "coverage"; } + fs::path getClangCoverageDir(const utbot::ProjectContext &projectContext) { return getCoverageDir(projectContext) / "lcov"; } + fs::path getGccCoverageDir(const utbot::ProjectContext &projectContext) { return getCoverageDir(projectContext) / "gcov"; } + fs::path getTestExecutable(const utbot::ProjectContext &projectContext, - const fs::path &filePath) { + const fs::path &filePath) { return getTestExecDir(projectContext) / filePath.stem(); } + fs::path getGeneratedHeaderPath(const utbot::ProjectContext &projectContext, const fs::path &sourceFilePath) { auto headerDir = getGeneratedHeaderDir(projectContext, sourceFilePath); return headerDir / replaceExtension(Paths::sourcePathToTestName(sourceFilePath), ".h"); } + fs::path getRecompiledFile(const utbot::ProjectContext &projectContext, const fs::path &filePath) { fs::path newFilename; @@ -271,16 +288,19 @@ namespace Paths { newFilename = fs::relative(filePath, projectContext.projectPath); newFilename = addExtension(newFilename, ".o"); } else { - newFilename = fs::relative(filePath, projectContext.buildDir()); + newFilename = fs::relative(filePath, projectContext.getBuildDirAbsPath()); } return getRecompiledDir(projectContext) / newFilename; } + fs::path getProfrawFilePath(const utbot::ProjectContext &projectContext, const std::string &testName) { return getClangCoverageDir(projectContext) / addExtension(testName, ".profraw"); } + fs::path getMainProfdataPath(const utbot::ProjectContext &projectContext) { return getClangCoverageDir(projectContext) / "main.profdata"; } + fs::path getCoverageJsonPath(const utbot::ProjectContext &projectContext) { return getClangCoverageDir(projectContext) / "coverage.json"; } @@ -306,7 +326,7 @@ namespace Paths { } fs::path getWrapperDirPath(const utbot::ProjectContext &projectContext) { - return projectContext.testDirPath / "wrapper"; + return projectContext.getTestDirAbsPath() / "wrapper"; } fs::path getWrapperFilePath(const utbot::ProjectContext &projectContext, @@ -323,7 +343,7 @@ namespace Paths { fs::path sourcePathToTestPath(const utbot::ProjectContext &projectContext, const fs::path &sourceFilePath) { - return projectContext.testDirPath / getRelativeDirPath(projectContext, sourceFilePath) / + return projectContext.getTestDirAbsPath() / getRelativeDirPath(projectContext, sourceFilePath) / sourcePathToTestName(sourceFilePath); } @@ -331,18 +351,21 @@ namespace Paths { return addSuffix(addOrigExtensionAsSuffixAndAddNew(source, ".cpp"), TEST_SUFFIX).filename(); } + fs::path testPathToSourceName(const fs::path &testFilePath) { return restoreExtensionFromSuffix(removeSuffix(testFilePath, TEST_SUFFIX), ".c").filename(); } + fs::path sourcePathToStubName(const fs::path &source) { return addSuffix(source, STUB_SUFFIX).filename(); } + fs::path getStubBitcodeFilePath(const fs::path &bitcodeFilePath) { return Paths::addSuffix(bitcodeFilePath, STUB_SUFFIX); } fs::path sourcePathToStubHeaderPath(const utbot::ProjectContext &projectContext, - const fs::path &source) { + const fs::path &source) { return replaceExtension(sourcePathToStubPath(projectContext, source), ".h"); } @@ -352,13 +375,13 @@ namespace Paths { fs::path sourcePathToStubPath(const utbot::ProjectContext &projectContext, const fs::path &source) { - return normalizedTrimmed((projectContext.testDirPath / "stubs" / getRelativeDirPath(projectContext, source) / - sourcePathToStubName(source))); + return normalizedTrimmed((projectContext.getTestDirAbsPath() / "stubs" / getRelativeDirPath(projectContext, source) / + sourcePathToStubName(source))); } fs::path testPathToSourcePath(const utbot::ProjectContext &projectContext, const fs::path &testFilePath) { - fs::path relative = fs::relative(testFilePath.parent_path(), projectContext.testDirPath); + fs::path relative = fs::relative(testFilePath.parent_path(), projectContext.getTestDirAbsPath()); fs::path filename = testPathToSourceName(testFilePath); return projectContext.projectPath / relative / filename; } @@ -378,13 +401,13 @@ namespace Paths { const fs::path &sourceFilePath) { fs::path makefileDir = getMakefileDir(projectContext, sourceFilePath); std::string makefileName = - addExtension(addSuffix(sourceFilePath.stem(), STUB_SUFFIX), MAKEFILE_EXTENSION); + addExtension(addSuffix(sourceFilePath.stem(), STUB_SUFFIX), MAKEFILE_EXTENSION); return makefileDir / makefileName; } std::optional headerPathToSourcePath(const fs::path &source) { if (Paths::isHeaderFile(source)) { - for (const std::string &extension : CXXFileExtensions) { + for (const std::string &extension: CXXFileExtensions) { fs::path sourceFilePath = replaceExtension(source, extension); if (fs::exists(sourceFilePath)) { return {sourceFilePath}; @@ -401,8 +424,8 @@ namespace Paths { } std::optional getRelativePathWithShellVariable(const fs::path &shellVariableForBase, - const std::string &base, - const std::string &source) { + const std::string &base, + const std::string &source) { std::string returnPath = source; if (StringUtils::startsWith(source, base)) { StringUtils::replaceFirst(returnPath, base, shellVariableForBase.string()); @@ -415,8 +438,8 @@ namespace Paths { fs::path stubPathToSourcePath(const utbot::ProjectContext &projectContext, const fs::path &stubPath) { fs::path sourceFilePath = - projectContext.projectPath / - fs::relative(stubPath, getStubsDirPath(projectContext)); + projectContext.projectPath / + fs::relative(stubPath, getStubsDirPath(projectContext)); return removeSuffix(sourceFilePath, STUB_SUFFIX); } diff --git a/server/src/Paths.h b/server/src/Paths.h index c83fcd428..d3724824f 100644 --- a/server/src/Paths.h +++ b/server/src/Paths.h @@ -43,7 +43,7 @@ namespace Paths { const std::vector &dirNames, const std::function &filter); - bool errorFileExists(const fs::path &path, std::string const& suffix); + bool errorFileExists(const fs::path &path, std::string const &suffix); static inline void setOptPath(fs::path &path, const std::string &value) { path = fs::path(value); @@ -120,9 +120,9 @@ namespace Paths { std::vector findFilesInFolder(const fs::path &folder, const CollectionUtils::FileSet &sourcePaths); - std::string mangle(const fs::path& path); + std::string mangle(const fs::path &path); - std::string mangleExtensions(const fs::path& path); + std::string mangleExtensions(const fs::path &path); static inline fs::path addOrigExtensionAsSuffixAndAddNew(const fs::path &path, const std::string &newExt) { @@ -143,8 +143,7 @@ namespace Paths { if (posEncodedExtension == std::string::npos) { // In `sample_class_test.cpp` the `class` is not an extension fnWithExt = fnWithoutExt + defaultExt; - } - else { + } else { // In `sample_class_dot_cpp.cpp` the `cpp` is an extension fnWithExt = fnWithoutExt.substr(0, posEncodedExtension) + dot @@ -197,7 +196,7 @@ namespace Paths { //endregion static inline fs::path getUTBotFiles(const utbot::ProjectContext &projectContext) { - return projectContext.buildDir() / CompilationUtils::UTBOT_FILES_DIR_NAME; + return projectContext.getBuildDirAbsPath() / CompilationUtils::UTBOT_FILES_DIR_NAME; } static inline fs::path getUTBotBuildDir(const utbot::ProjectContext &projectContext) { @@ -341,6 +340,9 @@ namespace Paths { fs::path getPathDirRelativeToTestDir(const utbot::ProjectContext &projectContext, const fs::path &sourceFilePath); + fs::path getPathDirRelativeToReportDir(const utbot::ProjectContext &projectContext, + const fs::path &sourceFilePath); + fs::path getPathDirRelativeToBuildDir(const utbot::ProjectContext &projectContext, const fs::path &sourceFilePath); @@ -405,8 +407,8 @@ namespace Paths { fs::path getRelativeDirPath(const utbot::ProjectContext &projectContext, const fs::path &source); std::optional getRelativePathWithShellVariable(const fs::path &shellVariableForBase, - const std::string &base, - const std::string &source); + const std::string &base, + const std::string &source); fs::path getMakefilePathFromSourceFilePath(const utbot::ProjectContext &projectContext, const fs::path &sourceFilePath, @@ -419,11 +421,7 @@ namespace Paths { //region stubs static inline fs::path getStubsDirPath(const utbot::ProjectContext &projectContext) { - return projectContext.testDirPath / "stubs"; - } - - static inline fs::path getStubsRelativeDirPath(const fs::path &relativeTestDirPath) { - return "stubs" / relativeTestDirPath; + return projectContext.getTestDirAbsPath() / "stubs"; } bool hasUncaughtException(const fs::path &path); @@ -440,6 +438,7 @@ namespace Paths { inline fs::path getGenerationStatsCSVPath(const utbot::ProjectContext &projectContext) { return getUTBotReportDir(projectContext) / "generation-stats.csv"; } + inline fs::path getExecutionStatsCSVPath(const utbot::ProjectContext &projectContext) { return getUTBotReportDir(projectContext) / "execution-stats.csv"; } diff --git a/server/src/ProjectContext.cpp b/server/src/ProjectContext.cpp index b9514b678..5b34e4bde 100644 --- a/server/src/ProjectContext.cpp +++ b/server/src/ProjectContext.cpp @@ -7,32 +7,55 @@ namespace utbot { ProjectContext::ProjectContext(std::string projectName, fs::path projectPath, - fs::path testDirPath, - fs::path buildDirRelativePath, fs::path clientProjectPath, - fs::path itfPath) - : projectName(std::move(projectName)), projectPath(std::move(projectPath)), - testDirPath(std::move(testDirPath)), - buildDirRelativePath(std::move(buildDirRelativePath)), + fs::path testDirRelPath, + fs::path reportDirRelPath, + fs::path buildDirRelPath, + fs::path itfRelPath) + : projectName(std::move(projectName)), clientProjectPath(std::move(clientProjectPath)), - itfPath(std::move(itfPath)) { + projectPath(std::move(projectPath)), + testDirRelPath(std::move(testDirRelPath)), + reportDirRelPath(std::move(reportDirRelPath)), + buildDirRelPath(std::move(buildDirRelPath)), + itfRelPath(std::move(itfRelPath)) { } ProjectContext::ProjectContext(const testsgen::ProjectContext &projectContext) : ProjectContext(projectContext.projectname(), projectContext.projectpath(), - projectContext.testdirpath(), - projectContext.builddirrelativepath(), projectContext.clientprojectpath(), - projectContext.itfpath()) {} + projectContext.testdirrelpath(), + projectContext.reportdirrelpath(), + projectContext.builddirrelpath(), + projectContext.itfrelpath()) {} ProjectContext::ProjectContext(const testsgen::SnippetRequest &request, fs::path serverBuildDir) - : ProjectContext(request.projectcontext().projectname(), request.projectcontext().projectpath(), - request.projectcontext().testdirpath(), request.projectcontext().builddirrelativepath(), + : ProjectContext(request.projectcontext().projectname(), + request.projectcontext().projectpath(), request.projectcontext().clientprojectpath(), - request.projectcontext().itfpath()) {} + request.projectcontext().testdirrelpath(), + request.projectcontext().reportdirrelpath(), + request.projectcontext().builddirrelpath(), + request.projectcontext().itfrelpath()) {} - fs::path ProjectContext::buildDir() const { - return projectPath / buildDirRelativePath; + fs::path ProjectContext::getTestDirAbsPath() const { + return projectPath / testDirRelPath; + } + + fs::path ProjectContext::getReportDirAbsPath() const { + return projectPath / reportDirRelPath; + } + + fs::path ProjectContext::getBuildDirAbsPath() const { + return projectPath / buildDirRelPath; + } + + bool ProjectContext::hasItfPath() const { + return !itfRelPath.string().empty(); + } + + fs::path ProjectContext::getItfAbsPath() const { + return projectPath / itfRelPath; } } diff --git a/server/src/ProjectContext.h b/server/src/ProjectContext.h index 2f3cc7d85..699262d56 100644 --- a/server/src/ProjectContext.h +++ b/server/src/ProjectContext.h @@ -7,32 +7,45 @@ namespace testsgen { class ProjectContext; + class SnippetRequest; } namespace utbot { -class ProjectContext { -public: - ProjectContext(std::string projectName, - fs::path projectPath, - fs::path testDirPath, - fs::path buildDirRelativePath, - fs::path serverBuildDir, - fs::path itfPath); - - explicit ProjectContext(const testsgen::ProjectContext &projectContext); - - ProjectContext(const testsgen::SnippetRequest &request, fs::path serverBuildDir); - - [[nodiscard]] fs::path buildDir() const; - - const std::string projectName; - const fs::path projectPath; - const fs::path testDirPath; - const fs::path buildDirRelativePath; - const fs::path clientProjectPath; - const fs::path itfPath; -}; + class ProjectContext { + public: + ProjectContext(std::string projectName, + fs::path projectPath, + fs::path clientProjectPath, + fs::path testDirRelPath, + fs::path reportDirRelPath, + fs::path buildDirRelPath, + fs::path itfRelPath); + + explicit ProjectContext(const testsgen::ProjectContext &projectContext); + + ProjectContext(const testsgen::SnippetRequest &request, fs::path serverBuildDir); + + [[nodiscard]] fs::path getTestDirAbsPath() const; + + [[nodiscard]] fs::path getReportDirAbsPath() const; + + [[nodiscard]] fs::path getBuildDirAbsPath() const; + + [[nodiscard]] bool hasItfPath() const; + + [[nodiscard]] fs::path getItfAbsPath() const; + + const std::string projectName; + const fs::path projectPath; + const fs::path clientProjectPath; + + private: + const fs::path testDirRelPath; + const fs::path reportDirRelPath; + const fs::path buildDirRelPath; + const fs::path itfRelPath; + }; } diff --git a/server/src/Server.cpp b/server/src/Server.cpp index 51b6867d7..d712d75f9 100644 --- a/server/src/Server.cpp +++ b/server/src/Server.cpp @@ -238,10 +238,9 @@ Status Server::TestsGenServiceImpl::ProcessBaseTestRequest(BaseTestGen &testGen, FeaturesFilter::filter(testGen.settingsContext, typesHandler, testGen.tests); StubsCollector(typesHandler).collect(testGen.tests); - if (!testGen.projectContext.itfPath.string().empty()) { + if (testGen.projectContext.hasItfPath()) { try { - fs::path fullFilePath = Paths::getFileFullPath(testGen.projectContext.itfPath, - testGen.projectContext.projectPath); + fs::path fullFilePath = testGen.projectContext.getItfAbsPath(); if (!fs::exists(fullFilePath)) { std::string message = "File with init and teardown functions, doesn't exists"; LOG_S(ERROR) << message; @@ -611,7 +610,7 @@ Status Server::TestsGenServiceImpl::ProcessProjectStubsRequest(BaseTestGen *test Synchronizer synchronizer(testGen, &sizeContext); synchronizer.synchronize(typesHandler); } - stubsWriter->writeResponse(testGen->synchronizedStubs, testGen->projectContext.testDirPath); + stubsWriter->writeResponse(testGen->synchronizedStubs, testGen->projectContext.getTestDirAbsPath()); return Status::OK; } @@ -671,12 +670,10 @@ Server::TestsGenServiceImpl::ConfigureProject(ServerContext *context, MEASURE_FUNCTION_EXECUTION_TIME - LOG_S(ERROR) << "ITF request path: " << request->projectcontext().itfpath(); utbot::ProjectContext utbotProjectContext{request->projectcontext()}; - LOG_S(ERROR) << "ITF request2 path: " << utbotProjectContext.itfPath; fs::path buildDirPath = - fs::path(utbotProjectContext.projectPath) / utbotProjectContext.buildDirRelativePath; + fs::path(utbotProjectContext.projectPath) / utbotProjectContext.getTestDirAbsPath(); switch (request->configmode()) { case ConfigMode::CHECK: return UserProjectConfiguration::CheckProjectConfiguration(buildDirPath, writer); diff --git a/server/src/Synchronizer.cpp b/server/src/Synchronizer.cpp index 0c611fc90..2d64479d5 100644 --- a/server/src/Synchronizer.cpp +++ b/server/src/Synchronizer.cpp @@ -211,7 +211,7 @@ void Synchronizer::synchronizeStubs(StubSet &outdatedStubs, testGen->synchronizedStubs.emplace_back(stubFile); } } - StubsWriter::writeStubsFilesOnServer(testGen->synchronizedStubs, testGen->projectContext.testDirPath); + StubsWriter::writeStubsFilesOnServer(testGen->synchronizedStubs, testGen->projectContext.getTestDirAbsPath()); } std::shared_ptr diff --git a/server/src/building/BuildDatabase.cpp b/server/src/building/BuildDatabase.cpp index 4d3e37b1b..f854c4ab5 100644 --- a/server/src/building/BuildDatabase.cpp +++ b/server/src/building/BuildDatabase.cpp @@ -562,7 +562,7 @@ std::shared_ptr BuildDatabase::getPriorityTarget() co } fs::path BuildDatabase::newDirForFile(const fs::path &file) const { - fs::path base = Paths::longestCommonPrefixPath(this->projectContext.buildDir(), + fs::path base = Paths::longestCommonPrefixPath(this->projectContext.getBuildDirAbsPath(), this->projectContext.projectPath); return Paths::createNewDirForFile(file, base, this->serverBuildDir); } diff --git a/server/src/commands/Commands.cpp b/server/src/commands/Commands.cpp index fc89f2b8a..1d5ab1ab1 100644 --- a/server/src/commands/Commands.cpp +++ b/server/src/commands/Commands.cpp @@ -337,7 +337,7 @@ Commands::ProjectContextOptionGroup::ProjectContextOptionGroup(CLI::App *command "Relative path to build directory with compile_commands.json and/or coverage.json.", true); projectContextOptions->add_option( - "-i,--init-teardown-path", itfPath, + "-i,--init-teardown-path", itfRelPath, "Relative paths to json, that contains list of initial and teardown functions", true); } @@ -364,8 +364,8 @@ std::string Commands::ProjectContextOptionGroup::getBuildDirectory() const { return buildDir; } -std::string Commands::ProjectContextOptionGroup::getItfPath() const { - return itfPath; +std::string Commands::ProjectContextOptionGroup::getItfRelPath() const { + return itfRelPath; } Commands::SettingsContextOptionGroup::SettingsContextOptionGroup(CLI::App *command) { diff --git a/server/src/commands/Commands.h b/server/src/commands/Commands.h index d05f5f78d..390adfb95 100644 --- a/server/src/commands/Commands.h +++ b/server/src/commands/Commands.h @@ -218,14 +218,14 @@ namespace Commands { [[nodiscard]] std::string getBuildDirectory() const; - [[nodiscard]] std::string getItfPath() const; + [[nodiscard]] std::string getItfRelPath() const; private: CLI::Option_group *projectContextOptions; fs::path projectPath; std::string testDir = "tests"; std::string buildDir = "build"; - std::string itfPath = ""; + std::string itfRelPath = ""; }; struct SettingsContextOptionGroup { diff --git a/server/src/coverage/TestRunner.cpp b/server/src/coverage/TestRunner.cpp index 7a8c1d65e..bbe59af86 100644 --- a/server/src/coverage/TestRunner.cpp +++ b/server/src/coverage/TestRunner.cpp @@ -44,9 +44,9 @@ std::vector TestRunner::getTestsFromMakefile(const fs::path &makefile, auto cmdGetAllTests = MakefileUtils::MakefileCommand(projectContext, makefile, printer::DefaultMakefilePrinter::TARGET_RUN, "--gtest_list_tests", {"GTEST_FILTER=*"}); - auto[out, status, _] = cmdGetAllTests.run(projectContext.buildDir(), false); + auto[out, status, _] = cmdGetAllTests.run(projectContext.getBuildDirAbsPath(), false); if (status != 0) { - auto [err, _, logFilePath] = cmdGetAllTests.run(projectContext.buildDir(), true); + auto [err, _, logFilePath] = cmdGetAllTests.run(projectContext.getBuildDirAbsPath(), true); progressWriter->writeProgress(StringUtils::stringFormat("command %s failed.\n" "see: \"%s\"", cmdGetAllTests.getFailedCommand(), @@ -81,8 +81,8 @@ std::vector TestRunner::getTestsToLaunch() { //for project std::vector result; - if (fs::exists(projectContext.testDirPath)) { - FileSystemUtils::RecursiveDirectoryIterator directoryIterator(projectContext.testDirPath); + if (fs::exists(projectContext.getTestDirAbsPath())) { + FileSystemUtils::RecursiveDirectoryIterator directoryIterator(projectContext.getTestDirAbsPath()); ExecUtils::doWorkWithProgress( directoryIterator, progressWriter, "Building tests", [this, &result](fs::directory_entry const &directoryEntry) { @@ -116,7 +116,7 @@ std::vector TestRunner::getTestsToLaunch() { } }); } else { - LOG_S(WARNING) << "Test folder doesn't exist: " << projectContext.testDirPath; + LOG_S(WARNING) << "Test folder doesn't exist: " << projectContext.getTestDirAbsPath(); } return result; } @@ -176,7 +176,7 @@ bool TestRunner::buildTest(const utbot::ProjectContext& projectContext, const fs auto command = MakefileUtils::MakefileCommand(projectContext, makefile, printer::DefaultMakefilePrinter::TARGET_BUILD, "", {}); LOG_S(DEBUG) << "Try compile tests for: " << sourcePath.string(); - auto[out, status, logFilePath] = command.run(projectContext.buildDir(), true); + auto[out, status, logFilePath] = command.run(projectContext.getBuildDirAbsPath(), true); if (status != 0) { return false; } @@ -198,7 +198,7 @@ size_t TestRunner::buildTests(const utbot::ProjectContext& projectContext, const testsgen::TestResultObject TestRunner::runTest(const BuildRunCommand &command, const std::optional &testTimeout) { fs::remove(Paths::getGTestResultsJsonPath(projectContext)); - auto res = command.runCommand.run(projectContext.buildDir(), true, true, testTimeout); + auto res = command.runCommand.run(projectContext.getBuildDirAbsPath(), true, true, testTimeout); GTestLogger::log(res.output); testsgen::TestResultObject testRes; testRes.set_testfilepath(command.unitTest.testFilePath); diff --git a/server/src/printers/NativeMakefilePrinter.cpp b/server/src/printers/NativeMakefilePrinter.cpp index fb9011801..2fb99a743 100644 --- a/server/src/printers/NativeMakefilePrinter.cpp +++ b/server/src/printers/NativeMakefilePrinter.cpp @@ -332,7 +332,7 @@ namespace printer { fs::path testSourcePath = Paths::sourcePathToTestPath(testGen->projectContext, sourcePath); fs::path compilationDirectory = compilationUnitInfo->getDirectory(); fs::path testObjectDir = Paths::getTestObjectDir(testGen->projectContext); - fs::path testSourceRelativePath = fs::relative(testSourcePath, testGen->projectContext.testDirPath); + fs::path testSourceRelativePath = fs::relative(testSourcePath, testGen->projectContext.getTestDirAbsPath()); fs::path testObjectPathRelative = getRelativePath( testObjectDir / Paths::addExtension(testSourceRelativePath, ".o")); testCompilationCommand.setOutput( @@ -547,7 +547,7 @@ namespace printer { getLibraryAbsolutePath(argument, linkCommand.getDirectory()); if (optionalLibraryAbsolutePath.has_value()) { const fs::path &absolutePath = optionalLibraryAbsolutePath.value(); - if (Paths::isSubPathOf(testGen->projectContext.buildDir(), absolutePath)) { + if (Paths::isSubPathOf(testGen->projectContext.getBuildDirAbsPath(), absolutePath)) { fs::path recompiledDir = Paths::getRecompiledFile(testGen->projectContext, absolutePath); std::string directoryFlag = getLibraryDirectoryFlag(recompiledDir); diff --git a/server/src/streams/stubs/CLIStubsWriter.cpp b/server/src/streams/stubs/CLIStubsWriter.cpp index b98cf49e8..48df38f77 100644 --- a/server/src/streams/stubs/CLIStubsWriter.cpp +++ b/server/src/streams/stubs/CLIStubsWriter.cpp @@ -4,8 +4,8 @@ #include "loguru.h" void CLIStubsWriter::writeResponse(const std::vector &synchronizedStubs, - const fs::path &testDirPath) { + const fs::path &testDirRelPath) { LOG_S(INFO) << "Writing stubs..."; - writeStubsFilesOnServer(synchronizedStubs, testDirPath); + writeStubsFilesOnServer(synchronizedStubs, testDirRelPath); LOG_S(INFO) << "Stubs generated"; } diff --git a/server/src/streams/stubs/CLIStubsWriter.h b/server/src/streams/stubs/CLIStubsWriter.h index b7f981b4e..550e2f1cb 100644 --- a/server/src/streams/stubs/CLIStubsWriter.h +++ b/server/src/streams/stubs/CLIStubsWriter.h @@ -8,7 +8,7 @@ class CLIStubsWriter : public StubsWriter { public: explicit CLIStubsWriter(): StubsWriter(nullptr) {}; - void writeResponse(const std::vector &synchronizedStubs, const fs::path &testDirPath) override; + void writeResponse(const std::vector &synchronizedStubs, const fs::path &testDirRelPath) override; }; diff --git a/server/src/streams/stubs/ServerStubsWriter.cpp b/server/src/streams/stubs/ServerStubsWriter.cpp index 2eab66ed0..57c081422 100644 --- a/server/src/streams/stubs/ServerStubsWriter.cpp +++ b/server/src/streams/stubs/ServerStubsWriter.cpp @@ -3,8 +3,8 @@ #include "loguru.h" void ServerStubsWriter::writeResponse(const std::vector &synchronizedStubs, - const fs::path &testDirPath) { - writeStubsFilesOnServer(synchronizedStubs, testDirPath); + const fs::path &testDirRelPath) { + writeStubsFilesOnServer(synchronizedStubs, testDirRelPath); if (!hasStream()) { return; } diff --git a/server/src/streams/stubs/ServerStubsWriter.h b/server/src/streams/stubs/ServerStubsWriter.h index 9fca3a252..6b801c916 100644 --- a/server/src/streams/stubs/ServerStubsWriter.h +++ b/server/src/streams/stubs/ServerStubsWriter.h @@ -10,7 +10,7 @@ class ServerStubsWriter : public StubsWriter { } void writeResponse(const std::vector &synchronizedStubs, - const fs::path &testDirPath) override; + const fs::path &testDirRelPath) override; private: bool synchronizeCode; }; diff --git a/server/src/streams/stubs/StubsWriter.cpp b/server/src/streams/stubs/StubsWriter.cpp index 2640e573a..8acd4e97c 100644 --- a/server/src/streams/stubs/StubsWriter.cpp +++ b/server/src/streams/stubs/StubsWriter.cpp @@ -9,7 +9,7 @@ StubsWriter::StubsWriter(grpc::ServerWriter *writer) : ServerWriter(writer) { } -void StubsWriter::writeStubsFilesOnServer(const std::vector &stubs, const fs::path &testDirPath) { +void StubsWriter::writeStubsFilesOnServer(const std::vector &stubs, const fs::path &testDirRelPath) { for (const auto &stub : stubs) { FileSystemUtils::writeToFile(stub.filePath, stub.code); } diff --git a/server/src/streams/stubs/StubsWriter.h b/server/src/streams/stubs/StubsWriter.h index 10efc40e4..3a4dc2711 100644 --- a/server/src/streams/stubs/StubsWriter.h +++ b/server/src/streams/stubs/StubsWriter.h @@ -12,9 +12,9 @@ class StubsWriter : public utbot::ServerWriter { public: explicit StubsWriter(grpc::ServerWriter *writer); - virtual void writeResponse(const std::vector &synchronizedStubs, const fs::path &testDirPath) = 0; + virtual void writeResponse(const std::vector &synchronizedStubs, const fs::path &testDirRelPath) = 0; - static void writeStubsFilesOnServer(const std::vector &stubs, const fs::path &testDirPath); + static void writeStubsFilesOnServer(const std::vector &stubs, const fs::path &testDirRelPath); }; diff --git a/server/src/streams/tests/CLITestsWriter.cpp b/server/src/streams/tests/CLITestsWriter.cpp index 285500fc1..0daa6bc68 100644 --- a/server/src/streams/tests/CLITestsWriter.cpp +++ b/server/src/streams/tests/CLITestsWriter.cpp @@ -7,7 +7,7 @@ void CLITestsWriter::writeTestsWithProgress(tests::TestsMap &testMap, const std::string &message, - const fs::path &testDirPath, + const fs::path &testDirRelPath, std::function &&prepareTests, std::function &&prepareTotal) { std::cout << message << std::endl; @@ -15,7 +15,7 @@ void CLITestsWriter::writeTestsWithProgress(tests::TestsMap &testMap, for (auto it = testMap.begin(); it != testMap.end(); ++it) { tests::Tests& tests = it.value(); prepareTests(tests); - if (writeTestFile(tests, testDirPath)) { + if (writeTestFile(tests, testDirRelPath)) { ++totalTestsCounter; LOG_S(INFO) << tests.testFilename << " test file generated"; } @@ -31,8 +31,8 @@ void CLITestsWriter::writeReport(const std::string &content, LOG_S(INFO) << message; } -bool CLITestsWriter::writeTestFile(const tests::Tests &tests, const fs::path &testDirPath) { - fs::path testFilePath = testDirPath / tests.relativeFileDir / tests.testFilename; +bool CLITestsWriter::writeTestFile(const tests::Tests &tests, const fs::path &testDirRelPath) { + fs::path testFilePath = testDirRelPath / tests.relativeFileDir / tests.testFilename; FileSystemUtils::writeToFile(testFilePath, tests.code); return !tests.code.empty(); } diff --git a/server/src/streams/tests/CLITestsWriter.h b/server/src/streams/tests/CLITestsWriter.h index a5b176ab0..788236bd4 100644 --- a/server/src/streams/tests/CLITestsWriter.h +++ b/server/src/streams/tests/CLITestsWriter.h @@ -12,7 +12,7 @@ class CLITestsWriter : public TestsWriter { void writeTestsWithProgress(tests::TestsMap &testMap, const std::string &message, - const fs::path &testDirPath, + const fs::path &testDirRelPath, std::function &&prepareTests, std::function &&prepareTotal) override; @@ -21,7 +21,7 @@ class CLITestsWriter : public TestsWriter { const fs::path &pathToStore) const override; private: - static bool writeTestFile(const tests::Tests &tests, const fs::path &testDirPath); + static bool writeTestFile(const tests::Tests &tests, const fs::path &testDirRelPath); }; diff --git a/server/src/streams/tests/ServerTestsWriter.cpp b/server/src/streams/tests/ServerTestsWriter.cpp index 8c4b12f06..21f90818b 100644 --- a/server/src/streams/tests/ServerTestsWriter.cpp +++ b/server/src/streams/tests/ServerTestsWriter.cpp @@ -9,7 +9,7 @@ void ServerTestsWriter::writeTestsWithProgress(tests::TestsMap &testMap, const std::string &message, - const fs::path &testDirPath, + const fs::path &testDirRelPath, std::function &&prepareTests, std::function &&prepareTotal) { size_t size = testMap.size(); @@ -19,7 +19,7 @@ void ServerTestsWriter::writeTestsWithProgress(tests::TestsMap &testMap, tests::Tests &tests = it.value(); ExecUtils::throwIfCancelled(); prepareTests(tests); - if (writeFileAndSendResponse(tests, testDirPath, message, (100.0 * totalTestsCounter) / size, false)) { + if (writeFileAndSendResponse(tests, testDirRelPath, message, (100.0 * totalTestsCounter) / size, false)) { ++totalTestsCounter; } } @@ -28,11 +28,11 @@ void ServerTestsWriter::writeTestsWithProgress(tests::TestsMap &testMap, } bool ServerTestsWriter::writeFileAndSendResponse(const tests::Tests &tests, - const fs::path &testDirPath, + const fs::path &testDirRelPath, const std::string &message, double percent, bool isCompleted) const { - fs::path testFilePath = testDirPath / tests.relativeFileDir / tests.testFilename; + fs::path testFilePath = testDirRelPath / tests.relativeFileDir / tests.testFilename; if (!tests.code.empty()) { FileSystemUtils::writeToFile(testFilePath, tests.code); } diff --git a/server/src/streams/tests/ServerTestsWriter.h b/server/src/streams/tests/ServerTestsWriter.h index b6504bf29..e75cfcd2b 100644 --- a/server/src/streams/tests/ServerTestsWriter.h +++ b/server/src/streams/tests/ServerTestsWriter.h @@ -15,7 +15,7 @@ class ServerTestsWriter : public TestsWriter { void writeTestsWithProgress(tests::TestsMap &testMap, const std::string &message, - const fs::path &testDirPath, + const fs::path &testDirRelPath, std::function &&prepareTests, std::function &&prepareTotal) override; @@ -25,7 +25,7 @@ class ServerTestsWriter : public TestsWriter { private: [[nodiscard]] virtual bool writeFileAndSendResponse(const tests::Tests &tests, - const fs::path &testDirPath, + const fs::path &testDirRelPath, const std::string &message, double percent, bool isCompleted) const; diff --git a/server/src/streams/tests/TestsWriter.h b/server/src/streams/tests/TestsWriter.h index 2e080f7f8..5b856aa79 100644 --- a/server/src/streams/tests/TestsWriter.h +++ b/server/src/streams/tests/TestsWriter.h @@ -16,7 +16,7 @@ class TestsWriter : public utbot::ServerWriter { virtual void writeTestsWithProgress(tests::TestsMap &testMap, const std::string &message, - const fs::path &testDirPath, + const fs::path &testDirRelPath, std::function &&prepareTests, std::function &&prepareTotal) = 0; diff --git a/server/src/testgens/ProjectTestGen.cpp b/server/src/testgens/ProjectTestGen.cpp index 627a74645..828681514 100644 --- a/server/src/testgens/ProjectTestGen.cpp +++ b/server/src/testgens/ProjectTestGen.cpp @@ -14,7 +14,7 @@ ProjectTestGen::ProjectTestGen(const testsgen::ProjectRequest &request, request.settingscontext(), progressWriter, testMode), request(&request) { - fs::create_directories(projectContext.testDirPath); + fs::create_directories(projectContext.getTestDirAbsPath()); compileCommandsJsonPath = CompilationUtils::substituteRemotePathToCompileCommandsJsonPath(projectContext); projectBuildDatabase = std::make_shared(compileCommandsJsonPath, serverBuildDir, projectContext, diff --git a/server/src/utils/CLIUtils.cpp b/server/src/utils/CLIUtils.cpp index e851d35fc..a788043a4 100644 --- a/server/src/utils/CLIUtils.cpp +++ b/server/src/utils/CLIUtils.cpp @@ -51,7 +51,7 @@ createProjectContextByOptions(const ProjectContextOptionGroup &projectContextOpt auto projectContext = GrpcUtils::createProjectContext(projectContextOptions.getProjectName(), projectPath, testDir, projectContextOptions.getBuildDirectory(), - projectContextOptions.getItfPath()); + projectContextOptions.getItfRelPath()); return projectContext; } diff --git a/server/src/utils/CompilationUtils.cpp b/server/src/utils/CompilationUtils.cpp index 7f86fb690..7622b5834 100644 --- a/server/src/utils/CompilationUtils.cpp +++ b/server/src/utils/CompilationUtils.cpp @@ -75,7 +75,7 @@ namespace CompilationUtils { void substituteRemotePathToCCJsonForFile(const utbot::ProjectContext &projectContext, const std::string &jsonFileName) { - fs::path compileCommandsJsonPath = projectContext.buildDir() / jsonFileName; + fs::path compileCommandsJsonPath = projectContext.getBuildDirAbsPath() / jsonFileName; fs::create_directories(Paths::getUTBotBuildDir(projectContext)); if (!fs::exists(compileCommandsJsonPath)) { std::string message = "Can't find " + compileCommandsJsonPath.string(); diff --git a/server/src/utils/GrpcUtils.cpp b/server/src/utils/GrpcUtils.cpp index 955299100..eee949b58 100644 --- a/server/src/utils/GrpcUtils.cpp +++ b/server/src/utils/GrpcUtils.cpp @@ -19,15 +19,16 @@ namespace GrpcUtils { std::unique_ptr createProjectContext(const std::string &projectName, const fs::path &projectPath, - const fs::path &testDirPath, - const fs::path &buildDirRelativePath, - const fs::path &itfPath) { + const fs::path &testDirRelPath, + const fs::path &buildDirRelPath, + const fs::path &itfRelPath) { auto result = std::make_unique(); result->set_projectname(projectName); result->set_projectpath(projectPath); - result->set_testdirpath(testDirPath); - result->set_builddirrelativepath(buildDirRelativePath); - result->set_itfpath(itfPath); + result->set_testdirrelpath(testDirRelPath); + result->set_reportdirrelpath("utbot_report"); + result->set_builddirrelpath(buildDirRelPath); + result->set_itfrelpath(itfRelPath); return result; } @@ -192,8 +193,7 @@ namespace GrpcUtils { const fs::path &output) { projectTarget.set_name(output.filename()); projectTarget.set_path(output); - fs::path description = - fs::relative(output, projectContext.projectPath / projectContext.buildDirRelativePath); + fs::path description = fs::relative(output, projectContext.getBuildDirAbsPath()); projectTarget.set_description(description); } diff --git a/server/src/utils/GrpcUtils.h b/server/src/utils/GrpcUtils.h index cdd55505d..7f58ad4f6 100644 --- a/server/src/utils/GrpcUtils.h +++ b/server/src/utils/GrpcUtils.h @@ -18,9 +18,9 @@ namespace GrpcUtils { std::unique_ptr createProjectContext(const std::string &projectName, const fs::path &projectPath, - const fs::path &testDirPath, - const fs::path &buildDirRelativePath, - const fs::path &itfPath); + const fs::path &testDirRelPath, + const fs::path &buildDirRelPath, + const fs::path &itfRelPath); std::unique_ptr createSettingsContext(bool generateForStaticFunctions, diff --git a/server/test/framework/BaseTest.cpp b/server/test/framework/BaseTest.cpp index 939494a8d..168f7936e 100644 --- a/server/test/framework/BaseTest.cpp +++ b/server/test/framework/BaseTest.cpp @@ -20,8 +20,8 @@ void BaseTest::setCompiler(CompilationUtils::CompilerName name) { } void BaseTest::setBuildDirectory(const std::string &buildDirectoryName) { - buildDirRelativePath = buildDirectoryName; - buildPath = suitePath / buildDirRelativePath; + buildDirRelPath = buildDirectoryName; + buildPath = suitePath / buildDirRelPath; } fs::path BaseTest::getTestFilePath(const std::string &fileName) { diff --git a/server/test/framework/BaseTest.h b/server/test/framework/BaseTest.h index 5da9aa570..e50e1ffae 100644 --- a/server/test/framework/BaseTest.h +++ b/server/test/framework/BaseTest.h @@ -22,7 +22,9 @@ class BaseTest : public testing::Test { fs::path suitePath; CompilerName compilerName = CompilerName::CLANG; - std::string buildDirRelativePath; + std::string buildDirRelPath; + std::string testsDirRelPath = "tests"; + std::string reportsDirRelPath = "utbot_report"; std::string clientProjectPath = ""; fs::path buildPath; std::vector srcPaths; diff --git a/server/test/framework/KleeGen_Tests.cpp b/server/test/framework/KleeGen_Tests.cpp index 8a3445dae..c198d9fe8 100644 --- a/server/test/framework/KleeGen_Tests.cpp +++ b/server/test/framework/KleeGen_Tests.cpp @@ -46,7 +46,7 @@ namespace { types::TypesHandler::SizeContext sizeContext; types::TypeMaps typeMaps; types::TypesHandler typesHandler(typeMaps, sizeContext); - auto request = testUtils::createProjectRequest(testSuite.name, suitePath, buildDirRelativePath, {}); + auto request = testUtils::createProjectRequest(testSuite.name, suitePath, buildDirRelPath, {}); auto testGen = ProjectTestGen(*request, writer.get(), TESTMODE); KleeGenerator generator(&testGen, typesHandler, {}); @@ -63,7 +63,7 @@ namespace { types::TypesHandler::SizeContext sizeContext; types::TypeMaps typeMaps; types::TypesHandler typesHandler(typeMaps, sizeContext); - auto request = testUtils::createProjectRequest(testSuite.name, suitePath, buildDirRelativePath, {}); + auto request = testUtils::createProjectRequest(testSuite.name, suitePath, buildDirRelPath, {}); auto testGen = ProjectTestGen(*request, writer.get(), TESTMODE); KleeGenerator generator(&testGen, typesHandler, {}); diff --git a/server/test/framework/Library_Test.cpp b/server/test/framework/Library_Test.cpp index b54eb7cbf..9bad1096f 100644 --- a/server/test/framework/Library_Test.cpp +++ b/server/test/framework/Library_Test.cpp @@ -19,7 +19,7 @@ namespace { std::pair createTestForFunction(const fs::path &pathToFile, int lineNum, int kleeTimeout = 60) { - auto lineRequest = testUtils::createLineRequest(projectName, suitePath, buildDirRelativePath, + auto lineRequest = testUtils::createLineRequest(projectName, suitePath, buildDirRelPath, srcPaths, pathToFile, lineNum, "", pathToFile, true, false, kleeTimeout); diff --git a/server/test/framework/Regression_Tests.cpp b/server/test/framework/Regression_Tests.cpp index 3e9bde527..6b4be2df4 100644 --- a/server/test/framework/Regression_Tests.cpp +++ b/server/test/framework/Regression_Tests.cpp @@ -27,7 +27,7 @@ namespace { std::pair createTestForFunction(const fs::path &pathToFile, int lineNum, bool verbose = true) { - auto lineRequest = testUtils::createLineRequest(projectName, suitePath, buildDirRelativePath, + auto lineRequest = testUtils::createLineRequest(projectName, suitePath, buildDirRelPath, srcPaths, pathToFile, lineNum, "", pathToFile, false, verbose, 0); auto request = GrpcUtils::createFunctionRequest(std::move(lineRequest)); @@ -39,7 +39,7 @@ namespace { std::pair createTestForFolder(const fs::path &pathToFolder, bool useStubs = true, bool verbose = true) { - auto folderRequest = testUtils::createProjectRequest(projectName, suitePath, buildDirRelativePath, + auto folderRequest = testUtils::createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH, useStubs, verbose, 0); auto request = GrpcUtils::createFolderRequest(std::move(folderRequest), pathToFolder); @@ -89,7 +89,7 @@ namespace { TEST_F(Regression_Test, Incomplete_Array_Type) { fs::path folderPath = suitePath / "SAT-760"; auto projectRequest = testUtils::createProjectRequest( - projectName, suitePath, buildDirRelativePath, { suitePath, folderPath }, "", "SAT-760"); + projectName, suitePath, buildDirRelPath, { suitePath, folderPath }, "", "SAT-760"); auto request = GrpcUtils::createFolderRequest(std::move(projectRequest), folderPath); auto testGen = FolderTestGen(*request, writer.get(), TESTMODE); diff --git a/server/test/framework/Server_Tests.cpp b/server/test/framework/Server_Tests.cpp index 2b757ebe8..84c3aa7f9 100644 --- a/server/test/framework/Server_Tests.cpp +++ b/server/test/framework/Server_Tests.cpp @@ -60,7 +60,7 @@ namespace { fs::path testsDirPath = getTestFilePath(testsRelativeDir); auto projectContext = GrpcUtils::createProjectContext( - projectName, suitePath, testsDirPath, buildDirRelativePath, ""); + projectName, suitePath, testsDirPath, buildDirRelPath, ""); auto settingsContext = GrpcUtils::createSettingsContext(true, false, 30, 0, false, false, ErrorMode::PASSING, false, false); @@ -118,7 +118,7 @@ namespace { FileGenResult performFeatureFileTestsRequest(const fs::path &filename) { auto projectRequest = - createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths); + createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths); auto request = GrpcUtils::createFileRequest(std::move(projectRequest), filename); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); Status status = Server::TestsGenServiceImpl::ProcessBaseTestRequest(testGen, writer.get()); @@ -701,7 +701,7 @@ namespace { TEST_F(Server_Test, Char_Literals_Test) { std::string suite = "char"; setSuite(suite); - auto request = createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths, "", + auto request = createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH); auto testGen = ProjectTestGen(*request, writer.get(), TESTMODE); @@ -724,7 +724,7 @@ namespace { fs::path b_c = getTestFilePath("b.c"); fs::path main_c = getTestFilePath("main.c"); { - auto request = createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths, "", "ex"); + auto request = createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, "", "ex"); auto testGen = ProjectTestGen(*request, writer.get(), TESTMODE); Status status = Server::TestsGenServiceImpl::ProcessBaseTestRequest(testGen, writer.get()); @@ -742,7 +742,7 @@ namespace { } })); } { - auto request = createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths, "", "one"); + auto request = createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, "", "one"); auto testGen = ProjectTestGen(*request, writer.get(), TESTMODE); Status status = Server::TestsGenServiceImpl::ProcessBaseTestRequest(testGen, writer.get()); @@ -757,7 +757,7 @@ namespace { } { auto request = - createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths, "", "two"); + createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, "", "two"); auto testGen = ProjectTestGen(*request, writer.get(), TESTMODE); Status status = Server::TestsGenServiceImpl::ProcessBaseTestRequest(testGen, writer.get()); @@ -777,7 +777,7 @@ namespace { TEST_F(Server_Test, Datacom_Test) { std::string suite = "datacom"; setSuite(suite); - auto request = createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths, "", + auto request = createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH); auto testGen = ProjectTestGen(*request, writer.get(), TESTMODE); @@ -821,7 +821,7 @@ namespace { TEST_F(Server_Test, Different_Variables_False) { auto projectRequest = - createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths, "", + createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH, false, true, 60, ErrorMode::PASSING, false); auto request = GrpcUtils::createFileRequest(std::move(projectRequest), different_variables_c); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); @@ -832,7 +832,7 @@ namespace { TEST_F(Server_Test, Different_Variables_True) { auto projectRequest = - createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths, "", + createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH, false, true, 60, ErrorMode::PASSING, true); auto request = GrpcUtils::createFileRequest(std::move(projectRequest), different_variables_c); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); @@ -994,7 +994,7 @@ namespace { std::string suite = "small-project"; setSuite(suite); srcPaths = {suitePath, suitePath / "lib", suitePath / "src"}; - auto request = createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths, "", + auto request = createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH); auto testGen = ProjectTestGen(*request, writer.get(), TESTMODE); @@ -1015,7 +1015,7 @@ namespace { std::string suite = "small-project"; setSuite(suite); srcPaths = {}; - auto request = createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths, "", + auto request = createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH); auto testGen = ProjectTestGen(*request, writer.get(), TESTMODE); @@ -1039,7 +1039,7 @@ namespace { std::string suite = "small-project"; setSuite(suite); srcPaths = { suitePath / "lib"}; - auto request = createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths, "", + auto request = createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH); auto testGen = ProjectTestGen(*request, writer.get(), TESTMODE); @@ -1061,7 +1061,7 @@ namespace { TEST_P(Parameterized_Server_Test, File_Test) { auto projectRequest = - createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths); + createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths); auto request = GrpcUtils::createFileRequest(std::move(projectRequest), basic_functions_c); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); Status status = Server::TestsGenServiceImpl::ProcessBaseTestRequest(testGen, writer.get()); @@ -1072,7 +1072,7 @@ namespace { } TEST_P(Parameterized_Server_Test, Folder_Test) { - auto projectRequest = createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths, "", + auto projectRequest = createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH); auto request = GrpcUtils::createFolderRequest(std::move(projectRequest), suitePath / "inner"); auto testGen = FolderTestGen(*request, writer.get(), TESTMODE); @@ -1084,7 +1084,7 @@ namespace { } TEST_P(Parameterized_Server_Test, Line_Test1) { - auto request = createLineRequest(projectName, suitePath, buildDirRelativePath, srcPaths, + auto request = createLineRequest(projectName, suitePath, buildDirRelPath, srcPaths, basic_functions_c, 17, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH, false, false, 0); auto testGen = LineTestGen(*request, writer.get(), TESTMODE); Status status = Server::TestsGenServiceImpl::ProcessBaseTestRequest(testGen, writer.get()); @@ -1100,7 +1100,7 @@ namespace { } TEST_P(Parameterized_Server_Test, Line_Test2) { - auto request = createLineRequest(projectName, suitePath, buildDirRelativePath, srcPaths, + auto request = createLineRequest(projectName, suitePath, buildDirRelPath, srcPaths, basic_functions_c, 17, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH, false, false, 0); auto testGen = LineTestGen(*request, writer.get(), TESTMODE); Status status = Server::TestsGenServiceImpl::ProcessBaseTestRequest(testGen, writer.get()); @@ -1117,7 +1117,7 @@ namespace { } TEST_P(Parameterized_Server_Test, Class_test1_cpp) { - auto request = createClassRequest(projectName, suitePath, buildDirRelativePath, srcPaths, + auto request = createClassRequest(projectName, suitePath, buildDirRelPath, srcPaths, multiple_classes_h, 6); auto testGen = ClassTestGen(*request, writer.get(), TESTMODE); Status status = Server::TestsGenServiceImpl::ProcessBaseTestRequest(testGen, writer.get()); @@ -1131,7 +1131,7 @@ namespace { } TEST_P(Parameterized_Server_Test, Class_test2_cpp) { - auto request = createClassRequest(projectName, suitePath, buildDirRelativePath, srcPaths, + auto request = createClassRequest(projectName, suitePath, buildDirRelPath, srcPaths, multiple_classes_h, 14); auto testGen = ClassTestGen(*request, writer.get(), TESTMODE); Status status = Server::TestsGenServiceImpl::ProcessBaseTestRequest(testGen, writer.get()); @@ -1145,7 +1145,7 @@ namespace { } TEST_P(Parameterized_Server_Test, DISABLED_Class_test3_cpp) { - auto request = createClassRequest(projectName, suitePath, buildDirRelativePath, srcPaths, + auto request = createClassRequest(projectName, suitePath, buildDirRelPath, srcPaths, multiple_classes_h, 18); auto testGen = ClassTestGen(*request, writer.get(), TESTMODE); Status status = Server::TestsGenServiceImpl::ProcessBaseTestRequest(testGen, writer.get()); @@ -1159,7 +1159,7 @@ namespace { } TEST_P(Parameterized_Server_Test, Function_Test) { - auto lineRequest = createLineRequest(projectName, suitePath, buildDirRelativePath, srcPaths, + auto lineRequest = createLineRequest(projectName, suitePath, buildDirRelPath, srcPaths, basic_functions_c, 6, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH, false, false, 0); auto request = GrpcUtils::createFunctionRequest(std::move(lineRequest)); auto testGen = FunctionTestGen(*request, writer.get(), TESTMODE); @@ -1186,7 +1186,7 @@ namespace { } TEST_P(Parameterized_Server_Test, Predicate_Test_Integer) { - auto lineRequest = createLineRequest(projectName, suitePath, buildDirRelativePath, srcPaths, + auto lineRequest = createLineRequest(projectName, suitePath, buildDirRelPath, srcPaths, basic_functions_c, 17, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH, false, false, 0); auto predicateInfo = std::make_unique(); predicateInfo->set_predicate("=="); @@ -1208,7 +1208,7 @@ namespace { } TEST_P(Parameterized_Server_Test, Predicate_Test_Str) { - auto lineRequest = createLineRequest(projectName, suitePath, buildDirRelativePath, srcPaths, + auto lineRequest = createLineRequest(projectName, suitePath, buildDirRelPath, srcPaths, basic_functions_c, 32, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH, false, false, 0); auto predicateInfo = std::make_unique(); predicateInfo->set_predicate("=="); @@ -1231,7 +1231,7 @@ namespace { TEST_P(Parameterized_Server_Test, Symbolic_Stdin_Test) { auto request = std::make_unique(); - auto lineRequest = createLineRequest(projectName, suitePath, buildDirRelativePath, srcPaths, + auto lineRequest = createLineRequest(projectName, suitePath, buildDirRelPath, srcPaths, symbolic_stdin_c, 8, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH, false, false, 0); request->set_allocated_linerequest(lineRequest.release()); auto testGen = FunctionTestGen(*request, writer.get(), TESTMODE); @@ -1252,7 +1252,7 @@ namespace { TEST_P(Parameterized_Server_Test, Symbolic_Stdin_Long_Read) { auto request = std::make_unique(); - auto lineRequest = createLineRequest(projectName, suitePath, buildDirRelativePath, srcPaths, + auto lineRequest = createLineRequest(projectName, suitePath, buildDirRelPath, srcPaths, symbolic_stdin_c, 19, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH, false, false, 0); request->set_allocated_linerequest(lineRequest.release()); auto testGen = FunctionTestGen(*request, writer.get(), TESTMODE); @@ -1270,7 +1270,7 @@ namespace { class TestRunner_Test : public Parameterized_Server_Test { protected: - fs::path testDirPath; + fs::path testDirRelPath; std::unique_ptr projectContext; fs::path basic_functions_c; @@ -1287,9 +1287,9 @@ namespace { Parameterized_Server_Test::SetUp(); setSuite("coverage"); - testDirPath = getTestFilePath(pregeneratedTestsRelativeDir); + testDirRelPath = getTestFilePath(pregeneratedTestsRelativeDir); projectContext = std::make_unique( - projectName, suitePath, testDirPath, buildDirRelativePath, clientProjectPath, ""); + projectName, suitePath, clientProjectPath, testDirRelPath, reportsDirRelPath, buildDirRelPath, ""); basic_functions_c = getTestFilePath("basic_functions.c"); simple_loop_uncovered_c = getTestFilePath("simple_loop_uncovered.c"); @@ -1310,7 +1310,7 @@ namespace { CoverageAndResultsGenerator generate(std::unique_ptr testFilter, bool withCoverage, ErrorMode errorMode = ErrorMode::FAILING) { auto request = createCoverageAndResultsRequest( - projectName, suitePath, testDirPath, buildDirRelativePath, std::move(testFilter)); + projectName, suitePath, testDirRelPath, buildDirRelPath, std::move(testFilter)); static auto coverageAndResultsWriter = std::make_unique(nullptr); CoverageAndResultsGenerator coverageGenerator{request.get(), coverageAndResultsWriter.get()}; @@ -1531,7 +1531,7 @@ namespace { std::string suite = "object-file"; setSuite(suite); static const std::string source2_c = getTestFilePath("source2.c"); - auto projectRequest = createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths, "", + auto projectRequest = createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH, false, false, 30, ErrorMode::FAILING); auto request = GrpcUtils::createFileRequest(std::move(projectRequest), source2_c); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); @@ -1544,7 +1544,7 @@ namespace { auto testFilter = GrpcUtils::createTestFilterForProject(); auto runRequest = createCoverageAndResultsRequest( projectName, suitePath, suitePath / "tests", - buildDirRelativePath, std::move(testFilter)); + buildDirRelPath, std::move(testFilter)); auto coverageAndResultsWriter = std::make_unique(nullptr); CoverageAndResultsGenerator coverageGenerator{runRequest.get(), coverageAndResultsWriter.get()}; utbot::SettingsContext settingsContext{true, true, 45, 0, true, false, ErrorMode::FAILING, false, false}; @@ -1568,13 +1568,13 @@ namespace { std::string suite = "precompiled"; setSuite(suite); static const std::string source_c = getTestFilePath("source.c"); - auto projectRequest = createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths, "", + auto projectRequest = createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH, false, false, 30, ErrorMode::FAILING, false, false); auto request = GrpcUtils::createFileRequest(std::move(projectRequest), source_c); EXPECT_THROW(FileTestGen(*request, writer.get(), TESTMODE), CompilationDatabaseException); - projectRequest = createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths, "", + projectRequest = createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH, false, false, 30, ErrorMode::FAILING, false, true); request = GrpcUtils::createFileRequest(std::move(projectRequest), source_c); @@ -1590,7 +1590,7 @@ namespace { std::string suite = "linkage-ld"; setSuite(suite); static const std::string issue_c = getTestFilePath("issue-638.c"); - auto projectRequest = createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths, "", + auto projectRequest = createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH, false, false, 30, ErrorMode::FAILING); auto request = GrpcUtils::createFileRequest(std::move(projectRequest), issue_c); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); @@ -1603,7 +1603,7 @@ namespace { auto testFilter = GrpcUtils::createTestFilterForProject(); auto runRequest = createCoverageAndResultsRequest( projectName, suitePath, suitePath / "tests", - buildDirRelativePath, std::move(testFilter)); + buildDirRelPath, std::move(testFilter)); auto coverageAndResultsWriter = std::make_unique(nullptr); CoverageAndResultsGenerator coverageGenerator{ runRequest.get(), coverageAndResultsWriter.get() }; utbot::SettingsContext settingsContext{ true, true, 45, 0, true, false, ErrorMode::FAILING, false, false}; @@ -1632,7 +1632,7 @@ namespace { testUtils::BuildCommandsTool::BEAR_BUILD_COMMANDS_TOOL, true); static const std::string methods_with_asserts_cpp = getTestFilePath("methods_with_asserts.cpp"); - auto projectRequest = createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths, "", + auto projectRequest = createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH, false, false, 30, ErrorMode::FAILING); auto request = GrpcUtils::createFileRequest(std::move(projectRequest), methods_with_asserts_cpp); @@ -1643,13 +1643,14 @@ namespace { testUtils::checkMinNumberOfTests(testGen.tests, 11); - auto projectContext = std::make_unique(projectName, suitePath, suitePath / "tests", - buildDirRelativePath, clientProjectPath, ""); + auto projectContext = std::make_unique(projectName, suitePath, clientProjectPath, + testsDirRelPath, reportsDirRelPath, + buildDirRelPath, ""); auto testFilter = GrpcUtils::createTestFilterForFile( Paths::sourcePathToTestPath(*projectContext, methods_with_asserts_cpp)); auto runRequest = createCoverageAndResultsRequest( - projectName, suitePath, suitePath / "tests", - buildDirRelativePath, std::move(testFilter)); + projectName, suitePath, testsDirRelPath, + buildDirRelPath, std::move(testFilter)); auto coverageAndResultsWriter = std::make_unique(nullptr); CoverageAndResultsGenerator coverageGenerator{runRequest.get(), coverageAndResultsWriter.get()}; utbot::SettingsContext settingsContext{true, true, 30, 0, true, false, ErrorMode::FAILING, false, false}; @@ -1680,7 +1681,7 @@ namespace { testUtils::BuildCommandsTool::BEAR_BUILD_COMMANDS_TOOL, true); static const std::string methods_with_asserts_cpp = getTestFilePath("methods_with_asserts.cpp"); - auto projectRequest = createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths, "", + auto projectRequest = createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH, false, false, 30, ErrorMode::PASSING); auto request = GrpcUtils::createFileRequest(std::move(projectRequest), methods_with_asserts_cpp); @@ -1691,13 +1692,14 @@ namespace { testUtils::checkMinNumberOfTests(testGen.tests, 11); - auto projectContext = std::make_unique(projectName, suitePath, suitePath / "tests", - buildDirRelativePath, clientProjectPath, ""); + auto projectContext = std::make_unique(projectName, suitePath, clientProjectPath, + testsDirRelPath, reportsDirRelPath, + buildDirRelPath, ""); auto testFilter = GrpcUtils::createTestFilterForFile( Paths::sourcePathToTestPath(*projectContext, methods_with_asserts_cpp)); auto runRequest = createCoverageAndResultsRequest( - projectName, suitePath, suitePath / "tests", - buildDirRelativePath, std::move(testFilter)); + projectName, suitePath, testsDirRelPath, + buildDirRelPath, std::move(testFilter)); auto coverageAndResultsWriter = std::make_unique(nullptr); CoverageAndResultsGenerator coverageGenerator{runRequest.get(), coverageAndResultsWriter.get()}; utbot::SettingsContext settingsContext{true, true, 30, 0, true, false, ErrorMode::PASSING, false, false}; @@ -1726,7 +1728,7 @@ namespace { testUtils::BuildCommandsTool::BEAR_BUILD_COMMANDS_TOOL, true); static const std::string methods_with_exceptions_cpp = getTestFilePath("methods_with_exceptions.cpp"); - auto projectRequest = createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths, "", + auto projectRequest = createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH, false, false, 30, ErrorMode::FAILING); auto request = GrpcUtils::createFileRequest(std::move(projectRequest), methods_with_exceptions_cpp); @@ -1737,13 +1739,14 @@ namespace { testUtils::checkMinNumberOfTests(testGen.tests, 8); - auto projectContext = std::make_unique(projectName, suitePath, suitePath / "tests", - buildDirRelativePath, clientProjectPath, ""); + auto projectContext = std::make_unique(projectName, suitePath, clientProjectPath, + testsDirRelPath, reportsDirRelPath, + buildDirRelPath, ""); auto testFilter = GrpcUtils::createTestFilterForFile( Paths::sourcePathToTestPath(*projectContext, methods_with_exceptions_cpp)); auto runRequest = createCoverageAndResultsRequest( - projectName, suitePath, suitePath / "tests", - buildDirRelativePath, std::move(testFilter)); + projectName, suitePath, testsDirRelPath, + buildDirRelPath, std::move(testFilter)); auto coverageAndResultsWriter = std::make_unique(nullptr); CoverageAndResultsGenerator coverageGenerator{runRequest.get(), coverageAndResultsWriter.get()}; utbot::SettingsContext settingsContext{true, true, 30, 0, true, false, ErrorMode::FAILING, false, false}; @@ -1772,7 +1775,7 @@ namespace { testUtils::BuildCommandsTool::BEAR_BUILD_COMMANDS_TOOL, true); static const std::string methods_with_exceptions_cpp = getTestFilePath("methods_with_exceptions.cpp"); - auto projectRequest = createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths, "", + auto projectRequest = createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH, false, false, 30, ErrorMode::PASSING); auto request = GrpcUtils::createFileRequest(std::move(projectRequest), methods_with_exceptions_cpp); @@ -1783,13 +1786,14 @@ namespace { testUtils::checkMinNumberOfTests(testGen.tests, 8); - auto projectContext = std::make_unique(projectName, suitePath, suitePath / "tests", - buildDirRelativePath, clientProjectPath, ""); + auto projectContext = std::make_unique(projectName, suitePath, clientProjectPath, + testsDirRelPath, reportsDirRelPath, + buildDirRelPath, ""); auto testFilter = GrpcUtils::createTestFilterForFile( Paths::sourcePathToTestPath(*projectContext, methods_with_exceptions_cpp)); auto runRequest = createCoverageAndResultsRequest( - projectName, suitePath, suitePath / "tests", - buildDirRelativePath, std::move(testFilter)); + projectName, suitePath, testsDirRelPath, + buildDirRelPath, std::move(testFilter)); auto coverageAndResultsWriter = std::make_unique(nullptr); CoverageAndResultsGenerator coverageGenerator{runRequest.get(), coverageAndResultsWriter.get()}; utbot::SettingsContext settingsContext{true, true, 30, 0, true, false, ErrorMode::PASSING, false, false}; @@ -1828,7 +1832,7 @@ namespace { setSuite("run"); const auto &[subProjectName, numberOfTests] = std::get<1>(GetParam()); suitePath /= subProjectName; - buildPath = suitePath / buildDirRelativePath; + buildPath = suitePath / buildDirRelPath; this->numberOfTests = numberOfTests; this->testsDirPath = getTestFilePath(pregeneratedTestsRelativeDir); timeout = (subProjectName == "timeout") ? 5 : 0; @@ -1862,7 +1866,7 @@ namespace { auto testFilter = GrpcUtils::createTestFilterForProject(); auto request = createCoverageAndResultsRequest( projectName, suitePath, testsDirPath, - buildDirRelativePath, std::move(testFilter)); + buildDirRelPath, std::move(testFilter)); auto coverageAndResultsWriter = std::make_unique(nullptr); CoverageAndResultsGenerator coverageGenerator{request.get(), coverageAndResultsWriter.get()}; utbot::SettingsContext settingsContext{true, true, 15, timeout, true, false, ErrorMode::FAILING, false, false}; @@ -1890,7 +1894,7 @@ namespace { TEST_P(Parameterized_Server_Test, Clang_Resources_Directory_Test) { std::string suite = "stddef"; setSuite(suite); - auto request = createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths, "", + auto request = createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH); auto testGen = ProjectTestGen(*request, writer.get(), TESTMODE); @@ -1903,7 +1907,7 @@ namespace { TEST_P(Parameterized_Server_Test, Installed_Dependency_Test) { std::string suite = "installed"; setSuite(suite); - auto request = createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths, "", + auto request = createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH); auto testGen = ProjectTestGen(*request, writer.get(), TESTMODE); @@ -1920,7 +1924,7 @@ namespace { std::string suite = "small-project"; setSuite(suite); srcPaths = {}; - auto request = createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths, "", + auto request = createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH); auto testGen = ProjectTestGen(*request, writer.get(), TESTMODE); @@ -1930,7 +1934,7 @@ namespace { TEST_F(Server_Test, Run_Tests_For_Linked_List) { fs::path linked_list_c = getTestFilePath("linked_list.c"); - auto request = testUtils::createFileRequest(projectName, suitePath, buildDirRelativePath, + auto request = testUtils::createFileRequest(projectName, suitePath, buildDirRelPath, srcPaths, linked_list_c, GrpcUtils::UTBOT_AUTO_TARGET_PATH, true, false); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); @@ -1938,14 +1942,13 @@ namespace { ASSERT_TRUE(status.ok()) << status.error_message(); EXPECT_GE(testUtils::getNumberOfTests(testGen.tests), 2); - fs::path testsDirPath = getTestFilePath("tests"); fs::path linked_list_test_cpp = Paths::sourcePathToTestPath( - utbot::ProjectContext(projectName, suitePath, testsDirPath, buildDirRelativePath, clientProjectPath, ""), - linked_list_c); + utbot::ProjectContext(projectName, suitePath, clientProjectPath, testsDirRelPath, reportsDirRelPath, buildDirRelPath, ""), + linked_list_c); auto testFilter = GrpcUtils::createTestFilterForFile(linked_list_test_cpp); auto runRequest = testUtils::createCoverageAndResultsRequest( - projectName, suitePath, testsDirPath, buildDirRelativePath, std::move(testFilter)); + projectName, suitePath, testsDirRelPath, buildDirRelPath, std::move(testFilter)); static auto coverageAndResultsWriter = std::make_unique(nullptr); @@ -1969,7 +1972,7 @@ namespace { TEST_F(Server_Test, Run_Tests_For_Tree) { fs::path tree_c = getTestFilePath("tree.c"); auto request = - testUtils::createFileRequest(projectName, suitePath, buildDirRelativePath, srcPaths, + testUtils::createFileRequest(projectName, suitePath, buildDirRelPath, srcPaths, tree_c, GrpcUtils::UTBOT_AUTO_TARGET_PATH, true, false); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); Status status = Server::TestsGenServiceImpl::ProcessBaseTestRequest(testGen, writer.get()); @@ -1979,11 +1982,11 @@ namespace { fs::path testsDirPath = getTestFilePath("tests"); fs::path tree_test_cpp = Paths::sourcePathToTestPath( - utbot::ProjectContext(projectName, suitePath, testsDirPath, buildDirRelativePath, clientProjectPath, ""), + utbot::ProjectContext(projectName, suitePath, clientProjectPath, testsDirRelPath, reportsDirRelPath, buildDirRelPath, ""), tree_c); auto testFilter = GrpcUtils::createTestFilterForFile(tree_test_cpp); auto runRequest = testUtils::createCoverageAndResultsRequest( - projectName, suitePath, testsDirPath, buildDirRelativePath, std::move(testFilter)); + projectName, suitePath, testsDirPath, buildDirRelPath, std::move(testFilter)); static auto coverageAndResultsWriter = std::make_unique(nullptr); @@ -2008,7 +2011,7 @@ namespace { TEST_F(Server_Test, Run_Tests_For_Complex_Structs) { fs::path complex_structs_c = getTestFilePath("complex_structs.c"); - auto request = testUtils::createFileRequest(projectName, suitePath, buildDirRelativePath, + auto request = testUtils::createFileRequest(projectName, suitePath, buildDirRelPath, srcPaths, complex_structs_c, GrpcUtils::UTBOT_AUTO_TARGET_PATH, true, false); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); @@ -2016,14 +2019,13 @@ namespace { ASSERT_TRUE(status.ok()) << status.error_message(); EXPECT_GE(testUtils::getNumberOfTests(testGen.tests), 11); - fs::path testsDirPath = getTestFilePath("tests"); - fs::path complex_structs_test_cpp = Paths::sourcePathToTestPath( - utbot::ProjectContext(projectName, suitePath, testsDirPath, buildDirRelativePath, clientProjectPath, ""), - complex_structs_c); + utbot::ProjectContext(projectName, suitePath, clientProjectPath, testsDirRelPath, reportsDirRelPath, + buildDirRelPath, ""), + complex_structs_c); auto testFilter = GrpcUtils::createTestFilterForFile(complex_structs_test_cpp); auto runRequest = testUtils::createCoverageAndResultsRequest( - projectName, suitePath, testsDirPath, buildDirRelativePath, std::move(testFilter)); + projectName, suitePath, testsDirRelPath, buildDirRelPath, std::move(testFilter)); static auto coverageAndResultsWriter = std::make_unique(nullptr); @@ -2046,7 +2048,7 @@ namespace { TEST_F(Server_Test, Run_Tests_For_Input_Output_C) { fs::path input_output_c = getTestFilePath("input_output.c"); - auto request = testUtils::createFileRequest(projectName, suitePath, buildDirRelativePath, + auto request = testUtils::createFileRequest(projectName, suitePath, buildDirRelPath, srcPaths, input_output_c, GrpcUtils::UTBOT_AUTO_TARGET_PATH, true, false); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); @@ -2069,14 +2071,12 @@ namespace { checkMinNumberOfTests(testGen.tests, expectedTestCountMap); - fs::path testsDirPath = getTestFilePath("tests"); - fs::path input_output_test_cpp = Paths::sourcePathToTestPath( - utbot::ProjectContext(projectName, suitePath, testsDirPath, buildDirRelativePath, clientProjectPath, ""), + utbot::ProjectContext(projectName, suitePath, testsDirRelPath, reportsDirRelPath, buildDirRelPath, clientProjectPath, ""), input_output_c); auto testFilter = GrpcUtils::createTestFilterForFile(input_output_test_cpp); auto runRequest = testUtils::createCoverageAndResultsRequest( - projectName, suitePath, testsDirPath, buildDirRelativePath, std::move(testFilter)); + projectName, suitePath, testsDirRelPath, buildDirRelPath, std::move(testFilter)); static auto coverageAndResultsWriter = std::make_unique(nullptr); @@ -2099,7 +2099,7 @@ namespace { TEST_F(Server_Test, Run_Tests_For_File_C) { fs::path file_c = getTestFilePath("file.c"); auto request = - testUtils::createFileRequest(projectName, suitePath, buildDirRelativePath, srcPaths, + testUtils::createFileRequest(projectName, suitePath, buildDirRelPath, srcPaths, file_c, GrpcUtils::UTBOT_AUTO_TARGET_PATH, true, false); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); testGen.setTargetForSource(file_c); @@ -2107,14 +2107,13 @@ namespace { ASSERT_TRUE(status.ok()) << status.error_message(); EXPECT_EQ(testUtils::getNumberOfTests(testGen.tests), 33); - fs::path testsDirPath = getTestFilePath("tests"); - fs::path file_test_cpp = Paths::sourcePathToTestPath( - utbot::ProjectContext(projectName, suitePath, testsDirPath, buildDirRelativePath, clientProjectPath, ""), - file_c); + utbot::ProjectContext(projectName, suitePath, clientProjectPath, testsDirRelPath, reportsDirRelPath, + buildDirRelPath, ""), + file_c); auto testFilter = GrpcUtils::createTestFilterForFile(file_test_cpp); auto runRequest = testUtils::createCoverageAndResultsRequest( - projectName, suitePath, testsDirPath, buildDirRelativePath, std::move(testFilter)); + projectName, suitePath, testsDirRelPath, buildDirRelPath, std::move(testFilter)); static auto coverageAndResultsWriter = std::make_unique(nullptr); @@ -2137,7 +2136,7 @@ namespace { TEST_F(Server_Test, Run_Tests_For_Hard_Linked_List) { fs::path hard_linked_list_c = getTestFilePath("hard_linked_list.c"); - auto request = testUtils::createFileRequest(projectName, suitePath, buildDirRelativePath, + auto request = testUtils::createFileRequest(projectName, suitePath, buildDirRelPath, srcPaths, hard_linked_list_c, GrpcUtils::UTBOT_AUTO_TARGET_PATH, true, false); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); @@ -2148,11 +2147,12 @@ namespace { fs::path testsDirPath = getTestFilePath("tests"); fs::path hard_linked_list_test_cpp = Paths::sourcePathToTestPath( - utbot::ProjectContext(projectName, suitePath, testsDirPath, buildDirRelativePath, clientProjectPath, ""), - hard_linked_list_c); + utbot::ProjectContext(projectName, suitePath, clientProjectPath, testsDirPath, reportsDirRelPath, + buildDirRelPath, ""), + hard_linked_list_c); auto testFilter = GrpcUtils::createTestFilterForFile(hard_linked_list_test_cpp); auto runRequest = testUtils::createCoverageAndResultsRequest( - projectName, suitePath, testsDirPath, buildDirRelativePath, std::move(testFilter)); + projectName, suitePath, testsDirPath, buildDirRelPath, std::move(testFilter)); static auto coverageAndResultsWriter = std::make_unique(nullptr); @@ -2175,7 +2175,7 @@ namespace { TEST_F(Server_Test, Run_Tests_For_Multi_Dim_Pointers) { fs::path multi_dim_pointers_c = getTestFilePath("multi_dim_pointers.c"); - auto request = testUtils::createFileRequest(projectName, suitePath, buildDirRelativePath, + auto request = testUtils::createFileRequest(projectName, suitePath, buildDirRelPath, srcPaths, multi_dim_pointers_c, GrpcUtils::UTBOT_AUTO_TARGET_PATH, true, false); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); @@ -2186,11 +2186,12 @@ namespace { fs::path testsDirPath = getTestFilePath("tests"); fs::path multi_dim_pointers_test_cpp = Paths::sourcePathToTestPath( - utbot::ProjectContext(projectName, suitePath, testsDirPath, buildDirRelativePath, clientProjectPath, ""), - multi_dim_pointers_c); + utbot::ProjectContext(projectName, suitePath, clientProjectPath, testsDirRelPath, reportsDirRelPath, + buildDirRelPath, ""), + multi_dim_pointers_c); auto testFilter = GrpcUtils::createTestFilterForFile(multi_dim_pointers_test_cpp); auto runRequest = testUtils::createCoverageAndResultsRequest( - projectName, suitePath, testsDirPath, buildDirRelativePath, std::move(testFilter)); + projectName, suitePath, testsDirPath, buildDirRelPath, std::move(testFilter)); static auto coverageAndResultsWriter = std::make_unique(nullptr); @@ -2213,7 +2214,7 @@ namespace { TEST_F(Server_Test, Run_Tests_For_Struct_With_Union) { fs::path struct_with_union_c = getTestFilePath("struct_with_union.c"); - auto request = testUtils::createFileRequest(projectName, suitePath, buildDirRelativePath, + auto request = testUtils::createFileRequest(projectName, suitePath, buildDirRelPath, srcPaths, struct_with_union_c, GrpcUtils::UTBOT_AUTO_TARGET_PATH, true, false); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); @@ -2224,11 +2225,11 @@ namespace { fs::path testsDirPath = getTestFilePath("tests"); fs::path struct_with_union_test_cpp = Paths::sourcePathToTestPath( - utbot::ProjectContext(projectName, suitePath, testsDirPath, buildDirRelativePath, clientProjectPath, ""), + utbot::ProjectContext(projectName, suitePath, testsDirPath, reportsDirRelPath, buildDirRelPath, clientProjectPath, ""), struct_with_union_c); auto testFilter = GrpcUtils::createTestFilterForFile(struct_with_union_test_cpp); auto runRequest = testUtils::createCoverageAndResultsRequest( - projectName, suitePath, testsDirPath, buildDirRelativePath, std::move(testFilter)); + projectName, suitePath, testsDirPath, buildDirRelPath, std::move(testFilter)); static auto coverageAndResultsWriter = std::make_unique(nullptr); @@ -2251,7 +2252,7 @@ namespace { TEST_F(Server_Test, Run_Tests_For_Structs_With_Pointers) { fs::path structs_with_pointers_c = getTestFilePath("structs_with_pointers.c"); - auto request = testUtils::createFileRequest(projectName, suitePath, buildDirRelativePath, + auto request = testUtils::createFileRequest(projectName, suitePath, buildDirRelPath, srcPaths, structs_with_pointers_c, GrpcUtils::UTBOT_AUTO_TARGET_PATH, true, false); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); @@ -2262,11 +2263,11 @@ namespace { fs::path testsDirPath = getTestFilePath("tests"); fs::path structs_with_pointers_test_cpp = Paths::sourcePathToTestPath( - utbot::ProjectContext(projectName, suitePath, testsDirPath, buildDirRelativePath, clientProjectPath, ""), + utbot::ProjectContext(projectName, suitePath, testsDirPath, reportsDirRelPath, buildDirRelPath, clientProjectPath, ""), structs_with_pointers_c); auto testFilter = GrpcUtils::createTestFilterForFile(structs_with_pointers_test_cpp); auto runRequest = testUtils::createCoverageAndResultsRequest( - projectName, suitePath, testsDirPath, buildDirRelativePath, std::move(testFilter)); + projectName, suitePath, testsDirPath, buildDirRelPath, std::move(testFilter)); static auto coverageAndResultsWriter = std::make_unique(nullptr); @@ -2289,7 +2290,7 @@ namespace { TEST_F(Server_Test, Run_Tests_For_Thread_Local) { fs::path thread_local_c = getTestFilePath("thread_local.c"); - auto request = testUtils::createFileRequest(projectName, suitePath, buildDirRelativePath, + auto request = testUtils::createFileRequest(projectName, suitePath, buildDirRelPath, srcPaths, thread_local_c, GrpcUtils::UTBOT_AUTO_TARGET_PATH, true, false); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); @@ -2300,11 +2301,11 @@ namespace { fs::path testsDirPath = getTestFilePath("tests"); fs::path thread_local_test_cpp = Paths::sourcePathToTestPath( - utbot::ProjectContext(projectName, suitePath, testsDirPath, buildDirRelativePath, clientProjectPath, ""), + utbot::ProjectContext(projectName, suitePath, clientProjectPath, testsDirPath, reportsDirRelPath, buildDirRelPath, ""), thread_local_c); auto testFilter = GrpcUtils::createTestFilterForFile(thread_local_test_cpp); auto runRequest = testUtils::createCoverageAndResultsRequest( - projectName, suitePath, testsDirPath, buildDirRelativePath, std::move(testFilter)); + projectName, suitePath, testsDirPath, buildDirRelPath, std::move(testFilter)); static auto coverageAndResultsWriter = std::make_unique(nullptr); diff --git a/server/test/framework/Stub_Tests.cpp b/server/test/framework/Stub_Tests.cpp index 1849ec70b..e9db9b2a5 100644 --- a/server/test/framework/Stub_Tests.cpp +++ b/server/test/framework/Stub_Tests.cpp @@ -35,9 +35,9 @@ namespace { fs::path sum_stub_c = getTestFilePath(testDirName + "/stubs/lib/calc/sum_stub.c"); - fs::path testsDirPath = getTestFilePath("tests"); - utbot::ProjectContext projectContext{projectName, suitePath, testsDirPath, - buildDirRelativePath, clientProjectPath, ""}; + utbot::ProjectContext projectContext = utbot::ProjectContext(projectName, suitePath, clientProjectPath, + testsDirRelPath, reportsDirRelPath, + buildDirRelPath, ""); fs::path sum_test_cpp = Paths::sourcePathToTestPath(projectContext, calc_sum_c); fs::path foreign_bar_test_cpp = @@ -117,7 +117,7 @@ namespace { TEST_F(Stub_Test, Project_Stubs_Test) { auto stubsWriter = std::make_unique(nullptr, false); - auto request = createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths, "", + auto request = createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, "", GrpcUtils::UTBOT_AUTO_TARGET_PATH, true); auto testGen = std::make_unique(*request, writer.get(), TESTMODE); std::vector stubSources = {calc_sum_c, calc_mult_c, literals_foo_c}; @@ -128,7 +128,7 @@ namespace { } TEST_F(Stub_Test, Implicit_Stubs_Test) { - auto request = createFileRequest(projectName, suitePath, buildDirRelativePath, srcPaths, + auto request = createFileRequest(projectName, suitePath, buildDirRelPath, srcPaths, literals_foo_c, GrpcUtils::UTBOT_AUTO_TARGET_PATH, true); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); @@ -140,7 +140,7 @@ namespace { TEST_F(Stub_Test, Pregenerated_Stubs_Test) { { - auto request = createFileRequest(projectName, suitePath, buildDirRelativePath, srcPaths, + auto request = createFileRequest(projectName, suitePath, buildDirRelPath, srcPaths, literals_foo_c, GrpcUtils::UTBOT_AUTO_TARGET_PATH, true); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); @@ -150,7 +150,7 @@ namespace { std::string stubCode = modifyStubFile(sum_stub_c); { - auto request = createFileRequest(projectName, suitePath, buildDirRelativePath, + auto request = createFileRequest(projectName, suitePath, buildDirRelPath, srcPaths, literals_foo_c, GrpcUtils::UTBOT_AUTO_TARGET_PATH, true); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); @@ -162,7 +162,7 @@ namespace { } TEST_F(Stub_Test, Multimodule_Lib_Heuristic_Test) { - auto request = testUtils::createProjectRequest(projectName, suitePath, buildDirRelativePath, + auto request = testUtils::createProjectRequest(projectName, suitePath, buildDirRelPath, {foreign, calc, suitePath, literals}, "", foreign_bar_c, true); auto testGen = ProjectTestGen(*request, writer.get(), TESTMODE); @@ -182,7 +182,7 @@ namespace { } TEST_F(Stub_Test, Run_Tests_mltimodule_Lib) { - auto request = testUtils::createFileRequest(projectName, suitePath, buildDirRelativePath, + auto request = testUtils::createFileRequest(projectName, suitePath, buildDirRelPath, srcPaths, foreign_bar_c, foreign_bar_c, true); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); @@ -192,7 +192,7 @@ namespace { auto testFilter = GrpcUtils::createTestFilterForFile(foreign_bar_test_cpp); auto runRequest = testUtils::createCoverageAndResultsRequest( - projectName, suitePath, testsDirPath, buildDirRelativePath, std::move(testFilter)); + projectName, suitePath, testsDirRelPath, buildDirRelPath, std::move(testFilter)); static auto coverageAndResultsWriter = std::make_unique(nullptr); @@ -203,7 +203,7 @@ namespace { } TEST_F(Stub_Test, File_Tests_With_Stubs) { - auto request = testUtils::createFileRequest(projectName, suitePath, buildDirRelativePath, + auto request = testUtils::createFileRequest(projectName, suitePath, buildDirRelPath, srcPaths, literals_foo_c, literals_foo_c, true); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); Status status = Server::TestsGenServiceImpl::ProcessBaseTestRequest(testGen, writer.get()); @@ -237,7 +237,7 @@ namespace { } TEST_F(Stub_Test, Run_Tests_For_Unused_Function) { - auto request = testUtils::createFileRequest(projectName, suitePath, buildDirRelativePath, + auto request = testUtils::createFileRequest(projectName, suitePath, buildDirRelPath, srcPaths, calc_sum_c, GrpcUtils::UTBOT_AUTO_TARGET_PATH, true); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); Status status = Server::TestsGenServiceImpl::ProcessBaseTestRequest(testGen, writer.get()); @@ -246,7 +246,7 @@ namespace { auto testFilter = GrpcUtils::createTestFilterForFile(sum_test_cpp); auto runRequest = testUtils::createCoverageAndResultsRequest( - projectName, suitePath, testsDirPath, buildDirRelativePath, std::move(testFilter)); + projectName, suitePath, testsDirRelPath, buildDirRelPath, std::move(testFilter)); static auto coverageAndResultsWriter = std::make_unique(nullptr); @@ -257,7 +257,7 @@ namespace { } TEST_F(Stub_Test, File_Tests_Without_Stubs) { - auto request = testUtils::createFileRequest(projectName, suitePath, buildDirRelativePath, + auto request = testUtils::createFileRequest(projectName, suitePath, buildDirRelPath, srcPaths, literals_foo_c, GrpcUtils::UTBOT_AUTO_TARGET_PATH, false); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); @@ -288,7 +288,7 @@ namespace { } TEST_F(Stub_Test, DISABLED_Sync_Stub_When_Source_Changed_Test) { - auto request = createFileRequest(projectName, suitePath, buildDirRelativePath, srcPaths, literals_foo_c, GrpcUtils::UTBOT_AUTO_TARGET_PATH, true); + auto request = createFileRequest(projectName, suitePath, buildDirRelPath, srcPaths, literals_foo_c, GrpcUtils::UTBOT_AUTO_TARGET_PATH, true); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); Status status = Server::TestsGenServiceImpl::ProcessBaseTestRequest(testGen, writer.get()); ASSERT_TRUE(status.ok()) << status.error_message(); @@ -297,10 +297,10 @@ namespace { modifySources(sourcesToModify); std::string stubCode = modifyStubFile(sum_stub_c); - auto request2 = createFileRequest(projectName, suitePath, buildDirRelativePath, srcPaths, literals_foo_c, GrpcUtils::UTBOT_AUTO_TARGET_PATH, true); + auto request2 = createFileRequest(projectName, suitePath, buildDirRelPath, srcPaths, literals_foo_c, GrpcUtils::UTBOT_AUTO_TARGET_PATH, true); auto testGen2 = FileTestGen(*request2, writer.get(), TESTMODE); { - auto request = createFileRequest(projectName, suitePath, buildDirRelativePath, srcPaths, + auto request = createFileRequest(projectName, suitePath, buildDirRelPath, srcPaths, literals_foo_c, GrpcUtils::UTBOT_AUTO_TARGET_PATH, true); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); @@ -308,7 +308,7 @@ namespace { ASSERT_TRUE(status.ok()) << status.error_message(); } { - auto request = createFileRequest(projectName, suitePath, buildDirRelativePath, + auto request = createFileRequest(projectName, suitePath, buildDirRelPath, srcPaths, literals_foo_c, GrpcUtils::UTBOT_AUTO_TARGET_PATH, true); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); @@ -332,21 +332,19 @@ namespace { }); TEST_P(ParametrizedVerboseTest, Stubs_For_Function_Pointers) { - auto request = createFileRequest(projectName, suitePath, buildDirRelativePath, srcPaths, function_pointers_c, + auto request = createFileRequest(projectName, suitePath, buildDirRelPath, srcPaths, function_pointers_c, GrpcUtils::UTBOT_AUTO_TARGET_PATH, true, std::get<0>(GetParam())); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); Status status = Server::TestsGenServiceImpl::ProcessBaseTestRequest(testGen, writer.get()); ASSERT_TRUE(status.ok()) << status.error_message(); EXPECT_EQ(testUtils::getNumberOfTests(testGen.tests), 7); - fs::path testsDirPath = getTestFilePath("tests"); - fs::path function_pointers_test_cpp = Paths::sourcePathToTestPath( - utbot::ProjectContext(projectName, suitePath, testsDirPath, buildDirRelativePath, clientProjectPath, ""), + utbot::ProjectContext(projectName, suitePath, clientProjectPath, testsDirRelPath, reportsDirRelPath, buildDirRelPath, ""), function_pointers_c); auto testFilter = GrpcUtils::createTestFilterForFile(function_pointers_test_cpp); auto runRequest = testUtils::createCoverageAndResultsRequest( - projectName, suitePath, testsDirPath, buildDirRelativePath, std::move(testFilter)); + projectName, suitePath, testsDirRelPath, buildDirRelPath, std::move(testFilter)); static auto coverageAndResultsWriter = std::make_unique(nullptr); diff --git a/server/test/framework/Syntax_Tests.cpp b/server/test/framework/Syntax_Tests.cpp index 420ce473f..4320b328c 100644 --- a/server/test/framework/Syntax_Tests.cpp +++ b/server/test/framework/Syntax_Tests.cpp @@ -93,7 +93,7 @@ namespace { std::pair createTestForFunction(const fs::path &pathToFile, int lineNum, int kleeTimeout = 60, fs::path ithPath = "") { - auto lineRequest = createLineRequest(projectName, suitePath, buildDirRelativePath, + auto lineRequest = createLineRequest(projectName, suitePath, buildDirRelPath, srcPaths, pathToFile, lineNum, ithPath, pathToFile, false, false, kleeTimeout); auto request = GrpcUtils::createFunctionRequest(std::move(lineRequest)); diff --git a/server/test/framework/Targets_Test.cpp b/server/test/framework/Targets_Test.cpp index 879cc4805..529610faa 100644 --- a/server/test/framework/Targets_Test.cpp +++ b/server/test/framework/Targets_Test.cpp @@ -22,7 +22,7 @@ using namespace testUtils; TEST_F(TargetsTest, Valid_Target_Test_ls) { auto projectRequest = - createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths, "", "ls"); + createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, "", "ls"); auto request = GrpcUtils::createFileRequest(std::move(projectRequest), parse_c); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); @@ -41,7 +41,7 @@ TEST_F(TargetsTest, Valid_Target_Test_ls) { TEST_F(TargetsTest, Valid_Target_Test_cat) { auto projectRequest = - createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths, "", "cat"); + createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, "", "cat"); auto request = GrpcUtils::createFileRequest(std::move(projectRequest), parse_c); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); @@ -59,7 +59,7 @@ TEST_F(TargetsTest, Valid_Target_Test_cat) { } TEST_F(TargetsTest, Valid_Target_Test_dummy) { - auto projectRequest = createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths, "", "dummy"); + auto projectRequest = createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, "", "dummy"); auto request = GrpcUtils::createFileRequest(std::move(projectRequest), parse_c); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); @@ -71,7 +71,7 @@ TEST_F(TargetsTest, Valid_Target_Test_dummy) { } TEST_F(TargetsTest, Valid_Target_Test_parse) { - auto projectRequest = createProjectRequest(projectName, suitePath, buildDirRelativePath, srcPaths, ""); + auto projectRequest = createProjectRequest(projectName, suitePath, buildDirRelPath, srcPaths, ""); auto request = GrpcUtils::createFileRequest(std::move(projectRequest), parse_c); auto testGen = FileTestGen(*request, writer.get(), TESTMODE); @@ -89,7 +89,7 @@ TEST_F(TargetsTest, Valid_Target_Test_parse) { TEST_F(TargetsTest, Valid_Target_Test_get_10) { std::unique_ptr projectRequest = createProjectRequest( - projectName, suitePath, buildDirRelativePath, srcPaths, "", "get_10", false, false, 15); + projectName, suitePath, buildDirRelPath, srcPaths, "", "get_10", false, false, 15); auto testGen = ProjectTestGen(*projectRequest.get(), writer.get(), TESTMODE, true); @@ -129,7 +129,7 @@ TEST_F(TargetsTest, Valid_Target_Test_get_10) { TEST_F(TargetsTest, Valid_Target_Test_get_20) { std::unique_ptr projectRequest = createProjectRequest( - projectName, suitePath, buildDirRelativePath, srcPaths, "", "get_20", false, false, 15); + projectName, suitePath, buildDirRelPath, srcPaths, "", "get_20", false, false, 15); auto testGen = ProjectTestGen(*projectRequest.get(), writer.get(), TESTMODE, true); @@ -169,7 +169,7 @@ TEST_F(TargetsTest, Valid_Target_Test_get_20) { TEST_F(TargetsTest, Valid_Target_Test_get_10_2) { std::unique_ptr projectRequest = createProjectRequest( - projectName, suitePath, buildDirRelativePath, srcPaths, "", "get_10_2", false, false, 15); + projectName, suitePath, buildDirRelPath, srcPaths, "", "get_10_2", false, false, 15); auto testGen = ProjectTestGen(*projectRequest.get(), writer.get(), TESTMODE, true); @@ -209,7 +209,7 @@ TEST_F(TargetsTest, Valid_Target_Test_get_10_2) { TEST_F(TargetsTest, Valid_Target_Test_libshared) { std::unique_ptr projectRequest = createProjectRequest( - projectName, suitePath, buildDirRelativePath, srcPaths, "", "libshared_get.so", false, false, 15); + projectName, suitePath, buildDirRelPath, srcPaths, "", "libshared_get.so", false, false, 15); auto testGen = ProjectTestGen(*projectRequest.get(), writer.get(), TESTMODE, true); @@ -249,7 +249,7 @@ TEST_F(TargetsTest, Valid_Target_Test_libshared) { TEST_F(TargetsTest, Valid_Target_Test_get_libstatic) { std::unique_ptr projectRequest = createProjectRequest( - projectName, suitePath, buildDirRelativePath, srcPaths, "", "libstatic_get.a", false, false, 15); + projectName, suitePath, buildDirRelPath, srcPaths, "", "libstatic_get.a", false, false, 15); auto testGen = ProjectTestGen(*projectRequest.get(), writer.get(), TESTMODE, true); diff --git a/server/test/framework/TestUtils.cpp b/server/test/framework/TestUtils.cpp index b76c6200b..e19e26fa2 100644 --- a/server/test/framework/TestUtils.cpp +++ b/server/test/framework/TestUtils.cpp @@ -222,9 +222,9 @@ namespace testUtils { std::unique_ptr createProjectRequest(const std::string &projectName, const fs::path &projectPath, - const std::string &buildDirRelativePath, + const std::string &buildDirRelPath, const std::vector &srcPaths, - const fs::path &itfPath, + const fs::path &itfRelPath, const std::string &targetOrSourcePath, bool useStubs, bool verbose, @@ -233,7 +233,7 @@ namespace testUtils { bool differentVariables, bool skipPrecompiled) { auto projectContext = GrpcUtils::createProjectContext( - projectName, projectPath, projectPath / "tests", buildDirRelativePath, itfPath); + projectName, projectPath, projectPath / "tests", buildDirRelPath, itfRelPath); auto settingsContext = GrpcUtils::createSettingsContext(true, verbose, kleeTimeout, 0, false, useStubs, errorMode, differentVariables, skipPrecompiled); @@ -245,7 +245,7 @@ namespace testUtils { std::unique_ptr createFileRequest(const std::string &projectName, const fs::path &projectPath, - const std::string &buildDirRelativePath, + const std::string &buildDirRelPath, const std::vector &srcPaths, const fs::path &filePath, const std::string &targetOrSourcePath, @@ -253,32 +253,32 @@ namespace testUtils { bool verbose, int kleeTimeout, ErrorMode errorMode) { - auto projectRequest = createProjectRequest(projectName, projectPath, buildDirRelativePath, + auto projectRequest = createProjectRequest(projectName, projectPath, buildDirRelPath, srcPaths, "", targetOrSourcePath, useStubs, verbose, kleeTimeout, errorMode); return GrpcUtils::createFileRequest(std::move(projectRequest), filePath); } std::unique_ptr createLineRequest(const std::string &projectName, const fs::path &projectPath, - const std::string &buildDirRelativePath, + const std::string &buildDirRelPath, const std::vector &srcPaths, const fs::path &filePath, int line, - const fs::path &itfPath, + const fs::path &itfRelPath, const std::string &targetOrSourcePath, bool useStubs, bool verbose, int kleeTimeout, ErrorMode errorMode) { - auto projectRequest = createProjectRequest(projectName, projectPath, buildDirRelativePath, - srcPaths, itfPath, targetOrSourcePath, useStubs, verbose, kleeTimeout, errorMode); + auto projectRequest = createProjectRequest(projectName, projectPath, buildDirRelPath, + srcPaths, itfRelPath, targetOrSourcePath, useStubs, verbose, kleeTimeout, errorMode); auto lineInfo = GrpcUtils::createSourceInfo(filePath, line); return GrpcUtils::createLineRequest(std::move(projectRequest), std::move(lineInfo)); } std::unique_ptr createClassRequest(const std::string &projectName, const fs::path &projectPath, - const std::string &buildDirRelativePath, + const std::string &buildDirRelPath, const std::vector &srcPaths, const fs::path &filePath, int line, @@ -287,7 +287,7 @@ namespace testUtils { bool verbose, int kleeTimeout, ErrorMode errorMode) { - auto lineRequest = createLineRequest(projectName, projectPath, buildDirRelativePath, + auto lineRequest = createLineRequest(projectName, projectPath, buildDirRelPath, srcPaths, filePath, line, "", targetOrSourcePath, useStubs, verbose, kleeTimeout, errorMode); return GrpcUtils::createClassRequest(std::move(lineRequest)); } @@ -308,12 +308,12 @@ namespace testUtils { std::unique_ptr createCoverageAndResultsRequest(const std::string &projectName, const fs::path &projectPath, - const fs::path &testDirPath, - const fs::path &buildDirRelativePath, + const fs::path &testDirRelPath, + const fs::path &buildDirRelPath, std::unique_ptr testFilter) { auto request = std::make_unique(); - auto projectContext = GrpcUtils::createProjectContext(projectName, projectPath, testDirPath, - buildDirRelativePath, ""); + auto projectContext = GrpcUtils::createProjectContext(projectName, projectPath, testDirRelPath, + buildDirRelPath, ""); request->set_allocated_projectcontext(projectContext.release()); request->set_allocated_testfilter(testFilter.release()); request->set_coverage(true); diff --git a/server/test/framework/TestUtils.h b/server/test/framework/TestUtils.h index 4c373c40d..0e946e255 100644 --- a/server/test/framework/TestUtils.h +++ b/server/test/framework/TestUtils.h @@ -71,9 +71,9 @@ namespace testUtils { std::unique_ptr createProjectRequest(const std::string &projectName, const fs::path &projectPath, - const std::string &buildDirRelativePath, + const std::string &buildDirRelPath, const std::vector &srcPaths, - const fs::path &itfPath = "", + const fs::path &itfRelPath = "", const std::string &targetOrSourcePath = GrpcUtils::UTBOT_AUTO_TARGET_PATH, bool useStubs = false, bool verbose = true, @@ -84,7 +84,7 @@ namespace testUtils { std::unique_ptr createFileRequest(const std::string &projectName, const fs::path &projectPath, - const std::string &buildDirRelativePath, + const std::string &buildDirRelPath, const std::vector &srcPaths, const fs::path &filePath, const std::string &targetOrSourcePath = GrpcUtils::UTBOT_AUTO_TARGET_PATH, @@ -95,11 +95,11 @@ namespace testUtils { std::unique_ptr createLineRequest(const std::string &projectName, const fs::path &projectPath, - const std::string &buildDirRelativePath, + const std::string &buildDirRelPath, const std::vector &srcPaths, const fs::path &filePath, int line, - const fs::path &itfPath = "", + const fs::path &itfRelPath = "", const std::string &targetOrSourcePath = GrpcUtils::UTBOT_AUTO_TARGET_PATH, bool useStubs = false, bool verbose = true, @@ -108,7 +108,7 @@ namespace testUtils { std::unique_ptr createClassRequest(const std::string &projectName, const fs::path &projectPath, - const std::string &buildDirRelativePath, + const std::string &buildDirRelPath, const std::vector &srcPaths, const fs::path &filePath, int line, @@ -121,14 +121,14 @@ namespace testUtils { std::unique_ptr createCoverageAndResultsRequest(const std::string &projectName, const fs::path &projectPath, - const fs::path &testDirPath, - const fs::path &buildDirRelativePath); + const fs::path &testDirRelPath, + const fs::path &buildDirRelPath); std::unique_ptr createCoverageAndResultsRequest(const std::string &projectName, const fs::path &projectPath, - const fs::path &testDirPath, - const fs::path &buildDirRelativePath, + const fs::path &testDirRelPath, + const fs::path &buildDirRelPath, std::unique_ptr testFilter); bool cmpChars(const std::string &charAsString, char c); diff --git a/vscode-plugin/src/client/client.ts b/vscode-plugin/src/client/client.ts index 2ea68200f..26d1cc6d4 100644 --- a/vscode-plugin/src/client/client.ts +++ b/vscode-plugin/src/client/client.ts @@ -384,8 +384,8 @@ export class Client { async checkProjectConfigurationRequest( projectName: string, projectPath: string, - buildDirRelativePath: string, - itfPath: string, + buildDirRelPath: string, + itfRelPath: string, cmakeOptions: Array, configMode: ConfigMode, progressKey: utbotUI.ProgressKey, @@ -395,9 +395,9 @@ export class Client { const projectContext = new ProjectContext(); projectContext.setProjectname(projectName); projectContext.setProjectpath(projectPath); - projectContext.setBuilddirrelativepath(buildDirRelativePath); + projectContext.setBuilddirrelpath(buildDirRelPath); projectContext.setClientprojectpath(vsUtils.getProjectDirByOpenedFile().fsPath); - projectContext.setItfpath(itfPath); + projectContext.setItfrelpath(itfRelPath); const projectConfigRequest = new ProjectConfigRequest(); projectConfigRequest.setProjectcontext(projectContext); projectConfigRequest.setConfigmode(configMode); @@ -428,10 +428,10 @@ export class Client { const projectContext = new ProjectContext(); projectContext.setProjectname(Prefs.getProjectName()); projectContext.setProjectpath(buildDir[0]); - projectContext.setTestdirpath(Prefs.getTestsDirPath()); - projectContext.setBuilddirrelativepath(buildDir[1]); + projectContext.setTestdirrelpath(Prefs.getTestDirRelativePath()); + projectContext.setBuilddirrelpath(buildDir[1]); projectContext.setClientprojectpath(vsUtils.getProjectDirByOpenedFile().fsPath); - projectContext.setItfpath(Prefs.getITFPath()); + projectContext.setItfrelpath(Prefs.getItfRelPath()); rpcRequest.setProjectcontext(projectContext); rpcRequest.setSettingscontext(Prefs.getSettingsContext()); @@ -613,7 +613,7 @@ export class Client { `Sending project tests request \n` + `projectName: ${params.projectName}\n` + `projectPath: ${params.projectPath}\n` + - `buildDirRelativePath: ${params.buildDirRelativePath}\n` + + `buildDirRelPath: ${params.buildDirRelPath}\n` + `targetPath: ${params.targetPath}` ); @@ -644,8 +644,8 @@ export class Client { const projectContext = new ProjectContext(); projectContext.setProjectname(Prefs.getProjectName()); projectContext.setProjectpath(params.projectPath); - projectContext.setTestdirpath(Prefs.getTestsDirPath()); - projectContext.setBuilddirrelativepath(params.buildDirRelativePath); + projectContext.setTestdirrelpath(Prefs.getTestDirRelativePath()); + projectContext.setBuilddirrelpath(params.buildDirRelPath); projectContext.setClientprojectpath(vsUtils.getProjectDirByOpenedFile().fsPath); rpcRequest.setProjectcontext(projectContext); rpcRequest.setSettingscontext(Prefs.getSettingsContext()); diff --git a/vscode-plugin/src/config/prefs.ts b/vscode-plugin/src/config/prefs.ts index 47f009003..a9cfbc716 100644 --- a/vscode-plugin/src/config/prefs.ts +++ b/vscode-plugin/src/config/prefs.ts @@ -200,26 +200,11 @@ export class Prefs { return this.getAssetBase(Prefs.CMAKE_OPTIONS_PREF, defcfg.DefaultConfigValues.DEFAULT_CMAKE_OPTIONS); } - - public static getTestsDirPath(): string { - if (this.isRemoteScenario()) { - return this.getRemoteTestsDirPath(); - } - return this.getLocalTestsDirPath(); - } - public static getLocalTestsDirPath(): string { const testsDirRelative = this.getTestDirRelativePath(); const root = vsUtils.getProjectDirByOpenedFile(); const testsDirPath = pathUtils.fsJoin(root.fsPath, testsDirRelative); - return testsDirPath; - } - - public static getRemoteTestsDirPath(): string { - const testsDirRelative = this.getTestDirRelativePath(); - const root = this.getRemoteRoot(); - const testsDirPath = path.posix.join(root, testsDirRelative); - return testsDirPath; + return testsDirPath;`` } public static getTestDirRelativePath(): string { @@ -261,12 +246,12 @@ export class Prefs { return this.getLocalSourcePaths(); } - public static getITFPath(): string { - const itfPath: string = this.getAssetBase(Prefs.ITF_PATH_PREF, ""); - if (itfPath.length === 0) { + public static getItfRelPath(): string { + const itfRelPath: string = this.getAssetBase(Prefs.ITF_PATH_PREF, ""); + if (itfRelPath.length === 0) { return ""; } - return pathUtils.normalizeRawPosixPath(itfPath); + return pathUtils.normalizeRawPosixPath(itfRelPath); } public static async setAsset(pref: string, newValue: T, raiseError: boolean = true): Promise { diff --git a/vscode-plugin/src/config/projectConfig.ts b/vscode-plugin/src/config/projectConfig.ts index feddc9a5a..66dabc9e0 100644 --- a/vscode-plugin/src/config/projectConfig.ts +++ b/vscode-plugin/src/config/projectConfig.ts @@ -15,14 +15,14 @@ export class ProjectConfig { private readonly projectName: string; private readonly projectPath: string; - private readonly buildDirRelativePath: string; - private readonly itfPath: string; + private readonly buildDirRelPath: string; + private readonly itfRelPath: string; private readonly cmakeOptions: Array; constructor(private readonly client: Client) { this.projectName = Prefs.getProjectName(); - [this.projectPath, this.buildDirRelativePath] = Prefs.getBuildDirPath(); - this.itfPath = Prefs.getITFPath(); + [this.projectPath, this.buildDirRelPath] = Prefs.getBuildDirPath(); + this.itfRelPath = Prefs.getItfRelPath(); this.cmakeOptions = Prefs.getCmakeOptions(); } @@ -92,7 +92,7 @@ export class ProjectConfig { return utbotUI.progresses().withProgress(async (progressKey, token) => { utbotUI.progresses().report(progressKey, "Check project configuration..."); const responseHandler = new DummyResponseHandler(); - return this.client.checkProjectConfigurationRequest(this.projectName, this.projectPath, this.buildDirRelativePath, this.itfPath, this.cmakeOptions, configMode, progressKey, token, responseHandler); + return this.client.checkProjectConfigurationRequest(this.projectName, this.projectPath, this.buildDirRelPath, this.itfRelPath, this.cmakeOptions, configMode, progressKey, token, responseHandler); }); } @@ -100,7 +100,7 @@ export class ProjectConfig { logger.info('Build folder not found'); const yesOption = 'Create build folder'; - return vs.window.showWarningMessage(`Build folder "${this.buildDirRelativePath}" + return vs.window.showWarningMessage(`Build folder "${this.buildDirRelPath}" specified in [Preferences](command:unittestbot.innercommand.openBuildDirectoryConfig), does not exist.`, ...[yesOption]).then(async selection => { if (selection === yesOption) { return this.handleBuildDirCreationRequest(); diff --git a/vscode-plugin/src/requests/params.ts b/vscode-plugin/src/requests/params.ts index 9f3c1017d..57f0d162a 100644 --- a/vscode-plugin/src/requests/params.ts +++ b/vscode-plugin/src/requests/params.ts @@ -10,7 +10,7 @@ export class RequestTestsParams { constructor( readonly projectPath: string, - readonly buildDirRelativePath: string, + readonly buildDirRelPath: string, readonly projectName: string, readonly sourcePaths: string[], readonly targetPath: string, @@ -22,7 +22,7 @@ export class RequestTestsParams { export class RequestCoverageAndResultParams { constructor(readonly projectPath: string, - readonly buildDirRelativePath: string, + readonly buildDirRelPath: string, readonly testInfo: GTestInfo | undefined, readonly progressKey: utbotUI.ProgressKey, readonly cancellationToken: vs.CancellationToken) {} @@ -30,7 +30,7 @@ export class RequestCoverageAndResultParams { export class RequestTestResultsParams { constructor(readonly projectPath: string, - readonly buildDirRelativePath: string, + readonly buildDirRelPath: string, readonly execPath: string, readonly fileName: string, readonly testName: string, diff --git a/vscode-plugin/src/requests/protos.ts b/vscode-plugin/src/requests/protos.ts index 497713461..9246b1448 100644 --- a/vscode-plugin/src/requests/protos.ts +++ b/vscode-plugin/src/requests/protos.ts @@ -18,7 +18,7 @@ export class Protos { public static projectRequestByParams(params: RequestTestsParams): ProjectRequest { return this.projectRequest( params.projectPath, - params.buildDirRelativePath, + params.buildDirRelPath, params.projectName, params.sourcePaths, params.synchronizeCode, @@ -27,7 +27,7 @@ export class Protos { public static projectRequest( projectPath: string, - buildDirRelativePath: string, + buildDirRelPath: string, projectName: string, srcPathsList: string[], synchronizeCode: boolean, @@ -37,10 +37,10 @@ export class Protos { const projectContext = new ProjectContext(); projectContext.setProjectname(projectName); projectContext.setProjectpath(projectPath); - projectContext.setTestdirpath(Prefs.getTestsDirPath()); - projectContext.setBuilddirrelativepath(buildDirRelativePath); + projectContext.setTestdirrelpath(Prefs.getTestDirRelativePath()); + projectContext.setBuilddirrelpath(buildDirRelPath); projectContext.setClientprojectpath(vsUtils.getProjectDirByOpenedFile().fsPath); - projectContext.setItfpath(Prefs.getITFPath()); + projectContext.setItfrelpath(Prefs.getItfRelPath()); projectInfo.setProjectcontext(projectContext); projectInfo.setSettingscontext(Prefs.getSettingsContext()); projectInfo.setSourcepathsList(srcPathsList);