free_mutant/lib/mutant/killer/forked.rb

45 lines
901 B
Ruby
Raw Normal View History

2013-01-15 17:46:05 -05:00
module Mutant
class Killer
# Killer that executes other killer in forked environment
class Forked < self
# Initialize object
#
# @param [Killer] killer
# @param [Strategy] strategy
# @param [Mutation] mutation
#
# @api private
#
def initialize(killer, strategy, mutation)
@killer = killer
super(strategy, mutation)
end
private
# Run killer
#
2013-04-17 23:31:21 -04:00
# @return [true]
2013-01-15 17:46:05 -05:00
# if mutant was killed
#
# @return [false]
# otherwise
#
# @api private
#
def run
pid = fork do
killer = @killer.new(strategy, mutation)
exit(killer.killed? ? CLI::EXIT_SUCCESS : CLI::EXIT_FAILURE)
2013-01-15 17:46:05 -05:00
end
status = Process.wait2(pid).last
status.exited? && status.success?
2013-01-15 17:46:05 -05:00
end
2013-06-14 14:54:02 -04:00
end # Forked
end # Killer
end # Mutant