mutant 0.10.17 → 0.10.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mutant.rb +1 -0
- data/lib/mutant/bootstrap.rb +2 -2
- data/lib/mutant/cli/command/environment.rb +4 -4
- data/lib/mutant/cli/command/environment/run.rb +2 -2
- data/lib/mutant/cli/command/environment/show.rb +1 -2
- data/lib/mutant/cli/command/environment/subject.rb +39 -0
- data/lib/mutant/cli/command/root.rb +1 -1
- data/lib/mutant/cli/command/subscription.rb +1 -1
- data/lib/mutant/expression.rb +7 -2
- data/lib/mutant/expression/method.rb +27 -4
- data/lib/mutant/expression/namespace.rb +14 -1
- data/lib/mutant/expression/parser.rb +2 -2
- data/lib/mutant/license.rb +1 -1
- data/lib/mutant/license/subscription.rb +1 -1
- data/lib/mutant/license/subscription/commercial.rb +1 -1
- data/lib/mutant/license/subscription/opensource.rb +1 -1
- data/lib/mutant/runner.rb +1 -1
- data/lib/mutant/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9150c0a23d648637691af94ce404b1f1d2317469ca669455b1419948b1c4e106
|
4
|
+
data.tar.gz: 6a100d36685ffe0fd66e7194d6f5bb075b9d9370450c7e585a5b34a31449ae48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95858317d816637debda988640307698dbf32670fc246c980b3d46243d198b546dae36138cb9793efd3575c44464d6a7d22b6ef3457752811fac2204120a5071
|
7
|
+
data.tar.gz: 6b6f0545d7fbdecd68c24e65fa75c386a1d95c1b06c557cb2d127e74119e7eca0e456922b1f2765e48c15f2dba3b9dc1498deff556844c9fd9eea52bcc20e71a
|
data/lib/mutant.rb
CHANGED
@@ -171,6 +171,7 @@ require 'mutant/cli/command/subscription'
|
|
171
171
|
require 'mutant/cli/command/environment'
|
172
172
|
require 'mutant/cli/command/environment/run'
|
173
173
|
require 'mutant/cli/command/environment/show'
|
174
|
+
require 'mutant/cli/command/environment/subject'
|
174
175
|
require 'mutant/cli/command/root'
|
175
176
|
require 'mutant/runner'
|
176
177
|
require 'mutant/runner/sink'
|
data/lib/mutant/bootstrap.rb
CHANGED
@@ -30,7 +30,7 @@ module Mutant
|
|
30
30
|
# @return [Either<String, Env>]
|
31
31
|
#
|
32
32
|
# rubocop:disable Metrics/MethodLength
|
33
|
-
def self.
|
33
|
+
def self.call(world, config)
|
34
34
|
env = Env
|
35
35
|
.empty(world, config)
|
36
36
|
.tap(&method(:infect))
|
@@ -109,7 +109,7 @@ module Mutant
|
|
109
109
|
return
|
110
110
|
end
|
111
111
|
|
112
|
-
expression_parser.
|
112
|
+
expression_parser.call(name).from_right {}
|
113
113
|
end
|
114
114
|
private_class_method :expression
|
115
115
|
# rubocop:enable Metrics/MethodLength
|
@@ -25,7 +25,7 @@ module Mutant
|
|
25
25
|
def bootstrap
|
26
26
|
Config.load_config_file(world)
|
27
27
|
.fmap(&method(:expand))
|
28
|
-
.bind { Bootstrap.
|
28
|
+
.bind { Bootstrap.call(world, @config) }
|
29
29
|
end
|
30
30
|
|
31
31
|
def expand(file_config)
|
@@ -33,7 +33,7 @@ module Mutant
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def parse_remaining_arguments(arguments)
|
36
|
-
Mutant.traverse(@config.expression_parser
|
36
|
+
Mutant.traverse(@config.expression_parser, arguments)
|
37
37
|
.fmap do |match_expressions|
|
38
38
|
matcher(match_expressions: match_expressions)
|
39
39
|
self
|
@@ -82,10 +82,10 @@ module Mutant
|
|
82
82
|
parser.separator('Matcher:')
|
83
83
|
|
84
84
|
parser.on('--ignore-subject EXPRESSION', 'Ignore subjects that match EXPRESSION as prefix') do |pattern|
|
85
|
-
add_matcher(:ignore_expressions, @config.expression_parser.
|
85
|
+
add_matcher(:ignore_expressions, @config.expression_parser.call(pattern).from_right)
|
86
86
|
end
|
87
87
|
parser.on('--start-subject EXPRESSION', 'Start mutation testing at a specific subject') do |pattern|
|
88
|
-
add_matcher(:start_expressions, @config.expression_parser.
|
88
|
+
add_matcher(:start_expressions, @config.expression_parser.call(pattern).from_right)
|
89
89
|
end
|
90
90
|
parser.on('--since REVISION', 'Only select subjects touched since REVISION') do |revision|
|
91
91
|
add_matcher(
|
@@ -26,9 +26,9 @@ module Mutant
|
|
26
26
|
private
|
27
27
|
|
28
28
|
def action
|
29
|
-
soft_fail(License.
|
29
|
+
soft_fail(License.call(world))
|
30
30
|
.bind { bootstrap }
|
31
|
-
.bind(&Runner.public_method(:
|
31
|
+
.bind(&Runner.public_method(:call))
|
32
32
|
.bind(&method(:from_result))
|
33
33
|
end
|
34
34
|
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Mutant
|
4
|
+
module CLI
|
5
|
+
class Command
|
6
|
+
class Environment
|
7
|
+
class Subject < self
|
8
|
+
NAME = 'subject'
|
9
|
+
SHORT_DESCRIPTION = 'Subject subcommands'
|
10
|
+
|
11
|
+
class List < self
|
12
|
+
NAME = 'list'
|
13
|
+
SHORT_DESCRIPTION = 'List subjects'
|
14
|
+
SUBCOMMANDS = EMPTY_ARRAY
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def action
|
19
|
+
bootstrap.fmap(&method(:list_subjects))
|
20
|
+
end
|
21
|
+
|
22
|
+
def list_subjects(env)
|
23
|
+
print('Subjects in environment: %d' % env.subjects.length)
|
24
|
+
env.subjects.each do |subject|
|
25
|
+
print(subject.expression.syntax)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def print(message)
|
30
|
+
world.stdout.puts(message)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
SUBCOMMANDS = [List].freeze
|
35
|
+
end # Subject
|
36
|
+
end # Environment
|
37
|
+
end # Command
|
38
|
+
end # CLI
|
39
|
+
end # Mutant
|
data/lib/mutant/expression.rb
CHANGED
@@ -55,9 +55,14 @@ module Mutant
|
|
55
55
|
# otherwise
|
56
56
|
def self.try_parse(input)
|
57
57
|
match = self::REGEXP.match(input)
|
58
|
-
|
58
|
+
from_match(match) if match
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.from_match(match)
|
59
62
|
names = anima.attribute_names
|
60
|
-
new(Hash[names.zip(names.map(&match.
|
63
|
+
new(Hash[names.zip(names.map(&match.public_method(:[])))])
|
61
64
|
end
|
65
|
+
private_class_method :from_match
|
66
|
+
|
62
67
|
end # Expression
|
63
68
|
end # Mutant
|
@@ -5,6 +5,8 @@ module Mutant
|
|
5
5
|
|
6
6
|
# Explicit method expression
|
7
7
|
class Method < self
|
8
|
+
extend AST::Sexp
|
9
|
+
|
8
10
|
include Anima.new(
|
9
11
|
:method_name,
|
10
12
|
:scope_name,
|
@@ -18,10 +20,7 @@ module Mutant
|
|
18
20
|
'#' => [Matcher::Methods::Instance]
|
19
21
|
)
|
20
22
|
|
21
|
-
METHOD_NAME_PATTERN =
|
22
|
-
/(?<method_name>[A-Za-z_][A-Za-z\d_]*[!?=]?)/,
|
23
|
-
*AST::Types::OPERATOR_METHODS.map(&:to_s)
|
24
|
-
).freeze
|
23
|
+
METHOD_NAME_PATTERN = /(?<method_name>.+)/.freeze
|
25
24
|
|
26
25
|
private_constant(*constants(false))
|
27
26
|
|
@@ -47,6 +46,30 @@ module Mutant
|
|
47
46
|
Matcher::Filter.new(methods_matcher, ->(subject) { subject.expression.eql?(self) })
|
48
47
|
end
|
49
48
|
|
49
|
+
def self.try_parse(input)
|
50
|
+
match = REGEXP.match(input) or return
|
51
|
+
|
52
|
+
from_match(match) if valid_method_name?(match[:method_name])
|
53
|
+
end
|
54
|
+
|
55
|
+
# Test if string is a valid Ruby method name
|
56
|
+
#
|
57
|
+
# Note that this crazyness is indeed the "correct" solution.
|
58
|
+
#
|
59
|
+
# See: https://github.com/whitequark/parser/issues/213
|
60
|
+
#
|
61
|
+
# @param [String]
|
62
|
+
#
|
63
|
+
# @return [Boolean]
|
64
|
+
def self.valid_method_name?(name)
|
65
|
+
buffer = ::Parser::Source::Buffer.new(nil, source: "def #{name}; end")
|
66
|
+
|
67
|
+
::Parser::CurrentRuby
|
68
|
+
.new
|
69
|
+
.parse(buffer).eql?(s(:def, name.to_sym, s(:args), nil))
|
70
|
+
end
|
71
|
+
private_class_method :valid_method_name?
|
72
|
+
|
50
73
|
private
|
51
74
|
|
52
75
|
def scope
|
@@ -67,7 +67,13 @@ module Mutant
|
|
67
67
|
#
|
68
68
|
# @return [Matcher]
|
69
69
|
def matcher
|
70
|
-
|
70
|
+
scope = find_scope
|
71
|
+
|
72
|
+
if scope
|
73
|
+
Matcher::Scope.new(scope)
|
74
|
+
else
|
75
|
+
Matcher::Null.new
|
76
|
+
end
|
71
77
|
end
|
72
78
|
|
73
79
|
# Syntax for expression
|
@@ -76,6 +82,13 @@ module Mutant
|
|
76
82
|
alias_method :syntax, :scope_name
|
77
83
|
public :syntax
|
78
84
|
|
85
|
+
private
|
86
|
+
|
87
|
+
def find_scope
|
88
|
+
Object.const_get(scope_name)
|
89
|
+
rescue NameError # rubocop:disable Lint/SuppressedException
|
90
|
+
end
|
91
|
+
|
79
92
|
end # Exact
|
80
93
|
end # Namespace
|
81
94
|
end # Expression
|
@@ -5,7 +5,7 @@ module Mutant
|
|
5
5
|
class Parser
|
6
6
|
include Concord.new(:types)
|
7
7
|
|
8
|
-
#
|
8
|
+
# Parse expression
|
9
9
|
#
|
10
10
|
# @param [String] input
|
11
11
|
#
|
@@ -14,7 +14,7 @@ module Mutant
|
|
14
14
|
#
|
15
15
|
# @return [nil]
|
16
16
|
# otherwise
|
17
|
-
def
|
17
|
+
def call(input)
|
18
18
|
expressions = expressions(input)
|
19
19
|
case expressions.length
|
20
20
|
when 0
|
data/lib/mutant/license.rb
CHANGED
data/lib/mutant/runner.rb
CHANGED
data/lib/mutant/version.rb
CHANGED
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.10.
|
4
|
+
version: 0.10.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Markus Schirp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: abstract_type
|
@@ -307,6 +307,7 @@ files:
|
|
307
307
|
- lib/mutant/cli/command/environment.rb
|
308
308
|
- lib/mutant/cli/command/environment/run.rb
|
309
309
|
- lib/mutant/cli/command/environment/show.rb
|
310
|
+
- lib/mutant/cli/command/environment/subject.rb
|
310
311
|
- lib/mutant/cli/command/root.rb
|
311
312
|
- lib/mutant/cli/command/subscription.rb
|
312
313
|
- lib/mutant/config.rb
|