Cleanup cli reporter
* Equalize on io object * Raise on cases where diff cannot be generated (simplifies explorational testing)
This commit is contained in:
parent
d278c627a5
commit
d62754d10d
1 changed files with 17 additions and 1 deletions
|
@ -2,6 +2,8 @@ module Mutant
|
|||
class Reporter
|
||||
# Reporter that reports in human readable format
|
||||
class CLI < self
|
||||
include Equalizer.new(:io)
|
||||
|
||||
# Reporter subject
|
||||
#
|
||||
# @param [Subject] subject
|
||||
|
@ -43,6 +45,14 @@ module Mutant
|
|||
self
|
||||
end
|
||||
|
||||
# Return IO stream
|
||||
#
|
||||
# @return [IO]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def io; @io; end
|
||||
|
||||
private
|
||||
|
||||
# Initialize reporter
|
||||
|
@ -66,9 +76,15 @@ module Mutant
|
|||
# @api private
|
||||
#
|
||||
def failure(killer)
|
||||
@io.puts(colorize(Color::RED, "!!! Uncovered Mutation !!!"))
|
||||
@io.puts(colorize(Color::RED, "!!! Mutant alive: #{killer.identification} !!!"))
|
||||
differ = Differ.new(killer.original_source,killer.mutation_source)
|
||||
diff = color? ? differ.colorized_diff : differ.diff
|
||||
# FIXME remove this branch before release
|
||||
if diff.empty?
|
||||
killer.send(:mutation).node.ascii_graph
|
||||
killer.send(:mutation).subject.node.ascii_graph
|
||||
raise "Unable to create a diff"
|
||||
end
|
||||
@io.puts(diff)
|
||||
@io.puts
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue