mutant 0.8.24 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +3 -3
- data/Changelog.md +14 -654
- data/Gemfile +13 -0
- data/Gemfile.lock +59 -64
- data/LICENSE +271 -20
- data/README.md +73 -140
- data/Rakefile +0 -21
- data/bin/mutant +7 -2
- data/config/reek.yml +2 -1
- data/config/rubocop.yml +5 -9
- data/docs/incremental.md +76 -0
- data/docs/known-problems.md +0 -14
- data/docs/mutant-minitest.md +1 -1
- data/docs/mutant-rspec.md +2 -24
- data/lib/mutant.rb +45 -53
- data/lib/mutant/ast/nodes.rb +0 -2
- data/lib/mutant/ast/types.rb +1 -117
- data/lib/mutant/base.rb +192 -0
- data/lib/mutant/bootstrap.rb +145 -0
- data/lib/mutant/cli.rb +68 -54
- data/lib/mutant/config.rb +119 -6
- data/lib/mutant/env.rb +94 -8
- data/lib/mutant/expression.rb +6 -1
- data/lib/mutant/expression/parser.rb +9 -31
- data/lib/mutant/integration.rb +64 -36
- data/lib/mutant/isolation.rb +16 -1
- data/lib/mutant/isolation/fork.rb +105 -40
- data/lib/mutant/license.rb +34 -0
- data/lib/mutant/license/subscription.rb +47 -0
- data/lib/mutant/license/subscription/commercial.rb +57 -0
- data/lib/mutant/license/subscription/opensource.rb +77 -0
- data/lib/mutant/loader.rb +27 -4
- data/lib/mutant/matcher.rb +48 -1
- data/lib/mutant/matcher/chain.rb +1 -1
- data/lib/mutant/matcher/config.rb +0 -2
- data/lib/mutant/matcher/filter.rb +1 -1
- data/lib/mutant/matcher/method.rb +11 -7
- data/lib/mutant/matcher/methods.rb +1 -1
- data/lib/mutant/matcher/namespace.rb +1 -1
- data/lib/mutant/matcher/null.rb +1 -1
- data/lib/mutant/matcher/scope.rb +1 -1
- data/lib/mutant/meta/example/dsl.rb +0 -8
- data/lib/mutant/mutation.rb +1 -2
- data/lib/mutant/mutator/node.rb +2 -9
- data/lib/mutant/mutator/node/arguments.rb +1 -1
- data/lib/mutant/mutator/node/class.rb +0 -8
- data/lib/mutant/mutator/node/define.rb +0 -12
- data/lib/mutant/mutator/node/generic.rb +30 -44
- data/lib/mutant/mutator/node/index.rb +4 -4
- data/lib/mutant/mutator/node/literal/regex.rb +0 -39
- data/lib/mutant/mutator/node/send.rb +13 -12
- data/lib/mutant/parallel.rb +61 -40
- data/lib/mutant/parallel/driver.rb +59 -0
- data/lib/mutant/parallel/source.rb +6 -2
- data/lib/mutant/parallel/worker.rb +63 -45
- data/lib/mutant/range.rb +15 -0
- data/lib/mutant/reporter/cli.rb +5 -11
- data/lib/mutant/reporter/cli/format.rb +3 -46
- data/lib/mutant/reporter/cli/printer/config.rb +5 -6
- data/lib/mutant/reporter/cli/printer/env.rb +40 -0
- data/lib/mutant/reporter/cli/printer/env_progress.rb +13 -17
- data/lib/mutant/reporter/cli/printer/isolation_result.rb +17 -3
- data/lib/mutant/reporter/cli/printer/mutation_result.rb +2 -3
- data/lib/mutant/reporter/cli/printer/status_progressive.rb +19 -10
- data/lib/mutant/repository.rb +0 -65
- data/lib/mutant/repository/diff.rb +104 -0
- data/lib/mutant/repository/diff/ranges.rb +52 -0
- data/lib/mutant/result.rb +16 -7
- data/lib/mutant/runner.rb +38 -47
- data/lib/mutant/runner/sink.rb +1 -1
- data/lib/mutant/selector/null.rb +19 -0
- data/lib/mutant/subject.rb +3 -1
- data/lib/mutant/subject/method/instance.rb +3 -1
- data/lib/mutant/transform.rb +511 -0
- data/lib/mutant/variable.rb +282 -0
- data/lib/mutant/version.rb +1 -1
- data/lib/mutant/warnings.rb +113 -0
- data/meta/case.rb +1 -0
- data/meta/class.rb +0 -9
- data/meta/def.rb +1 -26
- data/meta/regexp.rb +10 -20
- data/meta/send.rb +14 -46
- data/mutant-minitest.gemspec +1 -1
- data/mutant-rspec.gemspec +2 -2
- data/mutant.gemspec +15 -16
- data/mutant.yml +6 -0
- data/spec/integration/mutant/isolation/fork_spec.rb +22 -5
- data/spec/integration/mutant/minitest_spec.rb +3 -2
- data/spec/integration/mutant/rspec_spec.rb +4 -3
- data/spec/integrations.yml +16 -13
- data/spec/shared/base_behavior.rb +45 -0
- data/spec/shared/framework_integration_behavior.rb +43 -14
- data/spec/spec_helper.rb +21 -17
- data/spec/support/corpus.rb +56 -95
- data/spec/support/shared_context.rb +37 -14
- data/spec/support/xspec.rb +7 -3
- data/spec/unit/mutant/bootstrap_spec.rb +216 -0
- data/spec/unit/mutant/cli_spec.rb +173 -117
- data/spec/unit/mutant/config_spec.rb +126 -0
- data/spec/unit/mutant/either_spec.rb +247 -0
- data/spec/unit/mutant/env_spec.rb +162 -40
- data/spec/unit/mutant/expression/method_spec.rb +16 -0
- data/spec/unit/mutant/expression/parser_spec.rb +29 -33
- data/spec/unit/mutant/expression_spec.rb +5 -7
- data/spec/unit/mutant/integration_spec.rb +100 -9
- data/spec/unit/mutant/isolation/fork_spec.rb +125 -67
- data/spec/unit/mutant/isolation/result_spec.rb +33 -1
- data/spec/unit/mutant/license_spec.rb +257 -0
- data/spec/unit/mutant/loader_spec.rb +50 -11
- data/spec/unit/mutant/matcher/compiler_spec.rb +0 -78
- data/spec/unit/mutant/matcher/method/instance_spec.rb +55 -11
- data/spec/unit/mutant/matcher/method/singleton_spec.rb +12 -2
- data/spec/unit/mutant/matcher_spec.rb +102 -0
- data/spec/unit/mutant/maybe_spec.rb +60 -0
- data/spec/unit/mutant/meta/example/dsl_spec.rb +1 -17
- data/spec/unit/mutant/mutation_spec.rb +13 -6
- data/spec/unit/mutant/parallel/driver_spec.rb +112 -14
- data/spec/unit/mutant/parallel/source/array_spec.rb +25 -17
- data/spec/unit/mutant/parallel/worker_spec.rb +182 -44
- data/spec/unit/mutant/parallel_spec.rb +105 -8
- data/spec/unit/mutant/range_spec.rb +141 -0
- data/spec/unit/mutant/reporter/cli/printer/config_spec.rb +7 -21
- data/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb +15 -6
- data/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb +10 -2
- data/spec/unit/mutant/reporter/cli/printer/isolation_result_spec.rb +12 -4
- data/spec/unit/mutant/reporter/cli/printer/mutation_result_spec.rb +31 -2
- data/spec/unit/mutant/reporter/cli/printer/status_progressive_spec.rb +4 -4
- data/spec/unit/mutant/reporter/cli/printer/subject_result_spec.rb +5 -0
- data/spec/unit/mutant/reporter/cli_spec.rb +46 -123
- data/spec/unit/mutant/repository/diff/ranges_spec.rb +180 -0
- data/spec/unit/mutant/repository/diff_spec.rb +84 -71
- data/spec/unit/mutant/require_highjack_spec.rb +1 -1
- data/spec/unit/mutant/result/env_spec.rb +39 -9
- data/spec/unit/mutant/result/test_spec.rb +14 -0
- data/spec/unit/mutant/runner_spec.rb +88 -41
- data/spec/unit/mutant/selector/expression_spec.rb +11 -10
- data/spec/unit/mutant/selector/null_spec.rb +17 -0
- data/spec/unit/mutant/subject/method/instance_spec.rb +44 -5
- data/spec/unit/mutant/subject/method/singleton_spec.rb +9 -2
- data/spec/unit/mutant/subject_spec.rb +9 -1
- data/spec/unit/mutant/transform/array_spec.rb +92 -0
- data/spec/unit/mutant/transform/bool_spec.rb +63 -0
- data/spec/unit/mutant/transform/error_spec.rb +132 -0
- data/spec/unit/mutant/transform/exception_spec.rb +44 -0
- data/spec/unit/mutant/transform/hash_spec.rb +236 -0
- data/spec/unit/mutant/transform/index_spec.rb +92 -0
- data/spec/unit/mutant/transform/named_spec.rb +49 -0
- data/spec/unit/mutant/transform/primitive_spec.rb +56 -0
- data/spec/unit/mutant/transform/sequence_spec.rb +98 -0
- data/spec/unit/mutant/variable_spec.rb +618 -0
- data/spec/unit/mutant/warnings_spec.rb +89 -0
- data/spec/unit/mutant/world_spec.rb +63 -0
- data/test_app/Gemfile.minitest +0 -2
- metadata +79 -113
- data/.gitattributes +0 -1
- data/.ruby-gemset +0 -1
- data/config/triage.yml +0 -2
- data/lib/mutant/actor.rb +0 -57
- data/lib/mutant/actor/env.rb +0 -31
- data/lib/mutant/actor/mailbox.rb +0 -34
- data/lib/mutant/actor/receiver.rb +0 -42
- data/lib/mutant/actor/sender.rb +0 -26
- data/lib/mutant/ast/meta/restarg.rb +0 -19
- data/lib/mutant/ast/regexp.rb +0 -42
- data/lib/mutant/ast/regexp/transformer.rb +0 -187
- data/lib/mutant/ast/regexp/transformer/direct.rb +0 -123
- data/lib/mutant/ast/regexp/transformer/named_group.rb +0 -59
- data/lib/mutant/ast/regexp/transformer/options_group.rb +0 -83
- data/lib/mutant/ast/regexp/transformer/quantifier.rb +0 -114
- data/lib/mutant/ast/regexp/transformer/recursive.rb +0 -58
- data/lib/mutant/ast/regexp/transformer/root.rb +0 -31
- data/lib/mutant/ast/regexp/transformer/text.rb +0 -60
- data/lib/mutant/env/bootstrap.rb +0 -160
- data/lib/mutant/matcher/compiler.rb +0 -60
- data/lib/mutant/mutator/node/regexp.rb +0 -35
- data/lib/mutant/mutator/node/regexp/alternation_meta.rb +0 -23
- data/lib/mutant/mutator/node/regexp/capture_group.rb +0 -28
- data/lib/mutant/mutator/node/regexp/character_type.rb +0 -32
- data/lib/mutant/mutator/node/regexp/end_of_line_anchor.rb +0 -23
- data/lib/mutant/mutator/node/regexp/end_of_string_or_before_end_of_line_anchor.rb +0 -23
- data/lib/mutant/mutator/node/regexp/greedy_zero_or_more.rb +0 -27
- data/lib/mutant/parallel/master.rb +0 -181
- data/lib/mutant/reporter/cli/printer/status.rb +0 -53
- data/lib/mutant/reporter/cli/tput.rb +0 -46
- data/lib/mutant/warning_filter.rb +0 -61
- data/meta/regexp/character_types.rb +0 -23
- data/meta/regexp/regexp_alternation_meta.rb +0 -13
- data/meta/regexp/regexp_bol_anchor.rb +0 -10
- data/meta/regexp/regexp_bos_anchor.rb +0 -18
- data/meta/regexp/regexp_capture_group.rb +0 -19
- data/meta/regexp/regexp_eol_anchor.rb +0 -10
- data/meta/regexp/regexp_eos_anchor.rb +0 -8
- data/meta/regexp/regexp_eos_ob_eol_anchor.rb +0 -10
- data/meta/regexp/regexp_greedy_zero_or_more.rb +0 -12
- data/meta/regexp/regexp_root_expression.rb +0 -10
- data/meta/restarg.rb +0 -10
- data/spec/support/fake_actor.rb +0 -111
- data/spec/support/warning.rb +0 -66
- data/spec/unit/mutant/actor/binding_spec.rb +0 -34
- data/spec/unit/mutant/actor/env_spec.rb +0 -31
- data/spec/unit/mutant/actor/mailbox_spec.rb +0 -28
- data/spec/unit/mutant/actor/message_spec.rb +0 -25
- data/spec/unit/mutant/actor/receiver_spec.rb +0 -58
- data/spec/unit/mutant/actor/sender_spec.rb +0 -24
- data/spec/unit/mutant/ast/regexp/parse_spec.rb +0 -19
- data/spec/unit/mutant/ast/regexp/transformer/lookup_table/table_spec.rb +0 -21
- data/spec/unit/mutant/ast/regexp/transformer/lookup_table_spec.rb +0 -35
- data/spec/unit/mutant/ast/regexp/transformer_spec.rb +0 -21
- data/spec/unit/mutant/ast/regexp_spec.rb +0 -704
- data/spec/unit/mutant/env/bootstrap_spec.rb +0 -188
- data/spec/unit/mutant/matcher/compiler/subject_prefix_spec.rb +0 -26
- data/spec/unit/mutant/parallel/master_spec.rb +0 -338
- data/spec/unit/mutant/reporter/cli/printer/status_spec.rb +0 -121
- data/spec/unit/mutant/reporter/cli/tput_spec.rb +0 -50
- data/spec/unit/mutant/warning_filter_spec.rb +0 -106
- data/spec/unit/mutant_spec.rb +0 -17
- data/test_app/Gemfile.rspec3.7 +0 -7
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Mutant
|
4
|
-
class Mutator
|
5
|
-
class Node
|
6
|
-
module Regexp
|
7
|
-
# Mutator for greedy zero-or-more quantifier, `*`
|
8
|
-
class GreedyZeroOrMore < Node
|
9
|
-
handle(:regexp_greedy_zero_or_more)
|
10
|
-
|
11
|
-
children :min, :max, :subject
|
12
|
-
|
13
|
-
# Emit mutations
|
14
|
-
#
|
15
|
-
# Replace `/a*/` with `/a+/`
|
16
|
-
#
|
17
|
-
# @return [undefined]
|
18
|
-
def dispatch
|
19
|
-
emit(s(:regexp_greedy_one_or_more, *children))
|
20
|
-
emit_subject_mutations
|
21
|
-
emit(subject)
|
22
|
-
end
|
23
|
-
end # GreedyZeroOrMore
|
24
|
-
end # Regexp
|
25
|
-
end # Node
|
26
|
-
end # Mutator
|
27
|
-
end # Mutant
|
@@ -1,181 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Mutant
|
4
|
-
module Parallel
|
5
|
-
# Master parallel worker
|
6
|
-
class Master
|
7
|
-
include Concord.new(:config, :mailbox)
|
8
|
-
|
9
|
-
private_class_method :new
|
10
|
-
|
11
|
-
# Run master
|
12
|
-
#
|
13
|
-
# @param [Config] config
|
14
|
-
#
|
15
|
-
# @return [Actor::Sender]
|
16
|
-
def self.call(config)
|
17
|
-
config.env.spawn do |mailbox|
|
18
|
-
new(config, mailbox).__send__(:run)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
# Initialize object
|
23
|
-
#
|
24
|
-
# @return [undefined]
|
25
|
-
def initialize(*)
|
26
|
-
super
|
27
|
-
|
28
|
-
@stop = false
|
29
|
-
@workers = 0
|
30
|
-
@active_jobs = Set.new
|
31
|
-
@index = 0
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
# Run work loop
|
37
|
-
#
|
38
|
-
# rubocop:disable MethodLength
|
39
|
-
#
|
40
|
-
# @return [undefined]
|
41
|
-
def run
|
42
|
-
config.jobs.times do
|
43
|
-
@workers += 1
|
44
|
-
config.env.spawn do |worker_mailbox|
|
45
|
-
Worker.run(
|
46
|
-
mailbox: worker_mailbox,
|
47
|
-
processor: config.processor,
|
48
|
-
parent: mailbox.sender
|
49
|
-
)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
receive_loop
|
54
|
-
end
|
55
|
-
|
56
|
-
MAP = IceNine.deep_freeze(
|
57
|
-
ready: :handle_ready,
|
58
|
-
status: :handle_status,
|
59
|
-
result: :handle_result,
|
60
|
-
stop: :handle_stop
|
61
|
-
)
|
62
|
-
|
63
|
-
# Handle messages
|
64
|
-
#
|
65
|
-
# @param [Actor::Message] message
|
66
|
-
#
|
67
|
-
# @return [undefined]
|
68
|
-
def handle(message)
|
69
|
-
type, payload = message.type, message.payload
|
70
|
-
method = MAP.fetch(type) do
|
71
|
-
fail Actor::ProtocolError, "Unexpected message: #{type.inspect}"
|
72
|
-
end
|
73
|
-
__send__(method, payload)
|
74
|
-
end
|
75
|
-
|
76
|
-
# Run receive loop
|
77
|
-
#
|
78
|
-
# @return [undefined]
|
79
|
-
def receive_loop
|
80
|
-
handle(mailbox.receiver.call) until @workers.zero? && @stop
|
81
|
-
end
|
82
|
-
|
83
|
-
# Handle status
|
84
|
-
#
|
85
|
-
# @param [Actor::Sender] sender
|
86
|
-
#
|
87
|
-
# @return [undefined]
|
88
|
-
def handle_status(sender)
|
89
|
-
status = Status.new(
|
90
|
-
payload: sink.status,
|
91
|
-
done: sink.stop? || @workers.zero?,
|
92
|
-
active_jobs: @active_jobs.dup.freeze
|
93
|
-
)
|
94
|
-
sender.call(Actor::Message.new(:status, status))
|
95
|
-
end
|
96
|
-
|
97
|
-
# Handle result
|
98
|
-
#
|
99
|
-
# @param [JobResult] job_result
|
100
|
-
#
|
101
|
-
# @return [undefined]
|
102
|
-
def handle_result(job_result)
|
103
|
-
@active_jobs.delete(job_result.job)
|
104
|
-
sink.result(job_result.payload)
|
105
|
-
end
|
106
|
-
|
107
|
-
# Handle stop
|
108
|
-
#
|
109
|
-
# @param [Actor::Sender] sender
|
110
|
-
#
|
111
|
-
# @return [undefined]
|
112
|
-
def handle_stop(sender)
|
113
|
-
@stop = true
|
114
|
-
receive_loop
|
115
|
-
sender.call(Actor::Message.new(:stop))
|
116
|
-
end
|
117
|
-
|
118
|
-
# Handle ready worker
|
119
|
-
#
|
120
|
-
# @param [Actor::Sender] sender
|
121
|
-
#
|
122
|
-
# @return [undefined]
|
123
|
-
def handle_ready(sender)
|
124
|
-
if stop_work?
|
125
|
-
stop_worker(sender)
|
126
|
-
return
|
127
|
-
end
|
128
|
-
|
129
|
-
sender.call(Actor::Message.new(:job, next_job))
|
130
|
-
end
|
131
|
-
|
132
|
-
# Next job if any
|
133
|
-
#
|
134
|
-
# @return [Job]
|
135
|
-
# if next job is available
|
136
|
-
#
|
137
|
-
# @return [nil]
|
138
|
-
def next_job
|
139
|
-
Job.new(
|
140
|
-
index: @index,
|
141
|
-
payload: source.next
|
142
|
-
).tap do |job|
|
143
|
-
@index += 1
|
144
|
-
@active_jobs << job
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
# Stop worker
|
149
|
-
#
|
150
|
-
# @param [Actor::Sender] sender
|
151
|
-
#
|
152
|
-
# @return [undefined]
|
153
|
-
def stop_worker(sender)
|
154
|
-
@workers -= 1
|
155
|
-
sender.call(Actor::Message.new(:stop))
|
156
|
-
end
|
157
|
-
|
158
|
-
# Test if scheduling stopped
|
159
|
-
#
|
160
|
-
# @return [Boolean]
|
161
|
-
def stop_work?
|
162
|
-
@stop || !source.next? || sink.stop?
|
163
|
-
end
|
164
|
-
|
165
|
-
# Job source
|
166
|
-
#
|
167
|
-
# @return [Source]
|
168
|
-
def source
|
169
|
-
config.source
|
170
|
-
end
|
171
|
-
|
172
|
-
# Job result sink
|
173
|
-
#
|
174
|
-
# @return [Sink]
|
175
|
-
def sink
|
176
|
-
config.sink
|
177
|
-
end
|
178
|
-
|
179
|
-
end # Master
|
180
|
-
end # Parallel
|
181
|
-
end # Mutant
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Mutant
|
4
|
-
class Reporter
|
5
|
-
class CLI
|
6
|
-
class Printer
|
7
|
-
# Printer for runner status
|
8
|
-
class Status < self
|
9
|
-
|
10
|
-
delegate(:active_jobs, :payload)
|
11
|
-
|
12
|
-
ACTIVE_JOB_HEADER = 'Active Jobs:'
|
13
|
-
ACTIVE_JOB_FORMAT = '%d: %s'
|
14
|
-
|
15
|
-
# Print progress for collector
|
16
|
-
#
|
17
|
-
# @return [undefined]
|
18
|
-
def run
|
19
|
-
visit(EnvProgress, payload)
|
20
|
-
job_status
|
21
|
-
info('Active subjects: %d', active_subject_results.length)
|
22
|
-
visit_collection(SubjectProgress, active_subject_results)
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
# Print worker status
|
28
|
-
#
|
29
|
-
# @return [undefined]
|
30
|
-
def job_status
|
31
|
-
return if active_jobs.empty?
|
32
|
-
info(ACTIVE_JOB_HEADER)
|
33
|
-
active_jobs.sort_by(&:index).each do |job|
|
34
|
-
info(ACTIVE_JOB_FORMAT, job.index, job.payload.identification)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
# Active subject results
|
39
|
-
#
|
40
|
-
# @return [Array<Result::Subject>]
|
41
|
-
def active_subject_results
|
42
|
-
active_subjects = active_jobs.map(&:payload).flat_map(&:subject)
|
43
|
-
|
44
|
-
payload.subject_results.select do |subject_result|
|
45
|
-
active_subjects.include?(subject_result.subject)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
end # Status
|
50
|
-
end # Printer
|
51
|
-
end # CLI
|
52
|
-
end # Reporter
|
53
|
-
end # Mutant
|
@@ -1,46 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Mutant
|
4
|
-
class Reporter
|
5
|
-
class CLI
|
6
|
-
# Interface to the optionally present tput binary
|
7
|
-
class Tput
|
8
|
-
include Adamantium, Concord::Public.new(:prepare, :restore)
|
9
|
-
|
10
|
-
private_class_method :new
|
11
|
-
|
12
|
-
# Detected tput support
|
13
|
-
#
|
14
|
-
# @return [Tput]
|
15
|
-
# if tput support is present
|
16
|
-
#
|
17
|
-
# @return [nil]
|
18
|
-
# otherwise
|
19
|
-
def self.detect
|
20
|
-
reset = capture('tput reset')
|
21
|
-
save = capture('tput sc') if reset
|
22
|
-
restore = capture('tput rc') if save
|
23
|
-
clean = capture('tput ed') || capture('tput cd') if restore
|
24
|
-
new(reset + save, restore + clean) if clean
|
25
|
-
end
|
26
|
-
|
27
|
-
# Capture output
|
28
|
-
#
|
29
|
-
# @param [String] command
|
30
|
-
# command to run
|
31
|
-
#
|
32
|
-
# @return [String]
|
33
|
-
# stdout of command on success
|
34
|
-
#
|
35
|
-
# @return [nil]
|
36
|
-
# otherwise
|
37
|
-
def self.capture(command)
|
38
|
-
stdout, _stderr, exitstatus = Open3.capture3(command)
|
39
|
-
stdout if exitstatus.success?
|
40
|
-
end
|
41
|
-
private_class_method :capture
|
42
|
-
|
43
|
-
end # Tput
|
44
|
-
end # CLI
|
45
|
-
end # Reporter
|
46
|
-
end # Mutant
|
@@ -1,61 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Mutant
|
4
|
-
# Stream filter for warnings
|
5
|
-
class WarningFilter
|
6
|
-
include Equalizer.new(:target)
|
7
|
-
|
8
|
-
WARNING_PATTERN = /\A(?:.+):(?:\d+): warning: (?:.+)\n\z/.freeze
|
9
|
-
|
10
|
-
# Initialize object
|
11
|
-
#
|
12
|
-
# @param [#write] target
|
13
|
-
#
|
14
|
-
# @return [undefined]
|
15
|
-
def initialize(target)
|
16
|
-
@target = target
|
17
|
-
@warnings = []
|
18
|
-
end
|
19
|
-
|
20
|
-
# Warnings captured by filter
|
21
|
-
#
|
22
|
-
# @return [Array<String>]
|
23
|
-
attr_reader :warnings
|
24
|
-
|
25
|
-
# Target stream to capture warnings on
|
26
|
-
#
|
27
|
-
# @return [#write] target
|
28
|
-
#
|
29
|
-
# @return [undefined]
|
30
|
-
attr_reader :target
|
31
|
-
protected :target
|
32
|
-
|
33
|
-
# Write message to target filtering warnings
|
34
|
-
#
|
35
|
-
# @param [String] message
|
36
|
-
#
|
37
|
-
# @return [self]
|
38
|
-
def write(message)
|
39
|
-
if WARNING_PATTERN.match?(message)
|
40
|
-
warnings << message
|
41
|
-
else
|
42
|
-
target.write(message)
|
43
|
-
end
|
44
|
-
|
45
|
-
self
|
46
|
-
end
|
47
|
-
|
48
|
-
# Use warning filter during block execution
|
49
|
-
#
|
50
|
-
# @return [Array<String>]
|
51
|
-
def self.use
|
52
|
-
original = $stderr
|
53
|
-
$stderr = filter = new(original)
|
54
|
-
yield
|
55
|
-
filter.warnings
|
56
|
-
ensure
|
57
|
-
$stderr = original
|
58
|
-
end
|
59
|
-
|
60
|
-
end # WarningFilter
|
61
|
-
end # Mutant
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
mutations = {
|
4
|
-
[:regexp_digit_type, '/\d/'] => [:regexp_nondigit_type, '/\D/'],
|
5
|
-
[:regexp_hex_type, '/\h/'] => [:regexp_nonhex_type, '/\H/'],
|
6
|
-
[:regexp_space_type, '/\s/'] => [:regexp_nonspace_type, '/\S/'],
|
7
|
-
[:regexp_word_boundary_anchor, '/\b/'] => [:regexp_nonword_boundary_anchor, '/\B/'],
|
8
|
-
[:regexp_word_type, '/\w/'] => [:regexp_nonword_type, '/\W/'],
|
9
|
-
[:regexp_xgrapheme_type, '/\X/'] => [:regexp_linebreak_type, '/\R/']
|
10
|
-
}
|
11
|
-
|
12
|
-
mutations = mutations.merge(mutations.invert)
|
13
|
-
|
14
|
-
mutations.each do |(source_type, source_mutation), (_, regexp_mutation)|
|
15
|
-
Mutant::Meta::Example.add :regexp, source_type do
|
16
|
-
source(source_mutation)
|
17
|
-
|
18
|
-
singleton_mutations
|
19
|
-
regexp_mutations
|
20
|
-
|
21
|
-
mutation(regexp_mutation)
|
22
|
-
end
|
23
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
Mutant::Meta::Example.add :regexp_alternation_meta do
|
4
|
-
source '/\A(foo|bar|baz)\z/'
|
5
|
-
|
6
|
-
singleton_mutations
|
7
|
-
regexp_mutations
|
8
|
-
|
9
|
-
mutation '/\A(foo|bar)\z/'
|
10
|
-
mutation '/\A(foo|baz)\z/'
|
11
|
-
mutation '/\A(bar|baz)\z/'
|
12
|
-
mutation '/\A(?:foo|bar|baz)\z/'
|
13
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
Mutant::Meta::Example.add :regexp_bos_anchor do
|
4
|
-
source '/\A/'
|
5
|
-
|
6
|
-
singleton_mutations
|
7
|
-
regexp_mutations
|
8
|
-
end
|
9
|
-
|
10
|
-
Mutant::Meta::Example.add :regexp_bos_anchor do
|
11
|
-
source '/^#{a}/'
|
12
|
-
|
13
|
-
singleton_mutations
|
14
|
-
regexp_mutations
|
15
|
-
|
16
|
-
mutation '/^#{nil}/'
|
17
|
-
mutation '/^#{self}/'
|
18
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
Mutant::Meta::Example.add :regexp_capture_group do
|
4
|
-
source '/()/'
|
5
|
-
|
6
|
-
singleton_mutations
|
7
|
-
regexp_mutations
|
8
|
-
end
|
9
|
-
|
10
|
-
Mutant::Meta::Example.add :regexp_capture_group do
|
11
|
-
source '/(foo|bar)/'
|
12
|
-
|
13
|
-
singleton_mutations
|
14
|
-
regexp_mutations
|
15
|
-
|
16
|
-
mutation '/(?:foo|bar)/'
|
17
|
-
mutation '/(foo)/'
|
18
|
-
mutation '/(bar)/'
|
19
|
-
end
|