1
0
Fork 0
mirror of https://github.com/rubyjs/mini_racer synced 2023-03-27 23:21:28 -04:00
mini_racer/test/test_crash.rb
Sam 6fbec25677 FIX: properly handle timeouts in Ruby code
Notes

Thread#raise does not happen right away, it may be delayed so we use a lock to ensure we get it
Timeout thread is now a ruby managed thread, this allows it to properly communicate with ruby callbacks
Context#stop is fixed to work in all conditions
2016-09-22 15:49:06 +10:00

29 lines
438 B
Ruby

$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'mini_racer'
def test
context = MiniRacer::Context.new(timeout: 10)
context.attach("echo", proc{ |msg|
GC.start
msg
})
GC.disable
100.times { 'foo' } # alloc a handful of objects
GC.enable
context.eval("while(true) echo('foo');") rescue nil
# give some time to clean up
puts "we are done"
end
test
GC.start
test
10.times{GC.start}
test