summaryrefslogtreecommitdiff
path: root/spec/mspec/lib/mspec/runner/actions/timeout.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/mspec/lib/mspec/runner/actions/timeout.rb')
-rw-r--r--spec/mspec/lib/mspec/runner/actions/timeout.rb19
1 files changed, 16 insertions, 3 deletions
diff --git a/spec/mspec/lib/mspec/runner/actions/timeout.rb b/spec/mspec/lib/mspec/runner/actions/timeout.rb
index dddaa250b5..543b7366d7 100644
--- a/spec/mspec/lib/mspec/runner/actions/timeout.rb
+++ b/spec/mspec/lib/mspec/runner/actions/timeout.rb
@@ -8,6 +8,7 @@ class TimeoutAction
def register
MSpec.register :start, self
MSpec.register :before, self
+ MSpec.register :after, self
MSpec.register :finish, self
end
@@ -35,8 +36,12 @@ class TimeoutAction
if @queue.empty?
elapsed = now - @started
if elapsed > @timeout
- STDERR.puts "\n#{@current_state.description}"
- STDERR.puts "Example took longer than the configured timeout of #{@timeout}s"
+ if @current_state
+ STDERR.puts "\nExample took longer than the configured timeout of #{@timeout}s:"
+ STDERR.puts "#{@current_state.description}"
+ else
+ STDERR.puts "\nSome code outside an example took longer than the configured timeout of #{@timeout}s"
+ end
STDERR.flush
show_backtraces
@@ -56,6 +61,12 @@ class TimeoutAction
end
end
+ def after(state = nil)
+ @queue << -> do
+ @current_state = nil
+ end
+ end
+
def finish
@thread.kill
@thread.join
@@ -73,7 +84,9 @@ class TimeoutAction
Truffle::Debug.show_backtraces
else
Thread.list.each do |thread|
- STDERR.puts thread.inspect, thread.backtrace, ''
+ unless thread == Thread.current
+ STDERR.puts thread.inspect, thread.backtrace, ''
+ end
end
end
end