mutant 0.7.4 → 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -2
- data/Changelog.md +6 -2
- data/Gemfile +1 -0
- data/config/flay.yml +1 -1
- data/config/reek.yml +1 -1
- data/lib/mutant.rb +4 -3
- data/lib/mutant/cli.rb +2 -2
- data/lib/mutant/config.rb +2 -3
- data/lib/mutant/env.rb +29 -132
- data/lib/mutant/env/bootstrap.rb +155 -0
- data/lib/mutant/expression.rb +27 -0
- data/lib/mutant/expression/namespace.rb +2 -2
- data/lib/mutant/matcher/method.rb +1 -1
- data/lib/mutant/matcher/method/instance.rb +1 -1
- data/lib/mutant/mutation.rb +2 -30
- data/lib/mutant/mutator/node/begin.rb +1 -3
- data/lib/mutant/mutator/node/if.rb +2 -2
- data/lib/mutant/reporter/cli/printer.rb +5 -4
- data/lib/mutant/result.rb +1 -1
- data/lib/mutant/runner.rb +3 -3
- data/lib/mutant/runner/sink.rb +86 -53
- data/lib/mutant/selector.rb +17 -0
- data/lib/mutant/selector/expression.rb +28 -0
- data/lib/mutant/subject.rb +1 -19
- data/lib/mutant/version.rb +1 -1
- data/mutant.gemspec +3 -3
- data/spec/spec_helper.rb +1 -1
- data/spec/support/corpus.rb +5 -5
- data/spec/support/shared_context.rb +1 -6
- data/spec/unit/mutant/cli_spec.rb +2 -2
- data/spec/unit/mutant/env/boostrap_spec.rb +130 -0
- data/spec/unit/mutant/env_spec.rb +61 -49
- data/spec/unit/mutant/expression_spec.rb +13 -0
- data/spec/unit/mutant/matcher/filter_spec.rb +1 -1
- data/spec/unit/mutant/matcher/method/instance_spec.rb +1 -1
- data/spec/unit/mutant/matcher/method/singleton_spec.rb +1 -1
- data/spec/unit/mutant/mutation_spec.rb +0 -36
- data/spec/unit/mutant/reporter/trace_spec.rb +1 -1
- data/spec/unit/mutant/require_highjack_spec.rb +2 -4
- data/spec/unit/mutant/result/subject_spec.rb +2 -1
- data/spec/unit/mutant/runner/{sink_spec.rb → sink/mutation_spec.rb} +1 -3
- data/spec/unit/mutant/runner_spec.rb +4 -3
- data/spec/unit/mutant/selector/expression_spec.rb +60 -0
- data/spec/unit/mutant/subject/method/instance_spec.rb +3 -5
- data/spec/unit/mutant/subject/method/singleton_spec.rb +2 -3
- data/spec/unit/mutant/subject_spec.rb +1 -53
- data/spec/unit/mutant/warning_filter_spec.rb +2 -4
- metadata +18 -15
- data/lib/mutant/line_trace.rb +0 -34
- data/spec/unit/mutant/line_trace_spec.rb +0 -38
- data/spec/unit/mutant/subject/context_spec.rb +0 -16
@@ -5,11 +5,9 @@ RSpec.describe Mutant::RequireHighjack do
|
|
5
5
|
let(:require_calls) { [] }
|
6
6
|
|
7
7
|
let(:target) do
|
8
|
-
|
8
|
+
acc = require_calls
|
9
9
|
Module.new do
|
10
|
-
define_method(:require)
|
11
|
-
require_calls << logical_name
|
12
|
-
end
|
10
|
+
define_method(:require, &acc.method(:<<))
|
13
11
|
module_function :require
|
14
12
|
end
|
15
13
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
RSpec.describe Mutant::Runner do
|
2
2
|
# setup_shared_context
|
3
3
|
class FakeEnv
|
4
|
-
def self.
|
4
|
+
def self.kill
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.mutations
|
@@ -30,6 +30,7 @@ RSpec.describe Mutant::Runner do
|
|
30
30
|
|
31
31
|
before do
|
32
32
|
allow(FakeEnv).to receive(:config).and_return(config)
|
33
|
+
allow(FakeEnv).to receive(:actor_env).and_return(actor_env)
|
33
34
|
end
|
34
35
|
|
35
36
|
let(:parallel_config) do
|
@@ -37,8 +38,8 @@ RSpec.describe Mutant::Runner do
|
|
37
38
|
jobs: 1,
|
38
39
|
env: actor_env,
|
39
40
|
source: Mutant::Parallel::Source::Array.new(env.mutations),
|
40
|
-
sink: Mutant::Runner::Sink.new(env),
|
41
|
-
processor: env.method(:
|
41
|
+
sink: Mutant::Runner::Sink::Mutation.new(env),
|
42
|
+
processor: env.method(:kill)
|
42
43
|
)
|
43
44
|
end
|
44
45
|
|
@@ -0,0 +1,60 @@
|
|
1
|
+
RSpec.describe Mutant::Selector::Expression do
|
2
|
+
describe '#call' do
|
3
|
+
let(:object) { described_class.new(integration) }
|
4
|
+
|
5
|
+
let(:subject_class) do
|
6
|
+
Class.new(Mutant::Subject) do
|
7
|
+
def expression
|
8
|
+
Mutant::Expression.parse('SubjectA')
|
9
|
+
end
|
10
|
+
|
11
|
+
def match_expressions
|
12
|
+
[expression] << Mutant::Expression.parse('SubjectB')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:mutation_subject) { subject_class.new(context, node) }
|
18
|
+
let(:context) { double('Context') }
|
19
|
+
let(:node) { double('Node') }
|
20
|
+
|
21
|
+
let(:config) { Mutant::Config::DEFAULT.update(integration: integration) }
|
22
|
+
let(:integration) { double('Integration', all_tests: all_tests) }
|
23
|
+
|
24
|
+
let(:test_a) { double('test a', expression: Mutant::Expression.parse('SubjectA')) }
|
25
|
+
let(:test_b) { double('test b', expression: Mutant::Expression.parse('SubjectB')) }
|
26
|
+
let(:test_c) { double('test c', expression: Mutant::Expression.parse('SubjectC')) }
|
27
|
+
|
28
|
+
subject { object.call(mutation_subject) }
|
29
|
+
|
30
|
+
context 'without available tests' do
|
31
|
+
let(:all_tests) { [] }
|
32
|
+
|
33
|
+
it { should eql([]) }
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'without qualifying tests' do
|
37
|
+
let(:all_tests) { [test_c] }
|
38
|
+
|
39
|
+
it { should eql([]) }
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'with qualifying tests for first match expression' do
|
43
|
+
let(:all_tests) { [test_a] }
|
44
|
+
|
45
|
+
it { should eql([test_a]) }
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'with qualifying tests for second match expression' do
|
49
|
+
let(:all_tests) { [test_b] }
|
50
|
+
|
51
|
+
it { should eql([test_b]) }
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'with qualifying tests for the first and second match expression' do
|
55
|
+
let(:all_tests) { [test_a, test_b] }
|
56
|
+
|
57
|
+
it { should eql([test_a]) }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
RSpec.describe Mutant::Subject::Method::Instance do
|
2
|
-
let(:object) { described_class.new(
|
2
|
+
let(:object) { described_class.new(context, node) }
|
3
3
|
let(:context) { Mutant::Context::Scope.new(scope, double('Source Path')) }
|
4
|
-
let(:config) { Mutant::Config::DEFAULT }
|
5
4
|
|
6
5
|
let(:node) do
|
7
6
|
s(:def, :foo, s(:args))
|
@@ -91,9 +90,8 @@ RSpec.describe Mutant::Subject::Method::Instance do
|
|
91
90
|
end
|
92
91
|
|
93
92
|
RSpec.describe Mutant::Subject::Method::Instance::Memoized do
|
94
|
-
let(:object) { described_class.new(
|
95
|
-
let(:context) { double
|
96
|
-
let(:config) { Mutant::Config::DEFAULT }
|
93
|
+
let(:object) { described_class.new(context, node) }
|
94
|
+
let(:context) { double('Context') }
|
97
95
|
|
98
96
|
let(:node) do
|
99
97
|
s(:def, :foo, s(:args))
|
@@ -1,8 +1,7 @@
|
|
1
1
|
RSpec.describe Mutant::Subject::Method::Singleton do
|
2
2
|
|
3
|
-
let(:object) { described_class.new(
|
4
|
-
let(:
|
5
|
-
let(:node) { s(:defs, s(:self), :foo, s(:args)) }
|
3
|
+
let(:object) { described_class.new(context, node) }
|
4
|
+
let(:node) { s(:defs, s(:self), :foo, s(:args)) }
|
6
5
|
|
7
6
|
let(:context) do
|
8
7
|
Mutant::Context::Scope.new(scope, double('Source Path'))
|
@@ -11,9 +11,7 @@ RSpec.describe Mutant::Subject do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
let(:object) { class_under_test.new(
|
15
|
-
|
16
|
-
let(:config) { Mutant::Config::DEFAULT }
|
14
|
+
let(:object) { class_under_test.new(context, node) }
|
17
15
|
|
18
16
|
let(:node) do
|
19
17
|
Parser::CurrentRuby.parse(<<-RUBY)
|
@@ -62,56 +60,6 @@ RSpec.describe Mutant::Subject do
|
|
62
60
|
it_should_behave_like 'a command method'
|
63
61
|
end
|
64
62
|
|
65
|
-
describe '#tests' do
|
66
|
-
let(:config) { Mutant::Config::DEFAULT.update(integration: integration) }
|
67
|
-
let(:integration) { double('Integration', all_tests: all_tests) }
|
68
|
-
let(:test_a) { double('test', expression: Mutant::Expression.parse('SubjectA')) }
|
69
|
-
let(:test_b) { double('test', expression: Mutant::Expression.parse('SubjectB')) }
|
70
|
-
let(:test_c) { double('test', expression: Mutant::Expression.parse('SubjectC')) }
|
71
|
-
|
72
|
-
subject { object.tests }
|
73
|
-
|
74
|
-
context 'without available tests' do
|
75
|
-
let(:all_tests) { [] }
|
76
|
-
|
77
|
-
it { should eql([]) }
|
78
|
-
|
79
|
-
it_should_behave_like 'an idempotent method'
|
80
|
-
end
|
81
|
-
|
82
|
-
context 'without qualifying tests' do
|
83
|
-
let(:all_tests) { [test_c] }
|
84
|
-
|
85
|
-
it { should eql([]) }
|
86
|
-
|
87
|
-
it_should_behave_like 'an idempotent method'
|
88
|
-
end
|
89
|
-
|
90
|
-
context 'with qualifying tests for first match expression' do
|
91
|
-
let(:all_tests) { [test_a] }
|
92
|
-
|
93
|
-
it { should eql([test_a]) }
|
94
|
-
|
95
|
-
it_should_behave_like 'an idempotent method'
|
96
|
-
end
|
97
|
-
|
98
|
-
context 'with qualifying tests for second match expression' do
|
99
|
-
let(:all_tests) { [test_b] }
|
100
|
-
|
101
|
-
it { should eql([test_b]) }
|
102
|
-
|
103
|
-
it_should_behave_like 'an idempotent method'
|
104
|
-
end
|
105
|
-
|
106
|
-
context 'with qualifying tests for the first and second match expression' do
|
107
|
-
let(:all_tests) { [test_a, test_b] }
|
108
|
-
|
109
|
-
it { should eql([test_a]) }
|
110
|
-
|
111
|
-
it_should_behave_like 'an idempotent method'
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
63
|
describe '#node' do
|
116
64
|
subject { object.node }
|
117
65
|
|
@@ -8,11 +8,9 @@ RSpec.describe Mutant::WarningFilter do
|
|
8
8
|
let(:object) { described_class.new(target) }
|
9
9
|
|
10
10
|
let(:target) do
|
11
|
-
|
11
|
+
acc = writes
|
12
12
|
Module.new do
|
13
|
-
define_singleton_method
|
14
|
-
writes << message
|
15
|
-
end
|
13
|
+
define_singleton_method(:write, &acc.method(:<<))
|
16
14
|
end
|
17
15
|
end
|
18
16
|
|
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.7.
|
4
|
+
version: 0.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Markus Schirp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.2.
|
19
|
+
version: 2.2.0.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.2.
|
26
|
+
version: 2.2.0.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: ast
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.
|
117
|
+
version: 0.2.2
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.
|
124
|
+
version: 0.2.2
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: ice_nine
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -295,13 +295,13 @@ files:
|
|
295
295
|
- lib/mutant/delegator.rb
|
296
296
|
- lib/mutant/diff.rb
|
297
297
|
- lib/mutant/env.rb
|
298
|
+
- lib/mutant/env/bootstrap.rb
|
298
299
|
- lib/mutant/expression.rb
|
299
300
|
- lib/mutant/expression/method.rb
|
300
301
|
- lib/mutant/expression/methods.rb
|
301
302
|
- lib/mutant/expression/namespace.rb
|
302
303
|
- lib/mutant/integration.rb
|
303
304
|
- lib/mutant/isolation.rb
|
304
|
-
- lib/mutant/line_trace.rb
|
305
305
|
- lib/mutant/loader.rb
|
306
306
|
- lib/mutant/matcher.rb
|
307
307
|
- lib/mutant/matcher/chain.rb
|
@@ -393,6 +393,8 @@ files:
|
|
393
393
|
- lib/mutant/result.rb
|
394
394
|
- lib/mutant/runner.rb
|
395
395
|
- lib/mutant/runner/sink.rb
|
396
|
+
- lib/mutant/selector.rb
|
397
|
+
- lib/mutant/selector/expression.rb
|
396
398
|
- lib/mutant/subject.rb
|
397
399
|
- lib/mutant/subject/method.rb
|
398
400
|
- lib/mutant/subject/method/instance.rb
|
@@ -489,6 +491,7 @@ files:
|
|
489
491
|
- spec/unit/mutant/context/scope/unqualified_name_spec.rb
|
490
492
|
- spec/unit/mutant/context_spec.rb
|
491
493
|
- spec/unit/mutant/diff_spec.rb
|
494
|
+
- spec/unit/mutant/env/boostrap_spec.rb
|
492
495
|
- spec/unit/mutant/env_spec.rb
|
493
496
|
- spec/unit/mutant/expression/method_spec.rb
|
494
497
|
- spec/unit/mutant/expression/methods_spec.rb
|
@@ -497,7 +500,6 @@ files:
|
|
497
500
|
- spec/unit/mutant/expression_spec.rb
|
498
501
|
- spec/unit/mutant/integration_spec.rb
|
499
502
|
- spec/unit/mutant/isolation_spec.rb
|
500
|
-
- spec/unit/mutant/line_trace_spec.rb
|
501
503
|
- spec/unit/mutant/loader/eval_spec.rb
|
502
504
|
- spec/unit/mutant/matcher/chain_spec.rb
|
503
505
|
- spec/unit/mutant/matcher/compiler/subject_prefix_spec.rb
|
@@ -523,9 +525,9 @@ files:
|
|
523
525
|
- spec/unit/mutant/result/env_spec.rb
|
524
526
|
- spec/unit/mutant/result/subject_spec.rb
|
525
527
|
- spec/unit/mutant/runner/driver_spec.rb
|
526
|
-
- spec/unit/mutant/runner/
|
528
|
+
- spec/unit/mutant/runner/sink/mutation_spec.rb
|
527
529
|
- spec/unit/mutant/runner_spec.rb
|
528
|
-
- spec/unit/mutant/
|
530
|
+
- spec/unit/mutant/selector/expression_spec.rb
|
529
531
|
- spec/unit/mutant/subject/method/instance_spec.rb
|
530
532
|
- spec/unit/mutant/subject/method/singleton_spec.rb
|
531
533
|
- spec/unit/mutant/subject_spec.rb
|
@@ -552,7 +554,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
552
554
|
requirements:
|
553
555
|
- - ">="
|
554
556
|
- !ruby/object:Gem::Version
|
555
|
-
version:
|
557
|
+
version: 1.9.3
|
556
558
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
557
559
|
requirements:
|
558
560
|
- - ">="
|
@@ -560,7 +562,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
560
562
|
version: '0'
|
561
563
|
requirements: []
|
562
564
|
rubyforge_project:
|
563
|
-
rubygems_version: 2.
|
565
|
+
rubygems_version: 2.4.5
|
564
566
|
signing_key:
|
565
567
|
specification_version: 4
|
566
568
|
summary: Mutation testing tool for ruby under MRI and Rubinius
|
@@ -583,6 +585,7 @@ test_files:
|
|
583
585
|
- spec/unit/mutant/context/scope/unqualified_name_spec.rb
|
584
586
|
- spec/unit/mutant/context_spec.rb
|
585
587
|
- spec/unit/mutant/diff_spec.rb
|
588
|
+
- spec/unit/mutant/env/boostrap_spec.rb
|
586
589
|
- spec/unit/mutant/env_spec.rb
|
587
590
|
- spec/unit/mutant/expression/method_spec.rb
|
588
591
|
- spec/unit/mutant/expression/methods_spec.rb
|
@@ -591,7 +594,6 @@ test_files:
|
|
591
594
|
- spec/unit/mutant/expression_spec.rb
|
592
595
|
- spec/unit/mutant/integration_spec.rb
|
593
596
|
- spec/unit/mutant/isolation_spec.rb
|
594
|
-
- spec/unit/mutant/line_trace_spec.rb
|
595
597
|
- spec/unit/mutant/loader/eval_spec.rb
|
596
598
|
- spec/unit/mutant/matcher/chain_spec.rb
|
597
599
|
- spec/unit/mutant/matcher/compiler/subject_prefix_spec.rb
|
@@ -617,11 +619,12 @@ test_files:
|
|
617
619
|
- spec/unit/mutant/result/env_spec.rb
|
618
620
|
- spec/unit/mutant/result/subject_spec.rb
|
619
621
|
- spec/unit/mutant/runner/driver_spec.rb
|
620
|
-
- spec/unit/mutant/runner/
|
622
|
+
- spec/unit/mutant/runner/sink/mutation_spec.rb
|
621
623
|
- spec/unit/mutant/runner_spec.rb
|
622
|
-
- spec/unit/mutant/
|
624
|
+
- spec/unit/mutant/selector/expression_spec.rb
|
623
625
|
- spec/unit/mutant/subject/method/instance_spec.rb
|
624
626
|
- spec/unit/mutant/subject/method/singleton_spec.rb
|
625
627
|
- spec/unit/mutant/subject_spec.rb
|
626
628
|
- spec/unit/mutant/warning_filter_spec.rb
|
627
629
|
- spec/unit/mutant_spec.rb
|
630
|
+
has_rdoc:
|
data/lib/mutant/line_trace.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
module Mutant
|
2
|
-
# Line tracer
|
3
|
-
class LineTrace
|
4
|
-
include Adamantium::Flat, Concord.new(:contents)
|
5
|
-
|
6
|
-
private_class_method :new
|
7
|
-
|
8
|
-
# Test if trace coveres file at lineno
|
9
|
-
#
|
10
|
-
# @param [String] file
|
11
|
-
# @param [Fixnum] lineno
|
12
|
-
#
|
13
|
-
# @return [Boolean]
|
14
|
-
#
|
15
|
-
def cover?(file, lineno)
|
16
|
-
contents.fetch(file) { return false }.include?(lineno)
|
17
|
-
end
|
18
|
-
|
19
|
-
# Run block
|
20
|
-
#
|
21
|
-
# @return [Traces]
|
22
|
-
#
|
23
|
-
# @api private
|
24
|
-
#
|
25
|
-
def self.call(&block)
|
26
|
-
traces = Hash.new { |hash, file| hash[file] = Set.new }
|
27
|
-
TracePoint.trace(:return, :line) do |point|
|
28
|
-
traces[point.path] << point.lineno
|
29
|
-
end.tap(&block).disable
|
30
|
-
new(IceNine.deep_freeze(traces))
|
31
|
-
end
|
32
|
-
|
33
|
-
end # LineTrace
|
34
|
-
end # Mutant
|
@@ -1,38 +0,0 @@
|
|
1
|
-
RSpec.describe Mutant::LineTrace do
|
2
|
-
let(:object) { described_class }
|
3
|
-
|
4
|
-
test_a_line = __LINE__ + 2
|
5
|
-
def test_a
|
6
|
-
test_b
|
7
|
-
end
|
8
|
-
|
9
|
-
test_b_line = __LINE__ + 2
|
10
|
-
def test_b
|
11
|
-
end
|
12
|
-
|
13
|
-
test_c_line = __LINE__ + 2
|
14
|
-
def test_c
|
15
|
-
end
|
16
|
-
|
17
|
-
shared_examples_for 'line trace' do
|
18
|
-
it 'returns correct trace results' do
|
19
|
-
expect(subject.cover?(__FILE__, test_a_line)).to be(true)
|
20
|
-
expect(subject.cover?(__FILE__, test_b_line)).to be(true)
|
21
|
-
expect(subject.cover?(__FILE__, test_c_line)).to be(false)
|
22
|
-
expect(subject.cover?(__FILE__, __LINE__)).to be(false)
|
23
|
-
expect(subject.cover?('/dev/null', test_a_line)).to be(false)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '.cover?' do
|
28
|
-
subject { object.call { test_a } }
|
29
|
-
|
30
|
-
include_examples 'line trace'
|
31
|
-
end
|
32
|
-
|
33
|
-
describe '.call' do
|
34
|
-
subject { object.call { test_a } }
|
35
|
-
|
36
|
-
include_examples 'line trace'
|
37
|
-
end
|
38
|
-
end
|