Skip to content

Move JRuby's Ant integration specs here as minitest tests - #6

Merged
headius merged 1 commit into
jruby:masterfrom
zev:move-jruby-ant-specs
Oct 2, 2026
Merged

headius merged 1 commit into
jruby:masterfrom
zev:move-jruby-ant-specs

Conversation

@zev

@zev zev commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

JRuby tested this gem with RSpec specs under spec/java_integration/ant/, which made Ant a requirement for JRuby's own test suite. As discussed in jruby/jruby#9761, this moves those specs here so JRuby can drop them, and adds CI.

What's here

  • The 5 JRuby spec files are ported to minitest, one test file each:
    • ant_spec.rb → the new classes in test/test_ant.rb
    • project_spec.rb → test/test_project.rb
    • rake_spec.rb → test/test_rake.rb
    • target_spec.rb → test/test_target.rb
    • task_spec.rb → test/test_task.rb
  • The existing test/test_ant.rb test is converted from test-unit to minitest. test-unit was never declared as a dependency, so bundle exec rake test couldn't load it.
  • test/ant_test_helper.rb replaces JRuby's ant_spec_helper.rb. The RSpec have_structure / have_configured_structure matchers become assert_structure / assert_configured_structure, using the same matching code.
  • Dev dependencies: minitest and minitest-mock. Minitest 6, which ships with Ruby 4.1, moved Object#stub into the separate minitest-mock gem. The Ant.load tests use it in place of RSpec's allow/expect on File.exist?, and still assert that JAVA_HOME, tools.jar and classes.zip were all checked.
  • The bundler dev dependency is relaxed from ~> 2.1 to >= 2.1. With current Bundler (4.x, as shipped with JRuby) bundle install failed outright.
  • .github/workflows/test.yml runs bundle exec rake test on jruby and jruby-head with Java 21 and Ant.

Differences from the JRuby specs

  • The jarjar examples are dropped, as agreed in review. They defined a third-party Ant task with taskdef, which needed jarjar 1.1 on disk. The jar examples still cover structure and configured-structure matching, and the tests need no downloads.
  • target_spec's "does not support ant for calling other buildfiles" example is replaced. It built a = example_ant ... but then ran ant.execute_target(:bar) on the global ant, so it passed only because the global project had no :bar target. Ant's <ant> task is in fact supported, so the new test_supports_ant_for_calling_other_buildfiles writes a temporary buildfile, calls it with <ant> from a Ruby-defined target, and asserts its target ran. The antcall example next to it is accurate: antcall fails because it tries to re-read the project's build.xml, which a Ruby-defined project doesn't have.
  • rake_spec.rb's top-level def import(*args); java_import(*args); end is not ported. Nothing here calls it, and in JRuby it leaked into other specs that loaded in the same process.
  • Two mutable string literals (message = "") are now String.new, because rake test runs with -w and they warn about frozen string literals.

Testing

Locally with JRuby master (Java 21, Ant 1.10.18): bundle exec rake test → 30 runs, 65 assertions, 0 failures, 0 skips, no warnings. That's the 31 JRuby examples minus the 2 jarjar ones, plus the original ant_import test.

CI on my fork: rake test passed on jruby and jruby-head.

Co-authored with Claude Code.

@headius

headius commented Oct 1, 2026

Copy link
Copy Markdown
Member
  • nobody uses this integration any more.

Yeah it probably can be removed at this point, It was just dragged along as a legacy feature for a long time. Anyone who still wants it can use the gem.

  • the jarjar examples define a third-party Ant task with taskdef, which needs jarjar 1.1 on disk.

Let's just drop the jarjar stuff altogether.

  • target_spec's last example

Fix it if possible or remove it, since it's not testing what it claims.

@headius headius left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically approved modulo the couple of questions answered in my previous comment.

JRuby tested this gem with RSpec specs under spec/java_integration/ant,
which made Ant a requirement for JRuby's own test suite. Port them here
as minitest tests so JRuby can drop them, and convert the existing
test-unit test to minitest as well.

- test/ant_test_helper.rb replaces ant_spec_helper.rb; the RSpec
  structure matcher becomes assert_structure/assert_configured_structure
- the Ant.load tests stub File.exist? with minitest-mock
- the jarjar examples are dropped, since they needed a third-party jar;
  the jar examples still cover structure matching
- target_spec's "does not support ant" example passed only by accident;
  it now runs Ant's <ant> task against a temporary buildfile
- add a GitHub Actions workflow running `rake test` on JRuby with Ant
- relax the bundler development dependency so current Bundler works

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zev
zev force-pushed the move-jruby-ant-specs branch from d8728ac to 061cedf Compare October 2, 2026 01:14
@zev

zev commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! Done in 061cedf:

  • Dropped the jarjar examples and the download step; rake test no longer needs the network.
  • target_spec's last example now runs <ant> against a temporary buildfile and asserts its target ran, since <ant> is supported. The neighbouring antcall example really is unsupported (it tries to re-read a nonexistent build.xml), so it stays.

I'll remove rake-ant as a default gem on the JRuby side as part of jruby/jruby#9761.


Generated by Claude Code

Comment thread .github/workflows/test.yml
Comment thread .github/workflows/test.yml
@headius
headius merged commit b17ef68 into jruby:master Oct 2, 2026
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