Report colorized diff for all mutations
Will have a config switch soon
This commit is contained in:
parent
f39668d36d
commit
beba0f1155
1 changed files with 25 additions and 9 deletions
|
@ -56,6 +56,8 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def mutation(mutation)
|
def mutation(mutation)
|
||||||
|
colorized_diff(mutation.original_source, mutation.source)
|
||||||
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
# Report config
|
# Report config
|
||||||
|
@ -159,15 +161,7 @@ module Mutant
|
||||||
#
|
#
|
||||||
def failure(killer)
|
def failure(killer)
|
||||||
puts(colorize(Color::RED, "!!! Mutant alive: #{killer.identification} !!!"))
|
puts(colorize(Color::RED, "!!! Mutant alive: #{killer.identification} !!!"))
|
||||||
differ = Differ.new(killer.original_source,killer.mutation_source)
|
colorized_diff(killer.original_source, killer.mutated_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
|
|
||||||
puts(diff)
|
|
||||||
puts("Took: (%02.2fs)" % killer.runtime)
|
puts("Took: (%02.2fs)" % killer.runtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -213,6 +207,28 @@ module Mutant
|
||||||
io.puts(string)
|
io.puts(string)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Write colorized diff
|
||||||
|
#
|
||||||
|
# @param [String] original
|
||||||
|
# @param [String] current
|
||||||
|
#
|
||||||
|
# @return [self]
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
|
#
|
||||||
|
def colorized_diff(original, current)
|
||||||
|
differ = Differ.new(original, current)
|
||||||
|
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, so ast mutation or to_source has an error!"
|
||||||
|
end
|
||||||
|
puts(diff)
|
||||||
|
self
|
||||||
|
end
|
||||||
|
|
||||||
# Test for output to tty
|
# Test for output to tty
|
||||||
#
|
#
|
||||||
# @return [true]
|
# @return [true]
|
||||||
|
|
Loading…
Reference in a new issue