2011-11-10 10:12:41 -06:00
|
|
|
require 'v8'
|
|
|
|
|
2012-05-08 15:11:50 -05:00
|
|
|
def run_v8_gc
|
2012-06-19 04:32:58 -05:00
|
|
|
V8::C::V8::LowMemoryNotification()
|
2012-05-17 11:15:30 -05:00
|
|
|
while !V8::C::V8::IdleNotification() do
|
|
|
|
end
|
2012-05-08 15:11:50 -05:00
|
|
|
end
|
|
|
|
|
2011-11-10 10:12:41 -06:00
|
|
|
def rputs(msg)
|
|
|
|
puts "<pre>#{ERB::Util.h(msg)}</pre>"
|
|
|
|
$stdout.flush
|
|
|
|
end
|
2012-06-05 08:00:04 -05:00
|
|
|
|
2015-03-15 18:27:19 +00:00
|
|
|
module V8ContextHelpers
|
|
|
|
module GroupMethods
|
|
|
|
def requires_v8_context
|
|
|
|
around(:each) do |example|
|
|
|
|
bootstrap_v8_context(&example)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def bootstrap_v8_context
|
2012-06-05 08:00:04 -05:00
|
|
|
V8::C::Locker() do
|
|
|
|
V8::C::HandleScope() do
|
|
|
|
@cxt = V8::C::Context::New()
|
|
|
|
begin
|
|
|
|
@cxt.Enter()
|
2015-03-15 18:27:19 +00:00
|
|
|
yield
|
2012-06-05 08:00:04 -05:00
|
|
|
ensure
|
|
|
|
@cxt.Exit()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
RSpec.configure do |c|
|
2015-03-15 18:27:19 +00:00
|
|
|
c.include V8ContextHelpers
|
|
|
|
c.extend V8ContextHelpers::GroupMethods
|
|
|
|
end
|