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
@@ -0,0 +1,180 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe Mutant::Repository::Diff::Ranges do
|
4
|
+
describe '.parse' do
|
5
|
+
def apply
|
6
|
+
described_class.parse(diff)
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:diff) do
|
10
|
+
Tempfile.open('old') do |old_file|
|
11
|
+
old_file.write(old)
|
12
|
+
old_file.flush
|
13
|
+
Tempfile.open('new') do |new_file|
|
14
|
+
new_file.write(new)
|
15
|
+
new_file.flush
|
16
|
+
# rubocop:disable Lint/UnneededSplatExpansion
|
17
|
+
stdout, status = Open3.capture2(
|
18
|
+
*%W[
|
19
|
+
git
|
20
|
+
diff
|
21
|
+
--no-index
|
22
|
+
--unified=0
|
23
|
+
--
|
24
|
+
#{old_file.path}
|
25
|
+
#{new_file.path}
|
26
|
+
]
|
27
|
+
)
|
28
|
+
# rubocop:enable Lint/UnneededSplatExpansion
|
29
|
+
|
30
|
+
fail unless [0, 256].include?(status.to_i)
|
31
|
+
|
32
|
+
stdout
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'on empty diff' do
|
38
|
+
let(:old) { '' }
|
39
|
+
let(:new) { '' }
|
40
|
+
|
41
|
+
it 'returns emtpy set' do
|
42
|
+
expect(apply).to eql(Set.new)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'on empty old' do
|
47
|
+
let(:old) { '' }
|
48
|
+
|
49
|
+
context 'adding a single line' do
|
50
|
+
let(:new) do
|
51
|
+
<<~'STR'
|
52
|
+
a
|
53
|
+
STR
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'returns expected set' do
|
57
|
+
expect(apply).to eql([1..1].to_set)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'adding a multiple lines' do
|
62
|
+
let(:old) { '' }
|
63
|
+
|
64
|
+
let(:new) do
|
65
|
+
<<~'STR'
|
66
|
+
a
|
67
|
+
b
|
68
|
+
STR
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'returns expected set' do
|
72
|
+
expect(apply).to eql([1..2].to_set)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'on empty new' do
|
78
|
+
let(:new) { '' }
|
79
|
+
|
80
|
+
context 'removing a single line' do
|
81
|
+
let(:old) do
|
82
|
+
<<~'STR'
|
83
|
+
a
|
84
|
+
STR
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'returns expected set' do
|
88
|
+
expect(apply).to eql([1..1].to_set)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context 'removing a multiple lines' do
|
93
|
+
let(:old) do
|
94
|
+
<<~'STR'
|
95
|
+
a
|
96
|
+
b
|
97
|
+
STR
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'returns expected set' do
|
101
|
+
expect(apply).to eql([1..2].to_set)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context 'single line modification' do
|
107
|
+
let(:old) do
|
108
|
+
<<~'STR'
|
109
|
+
a
|
110
|
+
b
|
111
|
+
c
|
112
|
+
a
|
113
|
+
STR
|
114
|
+
end
|
115
|
+
|
116
|
+
let(:new) do
|
117
|
+
<<~'STR'
|
118
|
+
a
|
119
|
+
b
|
120
|
+
b
|
121
|
+
a
|
122
|
+
STR
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'returns expected set' do
|
126
|
+
expect(apply).to eql([3..3].to_set)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context 'nonempty old and new' do
|
131
|
+
context 'single line addition' do
|
132
|
+
let(:old) do
|
133
|
+
<<~'STR'
|
134
|
+
a
|
135
|
+
b
|
136
|
+
a
|
137
|
+
STR
|
138
|
+
end
|
139
|
+
|
140
|
+
let(:new) do
|
141
|
+
<<~'STR'
|
142
|
+
a
|
143
|
+
b
|
144
|
+
b
|
145
|
+
a
|
146
|
+
STR
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'returns expected set' do
|
150
|
+
expect(apply).to eql([3..3].to_set)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
context 'multi line modification' do
|
154
|
+
let(:old) do
|
155
|
+
<<~'STR'
|
156
|
+
a
|
157
|
+
b
|
158
|
+
c
|
159
|
+
d
|
160
|
+
a
|
161
|
+
STR
|
162
|
+
end
|
163
|
+
|
164
|
+
let(:new) do
|
165
|
+
<<~'STR'
|
166
|
+
a
|
167
|
+
b
|
168
|
+
b
|
169
|
+
b
|
170
|
+
a
|
171
|
+
STR
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'returns expected set' do
|
175
|
+
expect(apply).to eql([3..4].to_set)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
@@ -2,106 +2,119 @@
|
|
2
2
|
|
3
3
|
describe Mutant::Repository::Diff do
|
4
4
|
describe '#touches?' do
|
5
|
-
|
6
|
-
|
7
|
-
config: config,
|
8
|
-
from: 'from_rev',
|
9
|
-
to: 'to_rev'
|
10
|
-
)
|
5
|
+
def apply
|
6
|
+
subject.touches?(path, line_range)
|
11
7
|
end
|
12
8
|
|
13
|
-
|
14
|
-
instance_double(
|
15
|
-
Mutant::Config,
|
16
|
-
kernel: kernel,
|
17
|
-
open3: open3,
|
18
|
-
pathname: pathname
|
19
|
-
)
|
20
|
-
end
|
9
|
+
subject { described_class.new(world: world, to: 'to_rev') }
|
21
10
|
|
22
11
|
let(:pathname) { class_double(Pathname, pwd: pwd) }
|
23
12
|
let(:open3) { class_double(Open3) }
|
24
13
|
let(:kernel) { class_double(Kernel) }
|
25
14
|
let(:pwd) { Pathname.new('/foo') }
|
26
15
|
let(:path) { Pathname.new('/foo/bar.rb') }
|
27
|
-
let(:line_range) {
|
28
|
-
|
29
|
-
subject { object.touches?(path, line_range) }
|
30
|
-
|
31
|
-
shared_context 'test if git tracks the file' do
|
32
|
-
before do
|
33
|
-
# rubocop:disable Lint/UnneededSplatExpansion
|
34
|
-
expect(config.kernel).to receive(:system)
|
35
|
-
.ordered
|
36
|
-
.with(
|
37
|
-
*%W[git ls-files --error-unmatch -- #{path}],
|
38
|
-
out: File::NULL,
|
39
|
-
err: File::NULL
|
40
|
-
).and_return(git_ls_success?)
|
41
|
-
end
|
42
|
-
end
|
16
|
+
let(:line_range) { 4..5 }
|
43
17
|
|
44
|
-
|
45
|
-
|
18
|
+
let(:world) do
|
19
|
+
instance_double(
|
20
|
+
Mutant::World,
|
21
|
+
kernel: kernel,
|
22
|
+
pathname: pathname
|
23
|
+
)
|
24
|
+
end
|
46
25
|
|
47
|
-
|
48
|
-
|
49
|
-
|
26
|
+
let(:allowed_paths) do
|
27
|
+
%w[bar.rb baz.rb].map do |path|
|
28
|
+
[path, Pathname.new(path)]
|
29
|
+
end.to_h
|
30
|
+
end
|
50
31
|
|
51
|
-
|
32
|
+
let(:file_diff_expectations) { [] }
|
33
|
+
|
34
|
+
let(:raw_expectations) do
|
35
|
+
[
|
36
|
+
{
|
37
|
+
receiver: world,
|
38
|
+
selector: :capture_stdout,
|
39
|
+
arguments: [%w[git diff-index to_rev]],
|
40
|
+
reaction: { return: Mutant::Either::Right.new(index_stdout) }
|
41
|
+
},
|
42
|
+
*file_diff_expectations
|
43
|
+
]
|
52
44
|
end
|
53
45
|
|
54
|
-
|
55
|
-
|
46
|
+
before do
|
47
|
+
allow(pathname).to receive(:new, &allowed_paths.method(:fetch))
|
48
|
+
end
|
56
49
|
|
57
|
-
|
50
|
+
context 'when file is not touched in the diff' do
|
51
|
+
let(:index_stdout) { '' }
|
58
52
|
|
59
|
-
it
|
53
|
+
it 'returns false' do
|
54
|
+
verify_events { expect(apply).to be(false) }
|
55
|
+
end
|
60
56
|
end
|
61
57
|
|
62
|
-
context 'when
|
63
|
-
let(:
|
64
|
-
let(:status) { instance_double(Process::Status, success?: success?) }
|
65
|
-
let(:stdout) { instance_double(String, empty?: stdout_empty?) }
|
66
|
-
let(:stdout_empty?) { false }
|
58
|
+
context 'when a diff-index line is invalid' do
|
59
|
+
let(:index_stdout) { 'invalid-line' }
|
67
60
|
|
68
|
-
|
61
|
+
it 'raises error' do
|
62
|
+
expect { verify_events { apply } }
|
63
|
+
.to raise_error(
|
64
|
+
described_class::Error,
|
65
|
+
'Invalid git diff-index line: invalid-line'
|
66
|
+
)
|
67
|
+
end
|
68
|
+
end
|
69
69
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
.
|
70
|
+
context 'when file is touched in the diff' do
|
71
|
+
let(:index_stdout) do
|
72
|
+
<<~STR
|
73
|
+
:000000 000000 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 M\tbar.rb
|
74
|
+
:000000 000000 0000000000000000000000000000000000000000 0000000000000000000000000000000000000000 M\tbaz.rb
|
75
|
+
STR
|
75
76
|
end
|
76
77
|
|
77
|
-
let(:
|
78
|
-
|
78
|
+
let(:file_diff_expectations) do
|
79
|
+
[
|
80
|
+
{
|
81
|
+
receiver: world,
|
82
|
+
selector: :capture_stdout,
|
83
|
+
arguments: [%w[git diff --unified=0 to_rev -- /foo/bar.rb]],
|
84
|
+
reaction: { return: Mutant::Either::Right.new(diff_stdout) }
|
85
|
+
}
|
86
|
+
]
|
79
87
|
end
|
80
88
|
|
81
|
-
context '
|
82
|
-
let(:
|
89
|
+
context 'and diff touches the line range' do
|
90
|
+
let(:diff_stdout) do
|
91
|
+
<<~'DIFF'
|
92
|
+
--- bar.rb
|
93
|
+
+++ bar.rb
|
94
|
+
@@ -4 +4 @@ header
|
95
|
+
-a
|
96
|
+
+b
|
97
|
+
DIFF
|
98
|
+
end
|
83
99
|
|
84
|
-
it '
|
85
|
-
|
86
|
-
Mutant::Repository::RepositoryError,
|
87
|
-
"Command #{expected_git_log_command} failed!"
|
88
|
-
)
|
100
|
+
it 'returns true' do
|
101
|
+
verify_events { expect(apply).to be(true) }
|
89
102
|
end
|
90
103
|
end
|
91
104
|
|
92
|
-
context '
|
93
|
-
let(:
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
105
|
+
context 'and diff does not touch the line range' do
|
106
|
+
let(:diff_stdout) do
|
107
|
+
<<~'DIFF'
|
108
|
+
--- bar.rb
|
109
|
+
+++ bar.rb
|
110
|
+
@@ -3 +3 @@ header
|
111
|
+
-a
|
112
|
+
+b
|
113
|
+
DIFF
|
99
114
|
end
|
100
115
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
it { should be(true) }
|
116
|
+
it 'returns false' do
|
117
|
+
verify_events { expect(apply).to be(false) }
|
105
118
|
end
|
106
119
|
end
|
107
120
|
end
|
@@ -28,7 +28,7 @@ RSpec.describe Mutant::RequireHighjack do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'prevents warnings' do
|
31
|
-
expect(Mutant::
|
31
|
+
expect(Mutant::WORLD.warnings.call(&method(:apply))).to eql([])
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'returns the original implementation from singleton' do
|
@@ -14,9 +14,18 @@ RSpec.describe Mutant::Result::Env do
|
|
14
14
|
let(:env) do
|
15
15
|
instance_double(
|
16
16
|
Mutant::Env,
|
17
|
-
config:
|
18
|
-
|
19
|
-
mutations:
|
17
|
+
config: instance_double(Mutant::Config, fail_fast: fail_fast),
|
18
|
+
integration: integration,
|
19
|
+
mutations: [instance_double(Mutant::Mutation)],
|
20
|
+
selections: selections,
|
21
|
+
subjects: [subject_a, subject_b]
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
let(:integration) do
|
26
|
+
instance_double(
|
27
|
+
Mutant::Integration,
|
28
|
+
all_tests: [test_a, test_b]
|
20
29
|
)
|
21
30
|
end
|
22
31
|
|
@@ -29,6 +38,33 @@ RSpec.describe Mutant::Result::Env do
|
|
29
38
|
)
|
30
39
|
end
|
31
40
|
|
41
|
+
let(:selections) do
|
42
|
+
{
|
43
|
+
subject_a: [test_a],
|
44
|
+
subject_b: [test_a, test_b, test_c]
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
let(:subject_a) do
|
49
|
+
instance_double(Mutant::Subject, :a)
|
50
|
+
end
|
51
|
+
|
52
|
+
let(:subject_b) do
|
53
|
+
instance_double(Mutant::Subject, :b)
|
54
|
+
end
|
55
|
+
|
56
|
+
let(:test_a) do
|
57
|
+
instance_double(Mutant::Test, :a)
|
58
|
+
end
|
59
|
+
|
60
|
+
let(:test_b) do
|
61
|
+
instance_double(Mutant::Test, :b)
|
62
|
+
end
|
63
|
+
|
64
|
+
let(:test_c) do
|
65
|
+
instance_double(Mutant::Test, :c)
|
66
|
+
end
|
67
|
+
|
32
68
|
let(:fail_fast) { false }
|
33
69
|
let(:killed) { 0 }
|
34
70
|
let(:results) { 1 }
|
@@ -81,12 +117,6 @@ RSpec.describe Mutant::Result::Env do
|
|
81
117
|
it { should eql(1) }
|
82
118
|
end
|
83
119
|
|
84
|
-
describe '#amount_subjects' do
|
85
|
-
subject { object.amount_subjects }
|
86
|
-
|
87
|
-
it { should eql(1) }
|
88
|
-
end
|
89
|
-
|
90
120
|
describe '#stop?' do
|
91
121
|
subject { object.stop? }
|
92
122
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe Mutant::Result::Test::VoidValue do
|
4
|
+
describe '.new' do
|
5
|
+
it 'returns expected attributes' do
|
6
|
+
expect(described_class.instance.to_h).to eql(
|
7
|
+
output: '',
|
8
|
+
passed: false,
|
9
|
+
runtime: 0.0,
|
10
|
+
tests: []
|
11
|
+
)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|