mutant 0.5.26 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/.travis.yml +1 -0
  4. data/Changelog.md +16 -3
  5. data/Gemfile +0 -2
  6. data/Gemfile.devtools +2 -2
  7. data/README.md +9 -15
  8. data/bin/mutant +0 -1
  9. data/config/flay.yml +1 -1
  10. data/config/flog.yml +1 -1
  11. data/config/mutant.yml +1 -1
  12. data/config/reek.yml +14 -11
  13. data/config/rubocop.yml +1 -1
  14. data/lib/mutant.rb +22 -21
  15. data/lib/mutant/ast.rb +47 -0
  16. data/lib/mutant/cli.rb +7 -4
  17. data/lib/mutant/config.rb +1 -0
  18. data/lib/mutant/context.rb +1 -1
  19. data/lib/mutant/diff.rb +38 -7
  20. data/lib/mutant/env.rb +22 -3
  21. data/lib/mutant/expression.rb +15 -4
  22. data/lib/mutant/integration.rb +1 -1
  23. data/lib/mutant/isolation.rb +2 -4
  24. data/lib/mutant/matcher.rb +1 -1
  25. data/lib/mutant/matcher/method.rb +1 -1
  26. data/lib/mutant/matcher/method/singleton.rb +1 -1
  27. data/lib/mutant/matcher/methods.rb +0 -2
  28. data/lib/mutant/meta/example.rb +0 -2
  29. data/lib/mutant/meta/example/dsl.rb +1 -1
  30. data/lib/mutant/mutator.rb +1 -1
  31. data/lib/mutant/mutator/node.rb +3 -3
  32. data/lib/mutant/mutator/node/begin.rb +1 -1
  33. data/lib/mutant/mutator/node/block.rb +16 -3
  34. data/lib/mutant/mutator/node/if.rb +1 -1
  35. data/lib/mutant/mutator/node/literal/fixnum.rb +1 -1
  36. data/lib/mutant/mutator/node/resbody.rb +0 -2
  37. data/lib/mutant/mutator/node/send.rb +17 -7
  38. data/lib/mutant/mutator/node/send/index.rb +0 -2
  39. data/lib/mutant/mutator/registry.rb +1 -1
  40. data/lib/mutant/mutator/util.rb +1 -1
  41. data/lib/mutant/mutator/util/array.rb +1 -1
  42. data/lib/mutant/reporter.rb +13 -3
  43. data/lib/mutant/reporter/cli.rb +54 -8
  44. data/lib/mutant/reporter/cli/format.rb +197 -0
  45. data/lib/mutant/reporter/cli/printer.rb +402 -22
  46. data/lib/mutant/reporter/cli/tput.rb +27 -0
  47. data/lib/mutant/reporter/null.rb +4 -34
  48. data/lib/mutant/reporter/trace.rb +6 -38
  49. data/lib/mutant/result.rb +44 -56
  50. data/lib/mutant/runner.rb +99 -52
  51. data/lib/mutant/runner/collector.rb +134 -0
  52. data/lib/mutant/subject/method/instance.rb +12 -4
  53. data/lib/mutant/version.rb +1 -1
  54. data/lib/mutant/warning_filter.rb +0 -2
  55. data/lib/mutant/zombifier/file.rb +1 -1
  56. data/meta/block.rb +17 -1
  57. data/meta/send.rb +123 -1
  58. data/mutant-rspec.gemspec +3 -3
  59. data/mutant.gemspec +1 -1
  60. data/spec/integration/mutant/corpus_spec.rb +4 -195
  61. data/spec/integration/mutant/null_spec.rb +1 -3
  62. data/spec/integration/mutant/rspec_spec.rb +1 -3
  63. data/spec/integration/mutant/test_mutator_handles_types_spec.rb +1 -3
  64. data/spec/integration/mutant/zombie_spec.rb +1 -3
  65. data/spec/integrations.yml +7 -0
  66. data/spec/shared/method_matcher_behavior.rb +1 -1
  67. data/spec/spec_helper.rb +1 -0
  68. data/spec/support/compress_helper.rb +1 -0
  69. data/spec/support/corpus.rb +239 -0
  70. data/spec/support/mutation_verifier.rb +2 -4
  71. data/spec/unit/mutant/cli_spec.rb +20 -13
  72. data/spec/unit/mutant/context/root_spec.rb +1 -3
  73. data/spec/unit/mutant/context/scope/root_spec.rb +1 -3
  74. data/spec/unit/mutant/context/scope/unqualified_name_spec.rb +1 -3
  75. data/spec/unit/mutant/diff_spec.rb +37 -19
  76. data/spec/unit/mutant/expression/method_spec.rb +5 -7
  77. data/spec/unit/mutant/expression/methods_spec.rb +5 -7
  78. data/spec/unit/mutant/expression/namespace/flat_spec.rb +6 -8
  79. data/spec/unit/mutant/expression/namespace/recursive_spec.rb +6 -7
  80. data/spec/unit/mutant/expression_spec.rb +14 -5
  81. data/spec/unit/mutant/integration_spec.rb +14 -3
  82. data/spec/unit/mutant/isolation_spec.rb +2 -4
  83. data/spec/unit/mutant/loader/eval_spec.rb +1 -3
  84. data/spec/unit/mutant/matcher/chain_spec.rb +1 -3
  85. data/spec/unit/mutant/matcher/compiler/subject_prefix_spec.rb +21 -0
  86. data/spec/unit/mutant/matcher/compiler_spec.rb +28 -3
  87. data/spec/unit/mutant/matcher/filter_spec.rb +1 -3
  88. data/spec/unit/mutant/matcher/method/instance_spec.rb +3 -5
  89. data/spec/unit/mutant/matcher/method/singleton_spec.rb +22 -4
  90. data/spec/unit/mutant/matcher/methods/instance_spec.rb +7 -6
  91. data/spec/unit/mutant/matcher/methods/singleton_spec.rb +4 -6
  92. data/spec/unit/mutant/matcher/namespace_spec.rb +1 -3
  93. data/spec/unit/mutant/matcher/null_spec.rb +1 -3
  94. data/spec/unit/mutant/mutation_spec.rb +1 -3
  95. data/spec/unit/mutant/mutator/node_spec.rb +1 -3
  96. data/spec/unit/mutant/reporter/cli_spec.rb +444 -206
  97. data/spec/unit/mutant/reporter/null_spec.rb +1 -3
  98. data/spec/unit/mutant/require_highjack_spec.rb +1 -3
  99. data/spec/unit/mutant/runner_spec.rb +42 -28
  100. data/spec/unit/mutant/subject/context_spec.rb +1 -3
  101. data/spec/unit/mutant/subject/method/instance_spec.rb +27 -19
  102. data/spec/unit/mutant/subject/method/singleton_spec.rb +49 -17
  103. data/spec/unit/mutant/subject_spec.rb +1 -3
  104. data/spec/unit/mutant/test_spec.rb +1 -3
  105. data/spec/unit/mutant/warning_expectation.rb +1 -3
  106. data/spec/unit/mutant/warning_filter_spec.rb +1 -3
  107. data/spec/unit/mutant_spec.rb +13 -3
  108. data/test_app/Gemfile.devtools +2 -2
  109. data/test_app/spec/unit/test_app/literal/string_spec.rb +1 -1
  110. metadata +10 -21
  111. data/lib/mutant/matcher/method/finder.rb +0 -72
  112. data/lib/mutant/reporter/cli/progress.rb +0 -10
  113. data/lib/mutant/reporter/cli/progress/config.rb +0 -30
  114. data/lib/mutant/reporter/cli/progress/env.rb +0 -30
  115. data/lib/mutant/reporter/cli/progress/noop.rb +0 -27
  116. data/lib/mutant/reporter/cli/progress/result.rb +0 -12
  117. data/lib/mutant/reporter/cli/progress/result/mutation.rb +0 -45
  118. data/lib/mutant/reporter/cli/progress/result/subject.rb +0 -54
  119. data/lib/mutant/reporter/cli/progress/subject.rb +0 -27
  120. data/lib/mutant/reporter/cli/registry.rb +0 -81
  121. data/lib/mutant/reporter/cli/report.rb +0 -10
  122. data/lib/mutant/reporter/cli/report/env.rb +0 -92
  123. data/lib/mutant/reporter/cli/report/mutation.rb +0 -103
  124. data/lib/mutant/reporter/cli/report/subject.rb +0 -32
  125. data/lib/mutant/reporter/cli/report/test.rb +0 -28
  126. data/lib/mutant/walker.rb +0 -53
  127. data/spec/shared/mutator_behavior.rb +0 -55
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 40c90d9f752a1b8e3f120deb4c47f6a4a3683369
4
- data.tar.gz: 833c87b79967039486f66c6e295992642243f2e9
3
+ metadata.gz: b4c622c635f57a57ea3d7463d71da71c84450a8e
4
+ data.tar.gz: 4147047e1dd38d1115f415e5cb8e2eebba932c6d
5
5
  SHA512:
6
- metadata.gz: 243b80a0db1e4c41a0d47fbc2056cf48d10e268a6c5af1cc9728a5645022a0ae042287242a8bef1fed6ec2a3df19b24cc8c589083aa4940a104fdef9a3e0a079
7
- data.tar.gz: 113d8551fcc6102f8cc459b0e793e80abd77f685f80eb2895d5cf989b12eb65ffbc5d642bc762a5d750faeef90dde6a5c95a5c6d47365f3f6a30897f2cbf48a7
6
+ metadata.gz: fd80ff4f0469e2bf182c5060fe4696ce48373c014dd76dc083fc1a210812908c201c344afa6f34ec066c5714e0ad1a6f94ca436eb5c31fb9cf92d76b072c8467
7
+ data.tar.gz: 54779c5e90ebc0f5f909ae8b485eecb92da095e0abaf9f28d214d500ee2f0ea4d8e836b8cc17d9abe8a9b034b89de5651487ceeb25dd347c1e0a9864d5c444cb
data/.rspec CHANGED
@@ -1,4 +1,5 @@
1
1
  --color
2
+ --require spec_helper
2
3
  --format progress
3
4
  --warnings
4
5
  --order random
@@ -10,6 +10,7 @@ rvm:
10
10
  matrix:
11
11
  allow_failures:
12
12
  - rvm: 2.1.2 # still segfaults on stack overflow on define_method
13
+ - rvm: rbx-2 # Travis does not take care about RBX
13
14
  notifications:
14
15
  irc:
15
16
  channels:
@@ -1,3 +1,16 @@
1
+ # v0.6.0 2014-07-17
2
+
3
+ * Parallel execution / reporting.
4
+ * Add -j, --jobs flag to control concurrency.
5
+ * Fix blind spots on send with block.
6
+ * Add mutation from `foo { bar }` to `bar`
7
+ * Add mutation from `#reverse_merge` to `#merge`
8
+ * Add mutation from `#<=` to `#<`, `#==`, `#eql?`, `#equal?`
9
+ * Add mutation from `#>=` to `#>`, `#==`, `#eql?`, `#equal?`
10
+ * Add mutation from `#>` to `#==`, `#eql?`, `#equal?`
11
+ * Add mutation from `#<` to `#==`, `#eql?`, `#equal?`
12
+ * Fix reporting of diff errors to include context [tjchambers]
13
+
1
14
  # v0.5.26 2014-07-07
2
15
 
3
16
  * Fix exceptions generation matcher errors
@@ -63,7 +76,7 @@ Changes:
63
76
 
64
77
  * Report selected tests in progress runner
65
78
  * Fix scope of rspec selections to include meaningful parents.
66
- * Add short circuts on already dead mutations under multiple test selections.
79
+ * Add short circuits on already dead mutations under multiple test selections.
67
80
 
68
81
  # v0.5.16 2014-05-27
69
82
 
@@ -90,7 +103,7 @@ Changes:
90
103
 
91
104
  Changes:
92
105
 
93
- * Imporve reporting of isolation problems
106
+ * Improve reporting of isolation problems
94
107
  * Centralize test selection
95
108
  * Report selected tests
96
109
  * Report rspec output on noop failures
@@ -109,7 +122,7 @@ Changes:
109
122
  * Fix crash on while and until without body
110
123
  * Better require highjack based zombifier
111
124
  * Do not mutate nthref $1 to gvar $0
112
- * Use faster duplicate guarding hashing AST::Node intances
125
+ * Use faster duplicate guarding hashing AST::Node instances
113
126
  * Fix lots of shadowed invalid ASTs
114
127
  * Fix undefine initialize warnings, Closes #175
115
128
 
data/Gemfile CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- gem 'mutant', path: '.'
6
-
7
5
  gemspec name: 'mutant'
8
6
 
9
7
  gem 'devtools', git: 'https://github.com/rom-rb/devtools.git'
@@ -2,8 +2,8 @@
2
2
 
3
3
  group :development do
4
4
  gem 'rake', '~> 10.3.2'
5
- gem 'rspec', '~> 2.99.0'
6
- gem 'rspec-core', '~> 2.99.0'
5
+ gem 'rspec', '~> 3.0.0'
6
+ gem 'rspec-its', '~> 1.0.1'
7
7
  gem 'yard', '~> 0.8.7.4'
8
8
 
9
9
  platform :rbx do
data/README.md CHANGED
@@ -12,9 +12,8 @@ Mutant is a mutation testing tool for ruby.
12
12
  The idea is that if code can be changed and your tests do not notice, either that code isn't being covered
13
13
  or it does not have a speced side effect.
14
14
 
15
- Mutant supports MRI and RBX 1.9 and 2.0, while support for jruby is planned.
15
+ Mutant supports MRI and RBX 1.9, 2.0 and 2.1, while support for jruby is planned.
16
16
  It should also work under any ruby engine that supports POSIX-fork(2) semantics.
17
- Support for MRI 2.1 is unstable, because this MRI release segfaults on basic metaprogramming mutants dependencies do.
18
17
 
19
18
  Mutant uses a pure ruby [parser](https://github.com/whitequark/parser) and an [unparser](https://github.com/mbj/unparser)
20
19
  to do its magic.
@@ -37,11 +36,6 @@ Blog-Posts
37
36
  * http://www.sitepoint.com/mutation-testing-mutant/
38
37
  * http://solnic.eu/2013/01/23/mutation-testing-with-mutant.html
39
38
 
40
- Integrations
41
- ------------
42
-
43
- rspec2 and rspec-3 are supported currently. Minitest support is still *planned*.
44
-
45
39
  Projects using Mutant
46
40
  ---------------------
47
41
 
@@ -78,6 +72,8 @@ Please add an explicit dependency to `rspec-core` for the rspec version you want
78
72
  gem install mutant-rspec
79
73
  ```
80
74
 
75
+ The minitest integration is still in the works.
76
+
81
77
  Mutations
82
78
  ---------
83
79
 
@@ -143,20 +139,18 @@ Example for a subject like `Foo::Bar#baz` it will run all example groups with de
143
139
  `Foo::Bar#baz`, `Foo::Bar` and `Foo`. The order is important, so if mutant finds example groups in the
144
140
  current prefix level, these example groups *must* kill the mutation.
145
141
 
146
- This test selection strategy is compatible with the old `--rspec-dm2` and `--rspec-unit` strategy.
147
- The old flags were removed. It allows to define very fine grained specs, or coarse grained - as you like.
148
-
149
142
  Support
150
143
  -------
151
144
 
152
- I'm very happy to receive/answer feedback/questions and critism.
145
+ I'm very happy to receive/answer feedback/questions and criticism.
153
146
 
154
147
  Your options:
155
148
 
156
- * GitHub Issues https://github.com/mbj/mutant/issues
157
- * Ping me on https://twitter.com/_m_b_j_
158
- * #mutant channel on freenode, I hang around on CET daytimes. (nick mbj)
159
- You'll also find others [ROM](https://github.com/rom-rb) team members here that can answer questions.
149
+ * [GitHub Issues](https://github.com/mbj/mutant/issues)
150
+ * Ping me on [twitter](https://twitter.com/_m_b_j_)
151
+
152
+ There is also the [#mutant] channel on freenode. As my OSS time budged is very limited I cannot
153
+ join it often. Please prefer to use github issues with a 'Question: ' prefix in title.
160
154
 
161
155
  Credits
162
156
  -------
data/bin/mutant CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: utf-8
3
2
 
4
3
  trap('INT') do |status|
5
4
  exit! 128 + status
@@ -1,3 +1,3 @@
1
1
  ---
2
2
  threshold: 18
3
- total_score: 1040
3
+ total_score: 1069
@@ -1,2 +1,2 @@
1
1
  ---
2
- threshold: 29.3
2
+ threshold: 30.6
@@ -5,7 +5,7 @@ expect_coverage: 62.08
5
5
  ignore_subjects:
6
6
  # Mutation causes infinite runtime
7
7
  - Mutant::Runner.lookup
8
- # Suboptimal test selection stragegy (will be fixed soon) causes timeouts on CI
8
+ # Suboptimal test selection strategy (will be fixed soon) causes timeouts on CI
9
9
  - Mutant::Zombifier*
10
10
  - Mutant::Reporter*
11
11
  - Mutant::CLI*
@@ -12,6 +12,7 @@ ControlParameter:
12
12
  enabled: true
13
13
  exclude:
14
14
  - Mutant::Expression#match_length
15
+ - Mutant::Reporter::CLI::Printer::SubjectProgress#print_mutation_result
15
16
  DataClump:
16
17
  enabled: true
17
18
  exclude: []
@@ -28,9 +29,10 @@ FeatureEnvy:
28
29
  # Nature of OptionParser :(
29
30
  - Mutant::CLI#add_environment_options
30
31
  - Mutant::Env#scope_name
32
+ - Mutant::Diff#minimized_hunks
31
33
  - Mutant::Integration::Rspec#run
32
- - Mutant::Integration::Rspec2#full_description
33
- - Mutant::Integration::Rspec3#full_description
34
+ - Mutant::Integration::Rspec::Rspec2#full_description
35
+ - Mutant::Integration::Rspec::Rspec3#full_description
34
36
  - Mutant::Matcher::Method::Instance#match?
35
37
  - Mutant::Matcher::Method::Singleton#receiver?
36
38
  - Mutant::Mutation::Evil#success?
@@ -39,6 +41,8 @@ FeatureEnvy:
39
41
  - Mutant::Meta::Example::Verification#format_mutation
40
42
  - Mutant::Reporter::CLI#subject_results
41
43
  - Mutant::Runner#run_mutation_test
44
+ - Mutant::Runner#kill_mutation
45
+ - Mutant::Runner#finish
42
46
  IrresponsibleModule:
43
47
  enabled: true
44
48
  exclude: []
@@ -46,6 +50,7 @@ LongParameterList:
46
50
  enabled: true
47
51
  exclude:
48
52
  - Mutant::Matcher::Method::Instance#self.build?
53
+ - Mutant::Runner#finish # API client of parallel, one gets _ignored.
49
54
  - Mutant::Runner#self.run
50
55
  max_params: 2
51
56
  LongYieldList:
@@ -61,10 +66,8 @@ NestedIterators:
61
66
  - Mutant::Mutator::Util::Array::Element#dispatch
62
67
  - Mutant::Mutator::Node::Resbody#mutate_captures
63
68
  - Mutant::Mutator::Node::Arguments#emit_argument_mutations
64
- - Mutant::Reporter::CLI::Report::Env#generic_stats
65
69
  - Mutant::RequireHighjack#infect
66
70
  - Mutant::RequireHighjack#desinfect
67
- - Mutant::Reporter::CLI::Registry#included
68
71
  - Mutant::Subject#tests
69
72
  - Parser::Lexer#self.new
70
73
  max_allowed_nesting: 1
@@ -81,9 +84,8 @@ RepeatedConditional:
81
84
  TooManyInstanceVariables:
82
85
  enabled: true
83
86
  exclude:
84
- - Mutant::CLI # 4 vars
85
- - Mutant::Killer # 4 vars
86
87
  - Mutant::Mutator # 4 vars
88
+ - Mutant::Runner # 4 vars
87
89
  max_instance_variables: 3
88
90
  TooManyMethods:
89
91
  enabled: true
@@ -99,9 +101,9 @@ TooManyStatements:
99
101
  exclude:
100
102
  - Mutant#self.singleton_subclass_instance
101
103
  - Mutant::Integration::Rspec#run
102
- - Mutant::Reporter::CLI::Report::Env#run
103
- - Mutant::Reporter::CLI::Registry#included
104
104
  - Mutant::Reporter::CLI#colorized_diff
105
+ - Mutant::Reporter::CLI::Printer::EnvProgress#run
106
+ - Mutant::Reporter::CLI::Printer::Config#run
105
107
  - Mutant::RequireHighjack#infect
106
108
  - Mutant::Rspec::Killer#run
107
109
  - Mutant::Runner#visit_collection
@@ -156,11 +158,12 @@ UtilityFunction:
156
158
  - Mutant::CLI#reporter
157
159
  - Mutant::Integration::Rspec#configuration
158
160
  - Mutant::Integration::Rspec#options
159
- - Mutant::Integration::Rspec2#full_description
160
- - Mutant::Integration::Rspec2#new_reporter
161
- - Mutant::Integration::Rspec3#full_description
161
+ - Mutant::Integration::Rspec::Rspec2#full_description
162
+ - Mutant::Integration::Rspec::Rspec2#new_reporter
163
+ - Mutant::Integration::Rspec::Rspec3#full_description
162
164
  - Mutant::Meta::Example::Verification#format_mutation
163
165
  - Mutant::Mutation::Evil#success?
164
166
  - Mutant::Mutation::Neutral#success?
167
+ - Mutant::Reporter::CLI::Format::Progressive#new_buffer
165
168
  - Mutant::Runner#run_mutation_test
166
169
  max_helper_calls: 0
@@ -89,7 +89,7 @@ ConstantName:
89
89
  TrivialAccessors:
90
90
  Enabled: false
91
91
 
92
- # And also have a differend opinion here
92
+ # And also have a different opinion here
93
93
  AndOr:
94
94
  Enabled: false
95
95
 
@@ -17,6 +17,7 @@ require 'anima'
17
17
  require 'concord'
18
18
  require 'morpher'
19
19
  require 'parallel'
20
+ require 'open3'
20
21
 
21
22
  # Library namespace
22
23
  module Mutant
@@ -27,6 +28,16 @@ module Mutant
27
28
 
28
29
  SCOPE_OPERATOR = '::'.freeze
29
30
 
31
+ # Test if CI is detected via environment
32
+ #
33
+ # @return [Boolean]
34
+ #
35
+ # @api private
36
+ #
37
+ def self.ci?
38
+ ENV.key?('CI')
39
+ end
40
+
30
41
  # Lookup constant for location
31
42
  #
32
43
  # @param [String] location
@@ -91,7 +102,6 @@ require 'mutant/cache'
91
102
  require 'mutant/delegator'
92
103
  require 'mutant/warning_filter'
93
104
  require 'mutant/warning_expectation'
94
- require 'mutant/walker'
95
105
  require 'mutant/require_highjack'
96
106
  require 'mutant/isolation'
97
107
  require 'mutant/mutator'
@@ -167,7 +177,6 @@ require 'mutant/matcher/config'
167
177
  require 'mutant/matcher/compiler'
168
178
  require 'mutant/matcher/chain'
169
179
  require 'mutant/matcher/method'
170
- require 'mutant/matcher/method/finder'
171
180
  require 'mutant/matcher/method/singleton'
172
181
  require 'mutant/matcher/method/instance'
173
182
  require 'mutant/matcher/methods'
@@ -184,43 +193,35 @@ require 'mutant/integration'
184
193
  require 'mutant/cli'
185
194
  require 'mutant/color'
186
195
  require 'mutant/diff'
196
+ require 'mutant/runner'
197
+ require 'mutant/runner/collector'
187
198
  require 'mutant/result'
188
199
  require 'mutant/reporter'
189
200
  require 'mutant/reporter/null'
190
201
  require 'mutant/reporter/trace'
191
202
  require 'mutant/reporter/cli'
192
- require 'mutant/reporter/cli/registry'
193
203
  require 'mutant/reporter/cli/printer'
194
- require 'mutant/reporter/cli/report'
195
- require 'mutant/reporter/cli/report/env'
196
- require 'mutant/reporter/cli/report/subject'
197
- require 'mutant/reporter/cli/report/mutation'
198
- require 'mutant/reporter/cli/report/test'
199
- require 'mutant/reporter/cli/progress'
200
- require 'mutant/reporter/cli/progress/env'
201
- require 'mutant/reporter/cli/progress/config'
202
- require 'mutant/reporter/cli/progress/subject'
203
- require 'mutant/reporter/cli/progress/noop'
204
- require 'mutant/reporter/cli/progress/result'
205
- require 'mutant/reporter/cli/progress/result/mutation'
206
- require 'mutant/reporter/cli/progress/result/subject'
207
- require 'mutant/runner'
204
+ require 'mutant/reporter/cli/tput'
205
+ require 'mutant/reporter/cli/format'
208
206
  require 'mutant/zombifier'
209
207
  require 'mutant/zombifier/file'
210
208
 
211
209
  module Mutant
212
- # Repoen class to initialize constant to avoid dep circle
210
+ # Reopen class to initialize constant to avoid dep circle
213
211
  class Config
212
+ CI_DEFAULT_PROCESSOR_COUNT = 2
213
+
214
214
  DEFAULT = new(
215
215
  debug: false,
216
216
  fail_fast: false,
217
217
  integration: Integration::Null.new,
218
218
  matcher_config: Matcher::Config::DEFAULT,
219
- includes: [],
220
- requires: [],
219
+ includes: EMPTY_ARRAY,
220
+ requires: EMPTY_ARRAY,
221
221
  isolation: Mutant::Isolation::Fork,
222
- reporter: Reporter::CLI.new($stdout),
222
+ reporter: Reporter::CLI.build($stdout),
223
223
  zombie: false,
224
+ processes: Mutant.ci? ? CI_DEFAULT_PROCESSOR_COUNT : Parallel.processor_count,
224
225
  expected_coverage: 100.0
225
226
  )
226
227
  end # Config
@@ -1,5 +1,52 @@
1
1
  module Mutant
2
2
  # AST helpers
3
3
  module AST
4
+
5
+ # Walk all ast nodes
6
+ #
7
+ # @param [Parser::AST::Node]
8
+ #
9
+ # @yield [Parser::AST::Node]
10
+ # all nodes recursively including root
11
+ #
12
+ # @return [self]
13
+ #
14
+ # @api private
15
+ #
16
+ def self.walk(node, &block)
17
+ raise ArgumentError, 'block expected' unless block_given?
18
+
19
+ block.call(node)
20
+ node.children.grep(Parser::AST::Node).each do |child|
21
+ walk(child, &block)
22
+ end
23
+
24
+ self
25
+ end
26
+
27
+ # Find last node satisfing predicate (as block)
28
+ #
29
+ # @return [Parser::AST::Node]
30
+ # if satisfing node is found
31
+ #
32
+ # @yield [Parser::AST::Node]
33
+ #
34
+ # @yieldreturn [Boolean]
35
+ # true in case node satisfies predicate
36
+ #
37
+ # @return [nil]
38
+ # otherwise
39
+ #
40
+ # @api private
41
+ #
42
+ def self.find_last(node, &predicate)
43
+ raise ArgumentError, 'block expected' unless block_given?
44
+ neddle = nil
45
+ walk(node) do |candidate|
46
+ neddle = candidate if predicate.call(candidate, &predicate)
47
+ end
48
+ neddle
49
+ end
50
+
4
51
  end # AST
5
52
  end # Mutant
@@ -2,11 +2,11 @@ require 'optparse'
2
2
 
3
3
  module Mutant
4
4
 
5
- # Comandline parser
5
+ # Commandline parser
6
6
  class CLI
7
7
  include Adamantium::Flat, Equalizer.new(:config), Procto.call(:config)
8
8
 
9
- # Error faild when CLI argv is invalid
9
+ # Error failed when CLI argv is invalid
10
10
  Error = Class.new(RuntimeError)
11
11
 
12
12
  EXIT_FAILURE = 1
@@ -79,7 +79,7 @@ module Mutant
79
79
 
80
80
  # Parse matchers
81
81
  #
82
- # @param [Array<String>] patterns
82
+ # @param [Array<String>] expressions
83
83
  #
84
84
  # @return [undefined]
85
85
  #
@@ -112,6 +112,9 @@ module Mutant
112
112
  opts.on('-r', '--require NAME', 'Require file with NAME') do |name|
113
113
  add(:requires, name)
114
114
  end
115
+ opts.on('-j', '--jobs NUMBER', 'Number of kill processes. Defaults to number of processors.') do |number|
116
+ update(processes: Integer(number))
117
+ end
115
118
  end
116
119
 
117
120
  # Use integration
@@ -124,7 +127,7 @@ module Mutant
124
127
  #
125
128
  def setup_integration(name)
126
129
  require "mutant/integration/#{name}"
127
- update(integration: Integration.lookup(name).new)
130
+ update(integration: Integration.lookup(name))
128
131
  end
129
132
 
130
133
  # Add options