Skip to content

Commit

Permalink
Fix tests on Julia v0.7 (#136)
Browse files Browse the repository at this point in the history
* JuliaLang/julia#22161 updated the parser and
  caused some changes in how Coverage works
* For test/data/testparser.jl, line 10 is the end of a @doc string (`"""
  ->`), and Line 11 is an expression (`f6(x) = 6x`)
* Before the above commit, the zero count goes to line 10, and after,
  the zero count goes (more correctly?) to line 11
  • Loading branch information
kmsquire authored and tkelman committed Sep 8, 2017
1 parent b45798c commit bb8199e
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,17 @@ cd(dirname(@__DIR__)) do
cmdstr = "include(\"$(escape_string(srcname))\"); using Base.Test; @test f2(2) == 4"
run(`$JULIA_HOME/julia --code-coverage=user -e $cmdstr`)
r = process_file(srcname, datadir)
# The next one is the correct one, but julia & JuliaParser don't insert a line number after the 1-line @doc -> test
# See https://github.com/JuliaLang/julia/issues/9663 (when this is fixed, can uncomment the next line on julia 0.4)
target = Union{Int64,Void}[nothing, 1, nothing, 0, nothing, 0, nothing, nothing, nothing, 0, nothing, nothing, nothing, nothing, nothing, nothing, 0, nothing, nothing, 0, nothing, nothing, nothing, nothing]
#target = Union{Int64,Void}[nothing, 1, nothing, 0, nothing, 0, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, 0, nothing, nothing, 0, nothing, nothing, nothing, nothing]

# Parsing seems to have changed slightly in Julia (or JuliaParser?) between v0.6 and v0.7.
# Line 10 is the end of a @doc string (`""" ->`), and Line 11 is an expression (`f6(x) = 6x`)
# In v0.6, the zero count goes to line 10, and in v0.7, the zero count goes (more correctly?)
# to line 11

if VERSION < v"0.7.0-DEV.468"
target = Union{Int64,Void}[nothing, 1, nothing, 0, nothing, 0, nothing, nothing, nothing, 0, nothing, nothing, nothing, nothing, nothing, nothing, 0, nothing, nothing, 0, nothing, nothing, nothing, nothing]
else
target = Union{Int64,Void}[nothing, 1, nothing, 0, nothing, 0, nothing, nothing, nothing, nothing, 0, nothing, nothing, nothing, nothing, nothing, 0, nothing, nothing, 0, nothing, nothing, nothing, nothing]
end
@test r.coverage[1:length(target)] == target

covtarget = (sum(x->x != nothing && x > 0, target), sum(x->x != nothing, target))
Expand Down

0 comments on commit bb8199e

Please sign in to comment.