diff --git a/test/unit/minitest_assertions_test.rb b/test/unit/minitest_assertions_test.rb index 29011696..336b2527 100644 --- a/test/unit/minitest_assertions_test.rb +++ b/test/unit/minitest_assertions_test.rb @@ -7,16 +7,30 @@ class MinitestAssertionsTest < ActiveSupport::TestCase # inspect how before_teardown resolved (passed/skipped/failed) without polluting # the outer test's own assertions/reporting. # + # Rails 7.2+ only. `defined?` rather than a version comparison: the + # question is whether the constant is there to prepend, and edge/main can + # move independently of the version string. + RAILS_HAS_ASSERTION_ALARM = defined?(ActiveSupport::Testing::TestsWithoutAssertions) + # @param teardown [Proc, nil] optional replacement `teardown` method, to # simulate a user teardown that runs after `before_teardown`. Calls # `super()` first so DSLStub's own cleanup still happens. # @param like_rails [Boolean] prepend the module Rails prepends into every # ActiveSupport::TestCase, to observe its missing-assertions alarm. def run_inner_test(teardown: nil, like_rails: false, &block) + # Without the module there is no alarm to observe, and running anyway would + # assert that a thing which cannot fire did not fire -- green for the wrong + # reason, which is the failure mode this whole release exists to remove. + skip "ActiveSupport::Testing::TestsWithoutAssertions is Rails 7.2+" if like_rails && !RAILS_HAS_ASSERTION_ALARM + test_class = Class.new(::Minitest::Test) do # The real thing, not a stand-in: Rails prepends exactly this, - # unconditionally, at active_support/test_case.rb:205. - prepend ActiveSupport::Testing::TestsWithoutAssertions if like_rails + # unconditionally, at active_support/test_case.rb:205 -- but only since + # Rails 7.2. On 7.1 the constant does not exist, so the alarm this test + # observes is simply not a feature of that version. Skip rather than + # stub: a hand-rolled stand-in would assert that OUR code cooperates + # with a module Rails never prepends there, which proves nothing. + prepend ActiveSupport::Testing::TestsWithoutAssertions if like_rails && RAILS_HAS_ASSERTION_ALARM include SnapDiff::Minitest::Assertions include DSLStub diff --git a/test/unit/parallel_report_merge_test.rb b/test/unit/parallel_report_merge_test.rb index 14a7169a..e209e3b6 100644 --- a/test/unit/parallel_report_merge_test.rb +++ b/test/unit/parallel_report_merge_test.rb @@ -220,7 +220,16 @@ class ParallelReportMergeTest < ActiveSupport::TestCase # Runs the block in a real forked child, then the exact hook Rails runs # inside a parallel worker before it exits. + # + # JRuby has no `fork` (`Process.respond_to?(:fork)` is false, and calling it + # raises NotImplementedError), so Rails' fork-parallel mode -- the entire + # subject of this file -- cannot happen there. JRuby suites parallelize with + # threads, which record in the process that finalizes and are covered by + # "merging is a no-op when no worker ever forked" above. Skipping is the + # honest report: the behaviour is inapplicable, not untested. def fork_worker(&block) + skip "Rails' fork-parallel mode needs Kernel#fork, which #{RUBY_ENGINE} does not implement" unless Process.respond_to?(:fork) + pid = fork do block.call ActiveSupport::Testing::Parallelization.run_cleanup_hooks.each { |hook| hook.call(0) }