mutant 0.3.0.beta4 → 0.3.0.beta5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/README.md +4 -4
- data/TODO +0 -9
- data/bin/mutant +2 -2
- data/bin/zombie +2 -2
- data/config/flay.yml +1 -1
- data/config/reek.yml +1 -2
- data/lib/mutant.rb +3 -0
- data/lib/mutant/cache.rb +30 -0
- data/lib/mutant/cli.rb +4 -1
- data/lib/mutant/cli/classifier.rb +17 -34
- data/lib/mutant/cli/classifier/method.rb +2 -2
- data/lib/mutant/cli/classifier/namespace.rb +1 -1
- data/lib/mutant/config.rb +1 -1
- data/lib/mutant/constants.rb +2 -0
- data/lib/mutant/differ.rb +3 -3
- data/lib/mutant/loader.rb +1 -1
- data/lib/mutant/matcher.rb +3 -3
- data/lib/mutant/matcher/method.rb +6 -73
- data/lib/mutant/matcher/method/finder.rb +72 -0
- data/lib/mutant/matcher/method/singleton.rb +2 -2
- data/lib/mutant/matcher/methods.rb +2 -2
- data/lib/mutant/matcher/namespace.rb +2 -2
- data/lib/mutant/matcher/scope.rb +2 -2
- data/lib/mutant/mutation.rb +4 -1
- data/lib/mutant/mutator/node.rb +1 -1
- data/lib/mutant/zombifier.rb +255 -0
- data/mutant.gemspec +3 -3
- data/spec/integration/mutant/zombie_spec.rb +3 -3
- data/spec/shared/method_matcher_behavior.rb +3 -4
- data/spec/spec_helper.rb +4 -0
- data/spec/unit/mutant/cli/class_methods/new_spec.rb +6 -6
- data/spec/unit/mutant/cli/classifier/class_methods/build_spec.rb +9 -8
- data/spec/unit/mutant/context/scope/root_spec.rb +3 -3
- data/spec/unit/mutant/killer/rspec/class_methods/new_spec.rb +7 -5
- data/spec/unit/mutant/matcher/method/instance/each_spec.rb +8 -7
- data/spec/unit/mutant/matcher/method/singleton/each_spec.rb +5 -4
- data/spec/unit/mutant/matcher/methods/instance/each_spec.rb +5 -4
- data/spec/unit/mutant/matcher/methods/singleton/each_spec.rb +5 -4
- data/spec/unit/mutant/matcher/namespace/each_spec.rb +5 -3
- data/spec/unit/mutant/strategy/rspec/dm2/lookup/method/instance/spec_files_spec.rb +1 -1
- data/spec/unit/mutant/strategy/rspec/dm2/lookup/method/singleton/spec_files_spec.rb +2 -2
- data/spec/unit/mutant/subject/context_spec.rb +2 -2
- data/spec/unit/mutant/subject/each_spec.rb +1 -1
- data/spec/unit/mutant/subject/node_spec.rb +2 -2
- metadata +9 -8
- data/spec/support/zombie.rb +0 -174
data/spec/support/zombie.rb
DELETED
@@ -1,174 +0,0 @@
|
|
1
|
-
module Zombie
|
2
|
-
# Setup zombie
|
3
|
-
#
|
4
|
-
# @return [self]
|
5
|
-
#
|
6
|
-
# @api private
|
7
|
-
#
|
8
|
-
def self.setup
|
9
|
-
files.each do |path|
|
10
|
-
path = "#{File.expand_path(path, root)}.rb"
|
11
|
-
ast = File.read(path).to_ast
|
12
|
-
zombify(ast, path)
|
13
|
-
end
|
14
|
-
|
15
|
-
self
|
16
|
-
end
|
17
|
-
|
18
|
-
# Return library root directory
|
19
|
-
#
|
20
|
-
# @return [String]
|
21
|
-
#
|
22
|
-
# @api private
|
23
|
-
#
|
24
|
-
def self.root
|
25
|
-
File.expand_path('../../../lib',__FILE__)
|
26
|
-
end
|
27
|
-
private_class_method :root
|
28
|
-
|
29
|
-
class DummySubject
|
30
|
-
|
31
|
-
# Return line
|
32
|
-
#
|
33
|
-
# @return [Fixnum]
|
34
|
-
#
|
35
|
-
# @api private
|
36
|
-
#
|
37
|
-
attr_reader :source_line
|
38
|
-
|
39
|
-
# Return path
|
40
|
-
#
|
41
|
-
# @return [String]
|
42
|
-
#
|
43
|
-
# @api private
|
44
|
-
#
|
45
|
-
attr_reader :source_path
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
# Initialize object
|
50
|
-
#
|
51
|
-
# @param [String] path
|
52
|
-
# @param [Fixnum] line
|
53
|
-
#
|
54
|
-
# @return [undefined]
|
55
|
-
#
|
56
|
-
# @api private
|
57
|
-
#
|
58
|
-
def initialize(path, line)
|
59
|
-
@source_path, @source_line = path, line
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
# Replace Mutant with Zombie namespace
|
64
|
-
#
|
65
|
-
# @param [Rubinius::AST::Node]
|
66
|
-
#
|
67
|
-
# @api private
|
68
|
-
#
|
69
|
-
# @return [undefined]
|
70
|
-
#
|
71
|
-
def self.zombify(root, path)
|
72
|
-
node = find_mutant(root)
|
73
|
-
unless node
|
74
|
-
raise "unable to find mutant in AST from: #{path.inspect}"
|
75
|
-
end
|
76
|
-
|
77
|
-
name = node.name
|
78
|
-
|
79
|
-
node.name = Rubinius::AST::ModuleName.new(name.line, :Zombie)
|
80
|
-
|
81
|
-
scope = node.body
|
82
|
-
|
83
|
-
unless scope.kind_of?(Rubinius::AST::EmptyBody)
|
84
|
-
node.body = Rubinius::AST::ModuleScope.new(scope.line, node.name, scope.body)
|
85
|
-
end
|
86
|
-
|
87
|
-
::Mutant::Loader::Eval.run(root, DummySubject.new(path, 1))
|
88
|
-
end
|
89
|
-
private_class_method :zombify
|
90
|
-
|
91
|
-
# Find mutant module in AST
|
92
|
-
#
|
93
|
-
# @param [Rubinius::AST::Node]
|
94
|
-
#
|
95
|
-
# @return [Rubinius::AST::Node]
|
96
|
-
#
|
97
|
-
def self.find_mutant(root)
|
98
|
-
if is_mutant?(root)
|
99
|
-
return root
|
100
|
-
end
|
101
|
-
|
102
|
-
unless root.kind_of?(Rubinius::AST::Block)
|
103
|
-
raise "Cannot find mutant in: #{root.class}"
|
104
|
-
end
|
105
|
-
|
106
|
-
root.array.each do |node|
|
107
|
-
return node if is_mutant?(node)
|
108
|
-
end
|
109
|
-
|
110
|
-
nil
|
111
|
-
end
|
112
|
-
private_class_method :find_mutant
|
113
|
-
|
114
|
-
# Test if node is mutant module
|
115
|
-
#
|
116
|
-
# @param [Rubinius::AST::Node]
|
117
|
-
#
|
118
|
-
# @return [true]
|
119
|
-
# returns true if node is the mutant module
|
120
|
-
#
|
121
|
-
# @return [false]
|
122
|
-
# returns false otherwise
|
123
|
-
#
|
124
|
-
# @api private
|
125
|
-
#
|
126
|
-
def self.is_mutant?(node)
|
127
|
-
node.kind_of?(Rubinius::AST::Module) && is_mutant_name?(node.name)
|
128
|
-
end
|
129
|
-
private_class_method :is_mutant?
|
130
|
-
|
131
|
-
# Test if node is mutant module name
|
132
|
-
#
|
133
|
-
# @param [Rubinius::AST::ModuleName]
|
134
|
-
#
|
135
|
-
# @return [true]
|
136
|
-
# returns true if node is the mutant module name
|
137
|
-
#
|
138
|
-
# @return [false]
|
139
|
-
# returns false otherwise
|
140
|
-
#
|
141
|
-
# @api private
|
142
|
-
#
|
143
|
-
def self.is_mutant_name?(node)
|
144
|
-
node.name == :Mutant
|
145
|
-
end
|
146
|
-
private_class_method :is_mutant_name?
|
147
|
-
|
148
|
-
# Return all library files the mutant is made of.
|
149
|
-
#
|
150
|
-
# @return [Array<String>]
|
151
|
-
#
|
152
|
-
# @api private
|
153
|
-
#
|
154
|
-
# FIXME:
|
155
|
-
# Yeah looks very ugly but im currently to exited to do a cleanup.
|
156
|
-
#
|
157
|
-
def self.files
|
158
|
-
block = File.read('lib/mutant.rb').to_ast
|
159
|
-
files = block.array.select do |node|
|
160
|
-
node.class == Rubinius::AST::SendWithArguments &&
|
161
|
-
node.receiver.class == Rubinius::AST::Self &&
|
162
|
-
node.name == :require
|
163
|
-
end.map do |node|
|
164
|
-
arguments = node.arguments.array
|
165
|
-
raise unless arguments.one?
|
166
|
-
argument = arguments.first
|
167
|
-
raise unless argument.class == Rubinius::AST::StringLiteral
|
168
|
-
argument.string
|
169
|
-
end.select do |file|
|
170
|
-
file =~ /\Amutant/
|
171
|
-
end
|
172
|
-
end
|
173
|
-
private_class_method :files
|
174
|
-
end
|