Repository: rails/rails
File: activesupport/lib/active_support/testing/parallelization/worker.rb (Ruby)

Code before:
              after_fork
            rescue => @setup_exception; end

            work_from_queue
          ensure
            set_process_title("(stopping)")

            run_cleanup
            @queue.stop_worker(@id, Process.pid)
          end
        end

        def work_from_queue
          while job = @queue.pop
            perform_job(job)
          end
        end

        def perform_job(job)
          klass    = job[0]
          method   = job[1]
          reporter = job[2]

          set_process_title("#{klass}##{method}")

          result = klass.with_info_handler reporter do
            Minitest.run_one_method(klass, method)
          end

          safe_record(reporter, result)
        end

        def safe_record(reporter, result)
          add_setup_exception(result) if @setup_exception

          begin
            @queue.record(reporter, result)
          rescue DRb::DRbConnError
            result.failures.map! do |failure|
              if failure.respond_to?(:error)
                # minitest >5.14.0
                error = DRb::DRbRemoteError.new(failure.error)
              else
                error = DRb::DRbRemoteError.new(failure.exception)
              end
              Minitest::UnexpectedError.new(error)
            end
            @queue.record(reporter, result)
          rescue Interrupt
            @queue.interrupt
            raise

Review comment (suggestion):
@zzak can it be that you accidentally copied the updated code from the [thread pool executor](https://github.com/rails/rails/pull/56207/changes#diff-71d234acea2ee9c358f05f60594fe6b21892c1d97257f30af2667a556faea2c1R42) here, instead of the updated code from the [worker](https://github.com/rails/rails/pull/56202/changes#diff-1da4187009a2235b3dc012d208c7151864a6aa4dc53986bd152fc831428f20cbR51)? The lack of `with_info_handler` wrapping causes some minitest-based gems to break, like [minitest-hooks](https://github.com/jeremyevans/minitest-hooks/issues/31).

Code after:
              after_fork
            rescue => @setup_exception; end

            work_from_queue
          ensure
            set_process_title("(stopping)")

            run_cleanup
            @queue.stop_worker(@id, Process.pid)
          end
        end

        def work_from_queue
          while job = @queue.pop
            perform_job(job)
          end
        end

        def perform_job(job)
          klass    = job[0]
          method   = job[1]
          reporter = job[2]

          set_process_title("#{klass}##{method}")

          result = if Minitest.respond_to? :run_one_method then
            Minitest.run_one_method klass, method
          else
            klass.new(method).run
          end

          safe_record(reporter, result)
        end

        def safe_record(reporter, result)
          add_setup_exception(result) if @setup_exception

          begin
            @queue.record(reporter, result)
          rescue DRb::DRbConnError
            result.failures.map! do |failure|
              if failure.respond_to?(:error)
                # minitest >5.14.0
                error = DRb::DRbRemoteError.new(failure.error)
              else
                error = DRb::DRbRemoteError.new(failure.exception)
              end
              Minitest::UnexpectedError.new(error)
            end
            @queue.record(reporter, result)
          rescue Interrupt