spdlog icon indicating copy to clipboard operation
spdlog copied to clipboard

Branch coverage issue for SPDLOG in gcov

Open Saravanan1987 opened this issue 1 year ago • 4 comments

We are using spdlog in our code and generating coverage reports for our .cpp files. It appears that gcov is reporting some lines as partially covered:

Line 1: SPDLOG_INFO( "{} Config {}", std::string(20, '='), std::string(20, '=') ) shows branchesToCover="8" coveredBranches="4"

Line 2: SPDLOG_INFO( "Username: {}", username ) shows branchesToCover="4" coveredBranches="2"

We want to address these branch coverage issues without making significant changes to the codebase by using gcov exclude flags. Is there a way to configure gcov settings within spdlog to avoid these branch coverage issues?

Saravanan1987 avatar Sep 11 '24 19:09 Saravanan1987

Do you want coverage to be 100%? Some say that should not be the goal, but why would you want to do that?

tt4g avatar Sep 11 '24 21:09 tt4g

I don't aim for 100% coverage. Since we're using the library, I want to ensure the coverage isn't negatively impacted by it.

Saravanan1987 avatar Sep 11 '24 21:09 Saravanan1987

I think PR is acceptable if it does not change the behavior of spdlog. Note that a PR that changes behavior for the motive of “for coverage” is unlikely to be acceptable.

tt4g avatar Sep 11 '24 21:09 tt4g

FYI. due to the nature of the C++ language, coverage may not be high: c++ - constexpr constructor won't show coverage data - Stack Overflow

tt4g avatar Sep 11 '24 21:09 tt4g