module Maxitest::InterruptHandler

def capture_exceptions(&block)

capture interrupt and treat it as a regular error so we get a backtrace
def capture_exceptions(&block)
  super(&block)
rescue Interrupt => e
  Maxitest.interrupted = true
  failures << Minitest::UnexpectedError.new(e)
end

def run

skip remaining tests if we were interrupted
def run
  if Maxitest.interrupted
    # produce a real error so we do not crash in -v mode
    failures <<
      begin
        raise Minitest::Skip, 'Maxitest::Interrupted'
      rescue Minitest::Skip
        $!
      end
    result = Minitest::Result.from(self)
    result.time = 0
    result
  else
    super()
  end
end