29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/async/rspec/reactor.rb', line 29
def run_example(reactor, example, duration)
result = nil
reactor.run do |task|
task.annotate(self.class)
reactor = task.reactor
timer = nil
if duration
timer = reactor.async do |task|
task.annotate("timer task duration=#{duration}")
task.sleep(duration)
buffer = StringIO.new
reactor.print_hierarchy(buffer)
reactor.stop
raise TimeoutError, "run time exceeded duration #{duration}s:\r\n#{buffer.string}"
end
end
task.async do |spec_task|
spec_task.annotate("example runner")
result = example.run
if result.is_a? Exception
reactor.stop
else
spec_task.children.each(&:wait)
end
end.wait
timer.stop if timer
end
return result
end
|