mutant 0.5.26 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/.travis.yml +1 -0
- data/Changelog.md +16 -3
- data/Gemfile +0 -2
- data/Gemfile.devtools +2 -2
- data/README.md +9 -15
- data/bin/mutant +0 -1
- data/config/flay.yml +1 -1
- data/config/flog.yml +1 -1
- data/config/mutant.yml +1 -1
- data/config/reek.yml +14 -11
- data/config/rubocop.yml +1 -1
- data/lib/mutant.rb +22 -21
- data/lib/mutant/ast.rb +47 -0
- data/lib/mutant/cli.rb +7 -4
- data/lib/mutant/config.rb +1 -0
- data/lib/mutant/context.rb +1 -1
- data/lib/mutant/diff.rb +38 -7
- data/lib/mutant/env.rb +22 -3
- data/lib/mutant/expression.rb +15 -4
- data/lib/mutant/integration.rb +1 -1
- data/lib/mutant/isolation.rb +2 -4
- data/lib/mutant/matcher.rb +1 -1
- data/lib/mutant/matcher/method.rb +1 -1
- data/lib/mutant/matcher/method/singleton.rb +1 -1
- data/lib/mutant/matcher/methods.rb +0 -2
- data/lib/mutant/meta/example.rb +0 -2
- data/lib/mutant/meta/example/dsl.rb +1 -1
- data/lib/mutant/mutator.rb +1 -1
- data/lib/mutant/mutator/node.rb +3 -3
- data/lib/mutant/mutator/node/begin.rb +1 -1
- data/lib/mutant/mutator/node/block.rb +16 -3
- data/lib/mutant/mutator/node/if.rb +1 -1
- data/lib/mutant/mutator/node/literal/fixnum.rb +1 -1
- data/lib/mutant/mutator/node/resbody.rb +0 -2
- data/lib/mutant/mutator/node/send.rb +17 -7
- data/lib/mutant/mutator/node/send/index.rb +0 -2
- data/lib/mutant/mutator/registry.rb +1 -1
- data/lib/mutant/mutator/util.rb +1 -1
- data/lib/mutant/mutator/util/array.rb +1 -1
- data/lib/mutant/reporter.rb +13 -3
- data/lib/mutant/reporter/cli.rb +54 -8
- data/lib/mutant/reporter/cli/format.rb +197 -0
- data/lib/mutant/reporter/cli/printer.rb +402 -22
- data/lib/mutant/reporter/cli/tput.rb +27 -0
- data/lib/mutant/reporter/null.rb +4 -34
- data/lib/mutant/reporter/trace.rb +6 -38
- data/lib/mutant/result.rb +44 -56
- data/lib/mutant/runner.rb +99 -52
- data/lib/mutant/runner/collector.rb +134 -0
- data/lib/mutant/subject/method/instance.rb +12 -4
- data/lib/mutant/version.rb +1 -1
- data/lib/mutant/warning_filter.rb +0 -2
- data/lib/mutant/zombifier/file.rb +1 -1
- data/meta/block.rb +17 -1
- data/meta/send.rb +123 -1
- data/mutant-rspec.gemspec +3 -3
- data/mutant.gemspec +1 -1
- data/spec/integration/mutant/corpus_spec.rb +4 -195
- data/spec/integration/mutant/null_spec.rb +1 -3
- data/spec/integration/mutant/rspec_spec.rb +1 -3
- data/spec/integration/mutant/test_mutator_handles_types_spec.rb +1 -3
- data/spec/integration/mutant/zombie_spec.rb +1 -3
- data/spec/integrations.yml +7 -0
- data/spec/shared/method_matcher_behavior.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/support/compress_helper.rb +1 -0
- data/spec/support/corpus.rb +239 -0
- data/spec/support/mutation_verifier.rb +2 -4
- data/spec/unit/mutant/cli_spec.rb +20 -13
- data/spec/unit/mutant/context/root_spec.rb +1 -3
- data/spec/unit/mutant/context/scope/root_spec.rb +1 -3
- data/spec/unit/mutant/context/scope/unqualified_name_spec.rb +1 -3
- data/spec/unit/mutant/diff_spec.rb +37 -19
- data/spec/unit/mutant/expression/method_spec.rb +5 -7
- data/spec/unit/mutant/expression/methods_spec.rb +5 -7
- data/spec/unit/mutant/expression/namespace/flat_spec.rb +6 -8
- data/spec/unit/mutant/expression/namespace/recursive_spec.rb +6 -7
- data/spec/unit/mutant/expression_spec.rb +14 -5
- data/spec/unit/mutant/integration_spec.rb +14 -3
- data/spec/unit/mutant/isolation_spec.rb +2 -4
- data/spec/unit/mutant/loader/eval_spec.rb +1 -3
- data/spec/unit/mutant/matcher/chain_spec.rb +1 -3
- data/spec/unit/mutant/matcher/compiler/subject_prefix_spec.rb +21 -0
- data/spec/unit/mutant/matcher/compiler_spec.rb +28 -3
- data/spec/unit/mutant/matcher/filter_spec.rb +1 -3
- data/spec/unit/mutant/matcher/method/instance_spec.rb +3 -5
- data/spec/unit/mutant/matcher/method/singleton_spec.rb +22 -4
- data/spec/unit/mutant/matcher/methods/instance_spec.rb +7 -6
- data/spec/unit/mutant/matcher/methods/singleton_spec.rb +4 -6
- data/spec/unit/mutant/matcher/namespace_spec.rb +1 -3
- data/spec/unit/mutant/matcher/null_spec.rb +1 -3
- data/spec/unit/mutant/mutation_spec.rb +1 -3
- data/spec/unit/mutant/mutator/node_spec.rb +1 -3
- data/spec/unit/mutant/reporter/cli_spec.rb +444 -206
- data/spec/unit/mutant/reporter/null_spec.rb +1 -3
- data/spec/unit/mutant/require_highjack_spec.rb +1 -3
- data/spec/unit/mutant/runner_spec.rb +42 -28
- data/spec/unit/mutant/subject/context_spec.rb +1 -3
- data/spec/unit/mutant/subject/method/instance_spec.rb +27 -19
- data/spec/unit/mutant/subject/method/singleton_spec.rb +49 -17
- data/spec/unit/mutant/subject_spec.rb +1 -3
- data/spec/unit/mutant/test_spec.rb +1 -3
- data/spec/unit/mutant/warning_expectation.rb +1 -3
- data/spec/unit/mutant/warning_filter_spec.rb +1 -3
- data/spec/unit/mutant_spec.rb +13 -3
- data/test_app/Gemfile.devtools +2 -2
- data/test_app/spec/unit/test_app/literal/string_spec.rb +1 -1
- metadata +10 -21
- data/lib/mutant/matcher/method/finder.rb +0 -72
- data/lib/mutant/reporter/cli/progress.rb +0 -10
- data/lib/mutant/reporter/cli/progress/config.rb +0 -30
- data/lib/mutant/reporter/cli/progress/env.rb +0 -30
- data/lib/mutant/reporter/cli/progress/noop.rb +0 -27
- data/lib/mutant/reporter/cli/progress/result.rb +0 -12
- data/lib/mutant/reporter/cli/progress/result/mutation.rb +0 -45
- data/lib/mutant/reporter/cli/progress/result/subject.rb +0 -54
- data/lib/mutant/reporter/cli/progress/subject.rb +0 -27
- data/lib/mutant/reporter/cli/registry.rb +0 -81
- data/lib/mutant/reporter/cli/report.rb +0 -10
- data/lib/mutant/reporter/cli/report/env.rb +0 -92
- data/lib/mutant/reporter/cli/report/mutation.rb +0 -103
- data/lib/mutant/reporter/cli/report/subject.rb +0 -32
- data/lib/mutant/reporter/cli/report/test.rb +0 -28
- data/lib/mutant/walker.rb +0 -53
- data/spec/shared/mutator_behavior.rb +0 -55
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
module Mutant
|
|
2
|
-
class Reporter
|
|
3
|
-
class CLI
|
|
4
|
-
class Report
|
|
5
|
-
|
|
6
|
-
# Reporter for mutations
|
|
7
|
-
class Mutation < self
|
|
8
|
-
|
|
9
|
-
handle Mutant::Result::Mutation
|
|
10
|
-
|
|
11
|
-
delegate :mutation, :failed_test_results
|
|
12
|
-
|
|
13
|
-
DIFF_ERROR_MESSAGE = 'BUG: Mutation NOT resulted in exactly one diff. Please report a reproduction!'.freeze
|
|
14
|
-
|
|
15
|
-
MAP = {
|
|
16
|
-
Mutant::Mutation::Evil => :evil_details,
|
|
17
|
-
Mutant::Mutation::Neutral => :neutral_details,
|
|
18
|
-
Mutant::Mutation::Noop => :noop_details
|
|
19
|
-
}.freeze
|
|
20
|
-
|
|
21
|
-
NEUTRAL_MESSAGE =
|
|
22
|
-
"--- Neutral failure ---\n" \
|
|
23
|
-
"Original code was inserted unmutated. And the test did NOT PASS.\n" \
|
|
24
|
-
"Your tests do not pass initially or you found a bug in mutant / unparser.\n" \
|
|
25
|
-
"Subject AST:\n" \
|
|
26
|
-
"%s\n" \
|
|
27
|
-
"Unparsed Source:\n" \
|
|
28
|
-
"%s\n" \
|
|
29
|
-
"Test Reports: %d\n"
|
|
30
|
-
|
|
31
|
-
NOOP_MESSAGE =
|
|
32
|
-
"---- Noop failure -----\n" \
|
|
33
|
-
"No code was inserted. And the test did NOT PASS.\n" \
|
|
34
|
-
"This is typically a problem of your specs not passing unmutated.\n" \
|
|
35
|
-
"Test Reports: %d\n"
|
|
36
|
-
|
|
37
|
-
FOOTER = '-----------------------'.freeze
|
|
38
|
-
|
|
39
|
-
# Run report printer
|
|
40
|
-
#
|
|
41
|
-
# @return [self]
|
|
42
|
-
#
|
|
43
|
-
# @api private
|
|
44
|
-
#
|
|
45
|
-
def run
|
|
46
|
-
puts(mutation.identification)
|
|
47
|
-
print_details
|
|
48
|
-
puts(FOOTER)
|
|
49
|
-
self
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
private
|
|
53
|
-
|
|
54
|
-
# Return details
|
|
55
|
-
#
|
|
56
|
-
# @return [undefined]
|
|
57
|
-
#
|
|
58
|
-
# @api private
|
|
59
|
-
#
|
|
60
|
-
def print_details
|
|
61
|
-
send(MAP.fetch(mutation.class))
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
# Return evil details
|
|
65
|
-
#
|
|
66
|
-
# @return [String]
|
|
67
|
-
#
|
|
68
|
-
# @api private
|
|
69
|
-
#
|
|
70
|
-
def evil_details
|
|
71
|
-
original, current = mutation.original_source, mutation.source
|
|
72
|
-
diff = Mutant::Diff.build(original, current)
|
|
73
|
-
diff = color? ? diff.colorized_diff : diff.diff
|
|
74
|
-
puts(diff || DIFF_ERROR_MESSAGE)
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
# Noop details
|
|
78
|
-
#
|
|
79
|
-
# @return [String]
|
|
80
|
-
#
|
|
81
|
-
# @api private
|
|
82
|
-
#
|
|
83
|
-
def noop_details
|
|
84
|
-
info(NOOP_MESSAGE, failed_test_results.length)
|
|
85
|
-
visit_collection(failed_test_results)
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
# Neutral details
|
|
89
|
-
#
|
|
90
|
-
# @return [String]
|
|
91
|
-
#
|
|
92
|
-
# @api private
|
|
93
|
-
#
|
|
94
|
-
def neutral_details
|
|
95
|
-
info(NEUTRAL_MESSAGE, mutation.subject.node.inspect, mutation.source, failed_test_results.length)
|
|
96
|
-
visit_collection(failed_test_results)
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
end # Mutation
|
|
100
|
-
end # Report
|
|
101
|
-
end # CLI
|
|
102
|
-
end # Reporter
|
|
103
|
-
end # Mutant
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
module Mutant
|
|
2
|
-
class Reporter
|
|
3
|
-
class CLI
|
|
4
|
-
class Report
|
|
5
|
-
|
|
6
|
-
# Subject report printer
|
|
7
|
-
class Subject < self
|
|
8
|
-
|
|
9
|
-
delegate :subject, :failed_mutations
|
|
10
|
-
|
|
11
|
-
handle(Mutant::Result::Subject)
|
|
12
|
-
|
|
13
|
-
# Run report printer
|
|
14
|
-
#
|
|
15
|
-
# @return [self]
|
|
16
|
-
#
|
|
17
|
-
# @api private
|
|
18
|
-
#
|
|
19
|
-
def run
|
|
20
|
-
status(subject.identification)
|
|
21
|
-
subject.tests.each do |test|
|
|
22
|
-
puts("- #{test.identification}")
|
|
23
|
-
end
|
|
24
|
-
visit_collection(object.alive_mutation_results)
|
|
25
|
-
self
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
end # Subject
|
|
29
|
-
end # Report
|
|
30
|
-
end # CLI
|
|
31
|
-
end # Reporter
|
|
32
|
-
end # Mutant
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
module Mutant
|
|
2
|
-
class Reporter
|
|
3
|
-
class CLI
|
|
4
|
-
class Report
|
|
5
|
-
# Test result reporter
|
|
6
|
-
class Test < self
|
|
7
|
-
|
|
8
|
-
handle(Mutant::Result::Test)
|
|
9
|
-
|
|
10
|
-
delegate :test, :runtime
|
|
11
|
-
|
|
12
|
-
# Run test result reporter
|
|
13
|
-
#
|
|
14
|
-
# @return [self]
|
|
15
|
-
#
|
|
16
|
-
# @api private
|
|
17
|
-
#
|
|
18
|
-
def run
|
|
19
|
-
status('- %s / runtime: %s', test.identification, object.runtime)
|
|
20
|
-
puts('Test Output:')
|
|
21
|
-
puts(object.output)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
end
|
|
25
|
-
end # Report
|
|
26
|
-
end # CLI
|
|
27
|
-
end # Reporter
|
|
28
|
-
end # Mutant
|
data/lib/mutant/walker.rb
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
|
|
3
|
-
module Mutant
|
|
4
|
-
|
|
5
|
-
# Walker for all ast nodes
|
|
6
|
-
class Walker
|
|
7
|
-
|
|
8
|
-
# Run walkter
|
|
9
|
-
#
|
|
10
|
-
# @param [Parser::AST::Node] root
|
|
11
|
-
#
|
|
12
|
-
# @return [self]
|
|
13
|
-
#
|
|
14
|
-
# @api private
|
|
15
|
-
#
|
|
16
|
-
def self.run(root, &block)
|
|
17
|
-
new(root, block)
|
|
18
|
-
self
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
private_class_method :new
|
|
22
|
-
|
|
23
|
-
# Initialize and run walker
|
|
24
|
-
#
|
|
25
|
-
# @param [Parser::AST::Node] root
|
|
26
|
-
# @param [#call(node)] block
|
|
27
|
-
#
|
|
28
|
-
# @return [undefined]
|
|
29
|
-
#
|
|
30
|
-
# @api private
|
|
31
|
-
#
|
|
32
|
-
def initialize(root, block)
|
|
33
|
-
@root, @block = root, block
|
|
34
|
-
dispatch(root)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
private
|
|
38
|
-
|
|
39
|
-
# Perform dispatch
|
|
40
|
-
#
|
|
41
|
-
# @param [Parser::AST::Node] node
|
|
42
|
-
#
|
|
43
|
-
# @return [undefined]
|
|
44
|
-
#
|
|
45
|
-
# @api private
|
|
46
|
-
#
|
|
47
|
-
def dispatch(node)
|
|
48
|
-
@block.call(node)
|
|
49
|
-
node.children.grep(Parser::AST::Node).each(&method(:dispatch))
|
|
50
|
-
end
|
|
51
|
-
end # Walker
|
|
52
|
-
|
|
53
|
-
end # Mutant
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
|
|
3
|
-
shared_examples_for 'a mutator' do
|
|
4
|
-
subject { object.each(node, &yields.method(:<<)) }
|
|
5
|
-
|
|
6
|
-
let(:yields) { [] }
|
|
7
|
-
let(:object) { described_class }
|
|
8
|
-
|
|
9
|
-
unless instance_methods.include?(:node)
|
|
10
|
-
let(:node) { parse(source) }
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it_should_behave_like 'a command method'
|
|
14
|
-
|
|
15
|
-
context 'with no block' do
|
|
16
|
-
subject { object.each(node) }
|
|
17
|
-
|
|
18
|
-
it { should be_instance_of(to_enum.class) }
|
|
19
|
-
|
|
20
|
-
def coerce(input)
|
|
21
|
-
case input
|
|
22
|
-
when String
|
|
23
|
-
Parser::CurrentRuby.parse(input)
|
|
24
|
-
when Parser::AST::Node
|
|
25
|
-
input
|
|
26
|
-
else
|
|
27
|
-
raise
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def normalize(node)
|
|
32
|
-
Unparser::Preprocessor.run(node)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
let(:expected_mutations) do
|
|
36
|
-
mutations.map(&method(:coerce)).map(&method(:normalize))
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it 'generates the expected mutations' do
|
|
40
|
-
generated_mutations = subject.map(&method(:normalize))
|
|
41
|
-
|
|
42
|
-
verifier = MutationVerifier.new(node, expected_mutations, generated_mutations)
|
|
43
|
-
|
|
44
|
-
unless verifier.success?
|
|
45
|
-
fail verifier.error_report
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
shared_examples_for 'a noop mutator' do
|
|
52
|
-
let(:mutations) { [] }
|
|
53
|
-
|
|
54
|
-
it_should_behave_like 'a mutator'
|
|
55
|
-
end
|