mutant 0.5.10 → 0.5.11
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/.rubocop.yml +1 -0
- data/Changelog.md +12 -1
- data/README.md +3 -0
- data/Rakefile +0 -9
- data/bin/mutant +1 -1
- data/config/flay.yml +1 -1
- data/config/mutant.yml +13 -0
- data/config/reek.yml +6 -2
- data/lib/mutant/constants.rb +0 -13
- data/lib/mutant/mutator/node/conditional_loop.rb +2 -1
- data/lib/mutant/mutator/node/generic.rb +1 -1
- data/lib/mutant/mutator/node/if.rb +1 -1
- data/lib/mutant/mutator/node/literal/regex.rb +2 -2
- data/lib/mutant/mutator/node/match_current_line.rb +27 -0
- data/lib/mutant/mutator/node/named_value/variable_assignment.rb +1 -1
- data/lib/mutant/mutator/node/nthref.rb +3 -1
- data/lib/mutant/mutator/node/rescue.rb +0 -12
- data/lib/mutant/mutator/node/send/attribute_assignment.rb +51 -0
- data/lib/mutant/mutator/node/send/index.rb +43 -0
- data/lib/mutant/mutator/node/send.rb +7 -37
- data/lib/mutant/mutator/node.rb +4 -12
- data/lib/mutant/mutator.rb +2 -26
- data/lib/mutant/node_helpers.rb +3 -3
- data/lib/mutant/require_highjack.rb +64 -0
- data/lib/mutant/subject/method/instance.rb +9 -1
- data/lib/mutant/version.rb +1 -1
- data/lib/mutant/warning_expectation.rb +40 -0
- data/lib/mutant/warning_filter.rb +74 -0
- data/lib/mutant/zombifier/file.rb +81 -0
- data/lib/mutant/zombifier.rb +61 -240
- data/lib/mutant.rb +57 -1
- data/lib/parser_extensions.rb +25 -0
- data/mutant.gemspec +4 -3
- data/spec/integration/mutant/corpus_spec.rb +121 -0
- data/spec/integration/mutant/rspec_spec.rb +1 -1
- data/spec/integration/mutant/test_mutator_handles_types_spec.rb +1 -1
- data/spec/integration/mutant/zombie_spec.rb +3 -3
- data/spec/integrations.yml +23 -0
- data/spec/shared/mutator_behavior.rb +22 -72
- data/spec/spec_helper.rb +4 -2
- data/spec/support/mutation_verifier.rb +95 -0
- data/spec/unit/mutant/mutator/node/conditional_loop_spec.rb +16 -0
- data/spec/unit/mutant/mutator/node/match_current_line_spec.rb +4 -4
- data/spec/unit/mutant/mutator/node/named_value/access_spec.rb +6 -3
- data/spec/unit/mutant/mutator/node/nthref_spec.rb +2 -2
- data/spec/unit/mutant/mutator/node/op_assgn_spec.rb +3 -1
- data/spec/unit/mutant/mutator/node/send_spec.rb +0 -1
- data/spec/unit/mutant/require_highjack_spec.rb +54 -0
- data/spec/unit/mutant/subject/method/instance_spec.rb +34 -3
- data/spec/unit/mutant/warning_expectation.rb +71 -0
- data/spec/unit/mutant/warning_filter_spec.rb +94 -0
- metadata +40 -9
- data/lib/mutant/singleton_methods.rb +0 -30
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mutant::WarningExpectation do
|
4
|
+
let(:object) { described_class.new(expected_warnings) }
|
5
|
+
|
6
|
+
let(:expected_warnings) { [] }
|
7
|
+
let(:warnings) { [] }
|
8
|
+
|
9
|
+
let(:warning_a) { "foo.rb:10: warning: We have a problem!\n" }
|
10
|
+
let(:warning_b) { "bar.rb:10: warning: We have an other problem!\n" }
|
11
|
+
|
12
|
+
describe '#execute' do
|
13
|
+
subject { object.execute(&block) }
|
14
|
+
|
15
|
+
before do
|
16
|
+
@called = false
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:block) do
|
20
|
+
lambda do
|
21
|
+
@called = true
|
22
|
+
warnings.each(&Kernel.method(:warn))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'executes block' do
|
27
|
+
expect { subject }.to change { @called }.from(false).to(true)
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when no warnings occur during block execution' do
|
31
|
+
context 'and no warnings are expected' do
|
32
|
+
it_should_behave_like 'a command method'
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'and warnings are expected' do
|
36
|
+
let(:expected_warnings) { [warning_a] }
|
37
|
+
|
38
|
+
it 'raises an expectation error' do
|
39
|
+
expect { subject }.to raise_error(Mutant::WarningExpectation::ExpectationError.new([], [warning_a]))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'when warnings occur during block execution' do
|
45
|
+
let(:warnings) { [warning_a, warning_b] }
|
46
|
+
|
47
|
+
context 'and only some no warnings are expected' do
|
48
|
+
let(:expected_warnings) { [warning_a] }
|
49
|
+
|
50
|
+
it 'raises an expectation error' do
|
51
|
+
expect { subject }.to raise_error(Mutant::WarningExpectation::ExpectationError.new([warning_b], []))
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'and all warnings are expected' do
|
56
|
+
let(:expected_warnings) { [warning_a, warning_b] }
|
57
|
+
|
58
|
+
it_should_behave_like 'a command method'
|
59
|
+
end
|
60
|
+
|
61
|
+
context 'and there is an expected warning missing' do
|
62
|
+
let(:expected_warnings) { [warning_a] }
|
63
|
+
let(:warnings) { [warning_b] }
|
64
|
+
|
65
|
+
it 'raises an expectation error' do
|
66
|
+
expect { subject }.to raise_error(Mutant::WarningExpectation::ExpectationError.new([warning_b], [warning_a]))
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mutant::WarningFilter do
|
4
|
+
let(:object) { described_class.new(target) }
|
5
|
+
|
6
|
+
let(:target) do
|
7
|
+
writes = self.writes
|
8
|
+
Module.new do
|
9
|
+
define_singleton_method :write do |message|
|
10
|
+
writes << message
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:writes) { [] }
|
16
|
+
|
17
|
+
describe '#write' do
|
18
|
+
subject { object.write(message) }
|
19
|
+
|
20
|
+
context 'when writing a non warning message' do
|
21
|
+
let(:message) { 'foo' }
|
22
|
+
|
23
|
+
it 'writes message' do
|
24
|
+
expect { subject }.to change { writes }.from([]).to([message])
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'does not capture warning' do
|
28
|
+
subject
|
29
|
+
expect(subject.warnings).to eql([])
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when writing a warning message' do
|
34
|
+
let(:message) { "test.rb:1: warning: some warning\n" }
|
35
|
+
|
36
|
+
it 'captures warning' do
|
37
|
+
expect { subject }.to change { object.warnings }.from([]).to([message])
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'does not write message' do
|
41
|
+
subject
|
42
|
+
expect(writes).to eql([])
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '.use' do
|
48
|
+
let(:object) { described_class }
|
49
|
+
|
50
|
+
it 'executes block with warning filter enabled' do
|
51
|
+
found = false
|
52
|
+
object.use do
|
53
|
+
found = $stderr.kind_of?(described_class)
|
54
|
+
end
|
55
|
+
expect(found).to be(true)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'resets to original stderr after execution with exeception ' do
|
59
|
+
original = $stderr
|
60
|
+
begin
|
61
|
+
object.use { fail }
|
62
|
+
rescue
|
63
|
+
:make_rubo_cop_happy
|
64
|
+
end
|
65
|
+
expect($stderr).to be(original)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'returns warnings generated within block' do
|
69
|
+
warnings = object.use do
|
70
|
+
eval(<<-RUBY)
|
71
|
+
Class.new do
|
72
|
+
def foo
|
73
|
+
end
|
74
|
+
|
75
|
+
def foo
|
76
|
+
end
|
77
|
+
end
|
78
|
+
RUBY
|
79
|
+
end
|
80
|
+
expect(warnings).to eql(
|
81
|
+
[
|
82
|
+
"(eval):5: warning: method redefined; discarding old foo\n",
|
83
|
+
"(eval):2: warning: previous definition of foo was here\n"
|
84
|
+
]
|
85
|
+
)
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'resets to original stderr after execution' do
|
89
|
+
original = $stderr
|
90
|
+
object.use {}
|
91
|
+
expect($stderr).to be(original)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mutant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Markus Schirp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ast
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: diff-lcs
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +58,14 @@ dependencies:
|
|
44
58
|
requirements:
|
45
59
|
- - ~>
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.2.
|
61
|
+
version: 0.2.3
|
48
62
|
type: :runtime
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
66
|
- - ~>
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.2.
|
68
|
+
version: 0.2.3
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: procto
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +100,14 @@ dependencies:
|
|
86
100
|
requirements:
|
87
101
|
- - ~>
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.1.
|
103
|
+
version: 0.1.12
|
90
104
|
type: :runtime
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
108
|
- - ~>
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.1.
|
110
|
+
version: 0.1.12
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: ice_nine
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -184,14 +198,14 @@ dependencies:
|
|
184
198
|
requirements:
|
185
199
|
- - ~>
|
186
200
|
- !ruby/object:Gem::Version
|
187
|
-
version: 0.1.
|
201
|
+
version: 0.1.5
|
188
202
|
type: :runtime
|
189
203
|
prerelease: false
|
190
204
|
version_requirements: !ruby/object:Gem::Requirement
|
191
205
|
requirements:
|
192
206
|
- - ~>
|
193
207
|
- !ruby/object:Gem::Version
|
194
|
-
version: 0.1.
|
208
|
+
version: 0.1.5
|
195
209
|
- !ruby/object:Gem::Dependency
|
196
210
|
name: bundler
|
197
211
|
requirement: !ruby/object:Gem::Requirement
|
@@ -307,6 +321,7 @@ files:
|
|
307
321
|
- lib/mutant/mutator/node/literal/symbol.rb
|
308
322
|
- lib/mutant/mutator/node/loop_control.rb
|
309
323
|
- lib/mutant/mutator/node/masgn.rb
|
324
|
+
- lib/mutant/mutator/node/match_current_line.rb
|
310
325
|
- lib/mutant/mutator/node/mlhs.rb
|
311
326
|
- lib/mutant/mutator/node/named_value/access.rb
|
312
327
|
- lib/mutant/mutator/node/named_value/constant_assignment.rb
|
@@ -319,7 +334,9 @@ files:
|
|
319
334
|
- lib/mutant/mutator/node/restarg.rb
|
320
335
|
- lib/mutant/mutator/node/return.rb
|
321
336
|
- lib/mutant/mutator/node/send.rb
|
337
|
+
- lib/mutant/mutator/node/send/attribute_assignment.rb
|
322
338
|
- lib/mutant/mutator/node/send/binary.rb
|
339
|
+
- lib/mutant/mutator/node/send/index.rb
|
323
340
|
- lib/mutant/mutator/node/splat.rb
|
324
341
|
- lib/mutant/mutator/node/super.rb
|
325
342
|
- lib/mutant/mutator/node/when.rb
|
@@ -339,11 +356,11 @@ files:
|
|
339
356
|
- lib/mutant/reporter/cli/printer/mutation.rb
|
340
357
|
- lib/mutant/reporter/cli/printer/subject.rb
|
341
358
|
- lib/mutant/reporter/null.rb
|
359
|
+
- lib/mutant/require_highjack.rb
|
342
360
|
- lib/mutant/runner.rb
|
343
361
|
- lib/mutant/runner/config.rb
|
344
362
|
- lib/mutant/runner/mutation.rb
|
345
363
|
- lib/mutant/runner/subject.rb
|
346
|
-
- lib/mutant/singleton_methods.rb
|
347
364
|
- lib/mutant/strategy.rb
|
348
365
|
- lib/mutant/subject.rb
|
349
366
|
- lib/mutant/subject/method.rb
|
@@ -351,18 +368,25 @@ files:
|
|
351
368
|
- lib/mutant/subject/method/singleton.rb
|
352
369
|
- lib/mutant/version.rb
|
353
370
|
- lib/mutant/walker.rb
|
371
|
+
- lib/mutant/warning_expectation.rb
|
372
|
+
- lib/mutant/warning_filter.rb
|
354
373
|
- lib/mutant/zombifier.rb
|
374
|
+
- lib/mutant/zombifier/file.rb
|
375
|
+
- lib/parser_extensions.rb
|
355
376
|
- mutant-rspec.gemspec
|
356
377
|
- mutant.gemspec
|
378
|
+
- spec/integration/mutant/corpus_spec.rb
|
357
379
|
- spec/integration/mutant/rspec_spec.rb
|
358
380
|
- spec/integration/mutant/test_mutator_handles_types_spec.rb
|
359
381
|
- spec/integration/mutant/zombie_spec.rb
|
382
|
+
- spec/integrations.yml
|
360
383
|
- spec/rcov.opts
|
361
384
|
- spec/shared/method_matcher_behavior.rb
|
362
385
|
- spec/shared/mutator_behavior.rb
|
363
386
|
- spec/spec_helper.rb
|
364
387
|
- spec/support/compress_helper.rb
|
365
388
|
- spec/support/ice_nine_config.rb
|
389
|
+
- spec/support/mutation_verifier.rb
|
366
390
|
- spec/support/rspec.rb
|
367
391
|
- spec/support/test_app.rb
|
368
392
|
- spec/unit/mutant/cli/classifier/method_spec.rb
|
@@ -429,6 +453,7 @@ files:
|
|
429
453
|
- spec/unit/mutant/mutator/node/super_spec.rb
|
430
454
|
- spec/unit/mutant/mutator/node/yield_spec.rb
|
431
455
|
- spec/unit/mutant/mutator_spec.rb
|
456
|
+
- spec/unit/mutant/require_highjack_spec.rb
|
432
457
|
- spec/unit/mutant/rspec/killer_spec.rb
|
433
458
|
- spec/unit/mutant/runner/config_spec.rb
|
434
459
|
- spec/unit/mutant/runner/mutation/killer_spec.rb
|
@@ -440,6 +465,8 @@ files:
|
|
440
465
|
- spec/unit/mutant/subject/mutations_spec.rb
|
441
466
|
- spec/unit/mutant/subject/node_spec.rb
|
442
467
|
- spec/unit/mutant/subject_spec.rb
|
468
|
+
- spec/unit/mutant/warning_expectation.rb
|
469
|
+
- spec/unit/mutant/warning_filter_spec.rb
|
443
470
|
- spec/unit/mutant_spec.rb
|
444
471
|
- test_app/.rspec
|
445
472
|
- test_app/Gemfile.devtools
|
@@ -482,6 +509,7 @@ signing_key:
|
|
482
509
|
specification_version: 4
|
483
510
|
summary: Mutation testing tool for ruby under MRI and Rubinius
|
484
511
|
test_files:
|
512
|
+
- spec/integration/mutant/corpus_spec.rb
|
485
513
|
- spec/integration/mutant/rspec_spec.rb
|
486
514
|
- spec/integration/mutant/test_mutator_handles_types_spec.rb
|
487
515
|
- spec/integration/mutant/zombie_spec.rb
|
@@ -549,6 +577,7 @@ test_files:
|
|
549
577
|
- spec/unit/mutant/mutator/node/super_spec.rb
|
550
578
|
- spec/unit/mutant/mutator/node/yield_spec.rb
|
551
579
|
- spec/unit/mutant/mutator_spec.rb
|
580
|
+
- spec/unit/mutant/require_highjack_spec.rb
|
552
581
|
- spec/unit/mutant/rspec/killer_spec.rb
|
553
582
|
- spec/unit/mutant/runner/config_spec.rb
|
554
583
|
- spec/unit/mutant/runner/mutation/killer_spec.rb
|
@@ -560,5 +589,7 @@ test_files:
|
|
560
589
|
- spec/unit/mutant/subject/mutations_spec.rb
|
561
590
|
- spec/unit/mutant/subject/node_spec.rb
|
562
591
|
- spec/unit/mutant/subject_spec.rb
|
592
|
+
- spec/unit/mutant/warning_expectation.rb
|
593
|
+
- spec/unit/mutant/warning_filter_spec.rb
|
563
594
|
- spec/unit/mutant_spec.rb
|
564
595
|
has_rdoc:
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
# Singleton methods are defined here so zombie can pick them up
|
4
|
-
module Mutant
|
5
|
-
|
6
|
-
# Define instance of subclassed superclass as constant
|
7
|
-
#
|
8
|
-
# @param [Class] superclass
|
9
|
-
# @param [Symbol] name
|
10
|
-
#
|
11
|
-
# @return [self]
|
12
|
-
#
|
13
|
-
# @api private
|
14
|
-
#
|
15
|
-
def self.singleton_subclass_instance(name, superclass, &block)
|
16
|
-
klass = Class.new(superclass) do
|
17
|
-
def inspect
|
18
|
-
self.class.name
|
19
|
-
end
|
20
|
-
|
21
|
-
define_singleton_method(:name) do
|
22
|
-
"#{superclass.name}::#{name}".freeze
|
23
|
-
end
|
24
|
-
end
|
25
|
-
klass.class_eval(&block)
|
26
|
-
superclass.const_set(name, klass.new)
|
27
|
-
self
|
28
|
-
end
|
29
|
-
|
30
|
-
end # Mutant
|