Skip to content

Commit

Permalink
Let amend_coverage_from_src! skip partially covered code
Browse files Browse the repository at this point in the history
This is meant to fix issue JuliaCI#187
  • Loading branch information
fingolfin committed Mar 7, 2019
1 parent dc69585 commit 6dfd139
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/Coverage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,19 @@ module Coverage
flines = function_body_lines(ast)
if !isempty(flines)
flines .+= linestart-1

if any(l -> l > length(coverage), flines)
error("source file is longer than .cov file; source might have changed")
end

# If any line has coverage, assume that Julia executed this code, and
# don't modify any coverage data. This works around issues with inlined
# code, see https://github.com/JuliaCI/Coverage.jl/issues/187
if any(l -> coverage[l] != nothing, flines)
continue
end

for l in flines
if l > length(coverage)
error("source file is longer than .cov file; source might have changed")
end
if coverage[l] === nothing
coverage[l] = 0
end
Expand Down

0 comments on commit 6dfd139

Please sign in to comment.