Default to forking killer

* Remove rspec world preserving will never work correctly
* Add new unmutated nodes to noop mutators
This commit is contained in:
Markus Schirp 2012-12-04 19:38:58 +01:00
parent 5d1124fe18
commit 9533a92bb7
5 changed files with 19 additions and 34 deletions

View file

@ -2,9 +2,9 @@ module Mutant
class Killer
class Forked < self
def initialize(killer, mutation)
def initialize(killer, strategy, mutation)
@killer = killer
super(mutation)
super(strategy, mutation)
end
def type
@ -13,7 +13,7 @@ module Mutant
def run
fork do
@killer.new(@mutation)
@killer.new(strategy, mutation)
end
status = Process.wait2.last
@ -26,13 +26,14 @@ module Mutant
attr_reader :killer
def initialize(strategy)
def initialize(killer)
@killer = killer
end
def new(mutation)
Forked.new(@killer, mutation)
def new(strategy, mutation)
Forked.new(killer, strategy, mutation)
end
end
end

View file

@ -40,7 +40,6 @@ module Mutant
# @api private
#
def run_rspec
strategy.prepare_world
::RSpec::Core::Runner.run(command_line_arguments, @error_stream, @output_stream)
end

View file

@ -67,6 +67,7 @@ module Mutant
# @api private
#
def emit_implicit_self_receiver
return;
# FIXME: Edge case that is currently not very well undestood
return if name == :block_given?
return unless self?

View file

@ -12,7 +12,9 @@ module Mutant
handle(Rubinius::AST::AttributeAssignment)
handle(Rubinius::AST::Not)
handle(Rubinius::AST::And)
handle(Rubinius::AST::Defined)
handle(Rubinius::AST::Super)
handle(Rubinius::AST::Match3)
handle(Rubinius::AST::ZSuper)
handle(Rubinius::AST::MultipleAssignment)
handle(Rubinius::AST::ScopedConstant)

View file

@ -30,41 +30,23 @@ module Mutant
class Rspec < self
def self.original_world
@original_world ||=
begin
require './spec/spec_helper'
::RSpec.world
end
end
def self.prepare_world
::RSpec.instance_variable_set(:@world, original_world)
::RSpec.reset
cleanup_world
end
def self.cleanup_world
::RSpec::Core::ExampleGroup.children.clear
::RSpec::Core::ExampleGroup.constants.each do |name|
if name =~ /^Nested/
RSpec::Core::ExampleGroup.send(:remove_const, name)
end
end
end
KILLER = Killer::Rspec
KILLER = Killer::Forking.new(Killer::Rspec)
class DM2 < self
def self.filename_pattern(mutation)
name = mutation.subject.context.scope.name
subject = mutation.subject
name = subject.context.scope.name
matcher = subject.matcher
append = mutation.subject.matcher.kind_of?(Matcher::Method::Singleton) ? '/class_methods' : ''
append = matcher.kind_of?(Matcher::Method::Singleton) ? '/class_methods' : ''
path = Inflector.underscore(name)
"spec/unit/#{path}#{append}/*_spec.rb"
base = "spec/unit/#{path}#{append}"
"#{base}/#{matcher.method_name}_spec.rb"
end
end