Module: Maxitest::InterruptHandler

Included in:
Minitest::Test
Defined in:
lib/maxitest/interrupt.rb

Instance Method Summary collapse

Instance Method Details

#capture_exceptions(&block) ⇒ Object

capture interrupt and treat it as a regular error so we get a backtrace



14
15
16
17
18
19
# File 'lib/maxitest/interrupt.rb', line 14

def capture_exceptions(&block)
  super(&block)
rescue Interrupt => e
  Maxitest.interrupted = true
  failures << Minitest::UnexpectedError.new(e)
end

#runObject

skip remaining tests if we were interrupted



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/maxitest/interrupt.rb', line 22

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