2014-06-08 13:55:13 -04:00
|
|
|
module Mutant
|
|
|
|
# Module providing isolationg
|
|
|
|
module Isolation
|
|
|
|
Error = Class.new(RuntimeError)
|
|
|
|
|
|
|
|
# Call block in isolation
|
|
|
|
#
|
|
|
|
# This isolation implements the fork strategy.
|
|
|
|
# Future strategies will probably use a process pool that can
|
|
|
|
# handle multiple mutation kills, in-isolation at once.
|
|
|
|
#
|
|
|
|
# @return [Object]
|
|
|
|
#
|
|
|
|
# @raise [Error]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def self.call(&block)
|
2014-06-24 20:13:24 -04:00
|
|
|
Parallel.map([block], in_processes: 1) do |block|
|
|
|
|
block.call
|
|
|
|
end.first
|
2014-06-08 13:55:13 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end # Isolator
|
|
|
|
end # Mutant
|