7293386c26
* rubocop still warns about this on ruby 1.9.3, so it was fixed so it produces less output on travis.
46 lines
920 B
Ruby
46 lines
920 B
Ruby
# encoding: utf-8
|
|
|
|
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
|
|
#
|
|
# @return [true]
|
|
# 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)
|
|
end
|
|
|
|
status = Process.wait2(pid).last
|
|
status.exited? && status.success?
|
|
end
|
|
|
|
end # Forked
|
|
end # Killer
|
|
end # Mutant
|