mutant 0.11.32 → 0.11.33

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: ae3cb40ea1cb49e850683c312747478ba27756318f14cbacb05e3e2c6c6e3fd4
4
- data.tar.gz: e9c942e65d8ecdaaab775bad82fe893cb493de78be4d28d066f35635938ff9ed
3
+ metadata.gz: 14a2999151fdced3adcf95c921ef755b416f3753bef2073c7eafb5648d5a1117
4
+ data.tar.gz: 0e6587233ae3ff944daf6ad9740be5b16749da34b8312207b7827afd4a79efb3
5
5
  SHA512:
6
- metadata.gz: 4e97637434f143cee9125c8386d836897cf0dd727f8a619e69192dbea8078735f1ed1678877dd09e0efa26540a3f9885dc9056aea3e882eafe336a51c8a6bce1
7
- data.tar.gz: 2465556e466c2076d5af323ae2beba999af207ab692541c7d2c28f9dcb47b34332f898e185f57d75395dbf9a27a8244db31154a6835536e3cd2b11f95a9ea702
6
+ metadata.gz: 477a3d6cf75df00b4b3732932aa0042c7b7b07cf2dea107ac3537c24be585e5d3f4d1a9fc76a26cf1e2fa317c16bb5b63b0a41352a18733dfcabe4be8312a17a
7
+ data.tar.gz: a29d9393fab0760cd0c463d22d8f54b6f0b9578feb0da38068e20a075af21bd28cca417ea9820a5af1926eb37338754cf25cfbed4f60e491ebaa5267c7956ed2
@@ -38,7 +38,7 @@ module Mutant
38
38
  .with(matchable_scopes: matchable_scopes(env))
39
39
 
40
40
  matched_subjects = env.record(:subject_match) do
41
- Matcher.from_config(env.config.matcher).call(env)
41
+ Matcher.expand(env: env).call(env)
42
42
  end
43
43
 
44
44
  selected_subjects = subject_select(env, matched_subjects)
@@ -11,7 +11,8 @@ module Mutant
11
11
  "descendants:#{const_name}"
12
12
  end
13
13
 
14
- def matcher
14
+ # rubocop:disable Lint/UnusedMethodArgument
15
+ def matcher(env:)
15
16
  Matcher::Descendants.new(const_name: const_name)
16
17
  end
17
18
  end # Descendants
@@ -39,7 +39,9 @@ module Mutant
39
39
  # Matcher for expression
40
40
  #
41
41
  # @return [Matcher]
42
- def matcher
42
+ #
43
+ # rubocop:disable Lint/UnusedMethodArgument
44
+ def matcher(env:)
43
45
  matcher_candidates = MATCHERS.fetch(scope_symbol)
44
46
  .map { |submatcher| submatcher.new(scope: scope) }
45
47
 
@@ -34,7 +34,9 @@ module Mutant
34
34
  # Matcher on expression
35
35
  #
36
36
  # @return [Matcher::Method]
37
- def matcher
37
+ #
38
+ # rubocop:disable Lint/UnusedMethodArgument
39
+ def matcher(env:)
38
40
  matcher_candidates = MATCHERS.fetch(scope_symbol)
39
41
  .map { |submatcher| submatcher.new(scope: scope) }
40
42
 
@@ -34,7 +34,9 @@ module Mutant
34
34
  # Matcher for expression
35
35
  #
36
36
  # @return [Matcher]
37
- def matcher
37
+ #
38
+ # rubocop:disable Lint/UnusedMethodArgument
39
+ def matcher(env:)
38
40
  Matcher::Namespace.new(expression: self)
39
41
  end
40
42
 
@@ -65,7 +67,7 @@ module Mutant
65
67
  # Matcher matcher on expression
66
68
  #
67
69
  # @return [Matcher]
68
- def matcher
70
+ def matcher(env:)
69
71
  raw_scope = find_raw_scope
70
72
 
71
73
  if raw_scope
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mutant
4
+ class Expression
5
+ class Source < self
6
+ include Anima.new(:glob_expression)
7
+
8
+ REGEXP = /\Asource:(?<glob_expression>.+)\z/
9
+
10
+ def syntax
11
+ "source:#{glob_expression}"
12
+ end
13
+
14
+ def matcher(env:)
15
+ Matcher::Chain.new(matchers: find_matchers(env: env))
16
+ end
17
+
18
+ private
19
+
20
+ def find_matchers(env:)
21
+ scope_names(env: env).uniq.map do |scope_name|
22
+ Namespace::Recursive.new(scope_name: scope_name).matcher(env: nil)
23
+ end
24
+ end
25
+
26
+ def scope_names(env:)
27
+ env.world.pathname.glob(glob_expression).flat_map do |path|
28
+ toplevel_consts(env.parser.call(path).node).map(&Unparser.public_method(:unparse))
29
+ end
30
+ end
31
+
32
+ def toplevel_consts(node)
33
+ children = node.children
34
+
35
+ case node.type
36
+ when :class, :module
37
+ [children.fetch(0)]
38
+ when :begin
39
+ children.flat_map(&method(__method__))
40
+ else
41
+ EMPTY_ARRAY
42
+ end
43
+ end
44
+ end # Source
45
+ end # Expression
46
+ end # Mutant
@@ -15,13 +15,15 @@ module Mutant
15
15
 
16
16
  # Turn config into matcher
17
17
  #
18
- # @param [Config] config
18
+ # @param [Env] env
19
19
  #
20
20
  # @return [Matcher]
21
- def self.from_config(config)
21
+ def self.expand(env:)
22
+ matcher_config = env.config.matcher
23
+
22
24
  Filter.new(
23
- matcher: Chain.new(matchers: config.subjects.map(&:matcher)),
24
- predicate: method(:allowed_subject?).curry.call(config)
25
+ matcher: Chain.new(matchers: matcher_config.subjects.map { |subject| subject.matcher(env: env) }),
26
+ predicate: method(:allowed_subject?).curry.call(matcher_config)
25
27
  )
26
28
  end
27
29
 
data/lib/mutant/parser.rb CHANGED
@@ -18,7 +18,7 @@ module Mutant
18
18
  #
19
19
  # @return [AST::Node]
20
20
  def call(path)
21
- @cache[path] ||= parse(path.read)
21
+ @cache[path.expand_path] ||= parse(path.read)
22
22
  end
23
23
 
24
24
  private
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Mutant
4
4
  # Current mutant version
5
- VERSION = '0.11.32'
5
+ VERSION = '0.11.33'
6
6
  end # Mutant
data/lib/mutant.rb CHANGED
@@ -204,6 +204,7 @@ module Mutant
204
204
  require 'mutant/expression/methods'
205
205
  require 'mutant/expression/namespace'
206
206
  require 'mutant/expression/parser'
207
+ require 'mutant/expression/source'
207
208
  require 'mutant/test'
208
209
  require 'mutant/test/runner'
209
210
  require 'mutant/test/runner/sink'
@@ -347,7 +348,8 @@ module Mutant
347
348
  Expression::Method,
348
349
  Expression::Methods,
349
350
  Expression::Namespace::Exact,
350
- Expression::Namespace::Recursive
351
+ Expression::Namespace::Recursive,
352
+ Expression::Source
351
353
  ]
352
354
  ),
353
355
  environment_variables: EMPTY_HASH,
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.11.32
4
+ version: 0.11.33
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-03-20 00:00:00.000000000 Z
11
+ date: 2024-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diff-lcs
@@ -189,6 +189,7 @@ files:
189
189
  - lib/mutant/expression/methods.rb
190
190
  - lib/mutant/expression/namespace.rb
191
191
  - lib/mutant/expression/parser.rb
192
+ - lib/mutant/expression/source.rb
192
193
  - lib/mutant/hooks.rb
193
194
  - lib/mutant/integration.rb
194
195
  - lib/mutant/integration/null.rb