Merge pull request #74 from jessekempf/dump_rspec_stderr_when_noop_mutant_is_not_killed

Surface the output of rspec failures when killing noop mutants.
This commit is contained in:
Markus Schirp 2013-07-26 12:58:31 -07:00
commit 97f123124c
5 changed files with 60 additions and 3 deletions

View file

@ -18,9 +18,21 @@ module Mutant
def run
mutation.insert
# TODO: replace with real streams from configuration
# Note: we assume the only interesting output from a failed rspec run is stderr.
require 'stringio'
null = StringIO.new
!::RSpec::Core::Runner.run(command_line_arguments, null, null).zero?
rspec_err = StringIO.new
killed = !::RSpec::Core::Runner.run(command_line_arguments, nil, rspec_err).zero?
if killed and mutation.should_survive?
rspec_err.rewind
puts "#{mutation.class} test failed."
puts 'RSpec stderr:'
puts rspec_err.read
end
killed
end
# Return command line arguments

View file

@ -28,6 +28,18 @@ module Mutant
#
abstract_method :success?
# Indicate if a killer should treat a kill as problematic
#
# @return [true]
# if killing is unexpected
#
# @return [false]
# if killing is expected
#
# @api private
#
abstract_method :should_survive?
# Insert mutated node
#
# FIXME:

View file

@ -30,6 +30,16 @@ module Mutant
killer.killed?
end
# Indicate if a killer should treat a kill as problematic.
#
# @return [false] Killing evil mutants is not problematic.
#
# @api private
#
def should_survive?
false
end
end # Evil
end # Mutation
end # Mutant

View file

@ -10,6 +10,19 @@ module Mutant
SYMBOL = 'noop'
# Indicate if a killer should treat a kill as problematic.
#
# @return [false] Killing noop mutants is a serious problem. Failures
# in noop may indicate a broken test suite, but they can also be an
# indication mutant has altered the runtime environment in a subtle
# way and tickled an odd bug.
#
# @api private
#
def should_survive?
false
end
end
# Return identification
@ -39,6 +52,16 @@ module Mutant
!killer.killed?
end
# Indicate if a killer should treat a kill as problematic.
#
# @return [true] Neutral mutants must die.
#
# @api private
#
def should_survive?
false
end
end # Neutral
end # Mutation
end # Mutant

View file

@ -6,7 +6,7 @@ describe Mutant::Killer::Rspec, '.new' do
let(:strategy) { double('Strategy', :spec_files => ['foo'], :error_stream => $stderr, :output_stream => $stdout) }
let(:context) { double('Context') }
let(:mutation) { double('Mutation', :subject => mutation_subject) }
let(:mutation) { double('Mutation', :subject => mutation_subject, :should_survive? => false) }
let(:mutation_subject) { double('Mutation Subject') }
let(:object) { described_class }