Skip to content
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

Kcov updated #1

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Kcov updated #1

wants to merge 7 commits into from

Conversation

PolyProgrammist
Copy link
Member

No description provided.

Comment on lines +85 to +88
return { "-g", "--coverage" };
case CompilerName::CLANG:
case CompilerName::CLANGXX:
return { "-fprofile-instr-generate", "-fcoverage-mapping" };
return { "-g", "-fprofile-instr-generate", "-fcoverage-mapping" };

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to add "-g" option since it is already added in Makefile



static void addLine(uint32_t lineNumber, bool covered, FileCoverage &fileCoverage) {
assert(lineNumber > 0);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than calling the assert function which causes server to crash, please throw an exception

Comment on lines +91 to +98
std::string pathToReport = "";
for (const auto &entry: fs::directory_iterator(coverageReportDirPath.string())) {
std::regex reg("(calc.).*$");
if (std::regex_search(entry.path().string(), reg)) {
pathToReport = entry.path().string() + "/cov.xml";
break;
}
}
Copy link

@operasfantom operasfantom Jun 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's extract this block to private method getPathToReport

@@ -153,6 +157,7 @@ add_llvm_executable(utbot main.cpp)
target_link_libraries(utbot PUBLIC
UnitTestBotLib
loguru
pugixml #########

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to link with pugixml again since it is already linked to UnitTestBotLib. The same practice should be applicable to loguru library

@@ -180,6 +185,7 @@ if (ENABLE_UNIT_TESTS)
PUBLIC
gtest
UnitTestBotLib
pugixml
Copy link

@operasfantom operasfantom Jun 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the comment related to utbot target


std::string pathToReport = "";
for (const auto &entry: fs::directory_iterator(coverageReportDirPath.string())) {
std::regex reg("(calc.).*$");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can avoid building std::regex object every single time and construct the corresponding object just once per program, say, declaring it as a global const static variable

@@ -377,7 +377,9 @@ namespace printer {

declareTarget("bin", { FORCE }, { stringFormat("echo %s", coverageInfoBinary) });

utbot::RunCommand testRunCommand{ { testExecutablePath.string(), "$(GTEST_FLAGS)" },
std::string kcovRunCommand = "kcov " + (projectContext.buildDir.string() + "/report ") + testExecutablePath.string();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please reuse getKcovReportDir here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants