mutant 0.12.0 → 0.12.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e8ba758de42528dd4dd4fdb5686df439d9ea4e2b1635905e89d7a98b904b959
4
- data.tar.gz: df2317b0cabc5964fec52e0fc1d7e76c0f368a01f713fa411f03cba4808b834a
3
+ metadata.gz: b917d54d9bc5f8bd16f530001c6cf983ad0a0970d3e837f0736b31efb81e5c8d
4
+ data.tar.gz: 499669d7e30d80698a154b27f37f52893b504b30bb70b6edd473f118c9d49c74
5
5
  SHA512:
6
- metadata.gz: 3b74495aa82f4489e22a95b5c25f3185d759fa616354af51c07544bb66be08f69becf8e5021db80008d169c2de12e677bf8a3a38becb954c32dc8287f1eea24d
7
- data.tar.gz: 82e7bdc18591e89028a39a3489291452b0b73cc4bcc6ea7549e9fa376778de622ac53bd4a2dbbe7702ff875eb9d84f55b6fa1ad424e55bfb0e4c7bdaa7243d13
6
+ metadata.gz: caea8e933129291143d45128074ffeb821ad1acf2f8b9742351b5512c867f8909512c8f6716dca423c49d912ecfae631caea7543d6862f9c5193694b393ad624
7
+ data.tar.gz: 336f5ed118fa5f63cf5b30f080ab3218fa488937a5f75bf8b486ed77b8869fd1c69e57414f4f8453d8e29c00c016b483e9cda02d91ccd4b1ec166494c0aa9bee
data/lib/mutant/config.rb CHANGED
@@ -111,14 +111,13 @@ module Mutant
111
111
  #
112
112
  # @return [Either<String,Config>]
113
113
  def self.load_config_file(reporter:, world:)
114
- files = CANDIDATES
115
- .map(&world.pathname.public_method(:new))
116
- .select(&:readable?)
114
+ files = CANDIDATES.map(&world.pathname.public_method(:new)).select(&:readable?)
117
115
 
118
- if files.one?
119
- load_contents(reporter: reporter, path: files.first).fmap(&DEFAULT.public_method(:with))
120
- elsif files.empty?
116
+ case files
117
+ in []
121
118
  Either::Right.new(DEFAULT)
119
+ in [file]
120
+ load_contents(reporter: reporter, path: file).fmap(&DEFAULT.public_method(:with))
122
121
  else
123
122
  Either::Left.new(MORE_THAN_ONE_CONFIG_FILE % files.join(', '))
124
123
  end
@@ -15,12 +15,11 @@ module Mutant
15
15
  # @return [nil]
16
16
  # otherwise
17
17
  def call(input)
18
- expressions = expressions(input)
19
- case expressions.length
20
- when 0
18
+ case expressions(input)
19
+ in []
21
20
  Either::Left.new("Expression: #{input.inspect} is invalid")
22
- when 1
23
- Either::Right.new(expressions.first)
21
+ in [expression]
22
+ Either::Right.new(expression)
24
23
  else
25
24
  Either::Left.new("Expression: #{input.inspect} is ambiguous")
26
25
  end
@@ -18,9 +18,10 @@ module Mutant
18
18
  # @return [Result::Test]
19
19
  def call(_tests)
20
20
  Result::Test.new(
21
- output: '',
22
- passed: true,
23
- runtime: 0.0
21
+ job_index: nil,
22
+ output: '',
23
+ passed: true,
24
+ runtime: 0.0
24
25
  )
25
26
  end
26
27
 
@@ -50,5 +50,6 @@ module Mutant
50
50
  expression.prefix?(subject.expression)
51
51
  end
52
52
  end
53
+ private_class_method :ignore_subject?
53
54
  end # Matcher
54
55
  end # Mutant
@@ -21,14 +21,22 @@ module Mutant
21
21
  all?: %i[any?],
22
22
  any?: %i[all?],
23
23
  at: %i[fetch key?],
24
+ detect: %i[first last],
24
25
  fetch: %i[key?],
26
+ find: %i[first last],
27
+ first: %i[last],
25
28
  flat_map: %i[map],
26
29
  gsub: %i[sub],
27
30
  is_a?: %i[instance_of?],
28
31
  kind_of?: %i[instance_of?],
32
+ last: %i[first],
29
33
  map: %i[each],
30
34
  match: %i[match?],
35
+ max: %i[first last],
36
+ max_by: %i[first last],
31
37
  method: %i[public_method],
38
+ min: %i[first last],
39
+ min_by: %i[first last],
32
40
  reverse_each: %i[each],
33
41
  reverse_map: %i[map each],
34
42
  reverse_merge: %i[merge],
@@ -49,6 +57,8 @@ module Mutant
49
57
  .tap do |replacements|
50
58
  replacements.delete(:==)
51
59
  replacements.delete(:eql?)
60
+ replacements.delete(:first)
61
+ replacements.delete(:last)
52
62
  end
53
63
  .freeze
54
64
  end
@@ -13,7 +13,6 @@ module Mutant
13
13
 
14
14
  def dispatch
15
15
  emit_singletons
16
- emit(N_EMPTY_SUPER)
17
16
  children.each_index do |index|
18
17
  mutate_child(index)
19
18
  delete_child(index)
@@ -21,11 +21,11 @@ module Mutant
21
21
  attr_reader :log
22
22
 
23
23
  def error
24
- @errors.first
24
+ Util.max_one(@errors)
25
25
  end
26
26
 
27
27
  def result
28
- @results.first
28
+ Util.max_one(@results)
29
29
  end
30
30
 
31
31
  def initialize(*)
@@ -96,7 +96,7 @@ module Mutant
96
96
  end
97
97
 
98
98
  def length
99
- @lengths.first
99
+ Util.max_one(@lengths)
100
100
  end
101
101
 
102
102
  def advance_log
@@ -68,7 +68,7 @@ module Mutant
68
68
  #
69
69
  # @return [undefined]
70
70
  def run
71
- visit_collection(Result, object.failed_test_results)
71
+ visit_failed
72
72
  visit(Env, object.env)
73
73
  FORMATS.each do |report, format, value|
74
74
  __send__(report, format, __send__(value))
@@ -77,6 +77,27 @@ module Mutant
77
77
 
78
78
  private
79
79
 
80
+ def visit_failed
81
+ failed = object.failed_test_results
82
+
83
+ if object.env.config.fail_fast
84
+ visit_failed_tests(failed.take(1))
85
+ visit_other_failed(failed.drop(1))
86
+ else
87
+ visit_failed_tests(failed)
88
+ end
89
+ end
90
+
91
+ def visit_other_failed(other)
92
+ return if other.empty?
93
+
94
+ puts('Other failed tests (report suppressed from fail fast): %d' % other.length)
95
+ end
96
+
97
+ def visit_failed_tests(failed)
98
+ visit_collection(Result, failed)
99
+ end
100
+
80
101
  def efficiency_percent
81
102
  (testtime / runtime) * 100
82
103
  end
data/lib/mutant/result.rb CHANGED
@@ -158,7 +158,7 @@ module Mutant
158
158
 
159
159
  # Test result
160
160
  class Test
161
- include Anima.new(:passed, :runtime, :output)
161
+ include Anima.new(:job_index, :passed, :runtime, :output)
162
162
 
163
163
  alias_method :success?, :passed
164
164
 
@@ -170,9 +170,10 @@ module Mutant
170
170
  # @return [undefined]
171
171
  def initialize
172
172
  super(
173
- output: '',
174
- passed: false,
175
- runtime: 0.0
173
+ job_index: nil,
174
+ output: '',
175
+ passed: false,
176
+ runtime: 0.0
176
177
  )
177
178
  end
178
179
  end # VoidValue
@@ -22,7 +22,7 @@ module Mutant
22
22
  Result::TestEnv.new(
23
23
  env: env,
24
24
  runtime: env.world.timer.now - @start,
25
- test_results: @test_results
25
+ test_results: @test_results.sort_by!(&:job_index)
26
26
  )
27
27
  end
28
28
 
@@ -42,7 +42,11 @@ module Mutant
42
42
  fail response.error
43
43
  end
44
44
 
45
- @test_results << response.result.with(output: response.log)
45
+ @test_results << response.result.with(
46
+ job_index: response.job.index,
47
+ output: response.log
48
+ )
49
+
46
50
  self
47
51
  end
48
52
  end # Sink
data/lib/mutant/util.rb CHANGED
@@ -12,9 +12,30 @@ module Mutant
12
12
  #
13
13
  # @return [Object] first entry
14
14
  def self.one(array)
15
- return array.first if array.one?
15
+ case array
16
+ in [value]
17
+ value
18
+ else
19
+ fail SizeError, "expected size to be exactly 1 but size was #{array.size}"
20
+ end
21
+ end
16
22
 
17
- fail SizeError, "expected size to be exactly 1 but size was #{array.size}"
23
+ # Return only element in array if it contains max one member
24
+ #
25
+ # @param array [Array]
26
+ #
27
+ # @return [Object] first entry
28
+ # @return [nil] if empty
29
+ #
30
+ # rubocop:disable Lint/EmptyInPattern
31
+ def self.max_one(array)
32
+ case array
33
+ in []
34
+ in [value]
35
+ value
36
+ else
37
+ fail SizeError, "expected size to be max 1 but size was #{array.size}"
38
+ end
18
39
  end
19
40
  end # Util
20
41
  end # Mutant
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Mutant
4
4
  # Current mutant version
5
- VERSION = '0.12.0'
5
+ VERSION = '0.12.2'
6
6
  end # Mutant
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.12.0
4
+ version: 0.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Schirp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-22 00:00:00.000000000 Z
11
+ date: 2024-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diff-lcs
@@ -346,6 +346,7 @@ licenses:
346
346
  - Nonstandard
347
347
  metadata:
348
348
  rubygems_mfa_required: 'true'
349
+ source_code_uri: https://github.com/mbj/mutant
349
350
  post_install_message:
350
351
  rdoc_options: []
351
352
  require_paths:
@@ -361,7 +362,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
361
362
  - !ruby/object:Gem::Version
362
363
  version: '0'
363
364
  requirements: []
364
- rubygems_version: 3.5.3
365
+ rubygems_version: 3.5.9
365
366
  signing_key:
366
367
  specification_version: 4
367
368
  summary: ''