-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Coverage misses lines #28192
Comments
Now is perhaps a good time to update LineInfoNode to track line-number ranges in the parser (but might be hard still for the optimizer to handle updating this information). And see also https://github.com/JuliaLang/julia/pull/11802/files Perhaps we should inject this information before optimization (like we are doing at the llvm level), as this'll problem will only get worse as our optimizer gets better. We could more-easily do it then at the basic-block level. This would be more likely to require recompiling the system image to switch the flag though. |
We are seeing the same thing starting in Julia 0.7. Every Julia 0.7 and 1.0 project with test coverage I've seen suffer from the same thing. I've tried with |
Any updates on this issue? |
I don't know whether this is related, but LightGraphs just dropped to from 99.8% to 66% codecov (and the reported coverage gaps don't make sense). |
I have the same problem in one of my packages. It simply misses lines, as in the OP. |
To clarify, this issue is certainly amplified by recent changes to https://github.com/JuliaCI/Coverage.jl These are my "fault", although I "only" enabled code that was used on Julia 0.6 to also work correctly on Julia 0.7 and 1.0, which made the issue much more visible. Some discussions on mitigating the problem: |
Hey folks, this is really getting frustrating. LightGraphs dropped from 100% to 68% code coverage several months ago, and I can't use the Right now all our PRs are failing because we require codecov to be > 97%. I'd rather not change that, because it's an important metric. Also, it makes the project look bad to show a red "68%" coverage badge, especially when we've spent all this time getting coverage up to 100%. What workarounds are available right now? |
(Disclaimer: This doesn’t actually answer the core issue.)
On your --inline=no PR (sbromberger/LightGraphs.jl#1072), Travis passes on
Julia 0.7 but fails on Julia nightly. Perhaps as a short term fix you could
edit your .travis.yml to allow failures on Julia nightly?
…On Sun, Dec 2, 2018 at 18:58 Seth Bromberger ***@***.***> wrote:
Hey folks, this is really getting frustrating. LightGraphs dropped from
100% to 68% code coverage, and I can't use the --inline=no trick because
1) it results in an inference error (that doesn't occur with inlining), and
2) travis times out.
Right now all our PRs are failing because we require codecov to be > 97%.
I'd rather not change that, because it's an important metric. Also, it
makes the project look bad to show a red "68%" coverage badge.
What workarounds are available right now?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#28192 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFXArdY5knKt5DUZvQ_yPnOkmvmJ3fuqks5u1GkRgaJpZM4VW4vt>
.
|
@DilumAluthge thanks. That might address one concern, but all PRs will still fail because we have a policy of only allowing PRs that have an aggregate codecov of 99+% and that do not drop the overall codecov below 97%. |
As an update, setting I don't know how to get proper reporting at this point. |
Maybe you needs something like https://github.com/auchenberg/volkswagen for the interim ;-) |
So one option would be to revert some of the Another potential solution is described on JuliaCI/Coverage.jl#188 -- that PR is incomplete, though, but I do try to sketch how one could complete it. The core idea there is that a function which has zero lines with coverage likely is unused, so we just mark all its lines as unexecuted code. So far, |
This isn't the problem, I don't think. We have 100% coverage of all functions in the tests. The problem is that something changed and the coverage is not being reported. Here's an example. How is it that lines 26 and 28 both have coverage (3 separate times), but line 27 - which is not in the middle of any branch - has no coverage? I can tell you that this function is being tested here. This has happened throughout the codebase and it all started a few months ago.
Again, we don't have any of these to my knowledge. All functions are tested. We had a huge effort about a year and a half ago to ensure that all the code receives test coverage. |
We never found a workaround. |
@sbromberger Let me explain a bit longer as to why I think that what I wrote is 100% relevant to the problem. I need to elaborate a bit for this, so please bear with me... When Julia is aksed to generate coverage data, it outputs coverage files for every source file (see the description of this issue for an example). In there, it records (slightly simplified) for every line whether it contains code or not; if it contains code, it also records how often that line was executed, as a non-negative integer. The number Now, what happens in practice is that Julia reports a lot of lines which you and me would clearly consider as "this is code" instead as "this is not code at all". The result is that these lines do not contribute for coverage. Now, this essentially happens in two cases:
These two cases have ultimately (I think) the same origin (but really, it doesn't matter, so let's not squabble about it), but have very different effects:
Now, what happened until recently is that Coverage.jl for Julia 0.7 and 1.0 simply passed on the reported coverage data to Codecov. This resulted in reports like this one where you see that line 27 clearly contains code, but the report says it is not code. While in this newer report, line 27 is marked as "code that was not executed". But for Julia 0.6, Coverage.jl had (has) a function What does Hence my proposed fix: teach |
Thanks, @fingolfin - that was really helpful. If it helps, Also, I'm confused:
But we had ~100% code coverage in 0.6 as well, so whatever happened wasn't a 1:1 reimplementation for 0.7/1.0. |
In Julia 0.6, this inlining issue did not exist (AFAIU) |
Hmm, in our experiment it didn't make any difference whatsoever. Did we miss something? Here's the commit. And here's the resulting coverage report.
|
|
I think #30251 should much improve case 2 for |
@maleadt Thanks, that's useful. I picked a file "at random" to get an idea how often case 1 (code is inlined and incorrectly marked as unexecuted code) vs case 2 (actual dead code) is. Specifically, I chose Looking at it, we see that for example lines 43+44, which contain predicate_int(inst::Instruction) = API.LLVMGetICmpPredicate(ref(inst))
predicate_real(inst::Instruction) = API.LLVMGetFCmpPredicate(ref(inst)) are marked as "not code" in the former, but are marked as "dead code" in the latter. I can't tell which one is correct, though, but I assume you can tell us? If it is actual dead code, then this is case 2 in my description above, and so in a sense an improvement. If it is code that is not dead, then it means these functions were simply completely inlined. Unfortunately, this then is a situation which the heuristic I described as potential workaround above (and also see JuliaCI/Coverage.jl#188) won't be able to deal with. And then I don't see anything that Coverage.jl could do to disambiguate the two cases. So I guess if this is happening, then the only fix for it is to stop using |
According to https://github.com/maleadt/LLVM.jl/search?q=predicate_int&unscoped_q=predicate_int there is indeed no place calling |
Thanks for the analysis, that is dead (well, untested) code indeed so definitely an improvement. |
I found that amend_coverage missed a function (https://codecov.io/gh/maleadt/LLVM.jl/src/752aae1a6f86d17877633c6cea70a529a1ad05a4/src/passmanager.jl#L5), but that everything reported seemed correct. |
Awesome, thanks @vtjnash! |
Thanks @vtjnash ! Hmm, I wonder a bit about function |
That global code is executed during precompilation, in a different process, which doesn't get passed the coverage flag. The compiler also doesn't seem ready to handle this. But even then, these kind of codes are typically executed by the interpreter, which doesn't seem to record coverage at all. |
Nice, thanks! The |
Is there any solution now for julia 1 and 1.1? |
I haven't understood the extent of this problem until recently but this seems like Real Bad (TM) |
Can this get a milestone? |
What milestone and why? |
Any milestone (I'm guessing it would have to be 2.0 because if I'm understanding correctly, the solution is to update LineNumberNode to Vector{LineNumberNode}) because code coverage is a critical "sanity check" for testing and writing stable/functional code. |
For this file: https://github.com/invenia/Memento.jl/blob/master/src/stdlib.jl
The coverage report is:
Notice that
level = lowercase(string(cl_level))
is between two covered lines but somehow isn't reported as covered.The text was updated successfully, but these errors were encountered: