Let amend_coverage_from_src! skip partially covered code (WIP) #188
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is meant to fix issue #187, or at least reduce the problem, by not applying
amend_coverage_from_src!
to functions which already have some coverage information, based on the idea that those functions were executed by Julia, and the coverage information therein then should just be "trusted".There are various issues with this in its current state, but I don't have more time right now to tune it, so I though it's better to post this now in case people like @ronisbr or @tkoolen are interested in giving it a spin.
Among the problems are:
Meta.parse
will read a whole module in one go; but then unused functions in that module are not marked as code again. So the code needs to be refined to look inside modules, and then iterate over the functions therein. In fact it probably needs to traverse the whole AST and treat each function separately, to also deal with nested functions. Ho-hum. It would be really nice if we didn't have to do any of this, and Julia just did the "right thing" for functions that are never executed (whatever that means exactly...)Example:
src/Coverage.jl
from this package with master resp. 0.7.0 vs. with this PRwith
blocks also may need special treatment: correct coverage with master, incorrect with this PR.Note that both of these issues of course would also appear if
amend_coverage_from_src!
was simply removed.On the plus side, I suspect that e.g. the example by @tkooolen for coverage in
StaticArrays.jl/src/eigen.jl
will look a lot better, because a lot of the red lines will turn into gray/white (= "not code") again.I can try to see if things can be improved, but I'll have to learn how the AST returned by
Meta.parse
works... If somebody more knowledgeable than me on these things (e.g. some actual Julia developers) wants to take over, be my guest ;-).