Skip to content
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

Broken test coverage of functions inside functions #36825

Closed
guyvdbroeck opened this issue Jul 27, 2020 · 1 comment
Closed

Broken test coverage of functions inside functions #36825

guyvdbroeck opened this issue Jul 27, 2020 · 1 comment

Comments

@guyvdbroeck
Copy link

I'm having some trouble getting Julia to properly compute my test coverage.

A simple example of what goes wrong is in https://codecov.io/gh/Juice-jl/LogicCircuits.jl/src/257b9a792cb506329c7bb27e2ddfdedb1a097af7/src/LoadSave/vtree_line_compiler.jl
As you can see, there are functions defined inside of another function, and these are not accounted for properly. The code on line 45-48 is clearly not dead, and is actually executed in the unit tests, but not accounted for. Meanwhile the function headers on lines 44 and 50 are marked as not covered, even though they are executed during test.

Similar issues can be seen in other parts of my code that have a similar pattern: https://codecov.io/gh/Juice-jl/LogicCircuits.jl/src/257b9a792cb506329c7bb27e2ddfdedb1a097af7/src/LoadSave/circuit_line_compiler.jl
What's obviously a bug here is that some function bodies are covered, while their headers are not, which should be impossible.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Aug 27, 2020

It's a bit of a bigger bug, but I'm going to close this for at least the cases that aren't explicitly evil:

julia> @eval function f()
           $(Expr(:line, 6))
           nothing
       end
f (generic function with 1 method)

julia> @code_lowered f()
CodeInfo(
    @ REPL[1]:3 within `f'
1 ─     return Main.nothing
)

julia> ans.linetable
3-element Vector{Any}:
 Core.LineInfoNode(Main, :f, Symbol("REPL[1]"), 2, 0)
 Core.LineInfoNode(Main, :f, Symbol("REPL[1]"), 6, 0)
 Core.LineInfoNode(Main, :f, Symbol("REPL[1]"), 3, 0)

julia> f()

vtjnash added a commit that referenced this issue Aug 27, 2020
vtjnash added a commit that referenced this issue Aug 27, 2020
@vtjnash vtjnash closed this as completed in 8aaf971 Sep 1, 2020
vchuravy pushed a commit that referenced this issue Jan 22, 2021
vchuravy pushed a commit that referenced this issue Jan 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants