From a0f1871156ef0406590628e78eb7d38fc662b015 Mon Sep 17 00:00:00 2001 From: Vladislav Kalugin Date: Tue, 2 Apr 2024 15:13:53 +0300 Subject: [PATCH] Path refactoring (#677) * Name refactoring * Add option to CLI --- .../actions/AskServerToGenerateBuildDir.kt | 2 +- .../requests/CreateBuildFolderRequest.kt | 2 +- .../plugin/grpc/GrpcRequestBuilderFactory.kt | 2 +- .../plugin/grpc/GrpcRequestBuildersImpl.kt | 4 +- .../settings/UTBotAllProjectSettings.kt | 8 +- .../plugin/settings/UTBotConfigurable.kt | 4 +- .../settings/UTBotProjectStoredSettings.kt | 10 +- .../ui/wizard/steps/BuildOptionsStep.kt | 2 +- .../main/resources/messages/UTBot.properties | 6 +- .../buildingRequestsTests/BaseBuildingTest.kt | 8 +- .../BaseGenerationTestCase.kt | 4 +- server/proto/testgen.proto | 9 +- server/src/KleeRunner.cpp | 4 +- server/src/Paths.cpp | 119 ++++++---- server/src/Paths.h | 36 ++- server/src/ProjectContext.cpp | 53 +++-- server/src/ProjectContext.h | 57 +++-- server/src/Server.cpp | 12 +- server/src/Synchronizer.cpp | 2 +- server/src/building/BuildDatabase.cpp | 2 +- server/src/commands/Commands.cpp | 22 +- server/src/commands/Commands.h | 33 ++- server/src/coverage/TestRunner.cpp | 14 +- server/src/printers/NativeMakefilePrinter.cpp | 4 +- .../coverage/CLICoverageAndResultsWriter.cpp | 2 +- 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 | 29 ++- server/src/utils/CompilationUtils.cpp | 2 +- server/src/utils/GrpcUtils.cpp | 17 +- server/src/utils/GrpcUtils.h | 7 +- server/test/framework/BaseTest.cpp | 4 +- server/test/framework/BaseTest.h | 6 +- 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 | 207 +++++++++--------- 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 | 34 +-- server/test/framework/TestUtils.h | 20 +- vscode-plugin/.vscode/tasks.json | 19 +- vscode-plugin/package.json | 18 +- vscode-plugin/package.nls.json | 7 +- vscode-plugin/src/client/client.ts | 34 +-- vscode-plugin/src/config/defaultValues.ts | 19 +- vscode-plugin/src/config/prefs.ts | 46 ++-- vscode-plugin/src/config/projectConfig.ts | 12 +- vscode-plugin/src/explorer/utbotExplorer.ts | 24 +- vscode-plugin/src/extension.ts | 4 +- vscode-plugin/src/requests/params.ts | 6 +- vscode-plugin/src/requests/protos.ts | 11 +- 63 files changed, 587 insertions(+), 482 deletions(-) diff --git a/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/actions/AskServerToGenerateBuildDir.kt b/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/actions/AskServerToGenerateBuildDir.kt index c5a6dd947..a94609bde 100644 --- a/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/actions/AskServerToGenerateBuildDir.kt +++ b/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/actions/AskServerToGenerateBuildDir.kt @@ -8,7 +8,7 @@ import org.utbot.cpp.clion.plugin.utils.activeProject import org.utbot.cpp.clion.plugin.utils.client import testsgen.Testgen -class AskServerToGenerateBuildDir : UTBotBaseAction(UTBot.message("projectConfigure.generate.buildDir")) { +class AskServerToGenerateBuildDir : UTBotBaseAction(UTBot.message("projectConfigure.generate.buildRelDir")) { override fun actionPerformed(e: AnActionEvent) = CreateBuildDirRequest( GrpcRequestBuilderFactory(e.activeProject()).createProjectConfigRequestBuilder(Testgen.ConfigMode.CREATE_BUILD_DIR), diff --git a/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/client/requests/CreateBuildFolderRequest.kt b/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/client/requests/CreateBuildFolderRequest.kt index a8e720650..6ec3155e7 100644 --- a/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/client/requests/CreateBuildFolderRequest.kt +++ b/clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/client/requests/CreateBuildFolderRequest.kt @@ -26,7 +26,7 @@ class CreateBuildDirRequest( CreateBuildDirHandler( client, this, - UTBot.message("requests.buildDir.description.progress"), + UTBot.message("requests.buildRelDir.description.progress"), cancellationJob ).handle() } 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..76d928bb1 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 @@ -134,8 +134,8 @@ class UTBotConfigurable(private val myProject: Project) : BoundConfigurable( } private fun Panel.createPathsSettings() { - row(UTBot.message("settings.project.buildDir")) { - textField().bindText(settings::buildDirRelativePath).columns(COLUMNS_LARGE) + row(UTBot.message("settings.project.buildRelDir")) { + 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/main/resources/messages/UTBot.properties b/clion-plugin/src/main/resources/messages/UTBot.properties index 8e53c23a1..82ba9d6de 100644 --- a/clion-plugin/src/main/resources/messages/UTBot.properties +++ b/clion-plugin/src/main/resources/messages/UTBot.properties @@ -1,10 +1,10 @@ projectConfigure.configure=Configure Project -projectConfigure.generate.buildDir=Generate build directory +projectConfigure.generate.buildRelDir=Generate build directory projectConfigure.generate.json=Generate Missing JSON Files projectConfigure.reconfigure=Reset cache and configure project wizard.show=Quickstart wizard settings.project.sourcePaths=Source paths: -settings.project.buildDir=Build directory: +settings.project.buildRelDir=Build directory: settings.project.target=target path: settings.project.target.wrong.conversion=Possibly wrong target path. Could not create relative path from remote path settings.project.testsDir=Tests directory: @@ -28,7 +28,7 @@ requests.predicate.description.progress=Generating for predicate... requests.coverage.description.progress=Requesting results and coverage... requests.check.description.progress=Checking project configuration... requests.json.description.progress=Generating json files... -requests.buildDir.description.progress=Creating build directory... +requests.buildRelDir.description.progress=Creating build directory... uri.wiki=https://github.com/UnitTestBot/UTBotCpp/wiki deployment.utbot.host.description=UTBot Server host address. Learn more deployment.utbot.port.description=UTBot Server port. Learn more 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..87d8897fe 100644 --- a/server/src/KleeRunner.cpp +++ b/server/src/KleeRunner.cpp @@ -116,13 +116,13 @@ void KleeRunner::runKlee(const std::vector &testMethods, std::function prepareTotal = [&]() { testsWriter->writeReport(sarif::sarifPackResults(sarifResults), "Sarif Report was created", - Paths::getUTBotReportDir(projectContext) / sarif::SARIF_FILE_NAME); + projectContext.getReportDirAbsPath() / sarif::SARIF_FILE_NAME); }; 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..a6e66da39 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); @@ -431,17 +429,17 @@ namespace Paths { //region utbot_report + const std::string UTBOT_TESTS = "tests"; const std::string UTBOT_REPORT = "utbot_report"; - - inline fs::path getUTBotReportDir(const utbot::ProjectContext &projectContext) { - return projectContext.projectPath / UTBOT_REPORT; - } + const std::string UTBOT_BUILD = "build"; + const std::string UTBOT_ITF = ""; inline fs::path getGenerationStatsCSVPath(const utbot::ProjectContext &projectContext) { - return getUTBotReportDir(projectContext) / "generation-stats.csv"; + return projectContext.getReportDirAbsPath() / "generation-stats.csv"; } + inline fs::path getExecutionStatsCSVPath(const utbot::ProjectContext &projectContext) { - return getUTBotReportDir(projectContext) / "execution-stats.csv"; + return projectContext.getReportDirAbsPath() / "execution-stats.csv"; } //endregion 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..960e43d1f 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,9 @@ 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 buildDirPath = utbotProjectContext.getBuildDirAbsPath(); 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..ce9a398b9 100644 --- a/server/src/commands/Commands.cpp +++ b/server/src/commands/Commands.cpp @@ -329,15 +329,19 @@ Commands::ProjectContextOptionGroup::ProjectContextOptionGroup(CLI::App *command ->required(); projectContextOptions->add_option( - "-t,--tests-dir", testDir, "Relative path to directory in which tests will be generated.", + "-t,--tests-dir", testRelDir, "Relative path to directory in which tests will be generated.", true); projectContextOptions->add_option( - "-b,--build-dir", buildDir, + "-r,--report-dir", reportRelDir, "Relative path to directory in which sarif report will be generated.", + true); + + projectContextOptions->add_option( + "-b,--build-dir", buildRelDir, "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); } @@ -357,15 +361,19 @@ fs::path Commands::ProjectContextOptionGroup::getProjectPath() const { } std::string Commands::ProjectContextOptionGroup::getTestDirectory() const { - return testDir; + return testRelDir; +} + +std::string Commands::ProjectContextOptionGroup::getReportDirectory() const { + return reportRelDir; } std::string Commands::ProjectContextOptionGroup::getBuildDirectory() const { - return buildDir; + return buildRelDir; } -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..fbe32124c 100644 --- a/server/src/commands/Commands.h +++ b/server/src/commands/Commands.h @@ -50,6 +50,7 @@ namespace Commands { unsigned int getThreadsPerUser(); unsigned int getKleeProcessNumber(); + private: unsigned int port = 0; }; @@ -59,25 +60,43 @@ namespace Commands { explicit GenerateCommands(CLI::App *command); CLI::App *getProjectCommand(); + CLI::App *getStubsCommand(); + CLI::App *getFolderCommand(); + CLI::App *getFileCommand(); + CLI::App *getSnippetCommand(); + CLI::App *getFunctionCommand(); + CLI::App *getClassCommand(); + CLI::App *getLineCommand(); + CLI::App *getAssertionCommand(); + CLI::App *getPredicateCommand(); bool gotProjectCommand(); + bool gotStubsCommand(); + bool gotFolderCommand(); + bool gotFileCommand(); + bool gotSnippetCommand(); + bool gotFunctionCommand(); + bool gotClassCommand(); + bool gotLineCommand(); + bool gotAssertionCommand(); + bool gotPredicateCommand(); private: @@ -146,7 +165,7 @@ namespace Commands { // predicate info - testsgen::ValidationType type{ testsgen::ValidationType::INT32_T }; + testsgen::ValidationType type{testsgen::ValidationType::INT32_T}; static const std::map validationTypeMap; std::string validationType; std::string predicate; @@ -216,16 +235,19 @@ namespace Commands { [[nodiscard]] std::string getTestDirectory() const; + [[nodiscard]] std::string getReportDirectory() const; + [[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 testRelDir = Paths::UTBOT_TESTS; + std::string reportRelDir = Paths::UTBOT_REPORT; + std::string buildRelDir = Paths::UTBOT_BUILD; + std::string itfRelPath = Paths::UTBOT_ITF; }; struct SettingsContextOptionGroup { @@ -248,6 +270,7 @@ namespace Commands { [[nodiscard]] ErrorMode getErrorMode() const; [[nodiscard]] bool doDifferentVariablesOfTheSameType() const; + [[nodiscard]] bool getSkipObjectWithoutSource() const; private: 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/coverage/CLICoverageAndResultsWriter.cpp b/server/src/streams/coverage/CLICoverageAndResultsWriter.cpp index 3cdad2fe5..b25e0f2e2 100644 --- a/server/src/streams/coverage/CLICoverageAndResultsWriter.cpp +++ b/server/src/streams/coverage/CLICoverageAndResultsWriter.cpp @@ -51,7 +51,7 @@ void CLICoverageAndResultsWriter::writeResponse(const utbot::ProjectContext &pro } ss << "Totals:\n"; ss << totals; - fs::path resultsFilePath = Paths::getUTBotReportDir(projectContext) / "tests-result.log"; + fs::path resultsFilePath = projectContext.getReportDirAbsPath() / "tests-result.log"; FileSystemUtils::writeToFile(resultsFilePath, ss.str()); LOG_S(INFO) << ss.str(); } 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..13577979a 100644 --- a/server/src/utils/CLIUtils.cpp +++ b/server/src/utils/CLIUtils.cpp @@ -5,7 +5,6 @@ #include "commands/Commands.h" #include "loguru.h" -#include "config.h" using namespace GenerationUtils; using namespace Commands; @@ -45,27 +44,27 @@ void CLIUtils::setupLogger(const std::string &logPath, std::unique_ptr createProjectContextByOptions(const ProjectContextOptionGroup &projectContextOptions) { - fs::path projectPath = projectContextOptions.getProjectPath(); - fs::path testDir = - Paths::normalizedTrimmed(projectPath / projectContextOptions.getTestDirectory()); auto projectContext = - GrpcUtils::createProjectContext(projectContextOptions.getProjectName(), projectPath, - testDir, projectContextOptions.getBuildDirectory(), - projectContextOptions.getItfPath()); + GrpcUtils::createProjectContext(projectContextOptions.getProjectName(), + projectContextOptions.getProjectPath(), + projectContextOptions.getTestDirectory(), + projectContextOptions.getReportDirectory(), + projectContextOptions.getBuildDirectory(), + projectContextOptions.getItfRelPath()); return projectContext; } std::unique_ptr createSettingsContextByOptions(const SettingsContextOptionGroup &settingsContextOptionGroup) { return GrpcUtils::createSettingsContext( - settingsContextOptionGroup.doGenerateForStaticFunctions(), - settingsContextOptionGroup.isVerbose(), settingsContextOptionGroup.getTimeoutPerFunction(), - settingsContextOptionGroup.getTimeoutPerTest(), - settingsContextOptionGroup.isDeterministicSearcherUsed(), - settingsContextOptionGroup.withStubs(), - settingsContextOptionGroup.getErrorMode(), - settingsContextOptionGroup.doDifferentVariablesOfTheSameType(), - settingsContextOptionGroup.getSkipObjectWithoutSource()); + settingsContextOptionGroup.doGenerateForStaticFunctions(), + settingsContextOptionGroup.isVerbose(), settingsContextOptionGroup.getTimeoutPerFunction(), + settingsContextOptionGroup.getTimeoutPerTest(), + settingsContextOptionGroup.isDeterministicSearcherUsed(), + settingsContextOptionGroup.withStubs(), + settingsContextOptionGroup.getErrorMode(), + settingsContextOptionGroup.doDifferentVariablesOfTheSameType(), + settingsContextOptionGroup.getSkipObjectWithoutSource()); } std::vector getSourcePaths(const ProjectContextOptionGroup &projectContextOptions, 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..164814343 100644 --- a/server/src/utils/GrpcUtils.cpp +++ b/server/src/utils/GrpcUtils.cpp @@ -19,15 +19,17 @@ 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 &reportDirRelPath, + 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(reportDirRelPath); + result->set_builddirrelpath(buildDirRelPath); + result->set_itfrelpath(itfRelPath); return result; } @@ -192,8 +194,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..87f6d3076 100644 --- a/server/src/utils/GrpcUtils.h +++ b/server/src/utils/GrpcUtils.h @@ -18,9 +18,10 @@ 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 &reportDirRelPath, + 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..c5d5799b4 100644 --- a/server/test/framework/BaseTest.h +++ b/server/test/framework/BaseTest.h @@ -22,8 +22,10 @@ class BaseTest : public testing::Test { fs::path suitePath; CompilerName compilerName = CompilerName::CLANG; - std::string buildDirRelativePath; - std::string clientProjectPath = ""; + std::string buildDirRelPath; + std::string testsDirRelPath = Paths::UTBOT_TESTS; + std::string reportsDirRelPath = Paths::UTBOT_REPORT; + std::string clientProjectPath = Paths::UTBOT_ITF; 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..12c0c7bb4 100644 --- a/server/test/framework/Server_Tests.cpp +++ b/server/test/framework/Server_Tests.cpp @@ -59,8 +59,9 @@ namespace { void generateFiles(const fs::path &sourceFile, const fs::path &testsRelativeDir) { fs::path testsDirPath = getTestFilePath(testsRelativeDir); - auto projectContext = GrpcUtils::createProjectContext( - projectName, suitePath, testsDirPath, buildDirRelativePath, ""); + auto projectContext = GrpcUtils::createProjectContext(projectName, suitePath, testsDirPath, + Paths::UTBOT_REPORT, buildDirRelPath, + Paths::UTBOT_ITF); auto settingsContext = GrpcUtils::createSettingsContext(true, false, 30, 0, false, false, ErrorMode::PASSING, false, false); @@ -118,7 +119,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 +702,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 +725,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 +743,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 +758,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 +778,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 +822,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 +833,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 +995,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 +1016,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 +1040,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 +1062,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 +1073,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 +1085,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 +1101,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 +1118,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 +1132,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 +1146,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 +1160,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 +1187,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 +1209,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 +1232,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 +1253,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 +1271,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 +1288,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 +1311,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 +1532,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 +1545,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 +1569,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 +1591,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 +1604,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 +1633,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 +1644,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 +1682,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 +1693,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 +1729,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 +1740,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 +1776,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 +1787,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 +1833,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 +1867,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 +1895,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 +1908,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 +1925,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 +1935,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 +1943,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 +1973,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 +1983,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 +2012,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 +2020,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 +2049,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 +2072,13 @@ 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, clientProjectPath, testsDirRelPath, reportsDirRelPath, + buildDirRelPath, ""), 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 +2101,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 +2109,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 +2138,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 +2149,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 +2177,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 +2188,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 +2216,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 +2227,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, clientProjectPath, testsDirPath, reportsDirRelPath, buildDirRelPath, ""), 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 +2254,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 +2265,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, clientProjectPath, testsDirPath, reportsDirRelPath, buildDirRelPath, ""), 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 +2292,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 +2303,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..32867237d 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, Paths::UTBOT_TESTS, Paths::UTBOT_REPORT, 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)); } @@ -296,8 +296,8 @@ namespace testUtils { const fs::path &projectPath, const fs::path &filePath, ErrorMode errorMode) { - auto projectContext = - GrpcUtils::createProjectContext(projectName, projectPath, projectPath / "tests", "", ""); + auto projectContext = GrpcUtils::createProjectContext(projectName, projectPath, Paths::UTBOT_TESTS, + Paths::UTBOT_REPORT, "", Paths::UTBOT_ITF); // we actually don't pass all parameters except test directory and project name on client auto settingsContext = GrpcUtils::createSettingsContext(true, true, 10, 0, true, false, errorMode, false, false); @@ -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, + Paths::UTBOT_REPORT, 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/.vscode/tasks.json b/vscode-plugin/.vscode/tasks.json index ec98f06dc..9de2e4e0a 100644 --- a/vscode-plugin/.vscode/tasks.json +++ b/vscode-plugin/.vscode/tasks.json @@ -11,18 +11,25 @@ "presentation": { "reveal": "never" }, + "group": "build", + "label": "npm: watch", + "detail": "npm run lint && tsc -watch -p ./" + }, + { + "type": "npm", + "script": "compile", "group": { "kind": "build", "isDefault": true } // "dependsOn": [ - // "proto_gen" - // ] + // "proto_gen" + // ] } // { - // "label": "proto_gen", - // "command": "./protoc.sh", - // "args": ["${workspaceFolder}/../server/proto", "${workspaceFolder}/src/proto-ts"] - // }, + // "label": "proto_gen", + // "command": "./protoc.sh", + // "args": ["${workspaceFolder}/../server/proto", "${workspaceFolder}/src/proto-ts"] + // }, ] } diff --git a/vscode-plugin/package.json b/vscode-plugin/package.json index 1d9b5e46d..5983af9dd 100644 --- a/vscode-plugin/package.json +++ b/vscode-plugin/package.json @@ -470,11 +470,11 @@ "default": "", "markdownDescription": "%unittestbot.deployment.remotePath.description%" }, - "unittestbot.paths.buildDirectory": { + "unittestbot.paths.buildRelDirectory": { "type": "string", "default": "build", "minLength": 1, - "markdownDescription": "%unittestbot.paths.buildDirectory.description%" + "markdownDescription": "%unittestbot.paths.buildRelDirectory.description%" }, "unittestbot.paths.cmakeOptions": { "type": "array", @@ -487,21 +487,27 @@ ], "markdownDescription": "%unittestbot.paths.cmakeOptions.description%" }, - "unittestbot.paths.testsDirectory": { + "unittestbot.paths.testsRelDirectory": { "type": "string", "default": "tests", "minLength": 1, - "markdownDescription": "%unittestbot.paths.testsDirectory.description%" + "markdownDescription": "%unittestbot.paths.testsRelDirectory.description%" + }, + "unittestbot.paths.reportRelDirectory": { + "type": "string", + "default": "utbot_report", + "minLength": 1, + "markdownDescription": "%unittestbot.paths.reportRelDirectory.description%" }, "unittestbot.paths.sourceDirectories": { "type": "string", "default": "", "markdownDescription": "%unittestbot.paths.sourceDirectories.description%" }, - "unittestbot.paths.initialTeardownFunctions": { + "unittestbot.paths.itfRel": { "type": "string", "default": "", - "markdownDescription": "%unittestbot.paths.initialTeardownFunctions.description%" + "markdownDescription": "%unittestbot.paths.itfRel.description%" }, "unittestbot.testsGeneration.verboseFormatting": { "type": "boolean", diff --git a/vscode-plugin/package.nls.json b/vscode-plugin/package.nls.json index 02feb680e..57bca9e68 100644 --- a/vscode-plugin/package.nls.json +++ b/vscode-plugin/package.nls.json @@ -2,11 +2,12 @@ "unittestbot.deployment.utbotHost.description": "UTBot Server host address. [Learn more](https://github.com/UnitTestBot/UTBotCpp/wiki/vscode-extension-settings#deployment)", "unittestbot.deployment.utbotPort.description": "UTBot Server port. [Learn more](https://github.com/UnitTestBot/UTBotCpp/wiki/vscode-extension-settings#utbot-port)", "unittestbot.deployment.remotePath.description": "Remote path configuration specifies the path to the project on a remote host. [Learn more](https://github.com/UnitTestBot/UTBotCpp/wiki/vscode-extension-settings#remote-path)", - "unittestbot.paths.buildDirectory.description": "Relative path to build directory with compile_commands.json and/or coverage.json. [Learn more](https://github.com/UnitTestBot/UTBotCpp/wiki/vscode-extension-settings#build-directory)", + "unittestbot.paths.buildRelDirectory.description": "Relative path to build directory with compile_commands.json and/or coverage.json. [Learn more](https://github.com/UnitTestBot/UTBotCpp/wiki/vscode-extension-settings#build-directory)", "unittestbot.paths.cmakeOptions.description": "Options passed to CMake command. [Learn more](https://github.com/UnitTestBot/UTBotCpp/wiki/vscode-extension-settings#cmake-options)", - "unittestbot.paths.testsDirectory.description": "Relative path to directory in which tests will be generated. [Learn more](https://github.com/UnitTestBot/UTBotCpp/wiki/vscode-extension-settings#tests-directory)", + "unittestbot.paths.testsRelDirectory.description": "Relative path to directory in which tests will be generated. [Learn more](https://github.com/UnitTestBot/UTBotCpp/wiki/vscode-extension-settings#tests-directory)", + "unittestbot.paths.reportRelDirectory.description": "Relative path to directory in which sarif report for errors will be generated.", "unittestbot.paths.sourceDirectories.description": "Relative paths to directories, that are marked as source directories. Please, prefer using UTBot Explorer View instead of raw settings. [Learn more](https://github.com/UnitTestBot/UTBotCpp/wiki/vscode-extension-settings#source-directories)", - "unittestbot.paths.initialTeardownFunctions.description": "Relative paths to json, that contains list of initial and teardown functions", + "unittestbot.paths.itfRel.description": "Relative paths to json, that contains list of initial and teardown functions", "unittestbot.testsGeneration.verboseFormatting.description": "If set to true, tests will be formatted in more detailed form. [Learn more](https://github.com/UnitTestBot/UTBotCpp/wiki/vscode-extension-settings#verbose-formatting)", "unittestbot.testsGeneration.generateForStaticFunctions.description": "True, if you want UTBot to generate tests for static functions. [Learn more](https://github.com/UnitTestBot/UTBotCpp/wiki/vscode-extension-settings#generate-for-static-functions)", "unittestbot.testsGeneration.errorMode.description": "Choose the option: \"Failing\" means that error tests have runtime error, \"Passing\" means that no tests have runtime error.", diff --git a/vscode-plugin/src/client/client.ts b/vscode-plugin/src/client/client.ts index 2ea68200f..840d07058 100644 --- a/vscode-plugin/src/client/client.ts +++ b/vscode-plugin/src/client/client.ts @@ -242,12 +242,12 @@ export class Client { private async writeLog(responseAny: any): Promise { const logEntry = responseAny as LogEntry; - utbotUI.channels().outputServerLogChannel.append(logEntry.getMessage()); + utbotUI.channels().outputServerLogChannel.append(logEntry.toString()); } private async writeGTestLog(responseAny: any): Promise { const gtestEntry = responseAny as LogEntry; - utbotUI.channels().outputGTestChannel.appendLine(gtestEntry.getMessage()); + utbotUI.channels().outputGTestChannel.appendLine(gtestEntry.toString()); } private async provideLogChannel(): Promise { @@ -312,7 +312,7 @@ export class Client { } private updateConnectionState(connectionStatus: ConnectionStatus): void { - if (connectionStatus !== this.connectionStatus + if (connectionStatus !== this.connectionStatus && connectionStatus === ConnectionStatus.ESTABLISHED) { this.isNoConnectionEstablishedErrorLogged = true; } @@ -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.setClientprojectpath(vsUtils.getProjectDirByOpenedFile().fsPath); - projectContext.setItfpath(itfPath); + projectContext.setBuilddirrelpath(buildDirRelPath); + projectContext.setItfrelpath(itfRelPath); const projectConfigRequest = new ProjectConfigRequest(); projectConfigRequest.setProjectcontext(projectContext); projectConfigRequest.setConfigmode(configMode); @@ -428,10 +428,11 @@ export class Client { const projectContext = new ProjectContext(); projectContext.setProjectname(Prefs.getProjectName()); projectContext.setProjectpath(buildDir[0]); - projectContext.setTestdirpath(Prefs.getTestsDirPath()); - projectContext.setBuilddirrelativepath(buildDir[1]); projectContext.setClientprojectpath(vsUtils.getProjectDirByOpenedFile().fsPath); - projectContext.setItfpath(Prefs.getITFPath()); + projectContext.setTestdirrelpath(Prefs.getTestDirRelativePath()); + projectContext.setReportdirrelpath(Prefs.getReportDirRelativePath()); + projectContext.setBuilddirrelpath(buildDir[1]); + projectContext.setItfrelpath(Prefs.getItfRelPath()); rpcRequest.setProjectcontext(projectContext); rpcRequest.setSettingscontext(Prefs.getSettingsContext()); @@ -445,7 +446,7 @@ export class Client { } async requestFunctionTests( - params: RequestTestsParams, + params: RequestTestsParams, lineInfo: [string, number], responseHandler: ResponseHandler): Promise { logger.info( @@ -511,7 +512,7 @@ export class Client { } async requestFileTests( - params: RequestTestsParams, + params: RequestTestsParams, filePath: string, responseHandler: ResponseHandler): Promise { logger.info(`Sending file tests request, filepath: ${filePath}`); @@ -613,7 +614,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,9 +645,10 @@ export class Client { const projectContext = new ProjectContext(); projectContext.setProjectname(Prefs.getProjectName()); projectContext.setProjectpath(params.projectPath); - projectContext.setTestdirpath(Prefs.getTestsDirPath()); - projectContext.setBuilddirrelativepath(params.buildDirRelativePath); projectContext.setClientprojectpath(vsUtils.getProjectDirByOpenedFile().fsPath); + projectContext.setTestdirrelpath(Prefs.getTestDirRelativePath()); + projectContext.setReportdirrelpath(Prefs.getReportDirRelativePath()); + projectContext.setBuilddirrelpath(params.buildDirRelPath); rpcRequest.setProjectcontext(projectContext); rpcRequest.setSettingscontext(Prefs.getSettingsContext()); rpcRequest.setCoverage(true); @@ -782,7 +784,7 @@ export class Client { const logEntry = response as LogEntry; started.value = true; await this.handleResponse(response, progressKey, resolve, responseHandler); - utbotUI.channels().outputServerLogChannel.append(logEntry.getMessage()); + utbotUI.channels().outputServerLogChannel.append(logEntry.toString()); }) .on('error', (err) => { started.value = true; diff --git a/vscode-plugin/src/config/defaultValues.ts b/vscode-plugin/src/config/defaultValues.ts index 976af00a0..337268f60 100644 --- a/vscode-plugin/src/config/defaultValues.ts +++ b/vscode-plugin/src/config/defaultValues.ts @@ -1,9 +1,9 @@ import * as path from 'path'; import * as vs from 'vscode'; import * as vsUtils from '../utils/vscodeUtils'; -import { Prefs } from './prefs'; +import {Prefs} from './prefs'; import * as pathUtils from '../utils/pathUtils'; -import { isIP } from 'net'; +import {isIP} from 'net'; import {isWin32} from "../utils/utils"; export class DefaultConfigValues { @@ -14,6 +14,9 @@ export class DefaultConfigValues { public static readonly POSSIBLE_BUILD_DIR_NAMES = ['out', 'build']; public static readonly POSSIBLE_TEST_DIR_NAMES = ['test']; + public static readonly DEFAULT_BUILD_DIR_NAME = "build"; + public static readonly DEFAULT_TEST_DIR_NAME = "tests"; + public static readonly DEFAULT_CMAKE_OPTIONS = ['-DCMAKE_EXPORT_COMPILE_COMMANDS=ON', '-DCMAKE_EXPORT_LINK_COMMANDS=ON']; public static toWSLPathOnWindows(path: string): string { @@ -21,8 +24,8 @@ export class DefaultConfigValues { return path; } return path - .replace(/^(\w):|\\+/g,'/$1') - .replace(/^\//g,'/mnt/'); + .replace(/^(\w):|\\+/g, '/$1') + .replace(/^\//g, '/mnt/'); } public static hasConfiguredRemotePath(): boolean { @@ -52,7 +55,7 @@ export class DefaultConfigValues { return DefaultConfigValues.DEFAULT_SFTP_PORT; } - public static getDefaultSFTPUsername(): string{ + public static getDefaultSFTPUsername(): string { const username = vsUtils.getFromSftpConfig("username"); if ((username === undefined) || (username.length === 0)) { return "utbot"; @@ -92,7 +95,7 @@ export class DefaultConfigValues { public static async getDefaultBuildDirectoryPath(): Promise { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const rootPath = pathUtils.getRootPath(); - let buildDirName = "build"; + let buildDirName = DefaultConfigValues.DEFAULT_BUILD_DIR_NAME; if (!rootPath) { return buildDirName; } @@ -109,6 +112,10 @@ export class DefaultConfigValues { return buildDirName; } + public static async getDefaultTestsDirectoryPath(): Promise { + return DefaultConfigValues.DEFAULT_TEST_DIR_NAME; + } + public static looksLikeBuildDirectory(dirPath: string): boolean { return this.looksLike(dirPath, DefaultConfigValues.POSSIBLE_BUILD_DIR_NAMES); } diff --git a/vscode-plugin/src/config/prefs.ts b/vscode-plugin/src/config/prefs.ts index 47f009003..d5cf5876d 100644 --- a/vscode-plugin/src/config/prefs.ts +++ b/vscode-plugin/src/config/prefs.ts @@ -23,13 +23,15 @@ export class Prefs { public static HOST_PREF = 'unittestbot.deployment.utbotHost'; public static PORT_PREF = 'unittestbot.deployment.utbotPort'; + public static REMOTE_PATH_PREF = 'unittestbot.deployment.remotePath'; + public static TESTS_REL_DIR_PREF = 'unittestbot.paths.testsRelDirectory'; + public static REPORT_REL_PREF = 'unittestbot.paths.reportRelDirectory'; + public static BUILD_REL_DIR_PREF = 'unittestbot.paths.buildRelDirectory'; + public static ITF_REL_PATH_PREF = 'unittestbot.paths.itfRel'; - public static BUILD_DIR_PREF = 'unittestbot.paths.buildDirectory'; public static CMAKE_OPTIONS_PREF = 'unittestbot.paths.cmakeOptions'; - public static TESTS_DIR_PREF = 'unittestbot.paths.testsDirectory'; public static SOURCE_DIRS_PREF = 'unittestbot.paths.sourceDirectories'; - public static ITF_PATH_PREF = 'unittestbot.paths.initialTeardownFunctions'; public static VERBOSE_MODE_PREF = "unittestbot.testsGeneration.verboseFormatting"; @@ -178,13 +180,13 @@ export class Prefs { } public static getLocalBuildDirPath(): [string, string] { - const buildDir = this.getAsset(Prefs.BUILD_DIR_PREF); + const buildDir = this.getAsset(Prefs.BUILD_REL_DIR_PREF); const root = vsUtils.getProjectDirByOpenedFile(); return [root.fsPath, buildDir]; } public static getRemoteBuildDirPath(): [string, string] { - const buildDir = this.getAsset(Prefs.BUILD_DIR_PREF); + const buildDir = this.getAsset(Prefs.BUILD_REL_DIR_PREF); const root = this.getRemoteRoot(); return [root, buildDir]; } @@ -200,14 +202,6 @@ 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(); @@ -215,15 +209,13 @@ export class Prefs { return testsDirPath; } - public static getRemoteTestsDirPath(): string { - const testsDirRelative = this.getTestDirRelativePath(); - const root = this.getRemoteRoot(); - const testsDirPath = path.posix.join(root, testsDirRelative); - return testsDirPath; + public static getTestDirRelativePath(): string { + const testDirRaw = this.getAsset(Prefs.TESTS_REL_DIR_PREF); + return pathUtils.normalizeRawPosixPath(testDirRaw); } - public static getTestDirRelativePath(): string { - const testDirRaw = this.getAsset(Prefs.TESTS_DIR_PREF); + public static getReportDirRelativePath(): string { + const testDirRaw = this.getAsset(Prefs.REPORT_REL_PREF); return pathUtils.normalizeRawPosixPath(testDirRaw); } @@ -261,12 +253,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_REL_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 { @@ -356,7 +348,7 @@ export class Prefs { } public static async setBuildDirectory(path: string): Promise { - await this.setAsset(Prefs.BUILD_DIR_PREF, path); + await this.setAsset(Prefs.BUILD_REL_DIR_PREF, path); } public static async setCmakeOptions(options: string): Promise { @@ -365,7 +357,7 @@ export class Prefs { } public static getBuildDirectory(): string { - return this.getAsset(Prefs.BUILD_DIR_PREF); + return this.getAsset(Prefs.BUILD_REL_DIR_PREF); } public static isVerboseTestModeSet(): boolean { @@ -396,7 +388,7 @@ export class Prefs { errorMode = ErrorMode.PASSING; } else { errorMode = ErrorMode.FAILING; - } + } return errorMode; } 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/explorer/utbotExplorer.ts b/vscode-plugin/src/explorer/utbotExplorer.ts index 7b5a366d7..d11ba16e3 100644 --- a/vscode-plugin/src/explorer/utbotExplorer.ts +++ b/vscode-plugin/src/explorer/utbotExplorer.ts @@ -1,16 +1,16 @@ import * as vs from 'vscode'; -import { Commands } from '../config/commands'; -import { DefaultConfigValues } from "../config/defaultValues"; -import { Prefs } from '../config/prefs'; +import {Commands} from '../config/commands'; +import {DefaultConfigValues} from "../config/defaultValues"; +import {Prefs} from '../config/prefs'; import * as pathUtils from '../utils/pathUtils'; -import { registerCommand } from '../utils/utils'; -import { UTBotElement, UTBotExplorerFile, UTBotExplorerFolder } from "./utbotExplorerElement"; -import { UtbotExplorerEventsEmitter } from "./utbotExplorerEventsEmitter"; -import { UTBotExplorerStateStorage } from "./utbotExplorerStateStorage"; -import { UTBotExplorerTargetElement } from './UTBotExplorerTargetElement'; -import { UTBotSourceFoldersProvider } from "./utbotFoldersProvider"; -import { UTBotFoldersStorage } from "./utbotFoldersStorage"; -import { UTBotTargetsProvider } from './UTBotTargetsProvider'; +import {registerCommand} from '../utils/utils'; +import {UTBotElement, UTBotExplorerFile, UTBotExplorerFolder} from "./utbotExplorerElement"; +import {UtbotExplorerEventsEmitter} from "./utbotExplorerEventsEmitter"; +import {UTBotExplorerStateStorage} from "./utbotExplorerStateStorage"; +import {UTBotExplorerTargetElement} from './UTBotExplorerTargetElement'; +import {UTBotSourceFoldersProvider} from "./utbotFoldersProvider"; +import {UTBotFoldersStorage} from "./utbotFoldersStorage"; +import {UTBotTargetsProvider} from './UTBotTargetsProvider'; export class UTBotExplorer { @@ -107,7 +107,7 @@ export class UTBotExplorer { if (paths.length > 0) { await vs.workspace.openTextDocument(vs.Uri.file(paths[0])) .then(async (doc) => { - await vs.window.showTextDocument(doc, { preview: false }); + await vs.window.showTextDocument(doc, {preview: false}); }); } }); diff --git a/vscode-plugin/src/extension.ts b/vscode-plugin/src/extension.ts index 968b2372b..a884bd573 100644 --- a/vscode-plugin/src/extension.ts +++ b/vscode-plugin/src/extension.ts @@ -87,7 +87,7 @@ export async function activate(context: vs.ExtensionContext): Promise { }); vs.workspace.onDidChangeConfiguration(async (event) => { - if (event.affectsConfiguration(Prefs.BUILD_DIR_PREF)) { + if (event.affectsConfiguration(Prefs.BUILD_REL_DIR_PREF)) { await configureProject(); } }); @@ -239,7 +239,7 @@ export async function activate(context: vs.ExtensionContext): Promise { await showAllCommands(); }), registerCommand(Commands.OpenBuildDirectory, async () => { - await executeCommand('workbench.action.openSettings', 'unittestbot.paths.buildDirectory'); + await executeCommand('workbench.action.openSettings', 'unittestbot.paths.buildRelDirectory'); }) ); } 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..c981ffa63 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,11 @@ export class Protos { const projectContext = new ProjectContext(); projectContext.setProjectname(projectName); projectContext.setProjectpath(projectPath); - projectContext.setTestdirpath(Prefs.getTestsDirPath()); - projectContext.setBuilddirrelativepath(buildDirRelativePath); projectContext.setClientprojectpath(vsUtils.getProjectDirByOpenedFile().fsPath); - projectContext.setItfpath(Prefs.getITFPath()); + projectContext.setTestdirrelpath(Prefs.getTestDirRelativePath()); + projectContext.setReportdirrelpath(Prefs.getReportDirRelativePath()); + projectContext.setBuilddirrelpath(buildDirRelPath); + projectContext.setItfrelpath(Prefs.getItfRelPath()); projectInfo.setProjectcontext(projectContext); projectInfo.setSettingscontext(Prefs.getSettingsContext()); projectInfo.setSourcepathsList(srcPathsList);