Skip to content

Commit 1a985d3

Browse files
deivid-rodriguezhsbt
authored andcommitted
[rubygems/rubygems] Adapt specs to extraction of irb from ruby-core
This gets our daily Bundler CI back to green. ruby/rubygems@1bb70f75d2
1 parent 0ca5240 commit 1a985d3

File tree

8 files changed

+137
-8
lines changed

8 files changed

+137
-8
lines changed

spec/bundler/commands/console_spec.rb

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ def __pry__
3535
end
3636
RUBY
3737
end
38+
39+
build_dummy_irb
3840
end
3941
end
4042

@@ -46,7 +48,8 @@ def __pry__
4648
end
4749

4850
install_gemfile <<-G
49-
source "https://gem.repo1"
51+
source "https://gem.repo2"
52+
gem "irb"
5053
path "#{lib_path}" do
5154
gem "loadfuuu", require: true
5255
end
@@ -66,6 +69,7 @@ def __pry__
6669
before do
6770
install_gemfile <<-G
6871
source "https://gem.repo2"
72+
gem "irb"
6973
gem "myrack"
7074
gem "activesupport", :group => :test
7175
gem "myrack_middleware", :group => :development
@@ -81,16 +85,19 @@ def __pry__
8185
end
8286

8387
it "uses IRB as default console" do
88+
skip "Does not work in a ruby-core context if irb is in the default $LOAD_PATH because it enables the real IRB, not our dummy one" if ruby_core? && Gem.ruby_version < Gem::Version.new("3.5.0.a")
89+
8490
bundle "console" do |input, _, _|
85-
input.puts("__FILE__")
91+
input.puts("__method__")
8692
input.puts("exit")
8793
end
88-
expect(out).to include("(irb)")
94+
expect(out).to include("__irb__")
8995
end
9096

9197
it "starts another REPL if configured as such" do
9298
install_gemfile <<-G
9399
source "https://gem.repo2"
100+
gem "irb"
94101
gem "pry"
95102
G
96103
bundle "config set console pry"
@@ -103,14 +110,16 @@ def __pry__
103110
end
104111

105112
it "falls back to IRB if the other REPL isn't available" do
113+
skip "Does not work in a ruby-core context if irb is in the default $LOAD_PATH because it enables the real IRB, not our dummy one" if ruby_core? && Gem.ruby_version < Gem::Version.new("3.5.0.a")
114+
106115
bundle "config set console pry"
107116
# make sure pry isn't there
108117

109118
bundle "console" do |input, _, _|
110-
input.puts("__FILE__")
119+
input.puts("__method__")
111120
input.puts("exit")
112121
end
113-
expect(out).to include("(irb)")
122+
expect(out).to include("__irb__")
114123
end
115124

116125
it "does not try IRB twice if no console is configured and IRB is not available" do
@@ -161,6 +170,7 @@ def __pry__
161170
it "performs an automatic bundle install" do
162171
gemfile <<-G
163172
source "https://gem.repo2"
173+
gem "irb"
164174
gem "myrack"
165175
gem "activesupport", :group => :test
166176
gem "myrack_middleware", :group => :development

spec/bundler/commands/newgem_spec.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,12 @@ def bundle_exec_standardrb
478478

479479
prepare_gemspec(bundled_app("newgem", "newgem.gemspec"))
480480

481-
gems = ["rake-#{rake_version}"]
481+
build_repo2 do
482+
build_dummy_irb "9.9.9"
483+
end
484+
gems = ["rake-#{rake_version}", "irb-9.9.9"]
482485
path = Bundler.feature_flag.default_install_uses_path? ? local_gem_path(base: bundled_app("newgem")) : system_gem_path
483-
system_gems gems, path: path
486+
system_gems gems, path: path, gem_repo: gem_repo2
484487
bundle "exec rake build", dir: bundled_app("newgem")
485488

486489
expect(last_command.stdboth).not_to include("ERROR")

spec/bundler/commands/platform_spec.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -941,8 +941,13 @@ def should_be_patchlevel_fixnum
941941

942942
context "bundle console" do
943943
before do
944+
build_repo2 do
945+
build_dummy_irb
946+
end
947+
944948
install_gemfile <<-G
945-
source "https://gem.repo1"
949+
source "https://gem.repo2"
950+
gem "irb"
946951
gem "myrack"
947952
gem "activesupport", :group => :test
948953
gem "myrack_middleware", :group => :development

spec/bundler/support/builders.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,41 @@ def build_security_repo
228228
end
229229
end
230230

231+
# A minimal fake irb console
232+
def build_dummy_irb(version = "9.9.9")
233+
build_gem "irb", version do |s|
234+
s.write "lib/irb.rb", <<-RUBY
235+
class IRB
236+
class << self
237+
def toplevel_binding
238+
unless defined?(@toplevel_binding) && @toplevel_binding
239+
TOPLEVEL_BINDING.eval %{
240+
def self.__irb__; binding; end
241+
IRB.instance_variable_set(:@toplevel_binding, __irb__)
242+
class << self; undef __irb__; end
243+
}
244+
end
245+
@toplevel_binding.eval('private')
246+
@toplevel_binding
247+
end
248+
249+
def __irb__
250+
while line = gets
251+
begin
252+
puts eval(line, toplevel_binding).inspect.sub(/^"(.*)"$/, '=> \\1')
253+
rescue Exception => e
254+
puts "\#{e.class}: \#{e.message}"
255+
puts e.backtrace.first
256+
end
257+
end
258+
end
259+
alias start __irb__
260+
end
261+
end
262+
RUBY
263+
end
264+
end
265+
231266
def build_repo(path, **kwargs, &blk)
232267
return if File.directory?(path)
233268

tool/bundler/rubocop_gems.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
gem "rubocop", ">= 1.52.1", "< 2"
66

77
gem "minitest"
8+
gem "irb"
89
gem "rake"
910
gem "rake-compiler"
1011
gem "rspec"

tool/bundler/rubocop_gems.rb.lock

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@ GEM
22
remote: https://rubygems.org/
33
specs:
44
ast (2.4.2)
5+
date (3.4.1)
6+
date (3.4.1-java)
57
diff-lcs (1.5.1)
8+
io-console (0.8.0)
9+
io-console (0.8.0-java)
10+
irb (1.15.1)
11+
pp (>= 0.6.0)
12+
rdoc (>= 4.0.0)
13+
reline (>= 0.4.2)
14+
jar-dependencies (0.5.5)
615
json (2.9.1)
716
json (2.9.1-java)
817
language_server-protocol (3.17.0.3)
@@ -12,14 +21,27 @@ GEM
1221
ast (~> 2.4.1)
1322
racc
1423
power_assert (2.0.3)
24+
pp (0.6.2)
25+
prettyprint
26+
prettyprint (0.2.0)
27+
psych (5.2.3)
28+
date
29+
stringio
30+
psych (5.2.3-java)
31+
date
32+
jar-dependencies (>= 0.1.7)
1533
racc (1.8.1)
1634
racc (1.8.1-java)
1735
rainbow (3.1.1)
1836
rake (13.2.1)
1937
rake-compiler (1.2.7)
2038
rake
2139
rb_sys (0.9.91)
40+
rdoc (6.12.0)
41+
psych (>= 4.0.0)
2242
regexp_parser (2.10.0)
43+
reline (0.6.0)
44+
io-console (~> 0.5)
2345
rspec (3.13.0)
2446
rspec-core (~> 3.13.0)
2547
rspec-expectations (~> 3.13.0)
@@ -46,6 +68,7 @@ GEM
4668
rubocop-ast (1.37.0)
4769
parser (>= 3.3.1.0)
4870
ruby-progressbar (1.13.0)
71+
stringio (3.1.5)
4972
test-unit (3.6.2)
5073
power_assert
5174
unicode-display_width (3.1.4)
@@ -63,6 +86,7 @@ PLATFORMS
6386
x86_64-linux
6487

6588
DEPENDENCIES
89+
irb
6690
minitest
6791
rake
6892
rake-compiler
@@ -73,21 +97,33 @@ DEPENDENCIES
7397

7498
CHECKSUMS
7599
ast (2.4.2) sha256=1e280232e6a33754cde542bc5ef85520b74db2aac73ec14acef453784447cc12
100+
date (3.4.1) sha256=bf268e14ef7158009bfeaec40b5fa3c7271906e88b196d958a89d4b408abe64f
101+
date (3.4.1-java) sha256=74740d914c65a922a15657c25ff0e203c16f1d0f7aa910a9ebed712afe9819c4
76102
diff-lcs (1.5.1) sha256=273223dfb40685548436d32b4733aa67351769c7dea621da7d9dd4813e63ddfe
103+
io-console (0.8.0) sha256=cd6a9facbc69871d69b2cb8b926fc6ea7ef06f06e505e81a64f14a470fddefa2
104+
io-console (0.8.0-java) sha256=3cc6fd5c66e587145c1fdf8dc40c2e3d851e90722a5d0cc3f38da352f06fe1bd
105+
irb (1.15.1) sha256=d9bca745ac4207a8b728a52b98b766ca909b86ff1a504bcde3d6f8c84faae890
106+
jar-dependencies (0.5.5) sha256=2972b9fcba4b014e6446a84b5c09674a3e8648b95b71768e729f0e8e40568059
77107
json (2.9.1) sha256=d2bdef4644052fad91c1785d48263756fe32fcac08b96a20bb15840e96550d11
78108
json (2.9.1-java) sha256=88de8c79b54fee6ae1b4854bc48b8d7089f524cbacaf4596df24f86b10896ee8
79109
language_server-protocol (3.17.0.3) sha256=3d5c58c02f44a20d972957a9febe386d7e7468ab3900ce6bd2b563dd910c6b3f
80110
minitest (5.22.3) sha256=ea84676290cb5e2b4f31f25751af6050aa90d3e43e4337141c3e3e839611981e
81111
parallel (1.26.3) sha256=d86babb7a2b814be9f4b81587bf0b6ce2da7d45969fab24d8ae4bf2bb4d4c7ef
82112
parser (3.3.6.0) sha256=25d4e67cc4f0f7cab9a2ae1f38e2005b6904d2ea13c34734511d0faad038bc3b
83113
power_assert (2.0.3) sha256=cd5e13c267370427c9804ce6a57925d6030613e341cb48e02eec1f3c772d4cf8
114+
pp (0.6.2) sha256=947ec3120c6f92195f8ee8aa25a7b2c5297bb106d83b41baa02983686577b6ff
115+
prettyprint (0.2.0) sha256=2bc9e15581a94742064a3cc8b0fb9d45aae3d03a1baa6ef80922627a0766f193
116+
psych (5.2.3) sha256=84a54bb952d14604fea22d99938348814678782f58b12648fcdfa4d2fce859ee
117+
psych (5.2.3-java) sha256=3e5425b9e8a2f41cc2707d5ef14fdc1ae908abbafb12fe45727bd63900056585
84118
racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
85119
racc (1.8.1-java) sha256=54f2e6d1e1b91c154013277d986f52a90e5ececbe91465d29172e49342732b98
86120
rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
87121
rake (13.2.1) sha256=46cb38dae65d7d74b6020a4ac9d48afed8eb8149c040eccf0523bec91907059d
88122
rake-compiler (1.2.7) sha256=5176f8527bbf86db4b333915335eb5fa0b4f578cb82428c3e5e47e48179f0dee
89123
rb_sys (0.9.91) sha256=8c6ad8f97fd86f80530e942f1a904c229a510ca372c6b92dc05270a84e51ecda
124+
rdoc (6.12.0) sha256=7d6f706e070bffa5d18a448f24076cbfb34923a99c1eab842aa18e6ca69f56e0
90125
regexp_parser (2.10.0) sha256=cb6f0ddde88772cd64bff1dbbf68df66d376043fe2e66a9ef77fcb1b0c548c61
126+
reline (0.6.0) sha256=57620375dcbe56ec09bac7192bfb7460c716bbf0054dc94345ecaa5438e539d2
91127
rspec (3.13.0) sha256=d490914ac1d5a5a64a0e1400c1d54ddd2a501324d703b8cfe83f458337bab993
92128
rspec-core (3.13.0) sha256=557792b4e88da883d580342b263d9652b6a10a12d5bda9ef967b01a48f15454c
93129
rspec-expectations (3.13.0) sha256=621d48c62262f955421eaa418130744760802cad47e781df70dba4d9f897102e
@@ -96,6 +132,7 @@ CHECKSUMS
96132
rubocop (1.70.0) sha256=96751f8440b36a0ac6e9a8ab596900803118d83d6b83f2037bf8b3d7a5bc440e
97133
rubocop-ast (1.37.0) sha256=9513ac88aaf113d04b52912533ffe46475de1362d4aa41141b51b2455827c080
98134
ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
135+
stringio (3.1.5) sha256=bca92461515a131535743bc81d5559fa1de7d80cff9a654d6c0af6f9f27e35c8
99136
test-unit (3.6.2) sha256=3ce480c23990ca504a3f0d6619be2a560e21326cefd1b86d0f9433c387f26039
100137
unicode-display_width (3.1.4) sha256=8caf2af1c0f2f07ec89ef9e18c7d88c2790e217c482bfc78aaa65eadd5415ac1
101138
unicode-emoji (4.0.4) sha256=2c2c4ef7f353e5809497126285a50b23056cc6e61b64433764a35eff6c36532a

tool/bundler/standard_gems.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
gem "standard", "~> 1.0"
66

77
gem "minitest"
8+
gem "irb"
89
gem "rake"
910
gem "rake-compiler"
1011
gem "rspec"

tool/bundler/standard_gems.rb.lock

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@ GEM
22
remote: https://rubygems.org/
33
specs:
44
ast (2.4.2)
5+
date (3.4.1)
6+
date (3.4.1-java)
57
diff-lcs (1.5.1)
8+
io-console (0.8.0)
9+
io-console (0.8.0-java)
10+
irb (1.15.1)
11+
pp (>= 0.6.0)
12+
rdoc (>= 4.0.0)
13+
reline (>= 0.4.2)
14+
jar-dependencies (0.5.5)
615
json (2.7.1)
716
json (2.7.1-java)
817
language_server-protocol (3.17.0.3)
@@ -13,14 +22,27 @@ GEM
1322
ast (~> 2.4.1)
1423
racc
1524
power_assert (2.0.3)
25+
pp (0.6.2)
26+
prettyprint
27+
prettyprint (0.2.0)
28+
psych (5.2.3)
29+
date
30+
stringio
31+
psych (5.2.3-java)
32+
date
33+
jar-dependencies (>= 0.1.7)
1634
racc (1.7.3)
1735
racc (1.7.3-java)
1836
rainbow (3.1.1)
1937
rake (13.2.1)
2038
rake-compiler (1.2.7)
2139
rake
2240
rb_sys (0.9.91)
41+
rdoc (6.12.0)
42+
psych (>= 4.0.0)
2343
regexp_parser (2.9.0)
44+
reline (0.6.0)
45+
io-console (~> 0.5)
2446
rexml (3.2.6)
2547
rspec (3.13.0)
2648
rspec-core (~> 3.13.0)
@@ -64,6 +86,7 @@ GEM
6486
standard-performance (1.3.1)
6587
lint_roller (~> 1.1)
6688
rubocop-performance (~> 1.20.2)
89+
stringio (3.1.5)
6790
test-unit (3.6.2)
6891
power_assert
6992
unicode-display_width (2.5.0)
@@ -79,6 +102,7 @@ PLATFORMS
79102
x86_64-linux
80103

81104
DEPENDENCIES
105+
irb
82106
minitest
83107
rake
84108
rake-compiler
@@ -89,7 +113,13 @@ DEPENDENCIES
89113

90114
CHECKSUMS
91115
ast (2.4.2) sha256=1e280232e6a33754cde542bc5ef85520b74db2aac73ec14acef453784447cc12
116+
date (3.4.1) sha256=bf268e14ef7158009bfeaec40b5fa3c7271906e88b196d958a89d4b408abe64f
117+
date (3.4.1-java) sha256=74740d914c65a922a15657c25ff0e203c16f1d0f7aa910a9ebed712afe9819c4
92118
diff-lcs (1.5.1) sha256=273223dfb40685548436d32b4733aa67351769c7dea621da7d9dd4813e63ddfe
119+
io-console (0.8.0) sha256=cd6a9facbc69871d69b2cb8b926fc6ea7ef06f06e505e81a64f14a470fddefa2
120+
io-console (0.8.0-java) sha256=3cc6fd5c66e587145c1fdf8dc40c2e3d851e90722a5d0cc3f38da352f06fe1bd
121+
irb (1.15.1) sha256=d9bca745ac4207a8b728a52b98b766ca909b86ff1a504bcde3d6f8c84faae890
122+
jar-dependencies (0.5.5) sha256=2972b9fcba4b014e6446a84b5c09674a3e8648b95b71768e729f0e8e40568059
93123
json (2.7.1) sha256=187ea312fb58420ff0c40f40af1862651d4295c8675267c6a1c353f1a0ac3265
94124
json (2.7.1-java) sha256=bfd628c0f8357058c2cf848febfa6f140f70f94ec492693a31a0a1933038a61b
95125
language_server-protocol (3.17.0.3) sha256=3d5c58c02f44a20d972957a9febe386d7e7468ab3900ce6bd2b563dd910c6b3f
@@ -98,13 +128,19 @@ CHECKSUMS
98128
parallel (1.24.0) sha256=5bf38efb9b37865f8e93d7a762727f8c5fc5deb19949f4040c76481d5eee9397
99129
parser (3.3.0.5) sha256=7748313e505ca87045dc0465c776c802043f777581796eb79b1654c5d19d2687
100130
power_assert (2.0.3) sha256=cd5e13c267370427c9804ce6a57925d6030613e341cb48e02eec1f3c772d4cf8
131+
pp (0.6.2) sha256=947ec3120c6f92195f8ee8aa25a7b2c5297bb106d83b41baa02983686577b6ff
132+
prettyprint (0.2.0) sha256=2bc9e15581a94742064a3cc8b0fb9d45aae3d03a1baa6ef80922627a0766f193
133+
psych (5.2.3) sha256=84a54bb952d14604fea22d99938348814678782f58b12648fcdfa4d2fce859ee
134+
psych (5.2.3-java) sha256=3e5425b9e8a2f41cc2707d5ef14fdc1ae908abbafb12fe45727bd63900056585
101135
racc (1.7.3) sha256=b785ab8a30ec43bce073c51dbbe791fd27000f68d1c996c95da98bf685316905
102136
racc (1.7.3-java) sha256=b2ad737e788cfa083263ce7c9290644bb0f2c691908249eb4f6eb48ed2815dbf
103137
rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
104138
rake (13.2.1) sha256=46cb38dae65d7d74b6020a4ac9d48afed8eb8149c040eccf0523bec91907059d
105139
rake-compiler (1.2.7) sha256=5176f8527bbf86db4b333915335eb5fa0b4f578cb82428c3e5e47e48179f0dee
106140
rb_sys (0.9.91) sha256=8c6ad8f97fd86f80530e942f1a904c229a510ca372c6b92dc05270a84e51ecda
141+
rdoc (6.12.0) sha256=7d6f706e070bffa5d18a448f24076cbfb34923a99c1eab842aa18e6ca69f56e0
107142
regexp_parser (2.9.0) sha256=81a00ba141cec0d4b4bf58cb80cd9193e5180836d3fa6ef623f7886d3ba8bdd9
143+
reline (0.6.0) sha256=57620375dcbe56ec09bac7192bfb7460c716bbf0054dc94345ecaa5438e539d2
108144
rexml (3.2.6) sha256=e0669a2d4e9f109951cb1fde723d8acd285425d81594a2ea929304af50282816
109145
rspec (3.13.0) sha256=d490914ac1d5a5a64a0e1400c1d54ddd2a501324d703b8cfe83f458337bab993
110146
rspec-core (3.13.0) sha256=557792b4e88da883d580342b263d9652b6a10a12d5bda9ef967b01a48f15454c
@@ -118,6 +154,7 @@ CHECKSUMS
118154
standard (1.35.1) sha256=69a633610864f76e84b438d44b605fda020a3fc9b31a2d50d3487edb77a572ad
119155
standard-custom (1.0.2) sha256=424adc84179a074f1a2a309bb9cf7cd6bfdb2b6541f20c6bf9436c0ba22a652b
120156
standard-performance (1.3.1) sha256=0e813d7347fc116b395ae4a6bffcece3ad3114b06e537436a76da79b9194d119
157+
stringio (3.1.5) sha256=bca92461515a131535743bc81d5559fa1de7d80cff9a654d6c0af6f9f27e35c8
121158
test-unit (3.6.2) sha256=3ce480c23990ca504a3f0d6619be2a560e21326cefd1b86d0f9433c387f26039
122159
unicode-display_width (2.5.0) sha256=7e7681dcade1add70cb9fda20dd77f300b8587c81ebbd165d14fd93144ff0ab4
123160

0 commit comments

Comments
 (0)