mutant 0.7.8 → 0.7.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/Changelog.md +5 -0
  4. data/README.md +11 -29
  5. data/config/flay.yml +1 -1
  6. data/config/reek.yml +1 -0
  7. data/lib/mutant.rb +3 -3
  8. data/lib/mutant/cli.rb +12 -9
  9. data/lib/mutant/integration.rb +13 -0
  10. data/lib/mutant/meta/example.rb +2 -2
  11. data/lib/mutant/reporter/cli.rb +3 -2
  12. data/lib/mutant/reporter/cli/printer.rb +2 -2
  13. data/lib/mutant/reporter/cli/tput.rb +29 -11
  14. data/lib/mutant/result.rb +0 -2
  15. data/lib/mutant/version.rb +1 -1
  16. data/meta/and.rb +0 -2
  17. data/meta/and_asgn.rb +0 -2
  18. data/meta/array.rb +0 -2
  19. data/meta/begin.rb +0 -2
  20. data/meta/block.rb +0 -2
  21. data/meta/block_pass.rb +0 -2
  22. data/meta/blockarg.rb +0 -2
  23. data/meta/boolean.rb +0 -2
  24. data/meta/break.rb +0 -2
  25. data/meta/case.rb +0 -2
  26. data/meta/casgn.rb +0 -2
  27. data/meta/cbase.rb +0 -2
  28. data/meta/const.rb +0 -2
  29. data/meta/cvar.rb +0 -2
  30. data/meta/cvasgn.rb +0 -2
  31. data/meta/def.rb +0 -2
  32. data/meta/defined.rb +0 -2
  33. data/meta/dstr.rb +0 -2
  34. data/meta/dsym.rb +0 -2
  35. data/meta/ensure.rb +0 -2
  36. data/meta/false.rb +0 -2
  37. data/meta/float.rb +0 -2
  38. data/meta/gvar.rb +0 -2
  39. data/meta/gvasgn.rb +0 -2
  40. data/meta/hash.rb +0 -2
  41. data/meta/if.rb +0 -2
  42. data/meta/int.rb +0 -2
  43. data/meta/ivasgn.rb +0 -2
  44. data/meta/kwbegin.rb +0 -2
  45. data/meta/lvar.rb +0 -2
  46. data/meta/lvasgn.rb +0 -2
  47. data/meta/masgn.rb +0 -2
  48. data/meta/match_current_line.rb +0 -2
  49. data/meta/next.rb +0 -2
  50. data/meta/nil.rb +0 -2
  51. data/meta/nthref.rb +0 -2
  52. data/meta/op_assgn.rb +0 -2
  53. data/meta/or.rb +0 -2
  54. data/meta/or_asgn.rb +0 -2
  55. data/meta/range.rb +0 -2
  56. data/meta/redo.rb +0 -2
  57. data/meta/regex.rb +0 -2
  58. data/meta/rescue.rb +0 -2
  59. data/meta/restarg.rb +0 -2
  60. data/meta/return.rb +0 -2
  61. data/meta/self.rb +0 -2
  62. data/meta/send.rb +0 -2
  63. data/meta/str.rb +0 -2
  64. data/meta/super.rb +0 -2
  65. data/meta/symbol.rb +0 -2
  66. data/meta/true.rb +0 -2
  67. data/meta/until.rb +0 -2
  68. data/meta/while.rb +0 -2
  69. data/meta/yield.rb +0 -2
  70. data/mutant-rspec.gemspec +1 -1
  71. data/mutant.gemspec +3 -3
  72. data/spec/integration/mutant/rspec_spec.rb +3 -39
  73. data/spec/shared/framework_integration_behavior.rb +35 -0
  74. data/spec/unit/mutant/cli_spec.rb +34 -1
  75. data/spec/unit/mutant/env_spec.rb +0 -1
  76. data/spec/unit/mutant/integration/rspec_spec.rb +193 -0
  77. data/spec/unit/mutant/loader/eval_spec.rb +1 -1
  78. data/spec/unit/mutant/matcher/methods/instance_spec.rb +22 -21
  79. data/spec/unit/mutant/matcher/methods/singleton_spec.rb +21 -19
  80. data/spec/unit/mutant/parallel/worker_spec.rb +0 -2
  81. data/spec/unit/mutant/reporter/cli/tput_spec.rb +48 -0
  82. data/spec/unit/mutant/reporter/cli_spec.rb +29 -9
  83. data/test_app/Gemfile.rspec3.0 +1 -0
  84. data/test_app/Gemfile.rspec3.1 +1 -0
  85. data/test_app/Gemfile.rspec3.2 +1 -0
  86. data/test_app/lib/test_app.rb +1 -1
  87. data/test_app/lib/test_app/literal.rb +0 -2
  88. data/test_app/spec/spec_helper.rb +0 -2
  89. data/test_app/spec/unit/test_app/literal_spec.rb +22 -0
  90. metadata +15 -5
  91. data/test_app/spec/unit/test_app/literal/command_spec.rb +0 -11
  92. data/test_app/spec/unit/test_app/literal/string_spec.rb +0 -11
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source '@@a = true'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source 'def foo; end'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source 'defined?(foo)'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source '"foo#{bar}baz"'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source ':"foo#{bar}baz"'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source 'begin; rescue; ensure; true; end'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source 'false'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source '10.0'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source '$a'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source '$a = true'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source '{true => true, false => false}'
5
3
 
data/meta/if.rb CHANGED
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source 'if condition; true; else false; end'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source '10'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source '@a = true'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source 'begin; true; end'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source 'a = nil; a'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source 'a = true'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source 'a, b = c, d'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source 'true if /foo/'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source 'next true'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source 'nil'
5
3
  end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source '$1'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source '@a.b += 1'
5
3
 
data/meta/or.rb CHANGED
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source 'true or false'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source 'a ||= 1'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source '1..100'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source 'redo'
5
3
  end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source '/foo/'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source 'begin; rescue ExceptionA, ExceptionB => error; true; end'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source 'foo(*bar)'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source 'return'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source 'self'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source 'a > b'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source '"foo"'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source 'super'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source ':foo'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source 'true'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source 'until true; foo; bar; end'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source 'while true; foo; bar; end'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Mutant::Meta::Example.add do
4
2
  source 'yield true'
5
3
 
@@ -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,integration}/mutant/rspec/**/*.rb}`.split("\n")
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}")
@@ -14,16 +14,16 @@ Gem::Specification.new do |gem|
14
14
 
15
15
  gem.require_paths = %w[lib]
16
16
 
17
- mutant_rspec_files = `git ls-files -- lib/mutant/integration/rspec{,2,3}.rb`.split("\n")
17
+ mutant_integration_files = `git ls-files -- lib/mutant/integration/*.rb`.split("\n")
18
18
 
19
- gem.files = `git ls-files`.split("\n") - mutant_rspec_files
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 'rspec integration'
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 'rspec integration'
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 'rspec integration'
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
- --score COVERAGE Fail unless COVERAGE is not reached exactly
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