Skip to content

Fix extern #683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions server/src/Paths.cpp
Original file line number Diff line number Diff line change
@@ -375,8 +375,9 @@ namespace Paths {

fs::path sourcePathToStubPath(const utbot::ProjectContext &projectContext,
const fs::path &source) {
return normalizedTrimmed((projectContext.getTestDirAbsPath() / "stubs" / getRelativeDirPath(projectContext, source) /
sourcePathToStubName(source)));
return normalizedTrimmed(
(projectContext.getTestDirAbsPath() / "stubs" / getRelativeDirPath(projectContext, source) /
sourcePathToStubName(source)));
}

fs::path testPathToSourcePath(const utbot::ProjectContext &projectContext,
@@ -386,6 +387,20 @@ namespace Paths {
return projectContext.projectPath / relative / filename;
}

std::pair<fs::path, fs::path> getSourceAndTestPath(const utbot::ProjectContext &projectContext,
const fs::path &filePath) {
fs::path sourcePath;
fs::path testPath;
if (isSubPathOf(projectContext.getTestDirAbsPath(), filePath)) {
testPath = filePath;
sourcePath = testPathToSourcePath(projectContext, filePath);
} else {
testPath = sourcePathToTestPath(projectContext, filePath);
sourcePath = filePath;
}
return {sourcePath, testPath};
}

fs::path getMakefilePathFromSourceFilePath(const utbot::ProjectContext &projectContext,
const fs::path &sourceFilePath,
const std::string &suffix) {
3 changes: 3 additions & 0 deletions server/src/Paths.h
Original file line number Diff line number Diff line change
@@ -404,6 +404,9 @@ namespace Paths {

fs::path testPathToSourcePath(const utbot::ProjectContext &projectContext, const fs::path &testFilePath);

std::pair<fs::path, fs::path> getSourceAndTestPath(const utbot::ProjectContext &projectContext,
const fs::path &filePath);

fs::path getRelativeDirPath(const utbot::ProjectContext &projectContext, const fs::path &source);

std::optional<std::string> getRelativePathWithShellVariable(const fs::path &shellVariableForBase,
2 changes: 1 addition & 1 deletion server/src/Synchronizer.h
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ class Synchronizer {

[[nodiscard]] bool isProbablyOutdatedWrappers(const fs::path &srcFilePath) const;

[[nodiscard]] bool removeStubIfSourceAbsent(const StubOperator &stub) const;
bool removeStubIfSourceAbsent(const StubOperator &stub) const;

void synchronizeStubs(std::unordered_set<StubOperator, HashUtils::StubHash> &outdatedStubs,
const types::TypesHandler &typesHandler);
6 changes: 3 additions & 3 deletions server/src/building/IRParser.cpp
Original file line number Diff line number Diff line change
@@ -25,13 +25,13 @@ bool IRParser::parseModule(const fs::path &rootBitcode, tests::TestsMap &tests)
fs::path const &sourceFile = it.key();
tests::Tests &test = it.value();
test.isFilePresentedInArtifact = true;
for (const auto &[methodName, methodDescription] : test.methods) {
for (const auto &[methodName, methodDescription]: test.methods) {
std::string entryPointFunction = KleeUtils::entryPointFunction(test, methodName, true);
std::string methodDebugInfo =
StringUtils::stringFormat("Method: '%s', file: '%s'", methodName, sourceFile);
if (llvm::Function *pFunction = module->getFunction(entryPointFunction)) {
continue;
} else {
std::string methodDebugInfo =
StringUtils::stringFormat("Method: '%s', file: '%s'", methodName, sourceFile);
LOG_S(DEBUG) << "llvm::Function is null: " << methodDebugInfo;
test.isFilePresentedInArtifact = false;
}
3 changes: 1 addition & 2 deletions server/src/coverage/LlvmCoverageTool.cpp
Original file line number Diff line number Diff line change
@@ -112,8 +112,7 @@ LlvmCoverageTool::getCoverageCommands(const std::vector<UnitTest> &testsToLaunch
for (const std::string &objectFile : objectFiles) {
if (firstBIN) {
firstBIN = false;
}
else {
} else {
exportArguments.emplace_back("-object");
}
exportArguments.emplace_back(objectFile);
17 changes: 8 additions & 9 deletions server/src/coverage/TestRunner.cpp
Original file line number Diff line number Diff line change
@@ -127,29 +127,28 @@ std::vector<UnitTest> TestRunner::getTestsToLaunch() {
}
return result;
}
auto [sourcePath, testPath] = Paths::getSourceAndTestPath(projectContext,
projectContext.projectPath / testFilePath.value());
fs::path makefile = Paths::getMakefilePathFromSourceFilePath(projectContext, sourcePath);

if (testName.empty() && functionName.empty()) {
//for file
fs::path sourcePath = Paths::testPathToSourcePath(projectContext, testFilePath.value());
fs::path makefile = Paths::getMakefilePathFromSourceFilePath(projectContext, sourcePath);
return getTestsFromMakefile(makefile, testFilePath.value());
return getTestsFromMakefile(makefile, testPath);
}

if (testName.empty()) {
//for function
fs::path sourcePath = Paths::testPathToSourcePath(projectContext, testFilePath.value());
fs::path makefile = Paths::getMakefilePathFromSourceFilePath(projectContext, sourcePath);


std::string renamedMethodDescription = KleeUtils::getRenamedOperator(functionName);
StringUtils::replaceColon(renamedMethodDescription);

std::string filter = "*." + renamedMethodDescription + Paths::TEST_SUFFIX + "*";
std::string filter = "*." + renamedMethodDescription + Paths::TEST_SUFFIX + "*";

return getTestsFromMakefile(makefile, testFilePath.value(), filter);
return getTestsFromMakefile(makefile, testPath, filter);
}

//for single test
return {UnitTest{testFilePath.value(), testSuite, testName}};
return {UnitTest{testPath, testSuite, testName}};
}

grpc::Status TestRunner::runTests(bool withCoverage, const std::optional<std::chrono::seconds> &testTimeout) {
2 changes: 1 addition & 1 deletion server/src/fetchers/GlobalVariableUsageMatchCallback.cpp
Original file line number Diff line number Diff line change
@@ -67,7 +67,7 @@ void GlobalVariableUsageMatchCallback::handleUsage(const clang::FunctionDecl *fu
const std::string usedParamTypeString = varDecl->getType().getAsString();
types::Type paramType = types::Type(realParamType, usedParamTypeString, sourceManager);
method.globalParams.emplace_back(paramType, usage.variableName, AlignmentFetcher::fetch(varDecl));
if (varDecl->isExternC() && !varDecl->isKnownToBeDefined()) {
if (!paramType.isPointerToFunction() && varDecl->isExternC() && !varDecl->hasDefinition()) {
tests.externVariables.insert({paramType, usage.variableName});
}
}
Loading
Loading