[rubygems/rubygems] Test JRuby 10

Necessary changes to get tests passing are:

* Rewrite one "out of memory" error spec to not define a subclass inside
  a RSpec context block. Due to some [JRuby issue], that's failing in
  JRuby 10, so I rewrote the test so that the Bundler process really
  goes OOM and that class definition is not necessary.
* JRuby 10, even if Ruby 3.4-compatible, has not yet adapted backtraces
  to include receivers, so our tests need an special case for JRuby when
  detecting a test method call inside backtraces.
* Warbler test is upgraded to use JRuby 10. Getting it to pass needs [a
  PR] to warbler, so our test is temporarily pointing to that PR.

[JRuby issue]: https://github.com/jruby/jruby/issues/8838
[a PR]: https://github.com/jruby/warbler/pull/557

https://github.com/rubygems/rubygems/commit/edec85d4c3
This commit is contained in:
David Rodríguez 2025-05-13 12:54:35 +02:00 committed by Hiroshi SHIBATA
parent bfab76abe6
commit 6e8be3a634
4 changed files with 28 additions and 24 deletions

View File

@ -130,17 +130,13 @@ RSpec.describe Bundler, "friendly errors" do
# Does nothing
end
context "Java::JavaLang::OutOfMemoryError" do
module Java
module JavaLang
class OutOfMemoryError < StandardError; end
end
end
context "Java::JavaLang::OutOfMemoryError", :jruby_only do
it "Bundler.ui receive error" do
error = Java::JavaLang::OutOfMemoryError.new
expect(Bundler.ui).to receive(:error).with(/JVM has run out of memory/)
Bundler::FriendlyErrors.log_error(error)
install_gemfile <<-G, raise_on_error: false, env: { "JRUBY_OPTS" => "-J-Xmx32M" }, artifice: nil
source "https://gem.repo1"
G
expect(err).to include("JVM has run out of memory")
end
end

View File

@ -3,5 +3,5 @@
source "https://rubygems.org"
gem "demo", path: "./demo"
gem "jruby-jars", "~> 9.4"
gem "warbler", "~> 2.0"
gem "jruby-jars", "~> 10.0"
gem "warbler", github: "https://github.com/jruby/warbler/pull/557"

View File

@ -1,3 +1,15 @@
GIT
remote: https://github.com/jruby/warbler.git
revision: 3a3a89e9a055ab1badb4e6fee860e8617b4acfe1
ref: refs/pull/557/head
specs:
warbler (2.0.5)
jruby-jars (>= 9.0.0)
jruby-rack (>= 1.1.1, < 1.3)
rake (>= 13.0.3)
rexml (~> 3.0)
rubyzip (>= 1.0.0)
PATH
remote: demo
specs:
@ -6,15 +18,11 @@ PATH
GEM
remote: https://rubygems.org/
specs:
jruby-jars (9.4.10.0)
jruby-rack (1.1.21)
rake (13.0.1)
rubyzip (1.3.0)
warbler (2.0.5)
jruby-jars (>= 9.0.0.0)
jruby-rack (>= 1.1.1, < 1.3)
rake (>= 10.1.0)
rubyzip (~> 1.0, < 1.4)
jruby-jars (10.0.0.1)
jruby-rack (1.2.2)
rake (13.2.1)
rexml (3.4.1)
rubyzip (2.4.1)
PLATFORMS
arm64-darwin
@ -24,8 +32,8 @@ PLATFORMS
DEPENDENCIES
demo!
jruby-jars (~> 9.4)
warbler (~> 2.0)
jruby-jars (~> 10.0)
warbler!
BUNDLED WITH
2.7.0.dev

View File

@ -277,7 +277,7 @@ module Spec
end
def update_repo(path, build_compact_index: true)
exempted_caller = Gem.ruby_version >= Gem::Version.new("3.4.0.dev") ? "#{Module.nesting.first}#build_repo" : "build_repo"
exempted_caller = Gem.ruby_version >= Gem::Version.new("3.4.0.dev") && RUBY_ENGINE != "jruby" ? "#{Module.nesting.first}#build_repo" : "build_repo"
if path == gem_repo1 && caller_locations(1, 1).first.label != exempted_caller
raise "Updating gem_repo1 is unsupported -- use gem_repo2 instead"
end