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

JRuby support #86

Closed
raydog153 opened this issue Sep 29, 2011 · 30 comments
Closed

JRuby support #86

raydog153 opened this issue Sep 29, 2011 · 30 comments

Comments

@raydog153
Copy link

Jruby 1.6.4 has now added support for the ruby coverage library as seen in this closed issue ( https://jira.codehaus.org/browse/JRUBY-5935 ). When I tried simplecov when running my rspecs, at the end of the run when it is calculating the coverage, I got the following error:

SystemStackError: stack level too deep
eval at org/jruby/RubyKernel.java:1093
result at /home/ray/Perforce/ray_ray-desktop/ThirdParty/jruby/jruby-1.6.4/lib/ruby/1.9/erb.rb:753
formatted_file_list at /home/ray/Perforce/ray_ray-desktop/ThirdParty/jruby/jruby-1.6.4/lib/ruby/gems/1.8/gems/simplecov-html-0.5.3/lib/simplecov-html.rb:53
result at (erb):30
eval at org/jruby/RubyKernel.java:1093
result at /home/ray/Perforce/ray_ray-desktop/ThirdParty/jruby/jruby-1.6.4/lib/ruby/1.9/erb.rb:753
format at /home/ray/Perforce/ray_ray-desktop/ThirdParty/jruby/jruby-1.6.4/lib/ruby/gems/1.8/gems/simplecov-html-0.5.3/lib/simplecov-html.rb:19
open at org/jruby/RubyIO.java:1111
format at /home/ray/Perforce/ray_ray-desktop/ThirdParty/jruby/jruby-1.6.4/lib/ruby/gems/1.8/gems/simplecov-html-0.5.3/lib/simplecov-html.rb:18
format! at /home/ray/Perforce/ray_ray-desktop/ThirdParty/jruby/jruby-1.6.4/lib/ruby/gems/1.8/gems/simplecov-0.5.3/lib/simplecov/result.rb:90
at_exit at /home/ray/Perforce/ray_ray-desktop/ThirdParty/jruby/jruby-1.6.4/lib/ruby/gems/1.8/gems/simplecov-0.5.3/lib/simplecov/configuration.rb:133
call at org/jruby/RubyProc.java:262
(root) at /home/ray/Perforce/ray_ray-desktop/ThirdParty/jruby/jruby-1.6.4/lib/ruby/gems/1.8/gems/simplecov-0.5.3/lib/simplecov/defaults.rb:42

I was able to solve this issue by removing the jruby_float_fix.rb file. After this I am able to run rspec with simplecov and get a coverage report generated. Only problem now is that the coverage report is reporting 100% coverage for everything, and I know that is not true, esp when I run only one of my spec files. I'll gladly work with you to get this working as this is high priority for us, and I cannot find any other coverage tool out there that works for jruby and 1.9. Also one more issues is that for any view that is rendered, I get this error, but only when I start simplecov:

 Failure/Error: Unable to find matching line from backtrace
 ActionView::Template::Error:
   -1
 # org.jruby.ext.coverage.CoverageData$1.eventHandler(CoverageData.java:55)
 # org.jruby.runtime.EventHook.event(EventHook.java:30)
 # org.jruby.Ruby.callEventHooks(Ruby.java:2647)
 # org.jruby.evaluator.ASTInterpreter.callTraceFunction(ASTInterpreter.java:214)
 # org.jruby.ast.NewlineNode.interpret(NewlineNode.java:100)
 # org.jruby.ast.RootNode.interpret(RootNode.java:129)
 # org.jruby.evaluator.ASTInterpreter.INTERPRET_EVAL(ASTInterpreter.java:96)
 # org.jruby.evaluator.ASTInterpreter.evalSimple(ASTInterpreter.java:198)
 # org.jruby.RubyBasicObject.evalUnder(RubyBasicObject.java:1934)
 # org.jruby.RubyBasicObject.specificEval(RubyBasicObject.java:1913)
 # org.jruby.RubyModule.module_eval(RubyModule.java:2233)
 # org.jruby.RubyModule$i$module_eval_DBG.call(RubyModule$i$module_eval_DBG.gen:65535)
 # org.jruby.internal.runtime.methods.JavaMethod$JavaMethodZeroOrOneOrTwoOrThreeOrNBlock.call(JavaMethod.java:300)

.......

@raydog153
Copy link
Author

After some more work on this I found the problem with the 100% coverage being reported. Seems that Jruby does not indicate which lines are not code lines vs which lines are code and not run. So all code lines not run are nil in the coverage array coming back from jruby. I tried to do some modifications to the gem to detect which lines are code and set them to 0, and this partiall works, but needs more work to cover all test cases, since my simple fix doesn't work for lines of code the span across a single line. I filed a bug with JRuby to fix this, which would be the best, but not sure if that will happen. I will look more into how I can figure out what lines are valid lines of code that can be run to mark as 0 from nil. Here if the link to the JRuby bug: http://jira.codehaus.org/browse/JRUBY-6106

@colszowka
Copy link
Collaborator

Thanks for looking into this! Back when initial 1.9 support arrived in JRuby 1.6 RC1, I had a look into this but then realized the Coverage library was not included yet. I've removed the jruby_float_fix in the new release 0.5.4, so at least this obstacle is out of the way.

I currently don't really have time to dig further into this, but I'd gladly merge any pull requests that lead to JRuby support. From what you've explained it seems to me as if the Coverage library in JRuby needs to be brought to full compatibility with MRI's one. Working around this in SimpleCov might be possible, but I think this is something the Ruby impl needs to supply.

@colszowka
Copy link
Collaborator

@headius Has recently further investigated this and noted his findings in JRuby's bugtracker. Seems this isn't going to happen any time soon. Keeping this open though as a reminder to follow eventual new developments on that.

See: http://jira.codehaus.org/browse/JRUBY-6106

@colszowka
Copy link
Collaborator

There have recently been further changes to get this going in JRuby, see the aforementioned http://jira.codehaus.org/browse/JRUBY-6106, but it seems it does not work with SimpleCov just yet. Getting there though :)

@PragTob
Copy link
Collaborator

PragTob commented Aug 24, 2012

If anyone's interested, here is my updated bug report (or rather experience report) - feel free to chime in!

bug report

@rthbound
Copy link

rthbound commented Nov 1, 2012

What's the status on 1.7.0?

@PragTob
Copy link
Collaborator

PragTob commented Nov 1, 2012

The issue hasn't been touched since I reported my experience to the initial try by the great @headius (thanks). I'll try to give it another shot with 1.7.0.

Thought about digging into the implementation myself, but I want to do a lot of things and I guess it's hard to get into with a minimal knowledge of interpreters and JRuby itself. So don't count on me ;-)

@PragTob
Copy link
Collaborator

PragTob commented Nov 4, 2012

Seems to be working correctly with 1.7. Thank you so much @headius! Happy testing everyone!

@BrandonMathis
Copy link

Can I get an update on this from anyone. I'd like to test this out but I can't seem to set the debug flag.

jruby --debug -S bundle exec rake spec COVERAGE=on and bundle exec jruby --debug -S rake spec COVERAGE=on both give me the warning "tracing (e.g. set_trace_func) will not capture all events without --debug flag".

Is there something, syntactically, that I am doing wrong here?

@PragTob
Copy link
Collaborator

PragTob commented Mar 6, 2013

The feature shipped with jruby 1.7 and it works beautifully for us. This should be closed.

@BrandonMathis
Copy link

Is the command you are using similar to the one I posted above? I'm still getting the warning on jruby-1.7.3

@ghost
Copy link

ghost commented Mar 23, 2013

confirmed issue goes away using jruby-1.7.2 built with --1.9 --disable-binary

@headius
Copy link

headius commented Mar 23, 2013

@BrandonMathis "bundle exec" launches a new subprocess, but does not pass along flags from the original command. Try env var JRUBY_OPTS=--debug instead.

@colszowka
Copy link
Collaborator

Yeah, it seems to be working pretty nicely now (on 1.7.3). I also finally managed to get the Cucumber integration suite to behave this week, leading to passing travis builds. Unfortunately the JRuby 1.9 integration suite is incredibly slow, around 25 minutes on travis (see here for example). The MRI 1.9 builds only take around 5 minutes.

I already tried some of the things suggested in this blog post by Charles, but mostly to no avail. The main trouble is that the cukes need to shell out and run a billion of test/spec processes, which is very expensive on JRuby. In addition, I'm using the Aruba gem for the shell interaction steps, and that uses some flavor of popen instead of the standard ruby shell execution commands, so JRuby seems unable to reuse the running JVM. Additionally, recent x64 Oracle JVMs on Ubuntu only seem to have the hotspot server part built-in, so I can't force the use of the client VM.

@headius Do you happen to have some further advice on how I could get the runtime of the cucumber suite down?

@BrandonMathis
Copy link

export JRUBY_OPTS=--debug will get rid of the warning: tracing (e.g. set_trace_func) will not capture all events without --debug flag warning.

However, I am still getting a bundle of Warning: coverage data provided by Coverage exceeds number of lines warnings

colszowka added a commit that referenced this issue Apr 5, 2013
build times out on travis after 50 mins due to the massive process running being
slow on JRuby :( See #86
@likethesky
Copy link

So is there a safe way to turn off these scads of "Warning: coverage data provided by Coverage ..." warnings safely, when using JRuby? I also asked this Q on this issue thread: #98 (comment)

@likethesky
Copy link

Okay, trying one last 'ping' here... So do we just have to live with the 'exceeds number of lines' warnings on JRuby when using simplecov?

If there's no other solution to fixing it properly, is there at least a way to turn off just this one warning easily (and not miss any other warnings besides the 'Coverage exceeds number of lines' warning)? @BrandonMathis have you found a solution, or are you just "living with" the long list of warnings you're getting? Thanks all.

@BrandonMathis
Copy link

At the moment I am just living with the issues, we only use coverage in our CI box so no one on my team is very motivated to look much further into this. Since it's been a few months I would just close this issue out and I will alert you if I see any changes in my environment.

@urfolomeus
Copy link

I have the same issue with JRuby 1.7.4 and SimpleCov 1.8.0pre.

@PragTob
Copy link
Collaborator

PragTob commented Aug 5, 2013

I really think this issue should be closed as it works with JRuby and just fine at that.

For reference, we are not seeing issues with exceeds number of lines or something at shoes (recent travis build for reference). Using 0.7.1

@urfolomeus
Copy link

I've had a quick delve into the code tonight and, for me at least, it is only throwing this error on haml files. I suspect this is due to them being converted to html during the test, but don't know this for sure yet. Will have a proper look tomorrow. The line causing the issue is:

if coverage.size > src.size

lib/simplecov/source_file.rb:90

@likethesky
Copy link

Ah. Interesting. Yes, I can confirm that we're also using haml (on jruby) in our app that spews out all of these warnings. (Thanks for your reply on the status too, Brandon.)

@urfolomeus
Copy link

So simply adding this configuration block to the SimpleCov.start method has solved the issue for me:

SimpleCov.start 'rails' do
  add_filter 'app/views'
end

Obviously this means that no view output is in the coverage report, but the view test we have is just a background check to ensure I18n translations are in place so I can live with that. Happy to carry on digging tomorrow though to see what is different between running on ruby 2.0 and jruby. :)

@BrandonMathis
Copy link

I added add_filter 'app/views' into my simplecov config block and that removed most of the warnings. I guess the solution for me is to just filter out those files that I don't want hit by coverage.

@urfolomeus
Copy link

@BrandonMathis I'm still intrigued as to why this works fine on MRI but not JRuby, so I'll have a play about when I get a spare minute and do a comparison :)

@donv
Copy link
Contributor

donv commented Oct 31, 2013

👍 for fixing this 😃

@x-itec
Copy link

x-itec commented Mar 3, 2014

I dont see any fix for this problem with jruby 1.7.10

Warning: coverage data provided by Coverage exceeds ...
And I wont exclude any view. Hmm

bf4 added a commit to metricfu/metric_fu that referenced this issue May 2, 2014
 see #226
     jruby/jruby#1196
     https://jira.codehaus.org/browse/JRUBY-6106
     simplecov-ruby/simplecov#86

Travis ENV modified per
http://docs.travis-ci.com/user/ci-environment/#Environment-variables

@enebo https://twitter.com/tom_enebo/status/462289024107814914
recommended JRUBY_OPTS="-Xcli.debug=true"
but that didn't work and caused other failures
JRUBY_OPTS="--debug" Still produced the below error, as did
JRUBY_OPTS="--debug -Xcli.debug=true"

Failure message was
home/travis/build/metricfu/metric_fu/gemfiles/vendor/bundle/jruby/1.9/gems/simplecov-0.8.2/lib/simplecov.rb:31 warning: tracing (e.g. set_trace_func) will not capture all events without --debug flag

SimpleCov::Formatter::MetricFu calculates the same coverage from an RCov report as from SimpleCov
     Failure/Error: expect(source_file.coverage.count).to eq(covered_lines_from_rcov_text.count)

       expected: 11
            got: 8

       (compared using ==)
     # /home/travis/build/metricfu/metric_fu/spec/metric_fu/metrics/rcov/simplecov_formatter_spec.rb:52:in `(root)'
     # /home/travis/build/metricfu/metric_fu/spec/support/timeout.rb:6:in `(root)'
bf4 added a commit to metricfu/metric_fu that referenced this issue May 4, 2014
 see #226
     jruby/jruby#1196
     https://jira.codehaus.org/browse/JRUBY-6106
     simplecov-ruby/simplecov#86

Travis ENV modified per
http://docs.travis-ci.com/user/ci-environment/#Environment-variables

@enebo https://twitter.com/tom_enebo/status/462289024107814914
recommended JRUBY_OPTS="-Xcli.debug=true"
but that didn't work and caused other failures
JRUBY_OPTS="--debug" Still produced the below error, as did
JRUBY_OPTS="--debug -Xcli.debug=true"

Failure message was
home/travis/build/metricfu/metric_fu/gemfiles/vendor/bundle/jruby/1.9/gems/simplecov-0.8.2/lib/simplecov.rb:31 warning: tracing (e.g. set_trace_func) will not capture all events without --debug flag

SimpleCov::Formatter::MetricFu calculates the same coverage from an RCov report as from SimpleCov
     Failure/Error: expect(source_file.coverage.count).to eq(covered_lines_from_rcov_text.count)

       expected: 11
            got: 8

       (compared using ==)
     # /home/travis/build/metricfu/metric_fu/spec/metric_fu/metrics/rcov/simplecov_formatter_spec.rb:52:in `(root)'
     # /home/travis/build/metricfu/metric_fu/spec/support/timeout.rb:6:in `(root)'
@bf4 bf4 mentioned this issue May 17, 2015
@betesh
Copy link

betesh commented Jun 29, 2016

+1

The "exceeds number of lines" warning is being printed to stdout 3 times per view file.

jruby-1.7.22
rails (3.2.22.1)
rspec (3.4.0)
simplecov (0.11.2)
ERB, not HAML

UPDATE: I have deleted the coverage/ directory several times to make sure I'm starting in a clean state. Didn't help.

@bf4
Copy link
Collaborator

bf4 commented Jun 30, 2016

@betesh Last comment is from over two years ago. Please open a new issue. In that issue, please mention if you're attended to the JRUBY_OPTS recommendations.

@bf4 bf4 closed this as completed Jun 30, 2016
@betesh
Copy link

betesh commented Jul 1, 2016

I could open a new issue, but it would just link back to this one, as this one has all the details. Not sure what the benefit is of opening a new issue for the same problem. Was this issue partially solved?

please mention if you're attended to the JRUBY_OPTS recommendations.

When I use JRUBY_OPTS=--debug, I do not get the warning warning: tracing (e.g. set_trace_func) will not capture all events without --debug flag warning, but I do get the exceeds number of lines warning 3 times per view file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests