1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Drop support for Rubinius

Fixes #1775 (Drop support for Rubinius)

I am amazed how many hacks we've had just to support Rubinius. It feels good to
be able to remove them and reduce the complexity of the codebase.
This commit is contained in:
Kyrylo Silin 2018-10-07 00:58:53 +08:00
parent a6428b2f43
commit 743b905c81
24 changed files with 242 additions and 334 deletions

1
.gitignore vendored
View file

@ -11,7 +11,6 @@ coverage/
/tags /tags
vendor vendor
*.gem *.gem
.rbx/
.rvmrc .rvmrc
Gemfile.lock Gemfile.lock
*.swp *.swp

View file

@ -206,7 +206,6 @@ Layout/EmptyLinesAroundAccessModifier:
- 'lib/pry/helpers/table.rb' - 'lib/pry/helpers/table.rb'
- 'lib/pry/history_array.rb' - 'lib/pry/history_array.rb'
- 'lib/pry/plugins.rb' - 'lib/pry/plugins.rb'
- 'lib/pry/rbx_path.rb'
- 'spec/method_spec.rb' - 'spec/method_spec.rb'
# Offense count: 1 # Offense count: 1
@ -828,7 +827,6 @@ Naming/MethodName:
Naming/PredicateName: Naming/PredicateName:
Exclude: Exclude:
- 'spec/**/*' - 'spec/**/*'
- 'lib/pry/rbx_path.rb'
# Offense count: 26 # Offense count: 26
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
@ -842,13 +840,6 @@ Performance/Casecmp:
Exclude: Exclude:
- 'lib/pry/slop/option.rb' - 'lib/pry/slop/option.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: IncludeActiveSupportAliases.
Performance/DoubleStartEndWith:
Exclude:
- 'lib/pry/rbx_path.rb'
# Offense count: 2 # Offense count: 2
# Cop supports --auto-correct. # Cop supports --auto-correct.
Performance/InefficientHashSearch: Performance/InefficientHashSearch:
@ -1050,7 +1041,6 @@ Style/DoubleNegation:
- 'lib/pry/method/weird_method_locator.rb' - 'lib/pry/method/weird_method_locator.rb'
- 'lib/pry/pager.rb' - 'lib/pry/pager.rb'
- 'lib/pry/platform.rb' - 'lib/pry/platform.rb'
- 'lib/pry/rbx_path.rb'
- 'lib/pry/slop/option.rb' - 'lib/pry/slop/option.rb'
- 'lib/pry/wrapped_module.rb' - 'lib/pry/wrapped_module.rb'

View file

@ -22,9 +22,3 @@ end
group :development, :test do group :development, :test do
gem 'simplecov', '~> 0.8.0' gem 'simplecov', '~> 0.8.0'
end end
platform :rbx do
gem 'rubysl-singleton'
gem 'rubysl-prettyprint'
gem 'rb-readline'
end

View file

@ -133,7 +133,6 @@ require 'pathname'
require 'pry/version' require 'pry/version'
require 'pry/repl' require 'pry/repl'
require 'pry/rbx_path'
require 'pry/code' require 'pry/code'
require 'pry/history_array' require 'pry/history_array'
require 'pry/helpers' require 'pry/helpers'

View file

@ -41,8 +41,6 @@ class Pry
Pry.line_buffer.drop(1) Pry.line_buffer.drop(1)
elsif Pry::Method::Patcher.code_for(@filename) elsif Pry::Method::Patcher.code_for(@filename)
Pry::Method::Patcher.code_for(@filename) Pry::Method::Patcher.code_for(@filename)
elsif RbxPath.is_core_path?(@filename)
File.read(RbxPath.convert_path_to_full(@filename))
else else
path = abs_path path = abs_path
@code_type = type_from_filename(path) @code_type = type_from_filename(path)

View file

@ -317,7 +317,7 @@ class Pry
# `nil` if the filename is unavailable. # `nil` if the filename is unavailable.
def source_file def source_file
if source_location.nil? if source_location.nil?
if !rbx? and source_type == :c if source_type == :c
info = pry_doc_info info = pry_doc_info
info.file if info info.file if info
end end
@ -531,9 +531,9 @@ class Pry
end end
def ruby_source def ruby_source
# clone of MethodSource.source_helper that knows to use our # Clone of `MethodSource.source_helper` that knows to use our
# hacked version of source_location for rbx core methods, and # hacked version of `source_location` for our input buffer for methods
# our input buffer for methods defined in (pry) # defined in `(pry)`.
file, line = *source_location file, line = *source_location
raise SourceNotFoundError, "Could not locate source for #{name_with_owner}!" unless file raise SourceNotFoundError, "Could not locate source for #{name_with_owner}!" unless file

View file

@ -100,8 +100,7 @@ class Pry
# __FILE__ and __LINE__ the binding is at, we can hope to disambiguate these cases. # __FILE__ and __LINE__ the binding is at, we can hope to disambiguate these cases.
# #
# This obviously won't work if the source is unavaiable for some reason, or if both # This obviously won't work if the source is unavaiable for some reason, or if both
# methods have the same __FILE__ and __LINE__, or if we're in rbx where b.eval('__LINE__') # methods have the same __FILE__ and __LINE__.
# is broken.
# #
# @return [Pry::Method, nil] The Pry::Method representing the # @return [Pry::Method, nil] The Pry::Method representing the
# superclass method. # superclass method.
@ -122,9 +121,9 @@ class Pry
end end
end end
# Uhoh... none of the methods in the chain had the right __FILE__ and __LINE__ # Uhoh... none of the methods in the chain had the right `__FILE__` and
# This may be caused by rbx https://github.com/rubinius/rubinius/issues/953, # `__LINE__` due to unknown circumstances.
# or other unknown circumstances (TODO: we should warn the user when this happens) # TODO: we should warn the user when this happens.
nil nil
end end

View file

@ -59,14 +59,6 @@ module Pry::Platform
jruby? and RbConfig::CONFIG['ruby_version'] == '1.9' jruby? and RbConfig::CONFIG['ruby_version'] == '1.9'
end end
#
# @return [Boolean]
# Returns true when Pry is being run from Rubinius.
#
def rbx?
RbConfig::CONFIG['ruby_install_name'] == 'rbx'
end
# #
# @return [Boolean] # @return [Boolean]
# Returns true when Pry is being run from MRI (CRuby). # Returns true when Pry is being run from MRI (CRuby).
@ -96,6 +88,6 @@ module Pry::Platform
# Returns an Array of Ruby engines that Pry is known to run on. # Returns an Array of Ruby engines that Pry is known to run on.
# #
def known_engines def known_engines
[:jruby, :rbx, :mri] [:jruby, :mri]
end end
end end

View file

@ -93,9 +93,7 @@ class Pry
# Expand a file to its canonical name (following symlinks as appropriate) # Expand a file to its canonical name (following symlinks as appropriate)
def self.real_path_to(file) def self.real_path_to(file)
expanded = Pathname.new(File.expand_path(file)).realpath.to_s Pathname.new(File.expand_path(file)).realpath.to_s
# For rbx 1.9 mode [see rubinius issue #2165]
File.exist?(expanded) ? expanded : nil
rescue Errno::ENOENT, Errno::EACCES rescue Errno::ENOENT, Errno::EACCES
nil nil
end end

View file

@ -1,22 +0,0 @@
class Pry
module RbxPath
module_function
def is_core_path?(path)
Pry::Helpers::BaseHelpers.rbx? && (path.start_with?("kernel") || path.start_with?("lib")) && File.exist?(convert_path_to_full(path))
end
def convert_path_to_full(path)
if path.start_with?("kernel")
File.join File.dirname(Rubinius::KERNEL_PATH), path
elsif path.start_with?("lib")
File.join File.dirname(Rubinius::LIB_PATH), path
else
path
end
end
def rvm_ruby?(path)
!!(path =~ /\.rvm/)
end
end
end

View file

@ -109,10 +109,6 @@ class Pry
def singleton_class? def singleton_class?
if Pry::Method.safe_send(wrapped, :respond_to?, :singleton_class?) if Pry::Method.safe_send(wrapped, :respond_to?, :singleton_class?)
Pry::Method.safe_send(wrapped, :singleton_class?) Pry::Method.safe_send(wrapped, :singleton_class?)
elsif defined?(Rubinius)
# https://github.com/rubinius/rubinius/commit/2e71722dba53d1a92c54d5e3968d64d1042486fe singleton_class? added 30 Jul 2014
# https://github.com/rubinius/rubinius/commit/4310f6b2ef3c8fc88135affe697db4e29e4621c4 has been around since 2011
!!Rubinius::Type.singleton_class_object(wrapped)
else else
wrapped != Pry::Method.safe_send(wrapped, :ancestors).first wrapped != Pry::Method.safe_send(wrapped, :ancestors).first
end end
@ -323,11 +319,11 @@ class Pry
# We only want methods that have a non-nil `source_location`. We also # We only want methods that have a non-nil `source_location`. We also
# skip some spooky internal methods. # skip some spooky internal methods.
# (i.e we skip `__class_init__` because it's an odd rbx specific thing that causes tests to fail.) #
# @return [Array<Pry::Method>] # @return [Array<Pry::Method>]
def all_relevant_methods_for(mod) def all_relevant_methods_for(mod)
methods = all_methods_for(mod).select(&:source_location). methods = all_methods_for(mod).select(&:source_location).
reject{ |x| x.name == '__class_init__' || method_defined_by_forwardable_module?(x) } reject { |x| method_defined_by_forwardable_module?(x) }
return methods unless methods.empty? return methods unless methods.empty?

View file

@ -65,8 +65,6 @@ describe "cat" do
end end
end end
# this doesnt work so well on rbx due to differences in backtrace
# so we currently skip rbx until we figure out a workaround
describe "with --ex" do describe "with --ex" do
before do before do
@o = Object.new @o = Object.new
@ -77,7 +75,6 @@ describe "cat" do
end end
end end
if !Pry::Helpers::BaseHelpers.rbx?
it 'cat --ex should display repl code that generated exception' do it 'cat --ex should display repl code that generated exception' do
@t.eval unindent(<<-EOS) @t.eval unindent(<<-EOS)
begin begin
@ -98,7 +95,6 @@ describe "cat" do
expect(@t.eval('cat --ex')).to match(/this method is broken/) expect(@t.eval('cat --ex')).to match(/this method is broken/)
end end
end end
end
describe "with --ex N" do describe "with --ex N" do
it 'should cat first level of backtrace when --ex used with no argument ' do it 'should cat first level of backtrace when --ex used with no argument ' do

View file

@ -77,10 +77,6 @@ describe "edit" do
Pry.config.editor = lambda { |file, line| Pry.config.editor = lambda { |file, line|
File.open(file, 'w'){ |f| f << 'require_relative "baz.rb"' } File.open(file, 'w'){ |f| f << 'require_relative "baz.rb"' }
File.open(file.gsub('bar.rb', 'baz.rb'), 'w'){ |f| f << "Pad.required = true; FileUtils.rm(__FILE__)" } File.open(file.gsub('bar.rb', 'baz.rb'), 'w'){ |f| f << "Pad.required = true; FileUtils.rm(__FILE__)" }
if defined?(Rubinius::Compiler)
File.unlink Rubinius::Compiler.compiled_name file
end
nil nil
} }
pry_eval "edit #@tf_path" pry_eval "edit #@tf_path"
@ -186,15 +182,12 @@ describe "edit" do
after do after do
@tf.close(true) @tf.close(true)
File.unlink("#{@path}c") if File.exist?("#{@path}c") #rbx File.unlink("#{@path}c") if File.exist?("#{@path}c")
end end
it "should reload the file" do it "should reload the file" do
Pry.config.editor = lambda {|file, line| Pry.config.editor = lambda {|file, line|
File.open(file, 'w'){|f| f << "FOO = 'BAR'" } File.open(file, 'w'){|f| f << "FOO = 'BAR'" }
if defined?(Rubinius::Compiler)
File.unlink Rubinius::Compiler.compiled_name file
end
nil nil
} }

View file

@ -116,15 +116,11 @@ describe "ls" do
expect { pry_eval("ls -M String.new") }.to raise_error(Pry::CommandError, /-M only makes sense with a Module or a Class/) expect { pry_eval("ls -M String.new") }.to raise_error(Pry::CommandError, /-M only makes sense with a Module or a Class/)
end end
# see: https://travis-ci.org/pry/pry/jobs/5071918
unless Pry::Helpers::BaseHelpers.rbx?
it "should handle classes that (pathologically) define .ancestors" do it "should handle classes that (pathologically) define .ancestors" do
output = pry_eval("ls Class.new{ def self.ancestors; end; def hihi; end }") output = pry_eval("ls Class.new{ def self.ancestors; end; def hihi; end }")
expect(output).to match(/hihi/) expect(output).to match(/hihi/)
end end
end end
end
describe 'with -l' do describe 'with -l' do
focus 'should find locals and sort by descending size' do focus 'should find locals and sort by descending size' do
@ -211,14 +207,11 @@ describe "ls" do
describe "when no arguments given" do describe "when no arguments given" do
describe "when at the top-level" do describe "when at the top-level" do
# rubinius has a bug that means local_variables of "main" aren't reported inside eval()
unless Pry::Helpers::BaseHelpers.rbx?
it "should show local variables" do it "should show local variables" do
expect(pry_eval("ls")).to match(/_pry_/) expect(pry_eval("ls")).to match(/_pry_/)
expect(pry_eval("arbitrar = 1", "ls")).to match(/arbitrar/) expect(pry_eval("arbitrar = 1", "ls")).to match(/arbitrar/)
end end
end end
end
describe "when in a class" do describe "when in a class" do
it "should show constants" do it "should show constants" do

View file

@ -141,7 +141,7 @@ describe "save-file" do
end end
describe "saving commands" do describe "saving commands" do
it 'should save a command to a file', expect_failure: [:rbx] do it 'should save a command to a file' do
@t.eval "save-file --to '#{@path}' show-source" @t.eval "save-file --to '#{@path}' show-source"
cmd_source = Pry.config.commands["show-source"].source cmd_source = Pry.config.commands["show-source"].source
expect(File.read(@path)).to eq(cmd_source) expect(File.read(@path)).to eq(cmd_source)

View file

@ -18,7 +18,7 @@ describe Pry::Command::ShellCommand do
end end
it "saves the current working directory" do it "saves the current working directory" do
expect(Dir).to receive(:pwd).at_least(:once).and_return("initial_path") # called once in MRI, 2x in RBX expect(Dir).to receive(:pwd).and_return("initial_path")
@t.eval ".cd new_path" @t.eval ".cd new_path"
expect(@t.command_state.old_pwd).to eq("initial_path") expect(@t.command_state.old_pwd).to eq("initial_path")
@ -47,7 +47,7 @@ describe Pry::Command::ShellCommand do
describe "given a prior directory" do describe "given a prior directory" do
it "sends the user's last pry working directory to File.expand_path" do it "sends the user's last pry working directory to File.expand_path" do
expect(Dir).to receive(:pwd).at_least(:twice).and_return("initial_path") # called 2x in MRI, 3x in RBX expect(Dir).to receive(:pwd).twice.and_return("initial_path")
expect(Dir).to receive(:chdir).with(File.expand_path("new_path")) expect(Dir).to receive(:chdir).with(File.expand_path("new_path"))
@t.eval ".cd new_path" @t.eval ".cd new_path"

View file

@ -467,7 +467,6 @@ describe "show-doc" do
end end
end end
unless Pry::Helpers::BaseHelpers.rbx?
describe "can't find class docs" do describe "can't find class docs" do
describe "for classes" do describe "for classes" do
before do before do
@ -574,4 +573,3 @@ describe "show-doc" do
end end
end end
end end
end

View file

@ -649,13 +649,13 @@ describe "show-source" do
end end
describe "when current context is a C object" do describe "when current context is a C object" do
it "should display a warning, and not monkey-patched definition", expect_failure: [:rbx] do it "should display a warning, and not monkey-patched definition" do
out = pry_eval([1, 2, 3], 'show-source') out = pry_eval([1, 2, 3], 'show-source')
expect(out).not_to match(/doge/) expect(out).not_to match(/doge/)
expect(out).to match(/warning/i) expect(out).to match(/warning/i)
end end
it "recommends to use the --all switch when other candidates are found", expect_failure: [:rbx] do it "recommends to use the --all switch when other candidates are found" do
out = pry_eval([], 'show-source') out = pry_eval([], 'show-source')
expect(out).to match(/'--all' switch/i) expect(out).to match(/'--all' switch/i)
end end
@ -770,7 +770,6 @@ describe "show-source" do
end end
end end
unless Pry::Helpers::BaseHelpers.rbx?
describe "can't find class/module code" do describe "can't find class/module code" do
describe "for classes" do describe "for classes" do
before do before do
@ -883,4 +882,3 @@ describe "show-source" do
end end
end end
end end
end

View file

@ -195,8 +195,6 @@ describe "whereami" do
expect(out).to match(/blimey/) expect(out).to match(/blimey/)
end end
# https://github.com/rubinius/rubinius/pull/2247
unless Pry::Helpers::BaseHelpers.rbx?
it 'should show class when -c option used, and binding is outside a method' do it 'should show class when -c option used, and binding is outside a method' do
class Cor class Cor
def blimey;end def blimey;end
@ -208,7 +206,6 @@ describe "whereami" do
Object.remove_const(:Cor) Object.remove_const(:Cor)
end end
end end
end
it 'should not show line numbers or marker when -n switch is used' do it 'should not show line numbers or marker when -n switch is used' do
class Cor class Cor

View file

@ -20,7 +20,6 @@ end.new(nil)
# to help with tracking down bugs that cause an infinite loop in the test suite # to help with tracking down bugs that cause an infinite loop in the test suite
if ENV["SET_TRACE_FUNC"] if ENV["SET_TRACE_FUNC"]
require 'set_trace' if Pry::Helpers::BaseHelpers.rbx?
set_trace_func proc { |event, file, line, id, binding, classname| set_trace_func proc { |event, file, line, id, binding, classname|
STDERR.printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname STDERR.printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
} }

View file

@ -118,8 +118,6 @@ describe Pry::Method do
expect(m.name).to eq "bar" expect(m.name).to eq "bar"
end end
# Our source_location trick doesn't work, due to https://github.com/rubinius/rubinius/issues/953
unless Pry::Helpers::BaseHelpers.rbx?
it 'should find the super method correctly' do it 'should find the super method correctly' do
a = Class.new{ def gag33; binding; end; def self.line; __LINE__; end } a = Class.new{ def gag33; binding; end; def self.line; __LINE__; end }
b = Class.new(a){ def gag33; super; end } b = Class.new(a){ def gag33; super; end }
@ -131,7 +129,6 @@ describe Pry::Method do
expect(m.source_line).to eq a.line expect(m.source_line).to eq a.line
expect(m.name).to eq "gag33" expect(m.name).to eq "gag33"
end end
end
it 'should find the right method if a super method exists' do it 'should find the right method if a super method exists' do
a = Class.new{ def gag; binding; end; } a = Class.new{ def gag; binding; end; }
@ -144,8 +141,6 @@ describe Pry::Method do
expect(m.name).to eq "gag" expect(m.name).to eq "gag"
end end
# Temporarily disabled to work around rubinius/rubinius#2871.
unless Pry::Helpers::BaseHelpers.rbx?
it "should find the right method from a BasicObject" do it "should find the right method from a BasicObject" do
a = Class.new(BasicObject) { def gag; ::Kernel.binding; end; def self.line; __LINE__; end } a = Class.new(BasicObject) { def gag; ::Kernel.binding; end; def self.line; __LINE__; end }
@ -154,7 +149,6 @@ describe Pry::Method do
expect(m.source_file).to eq __FILE__ expect(m.source_file).to eq __FILE__
expect(m.source_line).to eq a.line expect(m.source_line).to eq a.line
end end
end
it 'should find the right method even if it was renamed and replaced' do it 'should find the right method even if it was renamed and replaced' do
o = Object.new o = Object.new

View file

@ -369,15 +369,12 @@ describe "test Pry defaults" do
expect(Pry.toplevel_binding.eval('self')).to equal(TOPLEVEL_BINDING.eval('self')) expect(Pry.toplevel_binding.eval('self')).to equal(TOPLEVEL_BINDING.eval('self'))
end end
# https://github.com/rubinius/rubinius/issues/1779
unless Pry::Helpers::BaseHelpers.rbx?
it 'should define private methods on Object' do it 'should define private methods on Object' do
TOPLEVEL_BINDING.eval 'def gooey_fooey; end' TOPLEVEL_BINDING.eval 'def gooey_fooey; end'
expect(method(:gooey_fooey).owner).to eq Object expect(method(:gooey_fooey).owner).to eq Object
expect(Pry::Method(method(:gooey_fooey)).visibility).to eq :private expect(Pry::Method(method(:gooey_fooey)).visibility).to eq :private
end end
end end
end
it 'should set the hooks default, and the default should be overridable' do it 'should set the hooks default, and the default should be overridable' do
Pry.config.input = InputTester.new("exit-all") Pry.config.input = InputTester.new("exit-all")

View file

@ -37,7 +37,7 @@ describe Pry do
end end
end end
it "should not load the pryrc if pryrc's directory permissions do not allow this", expect_failure: [:rbx] do it "should not load the pryrc if pryrc's directory permissions do not allow this" do
Dir.mktmpdir do |dir| Dir.mktmpdir do |dir|
File.chmod 0000, dir File.chmod 0000, dir
Pry::LOCAL_RC_FILE.replace File.join(dir, '.pryrc') Pry::LOCAL_RC_FILE.replace File.join(dir, '.pryrc')

View file

@ -28,10 +28,10 @@ describe Pry do
["puts )("], ["puts )("],
["1 1"], ["1 1"],
["puts :"] ["puts :"]
] + (Pry::Helpers::BaseHelpers.rbx? ? [] : [ ] + [
["def", "method(1"], # in this case the syntax error is "expecting ')'". ["def", "method(1"], # in this case the syntax error is "expecting ')'".
["o = Object.new.tap{ def o.render;","'MEH'", "}"] # in this case the syntax error is "expecting keyword_end". ["o = Object.new.tap{ def o.render;","'MEH'", "}"] # in this case the syntax error is "expecting keyword_end".
])).compact.each do |foo| ]).compact.each do |foo|
it "should raise an error on invalid syntax like #{foo.inspect}" do it "should raise an error on invalid syntax like #{foo.inspect}" do
redirect_pry_io(InputTester.new(*foo), @str_output) do redirect_pry_io(InputTester.new(*foo), @str_output) do
Pry.start Pry.start