7293386c26
* rubocop still warns about this on ruby 1.9.3, so it was fixed so it produces less output on travis.
56 lines
1.1 KiB
Ruby
56 lines
1.1 KiB
Ruby
# encoding: utf-8
|
|
|
|
module Mutant
|
|
class Killer
|
|
# Runner for rspec tests
|
|
class Rspec < self
|
|
|
|
private
|
|
|
|
# Run rspec test
|
|
#
|
|
# @return [true]
|
|
# when test is NOT successful
|
|
#
|
|
# @return [false]
|
|
# otherwise
|
|
#
|
|
# @api private
|
|
#
|
|
def run
|
|
mutation.insert
|
|
# TODO: replace with real streams from configuration
|
|
require 'stringio'
|
|
# Note: We assume interesting output from a failed rspec run is stderr.
|
|
rspec_err = StringIO.new
|
|
|
|
exit_code = ::RSpec::Core::Runner.run(cli_arguments, nil, rspec_err)
|
|
|
|
killed = !exit_code.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
|
|
#
|
|
# @return [Array]
|
|
#
|
|
# @api private
|
|
#
|
|
def cli_arguments
|
|
%W(
|
|
--fail-fast
|
|
) + strategy.spec_files(mutation.subject)
|
|
end
|
|
|
|
end # Rspec
|
|
end # Killer
|
|
end # Mutant
|