Repository navigation
Closed
Description
I've run into this twice now, and I'm sorry, but I don't know what's tripping it up.
I'm using guard to run my tests / simplecov.
If it runs with this code:
def following_all
...
all.map! do |a|
# Return array
if a.class == MyClass
... do something
else
... do something else
end
end
all.flatten!
end
It will be fine. But if I take out that the line with the comment (the comment doesn't matter, the extra line does) then it will crash.
/Users/ryanjm/.rvm/gems/ruby-1.9.2-head/gems/simplecov-0.4.2/lib/simplecov/source_file.rb:25:in `initialize': Only String accepted for source (ArgumentError)
from /Users/ryanjm/.rvm/gems/ruby-1.9.2-head/gems/simplecov-0.4.2/lib/simplecov/source_file.rb:66:in `new'
from /Users/ryanjm/.rvm/gems/ruby-1.9.2-head/gems/simplecov-0.4.2/lib/simplecov/source_file.rb:66:in `block in lines'
from /Users/ryanjm/.rvm/gems/ruby-1.9.2-head/gems/simplecov-0.4.2/lib/simplecov/source_file.rb:65:in `each'
from /Users/ryanjm/.rvm/gems/ruby-1.9.2-head/gems/simplecov-0.4.2/lib/simplecov/source_file.rb:65:in `each_with_index'
from /Users/ryanjm/.rvm/gems/ruby-1.9.2-head/gems/simplecov-0.4.2/lib/simplecov/source_file.rb:65:in `lines'
from /Users/ryanjm/.rvm/gems/ruby-1.9.2-head/gems/simplecov-0.4.2/lib/simplecov/source_file.rb:91:in `missed_lines'
from /Users/ryanjm/.rvm/gems/ruby-1.9.2-head/gems/simplecov-html-0.4.5/lib/simplecov-html.rb:80:in `block in lines_missed'
from /Users/ryanjm/.rvm/gems/ruby-1.9.2-head/gems/simplecov-html-0.4.5/lib/simplecov-html.rb:80:in `map'
from /Users/ryanjm/.rvm/gems/ruby-1.9.2-head/gems/simplecov-html-0.4.5/lib/simplecov-html.rb:80:in `lines_missed'
from /Users/ryanjm/.rvm/gems/ruby-1.9.2-head/gems/simplecov-html-0.4.5/lib/simplecov-html.rb:70:in `lines_of_code'
from /Users/ryanjm/.rvm/gems/ruby-1.9.2-head/gems/simplecov-html-0.4.5/lib/simplecov-html.rb:63:in `coverage'
from (erb):4:in `formatted_file_list'
....
Any idea what is tripping this issue?
Metadata
Metadata
Assignees
Labels
No labels
Activity
jherdman commentedon Jul 13, 2011
Bump! I'm seeing this quite regularly too.
ryanjm commentedon Jul 22, 2011
Bump again? This is happening a lot. Is there something I can do to reduce the probability of this happening? I prefer not having extra spaces between all of my lines of code.
goneflyin commentedon Jul 27, 2011
I wouldn't be certain it's as directly related to the above code as it may be thought.
Our CI build hit this exception after running specs on a Rails 3 project -- but we've got
More than that, however, is how we "fixed" it. I checked in a different change (eliminated a HAML warning by changing)
to:
= form_for
and then our CI build re-ran the tests, and the simplecov exception did not occur.
(apologies for the inconsistent syntax highlighting and blocking, can't quite get GFM to render it correctly)
At this time I'm not sure exactly what triggered the original problem, or how the rebuild fixed it, but there was no difference between the two builds that related to a ruby code structure as illustrated above.
ryanjm commentedon Jul 27, 2011
Interesting. I never get it for views. Only ever for blocks of code in my models.
goneflyin commentedon Jul 28, 2011
Sorry -- to be clear, my point was that we have code (the example above was from a controller) that resembles the example in the description of this issue. The view example was to point out that checking in only a change to a view where we change the hyphen(-) to an equals-sign (=) resulted in the CI build working, and the simplecov exception no longer occurred.
goneflyin commentedon Jul 28, 2011
Another observation I made yesterday, throwing a few debug strings into simplecov to understand the nature of the problem, is that the underlying problem may have something to do with the Coverage library in Ruby 1.9.
First -- the problem became (effectively) non-deterministic for me. I had reproduced the exception above via running my tests via rake. While tweaking only the source_file.rb file within the simplecov gem directory, the defect suddenly stopped happening and would no longer occur during this test run.
Second -- the unique situation causing the exception to be thrown seems to be due to the Coverage library returning an extra, non-existent line of data for a source file.
The exception is thrown from here (my slight hack to the exception message is included, so it won't match the released source perfectly):
In my case, whenever I get this exception thrown, the line_number is one more than the number of lines in the file. As a result, the src (intended to be the line of source code extracted from the file) is nil rather than the empty string.
I'll look at checking for this condition in the calling loop and try to display a warning and avoid triggering the exception. If I can get a decent patch done, I'll submit a pull request.
Workaround for potential Ruby 1.9.x defect identified in Issue simple…
Merge pull request #63 from goneflyin/master
colszowka commentedon Aug 1, 2011
Ok, thanks to @goneflyin this should be fixed in the next release / right now on master. Please let me know should this problem persist!