You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Upon reviewing this one I can see a major issue. MRI does not store eval parses in coverage at all? So the reported issue is more bizarre than just being the wrong size. The eval happens to have the exact same name as the file so it gets its coverage data stored in the hash. The original file is left out. If I remove the FILE from the eval then JRuby has 2 entries with the original file containing the proper data and an eval entry with the data you reported. I think I just need to remove any evals from recording coverage info?
Ah. So here is a clue simplecov-ruby/simplecov#38. So coverage only tracks require. I just checked and this also includes load. So I think I can just check to see if parse is eval and if so then it means it must have came from load/require.
Yucky wrinkle in fixing this. We enable a global hook for all LINE EVENTS whereas MRI will instrument live events into the source only for iseqs (which is IRScopes for us). Since FILE is used as the eval's name it ends up sending it's coverage events info to the coverage array and we end up mixing the eval and regular file coverage data up.
So the fix is to remove the global COVERAGE_HOOK and to replace it with instrumented code.
ifdefined?(JRUBY_VERSION) && defined?(JRuby)# @see https://github.com/jruby/jruby/issues/1196# @see https://github.com/metricfu/metric_fu/pull/226# @see https://github.com/colszowka/simplecov/issues/420# @see https://github.com/colszowka/simplecov/issues/86# @see https://jira.codehaus.org/browse/JRUBY-6106unlessJRuby.runtime.debug?warn'Coverage may be inaccurate; set "cli.debug=true" ("-Xcli.debug=true") in your .jrubyrc or' \
' do JRUBY_OPTS="-d"'end
@bf4 I think once I address not generating events for eval code along with a local fix I made to not mutilate the coverage array locally then coverage will just be working correctly. My last comment shows it is not quite trivial but I think doable.
So this will only be fixed from JRuby 9k and not JRuby 1.7 because we have a completely different runtime and the effort to fix this on 1.7 will be more than it was for 9k. If there is enough pushback someone can open a new issue against 1.7.
@enebo do I understand your comment correctly to mean that JRuby 9k+ shouldn't the comment of warning? It was attached to the 9.1 milestone so should it rather not be applicable to JRuby 9.1+?
tobi@speedy ~/dev/coverage_sample $ asdf local ruby jruby-9.1.7.0
tobi@speedy ~/dev/coverage_sample $ jruby runner.rb
11
runner.rb:4: warning: tracing (e.g. set_trace_func) will not capture all events without --debug flag
11
tobi@speedy ~/dev/coverage_sample $ jruby --debug runner.rb
11
11
tobi@speedy ~/dev/coverage_sample $ asdf local ruby jruby-9.0.5.0
tobi@speedy ~/dev/coverage_sample $ jruby runner.rb
11
runner.rb:4: warning: tracing (e.g. set_trace_func) will not capture all events without --debug flag
7
tobi@speedy ~/dev/coverage_sample $ jruby --debug runner.rb
11
7
tobi@speedy ~/dev/coverage_sample $
9.0.5.0 looks off but off in a different manner (albeit both with --debug and without)
edit: also just discovered another failure in the simplecov test suite that happens only on 9.0.5.0 but not 9.1 - so I guess the fixes really were 9.1, thanks for taking the time Tom!
@enebo question was more to confirm that coverage is only expected to work fully in 9.1+ to which I found out the answer is most likely yes so that's the official support target now. Thanks! :)
@enebo I remembered my question! Right now simplecov still propmpts users to enable the debug mode, is this still necessary or should we be good without debug mode?
@PragTob sorry for the long delay in replying but I was travelling. We still need --debug because we do not emit trace instructions into our emitted IR instructions without it. In the future we can invalidate ALL methods once tracing is called to re-compile all methods to emit a version with these instrs but it is not high in the priority list...
Activity
Turn off Coverage tests under JRuby.
Turn off Coverage tests under JRuby.
enebo commentedon Mar 21, 2016
Upon reviewing this one I can see a major issue. MRI does not store eval parses in coverage at all? So the reported issue is more bizarre than just being the wrong size. The eval happens to have the exact same name as the file so it gets its coverage data stored in the hash. The original file is left out. If I remove the FILE from the eval then JRuby has 2 entries with the original file containing the proper data and an eval entry with the data you reported. I think I just need to remove any evals from recording coverage info?
enebo commentedon Mar 21, 2016
Ah. So here is a clue simplecov-ruby/simplecov#38. So coverage only tracks require. I just checked and this also includes load. So I think I can just check to see if parse is eval and if so then it means it must have came from load/require.
enebo commentedon Mar 21, 2016
Yucky wrinkle in fixing this. We enable a global hook for all LINE EVENTS whereas MRI will instrument live events into the source only for iseqs (which is IRScopes for us). Since FILE is used as the eval's name it ends up sending it's coverage events info to the coverage array and we end up mixing the eval and regular file coverage data up.
So the fix is to remove the global COVERAGE_HOOK and to replace it with instrumented code.
bf4 commentedon Mar 22, 2016
@enebo Thanks for looking into this :)
SimpleCov now has https://github.com/colszowka/simplecov/blob/cffb463890eae605a9b3f0b4437d1dbbe2271c42/lib/simplecov.rb#L5-L17
and simplecov-ruby/simplecov#430
enebo commentedon Mar 22, 2016
@bf4 I think once I address not generating events for eval code along with a local fix I made to not mutilate the coverage array locally then coverage will just be working correctly. My last comment shows it is not quite trivial but I think doable.
Make RootNode of AST know whether it requires coverage or not.
Fixes #1196 Coverage reports wrong number of lines...and then some.
enebo commentedon Mar 23, 2016
So this will only be fixed from JRuby 9k and not JRuby 1.7 because we have a completely different runtime and the effort to fix this on 1.7 will be more than it was for 9k. If there is enough pushback someone can open a new issue against 1.7.
PragTob commentedon Jan 25, 2017
@enebo do I understand your comment correctly to mean that JRuby 9k+ shouldn't the comment of warning? It was attached to the 9.1 milestone so should it rather not be applicable to JRuby 9.1+?
As a reference I reran the examples of @donv :
9.0.5.0 looks off but off in a different manner (albeit both with --debug and without)
edit: also just discovered another failure in the simplecov test suite that happens only on 9.0.5.0 but not 9.1 - so I guess the fixes really were 9.1, thanks for taking the time Tom!
Officially Support JRuby 9.1+
enebo commentedon Jan 26, 2017
@PragTob so do I need to comment on anything now? I did not quite get your original question and then I see the edit.
PragTob commentedon Jan 26, 2017
@enebo question was more to confirm that coverage is only expected to work fully in 9.1+ to which I found out the answer is most likely yes so that's the official support target now. Thanks! :)
PragTob commentedon Feb 4, 2017
@enebo I remembered my question! Right now simplecov still propmpts users to enable the debug mode, is this still necessary or should we be good without debug mode?
enebo commentedon Feb 9, 2017
@PragTob sorry for the long delay in replying but I was travelling. We still need --debug because we do not emit trace instructions into our emitted IR instructions without it. In the future we can invalidate ALL methods once tracing is called to re-compile all methods to emit a version with these instrs but it is not high in the priority list...
Stop telling JRuby users to turn on full-trace mode