Skip to content

Run the test suite on JRuby (JRuby support, step 4)#3008

Open
soutaro wants to merge 5 commits into
claude/practical-mendel-hnqws8-3from
claude/practical-mendel-hnqws8-4
Open

Run the test suite on JRuby (JRuby support, step 4)#3008
soutaro wants to merge 5 commits into
claude/practical-mendel-hnqws8-3from
claude/practical-mendel-hnqws8-4

Conversation

@soutaro

@soutaro soutaro commented Jun 19, 2026

Copy link
Copy Markdown
Member

Stacked on #3000 (step 3). Review/merge that first; this PR's diff is against it.

Makes rake test run on JRuby, skipping the cases that can't work there — mirroring how the suite already handles TruffleRuby.

Result

$ jruby -S rake test
971 tests, 7819 assertions, 0 failures, 0 errors, 116 omissions

The full non-stdlib suite passes on JRuby (JRuby 10.0.6.0, verified locally). The 116 omissions are the genuinely-incompatible tests. No effect on CRuby (the omit_on_jruby! calls are no-ops there).

Two real bugs this surfaced

  • lib/rbs.rbrequire "pathname" unless defined?(Pathname) skipped loading pathname when another library (Bundler) had already defined the Pathname constant, leaving Kernel#Pathname undefined. RBS::EnvironmentLoader uses Pathname(...) at load time, so requiring RBS after Bundler (as test_helper does) raised NoMethodError on JRuby. Now requires it unconditionally (require is idempotent).
  • lib/rbs/wasm/location.rb — the pure-Ruby RBS::Location#[] returned nil for an unknown child name; the C extension raises. Now matches.

Making rake test work on JRuby

  • Rakefile — the test task no longer depends on :compile on JRuby (there is no C extension to build; rake wasm:jruby_setup assembles the wasm runtime instead).
  • gemspec — only stamps the java platform when actually building the release gem (RBS_PLATFORM=java); on JRuby it otherwise stays a ruby-platform gem so local development matches a ruby lockfile, while still skipping the C extension and shipping the wasm + jars.

Skips (omit_on_jruby!, alongside the existing omit_on_truffle_ruby!)

Tests Reason
Rb/Rbi/RuntimePrototypeTest, NodeUsageTest, cli prototype RubyVM::AbstractSyntaxTree not on JRuby
Test::RuntimeTestTest, cli test rbs test needs the TracePoint :end event
CommentBlockTest (3) Prism::Location#start_line_slice returns nil on JRuby's prism
TypeCheckTest (2) block-less loop Enumerator type-checks differently
cli collection install/update runs bundle install, which builds native gem extensions that don't compile on JRuby

CI

The jruby job now assembles the runtime and runs jruby -S rake test (instead of just two parser test files), and triggers on lib/test/sig changes. The test gems it needs are all pure Ruby; the native-extension dev tools in the main Gemfile (irb → io-console, activesupport → bigdecimal, ...) aren't installed, which is why the job uses gem install rather than the full bundle.

https://claude.ai/code/session_01LTveMt3NLbYHEboXuzAKpA


Generated by Claude Code

claude added 5 commits June 19, 2026 08:48
JRuby runs the parser in WebAssembly rather than the C extension, so:

- The `test` task no longer depends on `:compile` there (there is nothing to
  build; `rake wasm:jruby_setup` assembles the wasm runtime instead).
- The gemspec only stamps the `java` platform when actually building the
  release gem (RBS_PLATFORM=java); on JRuby it otherwise stays a `ruby`
  platform gem so local development matches a `ruby` lockfile, while still
  skipping the C extension and shipping the wasm + jars.

https://claude.ai/code/session_01LTveMt3NLbYHEboXuzAKpA
`require "pathname" unless defined?(Pathname)` skipped loading pathname when the
Pathname *constant* was already defined by another library (e.g. Bundler),
leaving `Kernel#Pathname` undefined. RBS::EnvironmentLoader uses `Pathname(...)`
at load time, so requiring RBS after Bundler raised NoMethodError on JRuby.
`require` is idempotent, so just require it unconditionally.

https://claude.ai/code/session_01LTveMt3NLbYHEboXuzAKpA
Mirror the existing `omit_on_truffle_ruby!` skips with `omit_on_jruby!` for the
tests that depend on `RubyVM::AbstractSyntaxTree` (prototype/node-usage), the
`TracePoint :end` event (`rbs test`), or prism's `start_line_slice`. Also skip
`rbs collection install/update`, which runs `bundle install` and builds native
gem extensions that do not compile on JRuby.

Also fix the pure-Ruby RBS::Location#[]: like the C extension, it now raises on
an unknown child name instead of returning nil.

https://claude.ai/code/session_01LTveMt3NLbYHEboXuzAKpA
These two cases already differ on TruffleRuby; the same Enumerator behavior
differs on JRuby, so omit them there too.

https://claude.ai/code/session_01LTveMt3NLbYHEboXuzAKpA
The JRuby job now assembles the WebAssembly runtime and runs `rake test` (the
whole non-stdlib suite, with JRuby-incompatible cases omitted) instead of just
the two parser test files, and triggers on lib/test/sig changes.

https://claude.ai/code/session_01LTveMt3NLbYHEboXuzAKpA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants