-
-
Notifications
You must be signed in to change notification settings - Fork 102
Conversation
2ac9a47
to
9f28c03
Compare
def ripper_supported? | ||
# JRuby supports Ripper but it seems to be unstable | ||
# and also reports wrong line number on JRuby 9.0.0.0. | ||
defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby' && RUBY_VERSION >= '1.9.2' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is too bad about JRuby's ripper support not being good enough for us to use. Has the issue been reported upstream? I imagine @headius and co would want to know and do something about this. Unfortunately, as this is currently written it'll lock JRuby users out from enjoying the benefits of the feature if/when JRuby's ripper is fixed.
Would it be possible to write some logic that detects if ripper is working on JRuby so that we allow it to be used if a user is running a future version of JRuby where the ripper issues have been fixed? Although, the obvious ways to do that would involve loading ripper and testing it out, which I don't think we want to do...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just reported the wrong line number issue jruby/jruby#3386.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to write some logic that detects if ripper is working on JRuby so that we allow it to be used if a user is running a future version of JRuby where the ripper issues have been fixed? Although, the obvious ways to do that would involve loading ripper and testing it out, which I don't think we want to do...
I added examples to check the Ripper behavior in rspec-support's spec rather than user's environement so that we can immediately notice the change on Travis CI in the future. By the way I noticed that we do not have CI for JRuby 9.0.0.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I confirmed specs in rspec/rspec-core#2083 properly passed on JRuby 1.7.14 - 1.7.22.
ee98c6d
to
4f5d608
Compare
elsif Ruby.jruby? && | ||
defined?(Gem::Version) && | ||
Gem::Version.new(JRUBY_VERSION) >= Gem::Version.new('1.7.14') && | ||
!JRUBY_VERSION.start_with?('9.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This conditional will return false
if rubygems is not loaded. It should not be a requirement that rubygems is loaded to use this feature. Users may want to run rspec
w/ the --disable=gems
flag and that should work, IMO. I think you can use our version checker instead:
https://github.com/rspec/rspec-support/blob/master/lib/rspec/support/version_checker.rb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
efff0a3
to
992711d
Compare
Not sure why but the CI is failing now, even on master branch...
|
Those are bundler platform values. Maybe a bundler regression? Did the bundler version change? |
No. Passed job: https://travis-ci.org/rspec/rspec-support/jobs/83149928
Failed job: https://travis-ci.org/rspec/rspec-support/jobs/83956734
|
345233f
to
9ba6ac5
Compare
Looking at the benchmark, I can see that ripper is certainly much slower on those JRuby 1.7.x releases but I'm not sure that it's so slow that it makes sense to disable the feature entirely. Consider that the benchmark shows 240-250 ripper parsing operations per second on those versions of JRuby. That's only 4 ms or so. I think the productivity boost from having the full code snippet is going to save the user much more than 4 ms of time. Besides, in the rspec-core PR you've implemented a source cache so the slow parsing cost will only be paid once per distinct file that has a failure. In my experience, it's a lot more common to have a few files, each with many failures, than to have many files, each with few failures. This slowness is also not a general slowdown we're adding for all |
def ripper_supported? | ||
true | ||
end | ||
rescue LibraryVersionTooLowError, UnsupportedVersionError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exceptions for control flow is always one of those things that feels smelly. Instead, WDYT of making VersionChecker#compare_version
public and using that to find out how the version compares w/o needing to use exceptions?
Actually, it looks like nothing is using the version checker so you should feel free to change it's API to whatever you need :).
4dcc8dc
to
5743811
Compare
|
end | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class looks nice and simple, but will it handle version numbers with .pre
, .rc1
, .beta
, etc in the name? The segments
method uses to_i
which will silently convert those to 0
. Looking at the JRuby downloads page, I see version numbers like 9.0.0.0.pre1
and 9.0.0.0.rc1
. Since we pass the JRUBY_VERSION
to this I think we need to handle those versions properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
This LGTM besides the concern about pre-release words in version numbers. |
LibraryVersionTooLowError = Class.new(StandardError) | ||
|
||
# @private | ||
class VersionChecker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is used outside of rspec-support
(I'm thinking rspec-rails
at least) so we might need to leave this in until we've switched those instances over.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current rspec-rails
is not using VersionChecker
and the rspec-support
dependency is pinned to major and minor versions, so I think removing VersionChecker
does not break anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wrong. It's still used here. The vendor
directory was ignored by my ag
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it was used somewhere! It was created for rspec-rails
originally :P
c6cbd07
to
d315fa1
Compare
d315fa1
to
61c960e
Compare
This LGTM apart from the build failure. |
54e84fd
to
e6fc120
Compare
Want to rebase this off master and see if it works now? |
e6fc120
to
ea46730
Compare
Done |
Sweet as, 🍏 |
Add RubyFeatures.ripper_supported?
As of rspec/rspec-support#245, `rspec/support/ruby_features` relies upon `rspec/support` being loaded first.
As of rspec/rspec-support#245, `rspec/support/ruby_features` relies upon `rspec/support` being loaded first.
For rspec/rspec-core#2083