Add better noop/neutral reporting
This commit is contained in:
parent
d5f5564dc0
commit
7813f92412
7 changed files with 84 additions and 15 deletions
|
@ -1,3 +1,3 @@
|
||||||
---
|
---
|
||||||
threshold: 18
|
threshold: 18
|
||||||
total_score: 1053
|
total_score: 1040
|
||||||
|
|
|
@ -195,6 +195,7 @@ require 'mutant/reporter/cli/report'
|
||||||
require 'mutant/reporter/cli/report/env'
|
require 'mutant/reporter/cli/report/env'
|
||||||
require 'mutant/reporter/cli/report/subject'
|
require 'mutant/reporter/cli/report/subject'
|
||||||
require 'mutant/reporter/cli/report/mutation'
|
require 'mutant/reporter/cli/report/mutation'
|
||||||
|
require 'mutant/reporter/cli/report/test'
|
||||||
require 'mutant/reporter/cli/progress'
|
require 'mutant/reporter/cli/progress'
|
||||||
require 'mutant/reporter/cli/progress/env'
|
require 'mutant/reporter/cli/progress/env'
|
||||||
require 'mutant/reporter/cli/progress/config'
|
require 'mutant/reporter/cli/progress/config'
|
||||||
|
|
|
@ -25,7 +25,7 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def define_delegator(name)
|
def define_delegator(name)
|
||||||
fail if instance_methods.include?(name)
|
fail "method #{name} already defined" if instance_methods.include?(name)
|
||||||
define_method(name) do
|
define_method(name) do
|
||||||
object.public_send(name)
|
object.public_send(name)
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ module Mutant
|
||||||
|
|
||||||
handle Mutant::Result::Mutation
|
handle Mutant::Result::Mutation
|
||||||
|
|
||||||
delegate :mutation
|
delegate :mutation, :failed_test_results
|
||||||
|
|
||||||
DIFF_ERROR_MESSAGE = 'BUG: Mutation NOT resulted in exactly one diff. Please report a reproduction!'.freeze
|
DIFF_ERROR_MESSAGE = 'BUG: Mutation NOT resulted in exactly one diff. Please report a reproduction!'.freeze
|
||||||
|
|
||||||
|
@ -26,13 +26,15 @@ module Mutant
|
||||||
"%s\n" \
|
"%s\n" \
|
||||||
"Unparsed Source:\n" \
|
"Unparsed Source:\n" \
|
||||||
"%s\n" \
|
"%s\n" \
|
||||||
"-----------------------\n".freeze
|
"Test Reports: %d\n"
|
||||||
|
|
||||||
NOOP_MESSAGE =
|
NOOP_MESSAGE =
|
||||||
"--- Noop failure ---\n" \
|
"---- Noop failure -----\n" \
|
||||||
"No code was inserted. And the test did NOT PASS.\n" \
|
"No code was inserted. And the test did NOT PASS.\n" \
|
||||||
"This is typically a problem of your specs not passing unmutated.\n" \
|
"This is typically a problem of your specs not passing unmutated.\n" \
|
||||||
"--------------------\n".freeze
|
"Test Reports: %d\n"
|
||||||
|
|
||||||
|
FOOTER = '-----------------------'.freeze
|
||||||
|
|
||||||
# Run report printer
|
# Run report printer
|
||||||
#
|
#
|
||||||
|
@ -42,7 +44,8 @@ module Mutant
|
||||||
#
|
#
|
||||||
def run
|
def run
|
||||||
puts(mutation.identification)
|
puts(mutation.identification)
|
||||||
puts(details)
|
print_details
|
||||||
|
puts(FOOTER)
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -50,11 +53,11 @@ module Mutant
|
||||||
|
|
||||||
# Return details
|
# Return details
|
||||||
#
|
#
|
||||||
# @return [String]
|
# @return [undefined]
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def details
|
def print_details
|
||||||
send(MAP.fetch(mutation.class))
|
send(MAP.fetch(mutation.class))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -68,7 +71,7 @@ module Mutant
|
||||||
original, current = mutation.original_source, mutation.source
|
original, current = mutation.original_source, mutation.source
|
||||||
diff = Mutant::Diff.build(original, current)
|
diff = Mutant::Diff.build(original, current)
|
||||||
diff = color? ? diff.colorized_diff : diff.diff
|
diff = color? ? diff.colorized_diff : diff.diff
|
||||||
diff || DIFF_ERROR_MESSAGE
|
info(diff || DIFF_ERROR_MESSAGE)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Noop details
|
# Noop details
|
||||||
|
@ -78,7 +81,8 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def noop_details
|
def noop_details
|
||||||
NOOP_MESSAGE
|
info(NOOP_MESSAGE, failed_test_results.length)
|
||||||
|
visit_collection(failed_test_results)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Neutral details
|
# Neutral details
|
||||||
|
@ -88,7 +92,8 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def neutral_details
|
def neutral_details
|
||||||
format(NEUTRAL_MESSAGE, mutation.subject.node.inspect, mutation.source)
|
info(NEUTRAL_MESSAGE, mutation.subject.node.inspect, mutation.source, failed_test_results.length)
|
||||||
|
visit_collection(failed_test_results)
|
||||||
end
|
end
|
||||||
|
|
||||||
end # Mutation
|
end # Mutation
|
||||||
|
|
28
lib/mutant/reporter/cli/report/test.rb
Normal file
28
lib/mutant/reporter/cli/report/test.rb
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
module Mutant
|
||||||
|
class Reporter
|
||||||
|
class CLI
|
||||||
|
class Report
|
||||||
|
# Test result reporter
|
||||||
|
class Test < self
|
||||||
|
|
||||||
|
handle(Mutant::Result::Test)
|
||||||
|
|
||||||
|
delegate :test, :runtime
|
||||||
|
|
||||||
|
# Run test result reporter
|
||||||
|
#
|
||||||
|
# @return [self]
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
|
#
|
||||||
|
def run
|
||||||
|
status('- %s / runtime: %s', test.identification, object.runtime)
|
||||||
|
puts('Test Output:')
|
||||||
|
puts(object.output)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end # Report
|
||||||
|
end # CLI
|
||||||
|
end # Reporter
|
||||||
|
end # Mutant
|
|
@ -284,6 +284,16 @@ module Mutant
|
||||||
test_results.any?(&:success?)
|
test_results.any?(&:success?)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Return failed test results
|
||||||
|
#
|
||||||
|
# @return [Array]
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
|
#
|
||||||
|
def failed_test_results
|
||||||
|
test_results.select(&:fail?)
|
||||||
|
end
|
||||||
|
|
||||||
sum :killtime, :test_results
|
sum :killtime, :test_results
|
||||||
|
|
||||||
end # Mutation
|
end # Mutation
|
||||||
|
|
|
@ -70,6 +70,19 @@ describe Mutant::Reporter::CLI do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
let(:test_results) do
|
||||||
|
[
|
||||||
|
double(
|
||||||
|
'Test Result',
|
||||||
|
class: Mutant::Result::Test,
|
||||||
|
test: _subject.tests.first,
|
||||||
|
runtime: 1.0,
|
||||||
|
output: 'test-output',
|
||||||
|
success?: mutation_result_success
|
||||||
|
)
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
let(:subject_results) do
|
let(:subject_results) do
|
||||||
[
|
[
|
||||||
Mutant::Result::Subject.new(
|
Mutant::Result::Subject.new(
|
||||||
|
@ -81,7 +94,9 @@ describe Mutant::Reporter::CLI do
|
||||||
class: Mutant::Result::Mutation,
|
class: Mutant::Result::Mutation,
|
||||||
mutation: mutation,
|
mutation: mutation,
|
||||||
killtime: 0.5,
|
killtime: 0.5,
|
||||||
success?: mutation_result_success
|
success?: mutation_result_success,
|
||||||
|
test_results: test_results,
|
||||||
|
failed_test_results: mutation_result_success ? [] : test_results
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
@ -192,6 +207,7 @@ describe Mutant::Reporter::CLI do
|
||||||
@@ -1,2 +1,2 @@
|
@@ -1,2 +1,2 @@
|
||||||
-true
|
-true
|
||||||
+false
|
+false
|
||||||
|
-----------------------
|
||||||
Subjects: 1
|
Subjects: 1
|
||||||
Mutations: 1
|
Mutations: 1
|
||||||
Kills: 0
|
Kills: 0
|
||||||
|
@ -215,6 +231,7 @@ describe Mutant::Reporter::CLI do
|
||||||
- test_id
|
- test_id
|
||||||
mutation_id
|
mutation_id
|
||||||
BUG: Mutation NOT resulted in exactly one diff. Please report a reproduction!
|
BUG: Mutation NOT resulted in exactly one diff. Please report a reproduction!
|
||||||
|
-----------------------
|
||||||
Subjects: 1
|
Subjects: 1
|
||||||
Mutations: 1
|
Mutations: 1
|
||||||
Kills: 0
|
Kills: 0
|
||||||
|
@ -246,6 +263,10 @@ describe Mutant::Reporter::CLI do
|
||||||
(true)
|
(true)
|
||||||
Unparsed Source:
|
Unparsed Source:
|
||||||
true
|
true
|
||||||
|
Test Reports: 1
|
||||||
|
- test_id / runtime: 1.0
|
||||||
|
Test Output:
|
||||||
|
test-output
|
||||||
-----------------------
|
-----------------------
|
||||||
Subjects: 1
|
Subjects: 1
|
||||||
Mutations: 1
|
Mutations: 1
|
||||||
|
@ -269,10 +290,14 @@ describe Mutant::Reporter::CLI do
|
||||||
subject_id
|
subject_id
|
||||||
- test_id
|
- test_id
|
||||||
mutation_id
|
mutation_id
|
||||||
--- Noop failure ---
|
---- Noop failure -----
|
||||||
No code was inserted. And the test did NOT PASS.
|
No code was inserted. And the test did NOT PASS.
|
||||||
This is typically a problem of your specs not passing unmutated.
|
This is typically a problem of your specs not passing unmutated.
|
||||||
--------------------
|
Test Reports: 1
|
||||||
|
- test_id / runtime: 1.0
|
||||||
|
Test Output:
|
||||||
|
test-output
|
||||||
|
-----------------------
|
||||||
Subjects: 1
|
Subjects: 1
|
||||||
Mutations: 1
|
Mutations: 1
|
||||||
Kills: 0
|
Kills: 0
|
||||||
|
|
Loading…
Add table
Reference in a new issue