mutant 0.7.8 → 0.7.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Changelog.md +5 -0
- data/README.md +11 -29
- data/config/flay.yml +1 -1
- data/config/reek.yml +1 -0
- data/lib/mutant.rb +3 -3
- data/lib/mutant/cli.rb +12 -9
- data/lib/mutant/integration.rb +13 -0
- data/lib/mutant/meta/example.rb +2 -2
- data/lib/mutant/reporter/cli.rb +3 -2
- data/lib/mutant/reporter/cli/printer.rb +2 -2
- data/lib/mutant/reporter/cli/tput.rb +29 -11
- data/lib/mutant/result.rb +0 -2
- data/lib/mutant/version.rb +1 -1
- data/meta/and.rb +0 -2
- data/meta/and_asgn.rb +0 -2
- data/meta/array.rb +0 -2
- data/meta/begin.rb +0 -2
- data/meta/block.rb +0 -2
- data/meta/block_pass.rb +0 -2
- data/meta/blockarg.rb +0 -2
- data/meta/boolean.rb +0 -2
- data/meta/break.rb +0 -2
- data/meta/case.rb +0 -2
- data/meta/casgn.rb +0 -2
- data/meta/cbase.rb +0 -2
- data/meta/const.rb +0 -2
- data/meta/cvar.rb +0 -2
- data/meta/cvasgn.rb +0 -2
- data/meta/def.rb +0 -2
- data/meta/defined.rb +0 -2
- data/meta/dstr.rb +0 -2
- data/meta/dsym.rb +0 -2
- data/meta/ensure.rb +0 -2
- data/meta/false.rb +0 -2
- data/meta/float.rb +0 -2
- data/meta/gvar.rb +0 -2
- data/meta/gvasgn.rb +0 -2
- data/meta/hash.rb +0 -2
- data/meta/if.rb +0 -2
- data/meta/int.rb +0 -2
- data/meta/ivasgn.rb +0 -2
- data/meta/kwbegin.rb +0 -2
- data/meta/lvar.rb +0 -2
- data/meta/lvasgn.rb +0 -2
- data/meta/masgn.rb +0 -2
- data/meta/match_current_line.rb +0 -2
- data/meta/next.rb +0 -2
- data/meta/nil.rb +0 -2
- data/meta/nthref.rb +0 -2
- data/meta/op_assgn.rb +0 -2
- data/meta/or.rb +0 -2
- data/meta/or_asgn.rb +0 -2
- data/meta/range.rb +0 -2
- data/meta/redo.rb +0 -2
- data/meta/regex.rb +0 -2
- data/meta/rescue.rb +0 -2
- data/meta/restarg.rb +0 -2
- data/meta/return.rb +0 -2
- data/meta/self.rb +0 -2
- data/meta/send.rb +0 -2
- data/meta/str.rb +0 -2
- data/meta/super.rb +0 -2
- data/meta/symbol.rb +0 -2
- data/meta/true.rb +0 -2
- data/meta/until.rb +0 -2
- data/meta/while.rb +0 -2
- data/meta/yield.rb +0 -2
- data/mutant-rspec.gemspec +1 -1
- data/mutant.gemspec +3 -3
- data/spec/integration/mutant/rspec_spec.rb +3 -39
- data/spec/shared/framework_integration_behavior.rb +35 -0
- data/spec/unit/mutant/cli_spec.rb +34 -1
- data/spec/unit/mutant/env_spec.rb +0 -1
- data/spec/unit/mutant/integration/rspec_spec.rb +193 -0
- data/spec/unit/mutant/loader/eval_spec.rb +1 -1
- data/spec/unit/mutant/matcher/methods/instance_spec.rb +22 -21
- data/spec/unit/mutant/matcher/methods/singleton_spec.rb +21 -19
- data/spec/unit/mutant/parallel/worker_spec.rb +0 -2
- data/spec/unit/mutant/reporter/cli/tput_spec.rb +48 -0
- data/spec/unit/mutant/reporter/cli_spec.rb +29 -9
- data/test_app/Gemfile.rspec3.0 +1 -0
- data/test_app/Gemfile.rspec3.1 +1 -0
- data/test_app/Gemfile.rspec3.2 +1 -0
- data/test_app/lib/test_app.rb +1 -1
- data/test_app/lib/test_app/literal.rb +0 -2
- data/test_app/spec/spec_helper.rb +0 -2
- data/test_app/spec/unit/test_app/literal_spec.rb +22 -0
- metadata +15 -5
- data/test_app/spec/unit/test_app/literal/command_spec.rb +0 -11
- data/test_app/spec/unit/test_app/literal/string_spec.rb +0 -11
data/meta/cvasgn.rb
CHANGED
data/meta/def.rb
CHANGED
data/meta/defined.rb
CHANGED
data/meta/dstr.rb
CHANGED
data/meta/dsym.rb
CHANGED
data/meta/ensure.rb
CHANGED
data/meta/false.rb
CHANGED
data/meta/float.rb
CHANGED
data/meta/gvar.rb
CHANGED
data/meta/gvasgn.rb
CHANGED
data/meta/hash.rb
CHANGED
data/meta/if.rb
CHANGED
data/meta/int.rb
CHANGED
data/meta/ivasgn.rb
CHANGED
data/meta/kwbegin.rb
CHANGED
data/meta/lvar.rb
CHANGED
data/meta/lvasgn.rb
CHANGED
data/meta/masgn.rb
CHANGED
data/meta/match_current_line.rb
CHANGED
data/meta/next.rb
CHANGED
data/meta/nil.rb
CHANGED
data/meta/nthref.rb
CHANGED
data/meta/op_assgn.rb
CHANGED
data/meta/or.rb
CHANGED
data/meta/or_asgn.rb
CHANGED
data/meta/range.rb
CHANGED
data/meta/redo.rb
CHANGED
data/meta/regex.rb
CHANGED
data/meta/rescue.rb
CHANGED
data/meta/restarg.rb
CHANGED
data/meta/return.rb
CHANGED
data/meta/self.rb
CHANGED
data/meta/send.rb
CHANGED
data/meta/str.rb
CHANGED
data/meta/super.rb
CHANGED
data/meta/symbol.rb
CHANGED
data/meta/true.rb
CHANGED
data/meta/until.rb
CHANGED
data/meta/while.rb
CHANGED
data/meta/yield.rb
CHANGED
data/mutant-rspec.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
|
|
14
14
|
|
15
15
|
gem.require_paths = %w[lib]
|
16
16
|
gem.files = `git ls-files -- lib/mutant/integration/rspec.rb`.split("\n")
|
17
|
-
gem.test_files = `git ls-files -- spec/{unit
|
17
|
+
gem.test_files = `git ls-files -- spec/{integration,unit}/mutant/rspec_spec.rb}`.split("\n")
|
18
18
|
gem.extra_rdoc_files = %w[TODO LICENSE]
|
19
19
|
|
20
20
|
gem.add_runtime_dependency('mutant', "~> #{gem.version}")
|
data/mutant.gemspec
CHANGED
@@ -14,16 +14,16 @@ Gem::Specification.new do |gem|
|
|
14
14
|
|
15
15
|
gem.require_paths = %w[lib]
|
16
16
|
|
17
|
-
|
17
|
+
mutant_integration_files = `git ls-files -- lib/mutant/integration/*.rb`.split("\n")
|
18
18
|
|
19
|
-
gem.files = `git ls-files`.split("\n") -
|
19
|
+
gem.files = `git ls-files`.split("\n") - mutant_integration_files
|
20
20
|
gem.test_files = `git ls-files -- spec/{unit,integration}`.split("\n")
|
21
21
|
gem.extra_rdoc_files = %w[TODO LICENSE]
|
22
22
|
gem.executables = %w[mutant]
|
23
23
|
|
24
24
|
gem.required_ruby_version = '>= 1.9.3'
|
25
25
|
|
26
|
-
gem.add_runtime_dependency('parser', '~> 2.2.0.2')
|
26
|
+
gem.add_runtime_dependency('parser', '~> 2.2', '>= 2.2.0.2')
|
27
27
|
gem.add_runtime_dependency('ast', '~> 2.0')
|
28
28
|
gem.add_runtime_dependency('diff-lcs', '~> 1.2')
|
29
29
|
gem.add_runtime_dependency('parallel', '~> 1.3')
|
@@ -2,57 +2,21 @@ RSpec.describe 'rspec integration', mutant: false do
|
|
2
2
|
|
3
3
|
let(:base_cmd) { 'bundle exec mutant -I lib --require test_app --use rspec' }
|
4
4
|
|
5
|
-
shared_examples_for 'rspec integration' do
|
6
|
-
around do |example|
|
7
|
-
Bundler.with_clean_env do
|
8
|
-
Dir.chdir(TestApp.root) do
|
9
|
-
Kernel.system("bundle install --gemfile=#{gemfile}") || fail('Bundle install failed!')
|
10
|
-
ENV['BUNDLE_GEMFILE'] = gemfile
|
11
|
-
example.run
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
specify 'it allows to kill mutations' do
|
17
|
-
expect(Kernel.system("#{base_cmd} TestApp::Literal#string")).to be(true)
|
18
|
-
end
|
19
|
-
|
20
|
-
specify 'it allows to exclude mutations' do
|
21
|
-
cli = <<-CMD.split("\n").join(' ')
|
22
|
-
#{base_cmd}
|
23
|
-
TestApp::Literal#string
|
24
|
-
TestApp::Literal#uncovered_string
|
25
|
-
--ignore-subject TestApp::Literal#uncovered_string
|
26
|
-
CMD
|
27
|
-
expect(Kernel.system(cli)).to be(true)
|
28
|
-
end
|
29
|
-
|
30
|
-
specify 'fails to kill mutations when they are not covered' do
|
31
|
-
cli = "#{base_cmd} TestApp::Literal#uncovered_string"
|
32
|
-
expect(Kernel.system(cli)).to be(false)
|
33
|
-
end
|
34
|
-
|
35
|
-
specify 'fails when some mutations are not covered' do
|
36
|
-
cli = "#{base_cmd} TestApp::Literal"
|
37
|
-
expect(Kernel.system(cli)).to be(false)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
5
|
context 'RSpec 3.0' do
|
42
6
|
let(:gemfile) { 'Gemfile.rspec3.0' }
|
43
7
|
|
44
|
-
it_behaves_like '
|
8
|
+
it_behaves_like 'framework integration'
|
45
9
|
end
|
46
10
|
|
47
11
|
context 'RSpec 3.1' do
|
48
12
|
let(:gemfile) { 'Gemfile.rspec3.1' }
|
49
13
|
|
50
|
-
it_behaves_like '
|
14
|
+
it_behaves_like 'framework integration'
|
51
15
|
end
|
52
16
|
|
53
17
|
context 'RSpec 3.2' do
|
54
18
|
let(:gemfile) { 'Gemfile.rspec3.2' }
|
55
19
|
|
56
|
-
it_behaves_like '
|
20
|
+
it_behaves_like 'framework integration'
|
57
21
|
end
|
58
22
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
RSpec.shared_examples_for 'framework integration' do
|
2
|
+
around do |example|
|
3
|
+
Bundler.with_clean_env do
|
4
|
+
Dir.chdir(TestApp.root) do
|
5
|
+
Kernel.system("bundle install --gemfile=#{gemfile}") || fail('Bundle install failed!')
|
6
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
7
|
+
example.run
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
specify 'it allows to kill mutations' do
|
13
|
+
expect(Kernel.system("#{base_cmd} TestApp::Literal#string")).to be(true)
|
14
|
+
end
|
15
|
+
|
16
|
+
specify 'it allows to exclude mutations' do
|
17
|
+
cli = <<-CMD.split("\n").join(' ')
|
18
|
+
#{base_cmd}
|
19
|
+
TestApp::Literal#string
|
20
|
+
TestApp::Literal#uncovered_string
|
21
|
+
--ignore-subject TestApp::Literal#uncovered_string
|
22
|
+
CMD
|
23
|
+
expect(Kernel.system(cli)).to be(true)
|
24
|
+
end
|
25
|
+
|
26
|
+
specify 'fails to kill mutations when they are not covered' do
|
27
|
+
cli = "#{base_cmd} TestApp::Literal#uncovered_string"
|
28
|
+
expect(Kernel.system(cli)).to be(false)
|
29
|
+
end
|
30
|
+
|
31
|
+
specify 'fails when some mutations are not covered' do
|
32
|
+
cli = "#{base_cmd} TestApp::Literal"
|
33
|
+
expect(Kernel.system(cli)).to be(false)
|
34
|
+
end
|
35
|
+
end
|
@@ -132,7 +132,8 @@ Environment:
|
|
132
132
|
-j, --jobs NUMBER Number of kill jobs. Defaults to number of processors.
|
133
133
|
|
134
134
|
Options:
|
135
|
-
--
|
135
|
+
--expected-coverage COVERAGE Fail unless COVERAGE is not reached exactly, parsed via Rational()
|
136
|
+
--score COVERAGE Fail unless COVERAGE is not reached exactly [deprecated]
|
136
137
|
--use STRATEGY Use STRATEGY for killing mutations
|
137
138
|
--ignore-subject PATTERN Ignore subjects that match PATTERN
|
138
139
|
--code CODE Scope execution to subjects with CODE
|
@@ -196,6 +197,38 @@ Options:
|
|
196
197
|
end
|
197
198
|
end
|
198
199
|
|
200
|
+
context 'with expected-coverage flag' do
|
201
|
+
context 'given as decimal' do
|
202
|
+
let(:flags) { %w[--expected-coverage 0.1] }
|
203
|
+
|
204
|
+
it_should_behave_like 'a cli parser'
|
205
|
+
|
206
|
+
it 'configures expected coverage' do
|
207
|
+
expect(subject.config.expected_coverage).to eql(Rational(1, 10))
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
context 'given as scientific' do
|
212
|
+
let(:flags) { %w[--expected-coverage 1e-1] }
|
213
|
+
|
214
|
+
it_should_behave_like 'a cli parser'
|
215
|
+
|
216
|
+
it 'configures expected coverage' do
|
217
|
+
expect(subject.config.expected_coverage).to eql(Rational(1, 10))
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
context 'given as rational' do
|
222
|
+
let(:flags) { %w[--expected-coverage 1/10] }
|
223
|
+
|
224
|
+
it_should_behave_like 'a cli parser'
|
225
|
+
|
226
|
+
it 'configures expected coverage' do
|
227
|
+
expect(subject.config.expected_coverage).to eql(Rational(1, 10))
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
199
232
|
context 'with score flag' do
|
200
233
|
let(:flags) { %w[--score 50.0] }
|
201
234
|
|