mutant 0.12.2 → 0.12.3
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/lib/mutant/ast/named_children.rb +2 -2
- data/lib/mutant/ast/pattern/lexer.rb +6 -6
- data/lib/mutant/ast/pattern/parser.rb +9 -9
- data/lib/mutant/ast/structure.rb +1 -1
- data/lib/mutant/ast.rb +1 -1
- data/lib/mutant/bootstrap.rb +12 -12
- data/lib/mutant/cli/command/environment/test.rb +2 -2
- data/lib/mutant/cli/command/environment.rb +8 -8
- data/lib/mutant/cli/command/util.rb +2 -2
- data/lib/mutant/cli/command.rb +8 -8
- data/lib/mutant/cli.rb +1 -1
- data/lib/mutant/config.rb +2 -2
- data/lib/mutant/env.rb +10 -10
- data/lib/mutant/expression/descendants.rb +1 -1
- data/lib/mutant/expression/method.rb +2 -2
- data/lib/mutant/expression/methods.rb +2 -2
- data/lib/mutant/expression/source.rb +3 -3
- data/lib/mutant/integration.rb +2 -2
- data/lib/mutant/isolation/fork.rb +4 -4
- data/lib/mutant/isolation/none.rb +2 -2
- data/lib/mutant/matcher/descendants.rb +1 -1
- data/lib/mutant/matcher/method/instance.rb +3 -3
- data/lib/mutant/matcher/method/metaclass.rb +2 -2
- data/lib/mutant/matcher/method/singleton.rb +1 -1
- data/lib/mutant/matcher/method.rb +5 -19
- data/lib/mutant/matcher/methods.rb +2 -2
- data/lib/mutant/matcher/namespace.rb +1 -1
- data/lib/mutant/matcher/scope.rb +1 -1
- data/lib/mutant/matcher.rb +1 -1
- data/lib/mutant/meta/example/verification.rb +1 -1
- data/lib/mutant/meta/example.rb +4 -4
- data/lib/mutant/meta.rb +1 -1
- data/lib/mutant/mutation/runner/sink.rb +3 -3
- data/lib/mutant/mutation/runner.rb +1 -1
- data/lib/mutant/mutation.rb +2 -2
- data/lib/mutant/mutator/node/block.rb +1 -1
- data/lib/mutant/mutator/node/break.rb +1 -1
- data/lib/mutant/mutator/node/index.rb +1 -1
- data/lib/mutant/mutator/node/kwbegin.rb +1 -1
- data/lib/mutant/mutator/node/named_value/access.rb +1 -1
- data/lib/mutant/mutator/node/next.rb +1 -1
- data/lib/mutant/mutator/node/send/conditional.rb +1 -1
- data/lib/mutant/mutator/node/send.rb +1 -1
- data/lib/mutant/mutator/node/yield.rb +1 -1
- data/lib/mutant/mutator/node/zsuper.rb +0 -1
- data/lib/mutant/mutator/node.rb +5 -5
- data/lib/mutant/mutator/regexp.rb +2 -2
- data/lib/mutant/parallel/connection.rb +2 -2
- data/lib/mutant/parallel/pipe.rb +2 -2
- data/lib/mutant/parallel/worker.rb +10 -10
- data/lib/mutant/parallel.rb +3 -3
- data/lib/mutant/parser.rb +1 -1
- data/lib/mutant/registry.rb +1 -1
- data/lib/mutant/reporter/cli/format.rb +1 -1
- data/lib/mutant/reporter/cli/printer/isolation_result.rb +2 -2
- data/lib/mutant/reporter/cli/printer/status_progressive.rb +1 -1
- data/lib/mutant/reporter/cli/printer/test.rb +1 -1
- data/lib/mutant/reporter/cli/printer.rb +1 -1
- data/lib/mutant/reporter/cli.rb +3 -3
- data/lib/mutant/repository/diff.rb +6 -5
- data/lib/mutant/segment/recorder.rb +8 -8
- data/lib/mutant/subject/config.rb +1 -1
- data/lib/mutant/subject/method/instance.rb +1 -1
- data/lib/mutant/subject.rb +1 -1
- data/lib/mutant/test/runner/sink.rb +1 -1
- data/lib/mutant/test/runner.rb +1 -1
- data/lib/mutant/timer.rb +2 -2
- data/lib/mutant/transform.rb +20 -20
- data/lib/mutant/variable.rb +2 -2
- data/lib/mutant/version.rb +1 -1
- data/lib/mutant/world.rb +7 -7
- data/lib/mutant.rb +8 -8
- metadata +6 -6
@@ -25,7 +25,7 @@ module Mutant
|
|
25
25
|
#
|
26
26
|
# @return [Enumerable<Subject>]
|
27
27
|
def call(env)
|
28
|
-
evaluator.call(scope
|
28
|
+
evaluator.call(scope:, target_method:, env:)
|
29
29
|
end
|
30
30
|
|
31
31
|
# Abstract method match evaluator
|
@@ -76,9 +76,9 @@ module Mutant
|
|
76
76
|
def subject
|
77
77
|
self.class::SUBJECT_CLASS.new(
|
78
78
|
config: subject_config(matched_view.node),
|
79
|
-
context
|
79
|
+
context:,
|
80
80
|
node: matched_view.node,
|
81
|
-
visibility:
|
81
|
+
visibility:
|
82
82
|
)
|
83
83
|
end
|
84
84
|
|
@@ -87,7 +87,7 @@ module Mutant
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def context
|
90
|
-
Context.new(constant_scope
|
90
|
+
Context.new(constant_scope:, scope:, source_path:)
|
91
91
|
end
|
92
92
|
|
93
93
|
# rubocop:disable Metrics/MethodLength
|
@@ -101,7 +101,7 @@ module Mutant
|
|
101
101
|
if klass
|
102
102
|
klass.new(
|
103
103
|
const: node.children.fetch(0),
|
104
|
-
descendant:
|
104
|
+
descendant:
|
105
105
|
)
|
106
106
|
else
|
107
107
|
descendant
|
@@ -163,20 +163,6 @@ module Mutant
|
|
163
163
|
end
|
164
164
|
|
165
165
|
def visibility
|
166
|
-
# This can be cleaned up once we are on >ruby-3.0
|
167
|
-
# Method#{public,private,protected}? exists there.
|
168
|
-
#
|
169
|
-
# On Ruby 3.1 this can just be:
|
170
|
-
#
|
171
|
-
# if target_method.private?
|
172
|
-
# :private
|
173
|
-
# elsif target_method.protected?
|
174
|
-
# :protected
|
175
|
-
# else
|
176
|
-
# :public
|
177
|
-
# end
|
178
|
-
#
|
179
|
-
# Change to this once 3.0 is EOL.
|
180
166
|
if scope.raw.private_methods.include?(method_name)
|
181
167
|
:private
|
182
168
|
elsif scope.raw.protected_methods.include?(method_name)
|
@@ -22,7 +22,7 @@ module Mutant
|
|
22
22
|
def call(env)
|
23
23
|
Chain.new(
|
24
24
|
matchers: methods(env).map do |target_method|
|
25
|
-
matcher.new(scope
|
25
|
+
matcher.new(scope:, target_method:)
|
26
26
|
end
|
27
27
|
).call(env)
|
28
28
|
end
|
@@ -110,7 +110,7 @@ module Mutant
|
|
110
110
|
candidate_scope.instance_method(method_name)
|
111
111
|
rescue Exception => exception
|
112
112
|
env.warn(
|
113
|
-
MESSAGE % { scope
|
113
|
+
MESSAGE % { scope:, method_name:, exception: exception.inspect }
|
114
114
|
)
|
115
115
|
nil
|
116
116
|
end
|
data/lib/mutant/matcher/scope.rb
CHANGED
data/lib/mutant/matcher.rb
CHANGED
@@ -22,7 +22,7 @@ module Mutant
|
|
22
22
|
matcher_config = env.config.matcher
|
23
23
|
|
24
24
|
Filter.new(
|
25
|
-
matcher: Chain.new(matchers: matcher_config.subjects.map { |subject| subject.matcher(env:
|
25
|
+
matcher: Chain.new(matchers: matcher_config.subjects.map { |subject| subject.matcher(env:) }),
|
26
26
|
predicate: method(:allowed_subject?).curry.call(matcher_config)
|
27
27
|
)
|
28
28
|
end
|
data/lib/mutant/meta/example.rb
CHANGED
@@ -40,7 +40,7 @@ module Mutant
|
|
40
40
|
def context
|
41
41
|
Context.new(
|
42
42
|
constant_scope: Context::ConstantScope::None.new,
|
43
|
-
scope
|
43
|
+
scope:,
|
44
44
|
source_path: location.path
|
45
45
|
)
|
46
46
|
end
|
@@ -58,10 +58,10 @@ module Mutant
|
|
58
58
|
# @return [Enumerable<Mutant::Mutation>]
|
59
59
|
def generated
|
60
60
|
Mutator::Node.mutate(
|
61
|
-
config: Mutation::Config::DEFAULT.with(operators:
|
62
|
-
node:
|
61
|
+
config: Mutation::Config::DEFAULT.with(operators:),
|
62
|
+
node:
|
63
63
|
).map do |node|
|
64
|
-
Mutation::Evil.new(subject: self, node:
|
64
|
+
Mutation::Evil.new(subject: self, node:)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
memoize :generated
|
data/lib/mutant/meta.rb
CHANGED
@@ -18,7 +18,7 @@ module Mutant
|
|
18
18
|
# @return [undefined]
|
19
19
|
def self.add(*types, operators: :full, &block)
|
20
20
|
ALL << DSL.call(
|
21
|
-
block
|
21
|
+
block:,
|
22
22
|
location: caller_locations(1).first,
|
23
23
|
operators: Mutation::Operators.parse(operators.to_s).from_right,
|
24
24
|
types: Set.new(types)
|
@@ -22,7 +22,7 @@ module Mutant
|
|
22
22
|
# @return [Result::Env]
|
23
23
|
def status
|
24
24
|
Result::Env.new(
|
25
|
-
env
|
25
|
+
env:,
|
26
26
|
runtime: env.world.timer.now - @start,
|
27
27
|
subject_results: @subject_results.values
|
28
28
|
)
|
@@ -48,7 +48,7 @@ module Mutant
|
|
48
48
|
subject = mutation_result.mutation.subject
|
49
49
|
|
50
50
|
@subject_results[subject] = Result::Subject.new(
|
51
|
-
subject
|
51
|
+
subject:,
|
52
52
|
coverage_results: previous_coverage_results(subject).dup << coverage_result(mutation_result),
|
53
53
|
tests: env.selections.fetch(subject)
|
54
54
|
)
|
@@ -60,7 +60,7 @@ module Mutant
|
|
60
60
|
|
61
61
|
def coverage_result(mutation_result)
|
62
62
|
Result::Coverage.new(
|
63
|
-
mutation_result
|
63
|
+
mutation_result:,
|
64
64
|
criteria_result: mutation_result.criteria_result(env.config.coverage_criteria)
|
65
65
|
)
|
66
66
|
end
|
@@ -45,7 +45,7 @@ module Mutant
|
|
45
45
|
jobs: env.config.jobs,
|
46
46
|
on_process_start: env.method(:emit_mutation_worker_process_start),
|
47
47
|
process_name: 'mutant-worker-process',
|
48
|
-
sink: Sink.new(env:
|
48
|
+
sink: Sink.new(env:),
|
49
49
|
source: Parallel::Source::Array.new(jobs: env.mutations.each_index.to_a),
|
50
50
|
timeout: nil,
|
51
51
|
thread_name: 'mutant-worker-thread'
|
data/lib/mutant/mutation.rb
CHANGED
data/lib/mutant/mutator/node.rb
CHANGED
@@ -28,9 +28,9 @@ module Mutant
|
|
28
28
|
end
|
29
29
|
|
30
30
|
self::REGISTRY.lookup(node.type).call(
|
31
|
-
config
|
31
|
+
config:,
|
32
32
|
input: node,
|
33
|
-
parent:
|
33
|
+
parent:
|
34
34
|
)
|
35
35
|
end
|
36
36
|
|
@@ -67,7 +67,7 @@ module Mutant
|
|
67
67
|
alias_method :dup_node, :dup_input
|
68
68
|
|
69
69
|
def mutate(node:, parent: nil)
|
70
|
-
self.class.mutate(config
|
70
|
+
self.class.mutate(config:, node:, parent:)
|
71
71
|
end
|
72
72
|
|
73
73
|
def mutate_child(index, &block)
|
@@ -131,8 +131,8 @@ module Mutant
|
|
131
131
|
|
132
132
|
def run(mutator)
|
133
133
|
mutator.call(
|
134
|
-
config
|
135
|
-
input
|
134
|
+
config:,
|
135
|
+
input:,
|
136
136
|
parent: nil
|
137
137
|
).each(&method(:emit))
|
138
138
|
end
|
@@ -59,7 +59,7 @@ module Mutant
|
|
59
59
|
|
60
60
|
def emit_expression(klass:, text:)
|
61
61
|
emit(
|
62
|
-
klass.construct(text:
|
62
|
+
klass.construct(text:).tap do |new|
|
63
63
|
subexpressions.each do |expression|
|
64
64
|
new << Marshal.load(Marshal.dump(expression))
|
65
65
|
end
|
@@ -140,7 +140,7 @@ module Mutant
|
|
140
140
|
def dispatch
|
141
141
|
klass, text = MAP.fetch(input.class)
|
142
142
|
|
143
|
-
emit(klass.construct(text:
|
143
|
+
emit(klass.construct(text:).tap { |new| new.quantifier = input.quantifier })
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
@@ -46,7 +46,7 @@ module Mutant
|
|
46
46
|
|
47
47
|
Response.new(
|
48
48
|
error: reader.error,
|
49
|
-
job
|
49
|
+
job:,
|
50
50
|
log: reader.log,
|
51
51
|
result: reader.result
|
52
52
|
)
|
@@ -168,7 +168,7 @@ module Mutant
|
|
168
168
|
|
169
169
|
def self.from_pipes(marshal:, reader:, writer:)
|
170
170
|
new(
|
171
|
-
marshal
|
171
|
+
marshal:,
|
172
172
|
reader: Frame.new(io: reader.to_reader),
|
173
173
|
writer: Frame.new(io: writer.to_writer)
|
174
174
|
)
|
data/lib/mutant/parallel/pipe.rb
CHANGED
@@ -10,13 +10,13 @@ module Mutant
|
|
10
10
|
# @return [undefined]
|
11
11
|
def self.with(io)
|
12
12
|
io.pipe(binmode: true) do |(reader, writer)|
|
13
|
-
yield new(reader
|
13
|
+
yield new(reader:, writer:)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.from_io(io)
|
18
18
|
reader, writer = io.pipe(binmode: true)
|
19
|
-
new(reader
|
19
|
+
new(reader:, writer:)
|
20
20
|
end
|
21
21
|
|
22
22
|
# Writer end of the pipe
|
@@ -41,20 +41,20 @@ module Mutant
|
|
41
41
|
world.stdout.reopen(log_writer)
|
42
42
|
|
43
43
|
run_child(
|
44
|
-
config
|
45
|
-
connection: Connection.from_pipes(marshal
|
46
|
-
log_writer:
|
44
|
+
config:,
|
45
|
+
connection: Connection.from_pipes(marshal:, reader: request, writer: response),
|
46
|
+
log_writer:
|
47
47
|
)
|
48
48
|
end
|
49
49
|
|
50
|
-
connection = Connection.from_pipes(marshal
|
50
|
+
connection = Connection.from_pipes(marshal:, reader: response, writer: request)
|
51
51
|
|
52
52
|
new(
|
53
|
-
config
|
54
|
-
connection
|
53
|
+
config:,
|
54
|
+
connection:,
|
55
55
|
log_reader: log.to_reader,
|
56
56
|
response_reader: connection.reader.io,
|
57
|
-
pid:
|
57
|
+
pid:
|
58
58
|
)
|
59
59
|
end
|
60
60
|
private_class_method :start_config
|
@@ -98,10 +98,10 @@ module Mutant
|
|
98
98
|
response = Connection::Reader.read_response(
|
99
99
|
deadline: config.world.deadline(config.timeout),
|
100
100
|
io: config.world.io,
|
101
|
-
job
|
102
|
-
log_reader
|
101
|
+
job:,
|
102
|
+
log_reader:,
|
103
103
|
marshal: config.world.marshal,
|
104
|
-
response_reader:
|
104
|
+
response_reader:
|
105
105
|
)
|
106
106
|
|
107
107
|
job_done(job)
|
data/lib/mutant/parallel.rb
CHANGED
@@ -17,7 +17,7 @@ module Mutant
|
|
17
17
|
workers = workers(world, config, shared)
|
18
18
|
|
19
19
|
Driver.new(
|
20
|
-
workers
|
20
|
+
workers:,
|
21
21
|
threads: threads(world, config, workers),
|
22
22
|
**shared
|
23
23
|
)
|
@@ -28,11 +28,11 @@ module Mutant
|
|
28
28
|
Array.new(config.jobs) do |index|
|
29
29
|
Worker.start(
|
30
30
|
block: config.block,
|
31
|
-
index
|
31
|
+
index:,
|
32
32
|
on_process_start: config.on_process_start,
|
33
33
|
process_name: "#{config.process_name}-#{index}",
|
34
34
|
timeout: config.timeout,
|
35
|
-
world
|
35
|
+
world:,
|
36
36
|
**shared
|
37
37
|
)
|
38
38
|
end
|
data/lib/mutant/parser.rb
CHANGED
data/lib/mutant/registry.rb
CHANGED
@@ -58,7 +58,7 @@ module Mutant
|
|
58
58
|
puts('Log messages (combined stderr and stdout):')
|
59
59
|
|
60
60
|
log.each_line do |line|
|
61
|
-
puts('[killfork] %<line>s' % { line:
|
61
|
+
puts('[killfork] %<line>s' % { line: })
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -74,7 +74,7 @@ module Mutant
|
|
74
74
|
|
75
75
|
def print_timeout
|
76
76
|
timeout = object.timeout or return
|
77
|
-
puts(TIMEOUT_ERROR_MESSAGE % { timeout:
|
77
|
+
puts(TIMEOUT_ERROR_MESSAGE % { timeout: })
|
78
78
|
end
|
79
79
|
|
80
80
|
def print_exception
|
data/lib/mutant/reporter/cli.rb
CHANGED
@@ -15,7 +15,7 @@ module Mutant
|
|
15
15
|
new(
|
16
16
|
format: Format::Progressive.new(tty: output.respond_to?(:tty?) && output.tty?),
|
17
17
|
print_warnings: false,
|
18
|
-
output:
|
18
|
+
output:
|
19
19
|
)
|
20
20
|
end
|
21
21
|
|
@@ -80,7 +80,7 @@ module Mutant
|
|
80
80
|
#
|
81
81
|
# @return [self]
|
82
82
|
def report(env)
|
83
|
-
Printer::EnvResult.call(output
|
83
|
+
Printer::EnvResult.call(output:, object: env)
|
84
84
|
self
|
85
85
|
end
|
86
86
|
|
@@ -90,7 +90,7 @@ module Mutant
|
|
90
90
|
#
|
91
91
|
# @return [self]
|
92
92
|
def test_report(env)
|
93
|
-
Printer::Test::EnvResult.call(output
|
93
|
+
Printer::Test::EnvResult.call(output:, object: env)
|
94
94
|
self
|
95
95
|
end
|
96
96
|
|
@@ -40,8 +40,8 @@ module Mutant
|
|
40
40
|
.fmap { |status| world.pathname.new(status.stdout.chomp) }
|
41
41
|
end
|
42
42
|
|
43
|
-
def touched_path(path, &
|
44
|
-
touched_paths.from_right { |message| fail Error, message }.fetch(path, &
|
43
|
+
def touched_path(path, &)
|
44
|
+
touched_paths.from_right { |message| fail Error, message }.fetch(path, &)
|
45
45
|
end
|
46
46
|
|
47
47
|
def touched_paths
|
@@ -62,15 +62,16 @@ module Mutant
|
|
62
62
|
end
|
63
63
|
|
64
64
|
# rubocop:disable Metrics/MethodLength
|
65
|
+
# mutant:disable (3.2 specific mutation)
|
65
66
|
def parse_line(root, line)
|
66
67
|
match = FORMAT.match(line)
|
67
68
|
|
68
69
|
if match
|
69
70
|
Either::Right.new(
|
70
71
|
Path.new(
|
71
|
-
path: root.join(match.captures
|
72
|
-
to
|
73
|
-
world:
|
72
|
+
path: root.join(Util.one(match.captures)),
|
73
|
+
to:,
|
74
|
+
world:
|
74
75
|
)
|
75
76
|
)
|
76
77
|
else
|
@@ -23,9 +23,9 @@ module Mutant
|
|
23
23
|
|
24
24
|
yield.tap do
|
25
25
|
segments << Segment.new(
|
26
|
-
id
|
27
|
-
name
|
28
|
-
parent_id
|
26
|
+
id:,
|
27
|
+
name:,
|
28
|
+
parent_id:,
|
29
29
|
timestamp_end: timer.now,
|
30
30
|
timestamp_start: start
|
31
31
|
)
|
@@ -58,7 +58,7 @@ module Mutant
|
|
58
58
|
|
59
59
|
build_node(
|
60
60
|
value: id_index.fetch(root_id),
|
61
|
-
parent_index:
|
61
|
+
parent_index:
|
62
62
|
)
|
63
63
|
end
|
64
64
|
|
@@ -69,17 +69,17 @@ module Mutant
|
|
69
69
|
if segment.timestamp_end
|
70
70
|
segment
|
71
71
|
else
|
72
|
-
segment.with(timestamp_end:
|
72
|
+
segment.with(timestamp_end:)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
77
|
def build_node(value:, parent_index:)
|
78
78
|
Node.new(
|
79
|
-
value
|
79
|
+
value:,
|
80
80
|
children: build_children(
|
81
81
|
parent_id: value.id,
|
82
|
-
parent_index:
|
82
|
+
parent_index:
|
83
83
|
)
|
84
84
|
)
|
85
85
|
end
|
@@ -87,7 +87,7 @@ module Mutant
|
|
87
87
|
def build_children(parent_id:, parent_index:)
|
88
88
|
parent_index
|
89
89
|
.fetch(parent_id, EMPTY_ARRAY)
|
90
|
-
.map { |value| build_node(value
|
90
|
+
.map { |value| build_node(value:, parent_index:) }
|
91
91
|
end
|
92
92
|
|
93
93
|
def print_node(io, node, indent)
|