Issue Type: Bug Bug
Assignee: Thomas E Enebo
Attachments: jruby-coverage.diff
Components: Parser
Created: 29/Aug/12 2:01 AM
Description:

Hi there,

I've been trying out the great new coverage changes made in JRUBY-6106. I have a Sinatra app for which simplecov is now working perfectly, but I've hit an interesting problem when trying the same thing on a Rails app.

I'm building against the current git master
(4e471f489ee6e6aa5d74d64893d709c85a312ee1) with:

  ant clean && ant jar-jruby-complete

When I use the resulting jar to run my Rails app with simplecov enabled, I get exceptions like this:


  CoverageModule.java:40:in `result': java.lang.NullPointerException
          from CoverageModule$INVOKER$s$0$0$result.gen:-1:in `call'
          from CachingCallSite.java:292:in `cacheAndCall'
          from CachingCallSite.java:135:in `call'
          from CallNoArgNode.java:63:in `interpret'
          from CallOneArgNode.java:57:in `interpret'

After a bit of debugging I think I've tracked the problem down to what might be two different issues.

The first issue comes about when calling require on an empty file (or a file consisting of nothing but comments). This seems to cause a null to be added to the coverage data, which blows up when generating results. I can reproduce that with:

  $ GEM_HOME=$PWD/test_gems java -jar lib/jruby-complete.jar -S gem install simplecov

  $ echo > empty.rb

  $ cat | GEM_HOME=$PWD/test_gems java -jar lib/jruby-complete.jar -I. --debug --1.9 -
require "rubygems"
require 'simplecov'
SimpleCov.start

require "empty.rb"

^D

For me, that blows up with an exception like the one shown above.

I'm finding the other issue a bit harder to nail down. The ParserConfiguration.coverLine(int i) method takes a line number and marks it off as being covered. But when running my Rails app under simplecov, I see that 'i' isn't always positive--I see numbers ranging from -9 and up, and the negative number causes a RuntimeException when it tries to access an invalid array offset.

I haven't made much headway in figuring out why the parser would report a negative line number--it only seems to happen in my app when parsing .erb files, but I can't reproduce the problem when loading the same .erb templates from the command line. I thought I'd just check if line numbers sometimes being negative was expected before diving in further.

I've attached a patch that sorts things out for my local instance, but realise I'm probably just masking the symptoms. I thought it might help to show the spots I'm talking about, though.

Thanks for all your great work, and please let me know if I can do any debugging from this end.

Cheers,

Mark

Project: JRuby
Priority: Minor Minor
Reporter: Mark Triggs
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira
--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

Reply via email to