1 Object.flet(:at_exit => lambda {}) do
2 # keep miniunit's at_exit block from running
3 gem 'miniunit', ">= 1.0.1"
8 def Unit.puke(*args) # puke in a bucket
9 TestUnitBackend.failure_bucket(*args)
13 class TestUnitBackend < Backend
19 load(find_test_for(file))
20 # this will call record_failure as needed
21 with_no_output { Test::Unit.autotest }
25 def failure_bucket(klass, method, exception)
26 # FIXME: errors here could actually occur in impl rather than test file
27 (@layers[@file] ||= []) << Layer.from_failure(@file, klass, method, exception)
30 def find_test_for(file)
31 # TODO: return test for implementation if possible
36 Augment::BACKENDS['test'] = self
39 # TODO: let Layer.new handle this by using a Fixnum instead of range
40 def Layer.from_failure(file, klass, method, exception)
41 color = Test::Assertion === exception ? 'red' : 'yellow'
43 trace = exception.backtrace.detect { |e| e =~ Regexp.new(file) }
44 line = trace.match(/:(\d*):/)[1]
46 range = Layer.line_to_char_range(file, line.to_i)
47 Layer.new(range, color, exception.message, TestUnitBackend)