mutant 0.8.8 → 0.8.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +9 -0
- data/README.md +1 -1
- data/Rakefile +12 -8
- data/bin/mutant +5 -1
- data/config/flay.yml +1 -1
- data/lib/mutant.rb +18 -17
- data/lib/mutant/actor.rb +1 -7
- data/lib/mutant/actor/env.rb +0 -4
- data/lib/mutant/actor/mailbox.rb +0 -4
- data/lib/mutant/actor/receiver.rb +0 -4
- data/lib/mutant/actor/sender.rb +0 -2
- data/lib/mutant/ast.rb +1 -5
- data/lib/mutant/ast/meta/const.rb +0 -2
- data/lib/mutant/ast/meta/optarg.rb +0 -2
- data/lib/mutant/ast/meta/send.rb +0 -12
- data/lib/mutant/ast/named_children.rb +0 -10
- data/lib/mutant/ast/sexp.rb +1 -5
- data/lib/mutant/cli.rb +19 -38
- data/lib/mutant/color.rb +1 -7
- data/lib/mutant/config.rb +11 -7
- data/lib/mutant/context.rb +0 -4
- data/lib/mutant/context/scope.rb +0 -18
- data/lib/mutant/delegator.rb +0 -6
- data/lib/mutant/diff.rb +0 -18
- data/lib/mutant/env.rb +8 -24
- data/lib/mutant/env/bootstrap.rb +18 -41
- data/lib/mutant/expression.rb +0 -8
- data/lib/mutant/expression/method.rb +6 -7
- data/lib/mutant/expression/methods.rb +5 -9
- data/lib/mutant/expression/namespace.rb +0 -13
- data/lib/mutant/expression/parser.rb +0 -6
- data/lib/mutant/integration.rb +2 -20
- data/lib/mutant/isolation.rb +0 -4
- data/lib/mutant/loader.rb +20 -35
- data/lib/mutant/matcher.rb +1 -1
- data/lib/mutant/matcher/chain.rb +1 -3
- data/lib/mutant/matcher/compiler.rb +0 -8
- data/lib/mutant/matcher/config.rb +2 -10
- data/lib/mutant/matcher/filter.rb +1 -3
- data/lib/mutant/matcher/method.rb +4 -26
- data/lib/mutant/matcher/method/instance.rb +1 -7
- data/lib/mutant/matcher/method/singleton.rb +0 -12
- data/lib/mutant/matcher/methods.rb +1 -19
- data/lib/mutant/matcher/namespace.rb +1 -7
- data/lib/mutant/matcher/null.rb +1 -3
- data/lib/mutant/matcher/scope.rb +1 -5
- data/lib/mutant/matcher/static.rb +0 -2
- data/lib/mutant/meta.rb +0 -2
- data/lib/mutant/meta/example.rb +0 -28
- data/lib/mutant/meta/example/dsl.rb +2 -16
- data/lib/mutant/mutation.rb +9 -18
- data/lib/mutant/mutator.rb +0 -24
- data/lib/mutant/mutator/node.rb +1 -33
- data/lib/mutant/mutator/node/and_asgn.rb +0 -2
- data/lib/mutant/mutator/node/argument.rb +0 -10
- data/lib/mutant/mutator/node/arguments.rb +0 -12
- data/lib/mutant/mutator/node/begin.rb +0 -4
- data/lib/mutant/mutator/node/binary.rb +2 -11
- data/lib/mutant/mutator/node/block.rb +0 -6
- data/lib/mutant/mutator/node/break.rb +0 -2
- data/lib/mutant/mutator/node/case.rb +0 -6
- data/lib/mutant/mutator/node/conditional_loop.rb +0 -2
- data/lib/mutant/mutator/node/const.rb +1 -3
- data/lib/mutant/mutator/node/define.rb +4 -11
- data/lib/mutant/mutator/node/defined.rb +0 -2
- data/lib/mutant/mutator/node/dstr.rb +0 -2
- data/lib/mutant/mutator/node/dsym.rb +0 -2
- data/lib/mutant/mutator/node/generic.rb +1 -3
- data/lib/mutant/mutator/node/if.rb +0 -8
- data/lib/mutant/mutator/node/kwbegin.rb +0 -2
- data/lib/mutant/mutator/node/literal/array.rb +0 -4
- data/lib/mutant/mutator/node/literal/boolean.rb +0 -2
- data/lib/mutant/mutator/node/literal/fixnum.rb +0 -6
- data/lib/mutant/mutator/node/literal/float.rb +0 -6
- data/lib/mutant/mutator/node/literal/hash.rb +0 -6
- data/lib/mutant/mutator/node/literal/nil.rb +0 -2
- data/lib/mutant/mutator/node/literal/range.rb +0 -8
- data/lib/mutant/mutator/node/literal/regex.rb +0 -4
- data/lib/mutant/mutator/node/literal/string.rb +0 -2
- data/lib/mutant/mutator/node/literal/symbol.rb +0 -2
- data/lib/mutant/mutator/node/masgn.rb +0 -2
- data/lib/mutant/mutator/node/match_current_line.rb +0 -2
- data/lib/mutant/mutator/node/mlhs.rb +0 -2
- data/lib/mutant/mutator/node/named_value/access.rb +0 -8
- data/lib/mutant/mutator/node/named_value/constant_assignment.rb +1 -7
- data/lib/mutant/mutator/node/named_value/variable_assignment.rb +0 -4
- data/lib/mutant/mutator/node/next.rb +0 -2
- data/lib/mutant/mutator/node/noop.rb +0 -2
- data/lib/mutant/mutator/node/nthref.rb +0 -2
- data/lib/mutant/mutator/node/op_asgn.rb +0 -2
- data/lib/mutant/mutator/node/or_asgn.rb +0 -2
- data/lib/mutant/mutator/node/resbody.rb +0 -4
- data/lib/mutant/mutator/node/rescue.rb +0 -10
- data/lib/mutant/mutator/node/return.rb +0 -2
- data/lib/mutant/mutator/node/send.rb +4 -32
- data/lib/mutant/mutator/node/send/attribute_assignment.rb +0 -6
- data/lib/mutant/mutator/node/send/binary.rb +0 -6
- data/lib/mutant/mutator/node/send/index.rb +0 -6
- data/lib/mutant/mutator/node/splat.rb +0 -2
- data/lib/mutant/mutator/node/super.rb +0 -2
- data/lib/mutant/mutator/node/when.rb +0 -10
- data/lib/mutant/mutator/node/yield.rb +0 -2
- data/lib/mutant/mutator/node/zsuper.rb +0 -2
- data/lib/mutant/mutator/registry.rb +0 -6
- data/lib/mutant/mutator/util.rb +0 -4
- data/lib/mutant/mutator/util/array.rb +0 -6
- data/lib/mutant/mutator/util/symbol.rb +0 -2
- data/lib/mutant/parallel.rb +21 -17
- data/lib/mutant/parallel/master.rb +0 -28
- data/lib/mutant/parallel/source.rb +0 -10
- data/lib/mutant/parallel/worker.rb +15 -10
- data/lib/mutant/parser.rb +23 -0
- data/lib/mutant/reporter.rb +5 -8
- data/lib/mutant/reporter/cli.rb +1 -15
- data/lib/mutant/reporter/cli/format.rb +3 -25
- data/lib/mutant/reporter/cli/printer.rb +0 -18
- data/lib/mutant/reporter/cli/printer/config.rb +0 -2
- data/lib/mutant/reporter/cli/printer/env_progress.rb +0 -2
- data/lib/mutant/reporter/cli/printer/env_result.rb +0 -2
- data/lib/mutant/reporter/cli/printer/mutation_progress_result.rb +0 -4
- data/lib/mutant/reporter/cli/printer/mutation_result.rb +0 -16
- data/lib/mutant/reporter/cli/printer/status.rb +0 -6
- data/lib/mutant/reporter/cli/printer/status_progressive.rb +0 -4
- data/lib/mutant/reporter/cli/printer/subject_progress.rb +0 -8
- data/lib/mutant/reporter/cli/printer/subject_result.rb +0 -2
- data/lib/mutant/reporter/cli/printer/test_result.rb +0 -2
- data/lib/mutant/reporter/cli/tput.rb +0 -4
- data/lib/mutant/repository.rb +4 -22
- data/lib/mutant/require_highjack.rb +0 -2
- data/lib/mutant/result.rb +23 -43
- data/lib/mutant/runner.rb +7 -20
- data/lib/mutant/runner/sink.rb +43 -86
- data/lib/mutant/selector.rb +0 -2
- data/lib/mutant/selector/expression.rb +0 -2
- data/lib/mutant/subject.rb +0 -22
- data/lib/mutant/subject/method.rb +2 -10
- data/lib/mutant/subject/method/instance.rb +0 -6
- data/lib/mutant/subject/method/singleton.rb +0 -2
- data/lib/mutant/test.rb +4 -3
- data/lib/mutant/version.rb +1 -1
- data/lib/mutant/warning_filter.rb +0 -10
- data/lib/mutant/zombifier.rb +5 -20
- data/meta/or_asgn.rb +6 -0
- data/meta/send.rb +29 -0
- data/mutant-rspec.gemspec +1 -1
- data/spec/integration/mutant/rspec_spec.rb +1 -1
- data/spec/integrations.yml +2 -3
- data/spec/shared/method_matcher_behavior.rb +7 -7
- data/spec/spec_helper.rb +2 -9
- data/spec/support/corpus.rb +37 -30
- data/spec/support/rb_bug.rb +1 -2
- data/spec/support/ruby_vm.rb +6 -3
- data/spec/support/shared_context.rb +19 -20
- data/spec/unit/mutant/actor/binding_spec.rb +6 -6
- data/spec/unit/mutant/actor/env_spec.rb +2 -2
- data/spec/unit/mutant/actor/mailbox_spec.rb +6 -6
- data/spec/unit/mutant/actor/message_spec.rb +2 -2
- data/spec/unit/mutant/actor/receiver_spec.rb +4 -4
- data/spec/unit/mutant/actor/sender_spec.rb +6 -6
- data/spec/unit/mutant/ast_spec.rb +9 -0
- data/spec/unit/mutant/cli_spec.rb +16 -10
- data/spec/unit/mutant/context/scope/root_spec.rb +1 -1
- data/spec/unit/mutant/context/scope/unqualified_name_spec.rb +1 -1
- data/spec/unit/mutant/context/scope_spec.rb +3 -3
- data/spec/unit/mutant/context_spec.rb +0 -22
- data/spec/unit/mutant/env/boostrap_spec.rb +34 -41
- data/spec/unit/mutant/env_spec.rb +74 -32
- data/spec/unit/mutant/integration/rspec_spec.rb +23 -17
- data/spec/unit/mutant/integration_spec.rb +4 -4
- data/spec/unit/mutant/isolation_spec.rb +4 -4
- data/spec/unit/mutant/loader_spec.rb +42 -0
- data/spec/unit/mutant/matcher/compiler_spec.rb +3 -3
- data/spec/unit/mutant/matcher/config_spec.rb +1 -1
- data/spec/unit/mutant/matcher/method/instance_spec.rb +8 -1
- data/spec/unit/mutant/matcher/method/singleton_spec.rb +8 -1
- data/spec/unit/mutant/matcher/namespace_spec.rb +7 -8
- data/spec/unit/mutant/matcher/null_spec.rb +3 -2
- data/spec/unit/mutant/mutation_spec.rb +11 -5
- data/spec/unit/mutant/mutator/registry_spec.rb +1 -1
- data/spec/unit/mutant/parallel/master_spec.rb +9 -9
- data/spec/unit/mutant/parallel/source/array_spec.rb +3 -3
- data/spec/unit/mutant/parallel/worker_spec.rb +5 -5
- data/spec/unit/mutant/parallel_spec.rb +4 -4
- data/spec/unit/mutant/parser_spec.rb +24 -0
- data/spec/unit/mutant/reporter/cli/printer_spec.rb +3 -3
- data/spec/unit/mutant/reporter/cli/tput_spec.rb +2 -2
- data/spec/unit/mutant/reporter/cli_spec.rb +7 -7
- data/spec/unit/mutant/reporter/null_spec.rb +5 -4
- data/spec/unit/mutant/repository/diff_spec.rb +30 -18
- data/spec/unit/mutant/repository/subject_filter_spec.rb +5 -5
- data/spec/unit/mutant/require_highjack_spec.rb +1 -1
- data/spec/unit/mutant/result/env_spec.rb +9 -9
- data/spec/unit/mutant/result/subject_spec.rb +5 -5
- data/spec/unit/mutant/runner/driver_spec.rb +4 -4
- data/spec/unit/mutant/runner/{sink/mutation_spec.rb → sink_spec.rb} +16 -4
- data/spec/unit/mutant/runner_spec.rb +31 -31
- data/spec/unit/mutant/selector/expression_spec.rb +8 -8
- data/spec/unit/mutant/subject/method/instance_spec.rb +9 -3
- data/spec/unit/mutant/subject/method/singleton_spec.rb +1 -1
- data/spec/unit/mutant/subject_spec.rb +1 -5
- data/spec/unit/mutant_spec.rb +3 -3
- metadata +9 -15
- data/config/mutant.yml +0 -14
- data/lib/mutant/cache.rb +0 -29
- data/lib/mutant/reporter/trace.rb +0 -36
- data/spec/support/rspec.rb +0 -21
- data/spec/unit/mutant/cache_spec.rb +0 -22
- data/spec/unit/mutant/loader/eval_spec.rb +0 -44
- data/spec/unit/mutant/reporter/trace_spec.rb +0 -21
- data/test_app/Gemfile.rspec3.2 +0 -7
data/lib/mutant/runner/sink.rb
CHANGED
@@ -1,107 +1,64 @@
|
|
1
1
|
module Mutant
|
2
2
|
class Runner
|
3
|
-
# Abstract base class for computation sinks
|
4
3
|
class Sink
|
5
|
-
include
|
4
|
+
include Concord.new(:env)
|
6
5
|
|
7
|
-
#
|
6
|
+
# Initialize object
|
8
7
|
#
|
9
|
-
# @return [
|
8
|
+
# @return [undefined]
|
9
|
+
def initialize(*)
|
10
|
+
super
|
11
|
+
@start = Time.now
|
12
|
+
@subject_results = {}
|
13
|
+
end
|
14
|
+
|
15
|
+
# Runner status
|
10
16
|
#
|
11
|
-
# @
|
12
|
-
|
17
|
+
# @return [Result::Env]
|
18
|
+
def status
|
19
|
+
Result::Env.new(
|
20
|
+
env: env,
|
21
|
+
runtime: Time.now - @start,
|
22
|
+
subject_results: @subject_results.values
|
23
|
+
)
|
24
|
+
end
|
13
25
|
|
14
|
-
# Test if
|
26
|
+
# Test if scheduling stopped
|
15
27
|
#
|
16
28
|
# @return [Boolean]
|
17
|
-
|
18
|
-
|
19
|
-
|
29
|
+
def stop?
|
30
|
+
env.config.fail_fast && !status.subject_results.all?(&:success?)
|
31
|
+
end
|
20
32
|
|
21
|
-
#
|
33
|
+
# Handle mutation finish
|
22
34
|
#
|
23
|
-
# @param [
|
35
|
+
# @param [Result::Mutation] mutation_result
|
24
36
|
#
|
25
37
|
# @return [self]
|
26
|
-
|
27
|
-
|
28
|
-
abstract_method :result
|
29
|
-
|
30
|
-
# Mutation result sink
|
31
|
-
class Mutation < self
|
32
|
-
include Concord.new(:env)
|
33
|
-
|
34
|
-
# Initialize object
|
35
|
-
#
|
36
|
-
# @return [undefined]
|
37
|
-
#
|
38
|
-
# @api private
|
39
|
-
def initialize(*)
|
40
|
-
super
|
41
|
-
@start = Time.now
|
42
|
-
@subject_results = Hash.new do |_hash, subject|
|
43
|
-
Result::Subject.new(
|
44
|
-
subject: subject,
|
45
|
-
tests: [],
|
46
|
-
mutation_results: []
|
47
|
-
)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
# Runner status
|
52
|
-
#
|
53
|
-
# @return [Status]
|
54
|
-
#
|
55
|
-
# @api private
|
56
|
-
def status
|
57
|
-
env_result
|
58
|
-
end
|
38
|
+
def result(mutation_result)
|
39
|
+
subject = mutation_result.mutation.subject
|
59
40
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
def stop?
|
66
|
-
env.config.fail_fast && !env_result.subject_results.all?(&:success?)
|
67
|
-
end
|
41
|
+
@subject_results[subject] = Result::Subject.new(
|
42
|
+
subject: subject,
|
43
|
+
mutation_results: previous_mutation_results(subject) + [mutation_result],
|
44
|
+
tests: mutation_result.test_result.tests
|
45
|
+
)
|
68
46
|
|
69
|
-
|
70
|
-
|
71
|
-
# @param [Result::Mutation] mutation_result
|
72
|
-
#
|
73
|
-
# @return [self]
|
74
|
-
#
|
75
|
-
# @api private
|
76
|
-
def result(mutation_result)
|
77
|
-
mutation = mutation_result.mutation
|
47
|
+
self
|
48
|
+
end
|
78
49
|
|
79
|
-
|
50
|
+
private
|
80
51
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
# Current result
|
92
|
-
#
|
93
|
-
# @return [Result::Env]
|
94
|
-
#
|
95
|
-
# @api private
|
96
|
-
def env_result
|
97
|
-
Result::Env.new(
|
98
|
-
env: env,
|
99
|
-
runtime: Time.now - @start,
|
100
|
-
subject_results: @subject_results.values
|
101
|
-
)
|
102
|
-
end
|
52
|
+
# Return previous results
|
53
|
+
#
|
54
|
+
# @param [Subject]
|
55
|
+
#
|
56
|
+
# @return [Array<Result::Mutation>]
|
57
|
+
def previous_mutation_results(subject)
|
58
|
+
subject_result = @subject_results.fetch(subject) { return EMPTY_ARRAY }
|
59
|
+
subject_result.mutation_results
|
60
|
+
end
|
103
61
|
|
104
|
-
end # Mutation
|
105
62
|
end # Sink
|
106
63
|
end # Runner
|
107
64
|
end # Mutant
|
data/lib/mutant/selector.rb
CHANGED
data/lib/mutant/subject.rb
CHANGED
@@ -8,8 +8,6 @@ module Mutant
|
|
8
8
|
#
|
9
9
|
# @return [Enumerable<Mutation>]
|
10
10
|
# @return [undefined]
|
11
|
-
#
|
12
|
-
# @api private
|
13
11
|
def mutations
|
14
12
|
mutations = [neutral_mutation]
|
15
13
|
Mutator.each(node) do |mutant|
|
@@ -22,8 +20,6 @@ module Mutant
|
|
22
20
|
# Source path
|
23
21
|
#
|
24
22
|
# @return [Pathname]
|
25
|
-
#
|
26
|
-
# @api private
|
27
23
|
def source_path
|
28
24
|
context.source_path
|
29
25
|
end
|
@@ -31,8 +27,6 @@ module Mutant
|
|
31
27
|
# Prepare subject for insertion of mutation
|
32
28
|
#
|
33
29
|
# @return [self]
|
34
|
-
#
|
35
|
-
# @api private
|
36
30
|
def prepare
|
37
31
|
self
|
38
32
|
end
|
@@ -40,8 +34,6 @@ module Mutant
|
|
40
34
|
# Source line range
|
41
35
|
#
|
42
36
|
# @return [Range<Fixnum>]
|
43
|
-
#
|
44
|
-
# @api private
|
45
37
|
def source_lines
|
46
38
|
expression = node.location.expression
|
47
39
|
expression.line..expression.source_buffer.decompose_position(expression.end_pos).first
|
@@ -51,8 +43,6 @@ module Mutant
|
|
51
43
|
# First source line
|
52
44
|
#
|
53
45
|
# @return [Fixnum]
|
54
|
-
#
|
55
|
-
# @api private
|
56
46
|
def source_line
|
57
47
|
source_lines.begin
|
58
48
|
end
|
@@ -60,8 +50,6 @@ module Mutant
|
|
60
50
|
# Identification string
|
61
51
|
#
|
62
52
|
# @return [String]
|
63
|
-
#
|
64
|
-
# @api private
|
65
53
|
def identification
|
66
54
|
"#{expression.syntax}:#{source_path}:#{source_line}"
|
67
55
|
end
|
@@ -70,8 +58,6 @@ module Mutant
|
|
70
58
|
# Source representation of AST
|
71
59
|
#
|
72
60
|
# @return [String]
|
73
|
-
#
|
74
|
-
# @api private
|
75
61
|
def source
|
76
62
|
Unparser.unparse(wrap_node(node))
|
77
63
|
end
|
@@ -80,15 +66,11 @@ module Mutant
|
|
80
66
|
# Match expression
|
81
67
|
#
|
82
68
|
# @return [Expression]
|
83
|
-
#
|
84
|
-
# @api private
|
85
69
|
abstract_method :expression
|
86
70
|
|
87
71
|
# Match expressions
|
88
72
|
#
|
89
73
|
# @return [Enumerable<Expression>]
|
90
|
-
#
|
91
|
-
# @api private
|
92
74
|
abstract_method :match_expressions
|
93
75
|
|
94
76
|
private
|
@@ -96,8 +78,6 @@ module Mutant
|
|
96
78
|
# Neutral mutation
|
97
79
|
#
|
98
80
|
# @return [Mutation::Neutral]
|
99
|
-
#
|
100
|
-
# @api private
|
101
81
|
def neutral_mutation
|
102
82
|
Mutation::Neutral.new(self, wrap_node(node))
|
103
83
|
end
|
@@ -107,8 +87,6 @@ module Mutant
|
|
107
87
|
# @param [Parser::AST::Node] node
|
108
88
|
#
|
109
89
|
# @return [Parser::AST::Node]
|
110
|
-
#
|
111
|
-
# @api private
|
112
90
|
def wrap_node(node)
|
113
91
|
node
|
114
92
|
end
|
@@ -6,8 +6,6 @@ module Mutant
|
|
6
6
|
# Method name
|
7
7
|
#
|
8
8
|
# @return [Expression]
|
9
|
-
#
|
10
|
-
# @api private
|
11
9
|
def name
|
12
10
|
node.children.fetch(self.class::NAME_INDEX)
|
13
11
|
end
|
@@ -15,13 +13,11 @@ module Mutant
|
|
15
13
|
# Match expression
|
16
14
|
#
|
17
15
|
# @return [String]
|
18
|
-
#
|
19
|
-
# @api private
|
20
16
|
def expression
|
21
17
|
Expression::Method.new(
|
18
|
+
method_name: name.to_s,
|
22
19
|
scope_symbol: self.class::SYMBOL,
|
23
|
-
scope_name: scope.name
|
24
|
-
method_name: name.to_s
|
20
|
+
scope_name: scope.name
|
25
21
|
)
|
26
22
|
end
|
27
23
|
memoize :expression
|
@@ -29,8 +25,6 @@ module Mutant
|
|
29
25
|
# Match expressions
|
30
26
|
#
|
31
27
|
# @return [Array<Expression>]
|
32
|
-
#
|
33
|
-
# @api private
|
34
28
|
def match_expressions
|
35
29
|
[expression].concat(context.match_expressions)
|
36
30
|
end
|
@@ -41,8 +35,6 @@ module Mutant
|
|
41
35
|
# The scope
|
42
36
|
#
|
43
37
|
# @return [Class, Module]
|
44
|
-
#
|
45
|
-
# @api private
|
46
38
|
def scope
|
47
39
|
context.scope
|
48
40
|
end
|
@@ -10,8 +10,6 @@ module Mutant
|
|
10
10
|
# Prepare subject for mutation insertion
|
11
11
|
#
|
12
12
|
# @return [self]
|
13
|
-
#
|
14
|
-
# @api private
|
15
13
|
def prepare
|
16
14
|
scope.__send__(:undef_method, name)
|
17
15
|
self
|
@@ -24,8 +22,6 @@ module Mutant
|
|
24
22
|
# Prepare subject for mutation insertion
|
25
23
|
#
|
26
24
|
# @return [self]
|
27
|
-
#
|
28
|
-
# @api private
|
29
25
|
def prepare
|
30
26
|
scope.__send__(:memoized_methods).instance_variable_get(:@memory).delete(name)
|
31
27
|
super
|
@@ -39,8 +35,6 @@ module Mutant
|
|
39
35
|
# @param [Parser::AST::Node] mutant
|
40
36
|
#
|
41
37
|
# @return [Parser::AST::Node]
|
42
|
-
#
|
43
|
-
# @api private
|
44
38
|
def wrap_node(mutant)
|
45
39
|
s(:begin, mutant, s(:send, nil, :memoize, s(:args, s(:sym, name))))
|
46
40
|
end
|
data/lib/mutant/test.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
module Mutant
|
2
2
|
# Abstract base class for test that might kill a mutation
|
3
3
|
class Test
|
4
|
-
include Adamantium::Flat, Anima.new(
|
4
|
+
include Adamantium::Flat, Anima.new(
|
5
|
+
:expression,
|
6
|
+
:id
|
7
|
+
)
|
5
8
|
|
6
9
|
# Identification string
|
7
10
|
#
|
8
11
|
# @return [String]
|
9
|
-
#
|
10
|
-
# @api private
|
11
12
|
alias_method :identification, :id
|
12
13
|
|
13
14
|
end # Test
|
data/lib/mutant/version.rb
CHANGED
@@ -10,8 +10,6 @@ module Mutant
|
|
10
10
|
# @param [#write] target
|
11
11
|
#
|
12
12
|
# @return [undefined]
|
13
|
-
#
|
14
|
-
# @api private
|
15
13
|
def initialize(target)
|
16
14
|
@target = target
|
17
15
|
@warnings = []
|
@@ -20,8 +18,6 @@ module Mutant
|
|
20
18
|
# Warnings captured by filter
|
21
19
|
#
|
22
20
|
# @return [Array<String>]
|
23
|
-
#
|
24
|
-
# @api private
|
25
21
|
attr_reader :warnings
|
26
22
|
|
27
23
|
# Target stream to capture warnings on
|
@@ -29,8 +25,6 @@ module Mutant
|
|
29
25
|
# @return [#write] target
|
30
26
|
#
|
31
27
|
# @return [undefined]
|
32
|
-
#
|
33
|
-
# @api private
|
34
28
|
attr_reader :target
|
35
29
|
protected :target
|
36
30
|
|
@@ -39,8 +33,6 @@ module Mutant
|
|
39
33
|
# @param [String] message
|
40
34
|
#
|
41
35
|
# @return [self]
|
42
|
-
#
|
43
|
-
# @api private
|
44
36
|
def write(message)
|
45
37
|
if WARNING_PATTERN =~ message
|
46
38
|
warnings << message
|
@@ -54,8 +46,6 @@ module Mutant
|
|
54
46
|
# Use warning filter during block execution
|
55
47
|
#
|
56
48
|
# @return [Array<String>]
|
57
|
-
#
|
58
|
-
# @api private
|
59
49
|
def self.use
|
60
50
|
original = $stderr
|
61
51
|
$stderr = filter = new(original)
|
data/lib/mutant/zombifier.rb
CHANGED
@@ -3,13 +3,14 @@ module Mutant
|
|
3
3
|
class Zombifier
|
4
4
|
include Anima.new(
|
5
5
|
:includes,
|
6
|
-
:namespace,
|
7
6
|
:load_path,
|
8
7
|
:kernel,
|
8
|
+
:namespace,
|
9
|
+
:pathname,
|
9
10
|
:require_highjack,
|
10
|
-
:root_require
|
11
|
-
:pathname
|
11
|
+
:root_require
|
12
12
|
)
|
13
|
+
|
13
14
|
private(*anima.attribute_names)
|
14
15
|
|
15
16
|
include AST::Sexp
|
@@ -21,8 +22,6 @@ module Mutant
|
|
21
22
|
# @param [Symbol] namespace
|
22
23
|
#
|
23
24
|
# @return [undefined]
|
24
|
-
#
|
25
|
-
# @api private
|
26
25
|
def initialize(*)
|
27
26
|
super
|
28
27
|
@includes = %r{\A#{Regexp.union(includes)}(?:/.*)?\z}
|
@@ -32,8 +31,6 @@ module Mutant
|
|
32
31
|
# Call zombifier
|
33
32
|
#
|
34
33
|
# @return [self]
|
35
|
-
#
|
36
|
-
# @api private
|
37
34
|
def self.call(*args)
|
38
35
|
new(*args).__send__(:call)
|
39
36
|
self
|
@@ -44,8 +41,6 @@ module Mutant
|
|
44
41
|
# Run zombifier
|
45
42
|
#
|
46
43
|
# @return [undefined]
|
47
|
-
#
|
48
|
-
# @api private
|
49
44
|
def call
|
50
45
|
@original = require_highjack.call(method(:require))
|
51
46
|
require(root_require)
|
@@ -54,8 +49,6 @@ module Mutant
|
|
54
49
|
# Test if logical name is subjected to zombification
|
55
50
|
#
|
56
51
|
# @param [String]
|
57
|
-
#
|
58
|
-
# @api private
|
59
52
|
def include?(logical_name)
|
60
53
|
!@zombified.include?(logical_name) && includes =~ logical_name
|
61
54
|
end
|
@@ -65,8 +58,6 @@ module Mutant
|
|
65
58
|
# @param [#to_s] logical_name
|
66
59
|
#
|
67
60
|
# @return [undefined]
|
68
|
-
#
|
69
|
-
# @api private
|
70
61
|
def require(logical_name)
|
71
62
|
logical_name = logical_name.to_s
|
72
63
|
@original.call(logical_name)
|
@@ -83,8 +74,6 @@ module Mutant
|
|
83
74
|
#
|
84
75
|
# @raise [LoadError]
|
85
76
|
# otherwise
|
86
|
-
#
|
87
|
-
# @api private
|
88
77
|
def find(logical_name)
|
89
78
|
file_name = "#{logical_name}.rb"
|
90
79
|
|
@@ -103,8 +92,6 @@ module Mutant
|
|
103
92
|
# @param [Pathname] source_path
|
104
93
|
#
|
105
94
|
# @return [undefined]
|
106
|
-
#
|
107
|
-
# @api private
|
108
95
|
def zombify(source_path)
|
109
96
|
kernel.eval(
|
110
97
|
Unparser.unparse(namespaced_node(source_path)),
|
@@ -118,10 +105,8 @@ module Mutant
|
|
118
105
|
# @param [Pathname] source_path
|
119
106
|
#
|
120
107
|
# @return [Parser::AST::Node]
|
121
|
-
#
|
122
|
-
# @api private
|
123
108
|
def namespaced_node(source_path)
|
124
|
-
s(:module, s(:const, nil, namespace), Parser::CurrentRuby.parse(source_path.read))
|
109
|
+
s(:module, s(:const, nil, namespace), ::Parser::CurrentRuby.parse(source_path.read))
|
125
110
|
end
|
126
111
|
|
127
112
|
end # Zombifier
|