Skip to content

Commit 095a1f7

Browse files
authored
bundled gems migration (#1078)
* Pass lib directory of src repository for assert_in_out_err explicitly * Use git ls-files for bundled gems preparation * Inject reline gem path into assert_in_out_err * Keep current file list
1 parent 1ca7472 commit 095a1f7

File tree

5 files changed

+24
-9
lines changed

5 files changed

+24
-9
lines changed

irb.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
3333
"exe/irb",
3434
"irb.gemspec",
3535
"man/irb.1",
36-
] + Dir.glob("lib/**/*")
36+
] + Dir.chdir(File.expand_path('..', __FILE__)) { Dir.glob("lib/**/*") }
3737
spec.bindir = "exe"
3838
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
3939
spec.require_paths = ["lib"]

test/irb/test_option.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ class OptionTest < TestCase
66
def test_end_of_option
77
bug4117 = '[ruby-core:33574]'
88
bundle_exec = ENV.key?('BUNDLE_GEMFILE') ? ['-rbundler/setup'] : []
9-
status = assert_in_out_err(bundle_exec + %w[-W0 -rirb -e IRB.start(__FILE__) -- -f --], "", //, [], bug4117)
9+
libdir = File.expand_path("../../lib", __dir__)
10+
reline_libdir = Gem.loaded_specs["reline"].full_gem_path + "/lib"
11+
status = assert_in_out_err(bundle_exec + %W[-W0 -I#{libdir} -I#{reline_libdir} -rirb -e IRB.start(__FILE__) -- -f --], "", //, [], bug4117)
1012
assert(status.success?, bug4117)
1113
end
1214
end

test/irb/test_raise_exception.rb

+15-5
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@ module TestIRB
77
class RaiseExceptionTest < TestCase
88
def test_raise_exception_with_nil_backtrace
99
bundle_exec = ENV.key?('BUNDLE_GEMFILE') ? ['-rbundler/setup'] : []
10-
assert_in_out_err(bundle_exec + %w[-rirb -W0 -e IRB.start(__FILE__) -- -f --], <<-IRB, /#<Exception: foo>/, [])
10+
libdir = File.expand_path("../../lib", __dir__)
11+
reline_libdir = Gem.loaded_specs["reline"].full_gem_path + "/lib"
12+
assert_in_out_err(bundle_exec + %W[-I#{libdir} -I#{reline_libdir} -rirb -W0 -e IRB.start(__FILE__) -- -f --], <<-IRB, /#<Exception: foo>/, [])
1113
raise Exception.new("foo").tap {|e| def e.backtrace; nil; end }
1214
IRB
1315
end
1416

1517
def test_raise_exception_with_message_exception
1618
bundle_exec = ENV.key?('BUNDLE_GEMFILE') ? ['-rbundler/setup'] : []
19+
libdir = File.expand_path("../../lib", __dir__)
20+
reline_libdir = Gem.loaded_specs["reline"].full_gem_path + "/lib"
1721
expected = /#<Exception: foo>\nbacktraces are hidden because bar was raised when processing them/
18-
assert_in_out_err(bundle_exec + %w[-rirb -W0 -e IRB.start(__FILE__) -- -f --], <<-IRB, expected, [])
22+
assert_in_out_err(bundle_exec + %W[-I#{libdir} -I#{reline_libdir} -rirb -W0 -e IRB.start(__FILE__) -- -f --], <<-IRB, expected, [])
1923
e = Exception.new("foo")
2024
def e.message; raise 'bar'; end
2125
raise e
@@ -24,8 +28,10 @@ def e.message; raise 'bar'; end
2428

2529
def test_raise_exception_with_message_inspect_exception
2630
bundle_exec = ENV.key?('BUNDLE_GEMFILE') ? ['-rbundler/setup'] : []
31+
libdir = File.expand_path("../../lib", __dir__)
32+
reline_libdir = Gem.loaded_specs["reline"].full_gem_path + "/lib"
2733
expected = /Uninspectable exception occurred/
28-
assert_in_out_err(bundle_exec + %w[-rirb -W0 -e IRB.start(__FILE__) -- -f --], <<-IRB, expected, [])
34+
assert_in_out_err(bundle_exec + %W[-I#{libdir} -I#{reline_libdir} -rirb -W0 -e IRB.start(__FILE__) -- -f --], <<-IRB, expected, [])
2935
e = Exception.new("foo")
3036
def e.message; raise; end
3137
def e.inspect; raise; end
@@ -36,7 +42,9 @@ def e.inspect; raise; end
3642
def test_raise_exception_with_invalid_byte_sequence
3743
pend if RUBY_ENGINE == 'truffleruby' || /mswin|mingw/ =~ RUBY_PLATFORM
3844
bundle_exec = ENV.key?('BUNDLE_GEMFILE') ? ['-rbundler/setup'] : []
39-
assert_in_out_err(bundle_exec + %w[-rirb -W0 -e IRB.start(__FILE__) -- -f --], <<~IRB, /A\\xF3B \(StandardError\)/, [])
45+
libdir = File.expand_path("../../lib", __dir__)
46+
reline_libdir = Gem.loaded_specs["reline"].full_gem_path + "/lib"
47+
assert_in_out_err(bundle_exec + %W[-I#{libdir} -I#{reline_libdir} -rirb -W0 -e IRB.start(__FILE__) -- -f --], <<~IRB, /A\\xF3B \(StandardError\)/, [])
4048
raise StandardError, "A\\xf3B"
4149
IRB
4250
end
@@ -47,6 +55,8 @@ def test_raise_exception_with_different_encoding_containing_invalid_byte_sequenc
4755
ENV["HOME"] = tmpdir
4856

4957
bundle_exec = ENV.key?('BUNDLE_GEMFILE') ? ['-rbundler/setup'] : []
58+
libdir = File.expand_path("../../lib", __dir__)
59+
reline_libdir = Gem.loaded_specs["reline"].full_gem_path + "/lib"
5060
File.open("#{tmpdir}/euc.rb", 'w') do |f|
5161
f.write(<<~EOF)
5262
# encoding: euc-jp
@@ -60,7 +70,7 @@ def raise_euc_with_invalid_byte_sequence
6070
%w(LC_MESSAGES LC_ALL LC_CTYPE LANG).each {|n| env[n] = "ja_JP.UTF-8" }
6171
# TruffleRuby warns when the locale does not exist
6272
env['TRUFFLERUBYOPT'] = "#{ENV['TRUFFLERUBYOPT']} --log.level=SEVERE" if RUBY_ENGINE == 'truffleruby'
63-
args = [env] + bundle_exec + %W[-rirb -C #{tmpdir} -W0 -e IRB.start(__FILE__) -- -f --]
73+
args = [env] + bundle_exec + %W[-I#{libdir} -I#{reline_libdir} -rirb -C #{tmpdir} -W0 -e IRB.start(__FILE__) -- -f --]
6474
error = /raise_euc_with_invalid_byte_sequence': あ\\xFF \(RuntimeError\)/
6575
assert_in_out_err(args, <<~IRB, error, [], encoding: "UTF-8")
6676
require_relative 'euc'

test/irb/test_ruby_lex.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,9 @@ def test_assignment_expression_with_local_variable
200200
end
201201

202202
def test_initialising_the_old_top_level_ruby_lex
203-
assert_in_out_err(["--disable-gems", "-W:deprecated"], <<~RUBY, [], /warning: constant ::RubyLex is deprecated/)
203+
libdir = File.expand_path("../../lib", __dir__)
204+
reline_libdir = Gem.loaded_specs["reline"].full_gem_path + "/lib"
205+
assert_in_out_err(["-I#{libdir}", "-I#{reline_libdir}", "--disable-gems", "-W:deprecated"], <<~RUBY, [], /warning: constant ::RubyLex is deprecated/)
204206
require "irb"
205207
::RubyLex.new(nil)
206208
RUBY

test/irb/test_workspace.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,13 @@ def test_toplevel_binding_local_variables
8484
bug17623 = '[ruby-core:102468]'
8585
bundle_exec = ENV.key?('BUNDLE_GEMFILE') ? ['-rbundler/setup'] : []
8686
top_srcdir = "#{__dir__}/../.."
87+
reline_libdir = Gem.loaded_specs["reline"].full_gem_path + "/lib"
8788
irb_path = nil
8889
%w[exe libexec].find do |dir|
8990
irb_path = "#{top_srcdir}/#{dir}/irb"
9091
File.exist?(irb_path)
9192
end or omit 'irb command not found'
92-
assert_in_out_err(bundle_exec + ['-W0', "-C#{top_srcdir}", '-e', <<~RUBY, '--', '-f', '--'], 'binding.local_variables', /\[:_\]/, [], bug17623)
93+
assert_in_out_err(bundle_exec + ['-W0', "-I#{top_srcdir}/lib", "-I#{reline_libdir}", "-C#{top_srcdir}", '-e', <<~RUBY, '--', '-f', '--'], 'binding.local_variables', /\[:_\]/, [], bug17623)
9394
version = 'xyz' # typical rubygems loading file
9495
load('#{irb_path}')
9596
RUBY

0 commit comments

Comments
 (0)