-
Notifications
You must be signed in to change notification settings - Fork 68
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
Excluding dependencies in code coverage reports #26
Comments
Both the
If you're using the
could work. |
The following doesn't work... if(DEFINED ENV{CPM_SOURCE_CACHE})
add_code_coverage_all_targets(EXCLUDE $ENV{CPM_SOURCE_CACHE}/.*)
else()
add_code_coverage_all_targets(EXCLUDE build/.*)
endif()
target_code_coverage(Greeter)
target_code_coverage(GreeterTests AUTO .*) |
Ah, I see. To maintain flexibility between individual targets and the `all-type targets, they all maintain their own exclusion lists. So in this case, I'm pretty sure that, with the code above, running So to resolve here, I believe you just have to add the same excludes to the individual target_code_coverage calls, ala: if(DEFINED ENV{CPM_SOURCE_CACHE})
add_code_coverage_all_targets(EXCLUDE $ENV{CPM_SOURCE_CACHE}/.* build/.*)
else()
add_code_coverage_all_targets(EXCLUDE build/.*)
endif()
target_code_coverage(Greeter EXCLUDE $ENV{CPM_SOURCE_CACHE}/.* build/.*)
target_code_coverage(GreeterTests AUTO EXCLUDE .* $ENV{CPM_SOURCE_CACHE}/.*) |
I actually had an error in the above command, I didn't type if(DEFINED ENV{CPM_SOURCE_CACHE})
add_code_coverage_all_targets(EXCLUDE $ENV{CPM_SOURCE_CACHE}/.* build/.*)
else()
add_code_coverage_all_targets(EXCLUDE build/.*)
endif()
target_code_coverage(Greeter EXCLUDE $ENV{CPM_SOURCE_CACHE}/.* build/.*)
target_code_coverage(GreeterTests AUTO EXCLUDE .* $ENV{CPM_SOURCE_CACHE}/.*) /code-coverage.cmake:447 (add_dependencies):
The dependency target "ccov-report-GreeterTests" of target "ccov-report"
does not exist. |
Alright, new theory. After far too long, I think that the problem is that clang/LLVM excludes via a regex pattern, and GCC/lcov uses a globbing pattern. So try out having a pattern for both and see how that plays out: if(DEFINED ENV{CPM_SOURCE_CACHE})
add_code_coverage_all_targets(EXCLUDE
# For LLVM/clang
$ENV{CPM_SOURCE_CACHE}/.* build/.*
# For GCC/lcov
$ENV{CPM_SOURCE_CACHE}/* */build/*
)
else()
add_code_coverage_all_targets(EXCLUDE build/.* */build/*)
endif()
target_code_coverage(Greeter EXCLUDE $ENV{CPM_SOURCE_CACHE}/.* build/.* $ENV{CPM_SOURCE_CACHE}/* */build/*)
target_code_coverage(GreeterTests AUTO EXCLUDE .* * $ENV{CPM_SOURCE_CACHE}/.* $ENV{CPM_SOURCE_CACHE}/*) See if that starts removing things? |
And with gcc it just doesn't work (same error as before): code-coverage.cmake:424 (add_dependencies):
The dependency target "ccov-report-GreeterTests" of target "ccov-report"
does not exist. |
I'm having trouble reproducing this. Is there a repo/commit somewhere you can point me to with the issue? |
I've made it public https://github.com/mscofield0/ModernCppStarter |
Alright, I've got something that's works for me, with your repo, try it out.
The biggest thing that was wrecking me was the $ENV{CPM_SOURCE_CACHE}/, which if I didn't have it defined, meant that it was equivalent to '/', ie everything on a unix filesystem. Secondly was the build/* items, which for GCC appears in the .info files with the full path, and thus starting with just 'build' would match almost nothing. CHanging these to the CMAKE_BINARY_DIR, which is the root of the generated build files, including what CPM brings in by default, means all that would be automatically excluded. Also, if when running the GCC ccov you have an issue with the ccov-report target, update the CPMAddPackage for this repo from aa8c42b to e07087b or newer. |
It works on gcc lcov for me, but not for llvm-cov, the llvm-cov output remains the same as before. This is the CMake code: if(DEFINED ENV{CPM_SOURCE_CACHE})
# file(GLOB_RECURSE CCOV_EXCLUDES CONFIGURE_DEPENDS $ENV{CPM_SOURCE_CACHE}/*)
set(CCOV_EXCLUDES $ENV{CPM_SOURCE_CACHE}/.* $ENV{CPM_SOURCE_CACHE}/*)
endif()
# file(GLOB_RECURSE CCOV_EXCLUDES CONFIGURE_DEPENDS ${CMAKE_BINARY_DIR}/*)
set(CCOV_EXCLUDES ${CMAKE_BINARY_DIR}/.* ${CMAKE_BINARY_DIR}/*)
add_code_coverage_all_targets(EXCLUDE ${CCOV_EXCLUDES})
target_code_coverage(Greeter EXCLUDE ${CCOV_EXCLUDES})
target_code_coverage(GreeterTests AUTO EXCLUDE ${CCOV_EXCLUDES}) |
Bumping the issue |
I am using
CPM
for managing dependencies in my project and since it is source-based (downloads the source and then builds it),llvm-cov
finds and includes it in the code coverage report.I am using the caching feature of
CPM
so everything is in a.cache/CPM
directory.What do you suggest I do?
The text was updated successfully, but these errors were encountered: