-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
Kcov updated #1
Conversation
return { "-g", "--coverage" }; | ||
case CompilerName::CLANG: | ||
case CompilerName::CLANGXX: | ||
return { "-fprofile-instr-generate", "-fcoverage-mapping" }; | ||
return { "-g", "-fprofile-instr-generate", "-fcoverage-mapping" }; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
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; | ||
} | ||
} |
There was a problem hiding this comment.
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 ######### |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.).*$"); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reuse getKcovReportDir
here
No description provided.