Odd counts from code coverage on 0.7/1.0


#1

Probably not very important, but code coverage is giving slightly odd results on 1.0 (and 0.7) in comparison to 0.6. Does anyone know why? Consider

function foo(array::Vector{Float64})
  v = 0.0
  for i in 1:length(array)
    if mod(i, 10) != 0
      v += array[i]
    else
      v -= array[i]
    end
  end
  return v
end

foo(fill(1.0, 10000))

The .cov file produced by julia --code-coverage=user on 0.6 gives

        - function foo(array::Vector{Float64})
        1   v = 0.0
        1   for i in 1:length(array)
    10000     if mod(i, 10) != 0
     9000       v += array[i]
        -     else
     1000       v -= array[i]
        -     end
        -   end
        1   return v
        - end
        - 
        - foo(fill(1.0, 10000))
        - 

as expected. But on 0.7/1.0 it gives

        - function foo(array::Vector{Float64})
        1   v = 0.0
        1   for i in 1:length(array)
    10000     if mod(i, 10) != 0
     9000       v += array[i]
        -     else
    20000       v -= array[i]
        -     end
        -   end
        1   return v
        - end
        - 
        - foo(fill(1.0, 10000))
        - 

If the != is changed to ==, then the count for the if statement is correct (1000) but the count for the else statement is still 20000.


#2

Running with --inline=no gives the right counts. So I guess this has something to do with optimization.


#3

Recently I am getting very low coverage for some packages on Travis, for some packages it dropped from 90% to 50%. I wonder if this is related, or some recent change.


#4

Have seen something similar:

10/25 seems to have been the date where things changed.