mutant 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +7 -0
- data/config/flay.yml +1 -1
- data/config/reek.yml +1 -0
- data/lib/mutant.rb +10 -3
- data/lib/mutant/actor.rb +2 -5
- data/lib/mutant/actor/env.rb +1 -3
- data/lib/mutant/actor/mailbox.rb +2 -4
- data/lib/mutant/actor/receiver.rb +0 -2
- data/lib/mutant/actor/sender.rb +0 -1
- data/lib/mutant/ast.rb +22 -28
- data/lib/mutant/ast/meta.rb +8 -88
- data/lib/mutant/ast/named_children.rb +1 -8
- data/lib/mutant/ast/sexp.rb +0 -2
- data/lib/mutant/cache.rb +1 -3
- data/lib/mutant/cli.rb +9 -19
- data/lib/mutant/color.rb +0 -3
- data/lib/mutant/config.rb +6 -2
- data/lib/mutant/context.rb +2 -4
- data/lib/mutant/context/scope.rb +10 -16
- data/lib/mutant/delegator.rb +0 -3
- data/lib/mutant/diff.rb +8 -17
- data/lib/mutant/env.rb +3 -5
- data/lib/mutant/env/bootstrap.rb +32 -39
- data/lib/mutant/expression.rb +14 -132
- data/lib/mutant/expression/method.rb +25 -42
- data/lib/mutant/expression/methods.rb +17 -29
- data/lib/mutant/expression/namespace.rb +33 -28
- data/lib/mutant/expression/parser.rb +71 -0
- data/lib/mutant/integration.rb +17 -16
- data/lib/mutant/isolation.rb +14 -14
- data/lib/mutant/loader.rb +2 -4
- data/lib/mutant/matcher.rb +1 -11
- data/lib/mutant/matcher/chain.rb +0 -1
- data/lib/mutant/matcher/compiler.rb +19 -52
- data/lib/mutant/matcher/config.rb +65 -5
- data/lib/mutant/matcher/filter.rb +11 -1
- data/lib/mutant/matcher/method.rb +11 -21
- data/lib/mutant/matcher/method/instance.rb +2 -16
- data/lib/mutant/matcher/method/singleton.rb +3 -20
- data/lib/mutant/matcher/methods.rb +11 -21
- data/lib/mutant/matcher/namespace.rb +0 -4
- data/lib/mutant/matcher/null.rb +0 -1
- data/lib/mutant/matcher/scope.rb +0 -12
- data/lib/mutant/meta.rb +0 -1
- data/lib/mutant/meta/example.rb +12 -26
- data/lib/mutant/meta/example/dsl.rb +1 -8
- data/lib/mutant/mutation.rb +6 -14
- data/lib/mutant/mutator.rb +2 -14
- data/lib/mutant/mutator/node.rb +6 -33
- data/lib/mutant/mutator/node/and_asgn.rb +0 -1
- data/lib/mutant/mutator/node/argument.rb +0 -5
- data/lib/mutant/mutator/node/arguments.rb +1 -7
- data/lib/mutant/mutator/node/begin.rb +0 -2
- data/lib/mutant/mutator/node/binary.rb +0 -3
- data/lib/mutant/mutator/node/block.rb +0 -2
- data/lib/mutant/mutator/node/break.rb +0 -1
- data/lib/mutant/mutator/node/case.rb +0 -3
- data/lib/mutant/mutator/node/conditional_loop.rb +0 -1
- data/lib/mutant/mutator/node/const.rb +0 -1
- data/lib/mutant/mutator/node/define.rb +0 -1
- data/lib/mutant/mutator/node/defined.rb +0 -1
- data/lib/mutant/mutator/node/dstr.rb +0 -1
- data/lib/mutant/mutator/node/dsym.rb +0 -1
- data/lib/mutant/mutator/node/generic.rb +0 -1
- data/lib/mutant/mutator/node/if.rb +0 -4
- data/lib/mutant/mutator/node/kwbegin.rb +0 -1
- data/lib/mutant/mutator/node/literal/array.rb +0 -2
- data/lib/mutant/mutator/node/literal/boolean.rb +0 -1
- data/lib/mutant/mutator/node/literal/fixnum.rb +2 -5
- data/lib/mutant/mutator/node/literal/float.rb +1 -4
- data/lib/mutant/mutator/node/literal/hash.rb +0 -3
- data/lib/mutant/mutator/node/literal/nil.rb +0 -1
- data/lib/mutant/mutator/node/literal/range.rb +1 -5
- data/lib/mutant/mutator/node/literal/regex.rb +1 -3
- data/lib/mutant/mutator/node/literal/string.rb +0 -1
- data/lib/mutant/mutator/node/literal/symbol.rb +0 -1
- data/lib/mutant/mutator/node/masgn.rb +0 -1
- data/lib/mutant/mutator/node/match_current_line.rb +0 -1
- data/lib/mutant/mutator/node/mlhs.rb +0 -1
- data/lib/mutant/mutator/node/named_value/access.rb +0 -1
- data/lib/mutant/mutator/node/named_value/constant_assignment.rb +0 -2
- data/lib/mutant/mutator/node/named_value/variable_assignment.rb +0 -2
- data/lib/mutant/mutator/node/next.rb +0 -1
- data/lib/mutant/mutator/node/noop.rb +0 -1
- data/lib/mutant/mutator/node/nthref.rb +0 -1
- data/lib/mutant/mutator/node/op_asgn.rb +0 -1
- data/lib/mutant/mutator/node/or_asgn.rb +1 -2
- data/lib/mutant/mutator/node/resbody.rb +0 -2
- data/lib/mutant/mutator/node/rescue.rb +1 -6
- data/lib/mutant/mutator/node/return.rb +0 -1
- data/lib/mutant/mutator/node/send.rb +16 -17
- data/lib/mutant/mutator/node/send/attribute_assignment.rb +0 -3
- data/lib/mutant/mutator/node/send/binary.rb +0 -1
- data/lib/mutant/mutator/node/send/index.rb +0 -3
- data/lib/mutant/mutator/node/splat.rb +0 -1
- data/lib/mutant/mutator/node/super.rb +0 -1
- data/lib/mutant/mutator/node/when.rb +2 -7
- data/lib/mutant/mutator/node/yield.rb +0 -1
- data/lib/mutant/mutator/node/zsuper.rb +0 -1
- data/lib/mutant/mutator/registry.rb +1 -4
- data/lib/mutant/mutator/util.rb +0 -2
- data/lib/mutant/mutator/util/array.rb +0 -3
- data/lib/mutant/mutator/util/symbol.rb +0 -1
- data/lib/mutant/parallel.rb +3 -9
- data/lib/mutant/parallel/master.rb +7 -17
- data/lib/mutant/parallel/source.rb +2 -7
- data/lib/mutant/parallel/worker.rb +1 -5
- data/lib/mutant/reporter.rb +0 -4
- data/lib/mutant/reporter/cli.rb +1 -8
- data/lib/mutant/reporter/cli/format.rb +7 -18
- data/lib/mutant/reporter/cli/printer.rb +2 -12
- data/lib/mutant/reporter/cli/printer/config.rb +1 -4
- data/lib/mutant/reporter/cli/printer/env_progress.rb +3 -7
- data/lib/mutant/reporter/cli/printer/env_result.rb +0 -1
- data/lib/mutant/reporter/cli/printer/mutation_progress_result.rb +0 -2
- data/lib/mutant/reporter/cli/printer/mutation_result.rb +3 -11
- data/lib/mutant/reporter/cli/printer/status.rb +1 -4
- data/lib/mutant/reporter/cli/printer/status_progressive.rb +1 -3
- data/lib/mutant/reporter/cli/printer/subject_progress.rb +0 -5
- data/lib/mutant/reporter/cli/printer/subject_result.rb +0 -1
- data/lib/mutant/reporter/cli/printer/test_result.rb +0 -1
- data/lib/mutant/reporter/cli/tput.rb +4 -1
- data/lib/mutant/reporter/trace.rb +2 -4
- data/lib/mutant/repository.rb +88 -0
- data/lib/mutant/require_highjack.rb +0 -1
- data/lib/mutant/result.rb +25 -48
- data/lib/mutant/runner.rb +7 -16
- data/lib/mutant/runner/sink.rb +3 -11
- data/lib/mutant/selector.rb +1 -2
- data/lib/mutant/selector/expression.rb +1 -2
- data/lib/mutant/subject.rb +10 -21
- data/lib/mutant/subject/method.rb +11 -12
- data/lib/mutant/subject/method/instance.rb +1 -5
- data/lib/mutant/subject/method/singleton.rb +1 -3
- data/lib/mutant/test.rb +1 -2
- data/lib/mutant/version.rb +2 -2
- data/lib/mutant/warning_filter.rb +2 -7
- data/lib/mutant/zombifier.rb +6 -10
- data/meta/send.rb +8 -0
- data/spec/spec_helper.rb +5 -1
- data/spec/support/corpus.rb +5 -9
- data/spec/support/rb_bug.rb +0 -1
- data/spec/support/rspec.rb +0 -1
- data/spec/support/ruby_vm.rb +0 -2
- data/spec/unit/mutant/ast/meta/send_spec.rb +42 -0
- data/spec/unit/mutant/ast/named_children_spec.rb +51 -0
- data/spec/unit/mutant/ast/sexp_spec.rb +36 -0
- data/spec/unit/mutant/ast_spec.rb +8 -0
- data/spec/unit/mutant/cli_spec.rb +34 -19
- data/spec/unit/mutant/context/scope_spec.rb +11 -0
- data/spec/unit/mutant/env/boostrap_spec.rb +5 -2
- data/spec/unit/mutant/env_spec.rb +14 -15
- data/spec/unit/mutant/expression/method_spec.rb +10 -14
- data/spec/unit/mutant/expression/methods_spec.rb +24 -11
- data/spec/unit/mutant/expression/namespace/flat_spec.rb +5 -6
- data/spec/unit/mutant/expression/namespace/recursive_spec.rb +16 -10
- data/spec/unit/mutant/expression/parser_spec.rb +67 -0
- data/spec/unit/mutant/expression_spec.rb +24 -57
- data/spec/unit/mutant/integration/rspec_spec.rb +7 -7
- data/spec/unit/mutant/integration_spec.rb +2 -2
- data/spec/unit/mutant/isolation_spec.rb +31 -29
- data/spec/unit/mutant/matcher/compiler/subject_prefix_spec.rb +2 -2
- data/spec/unit/mutant/matcher/compiler_spec.rb +27 -58
- data/spec/unit/mutant/matcher/config_spec.rb +45 -0
- data/spec/unit/mutant/matcher/filter_spec.rb +12 -5
- data/spec/unit/mutant/matcher/method/instance_spec.rb +0 -1
- data/spec/unit/mutant/matcher/method/singleton_spec.rb +0 -1
- data/spec/unit/mutant/matcher/namespace_spec.rb +4 -4
- data/spec/unit/mutant/parallel/worker_spec.rb +1 -1
- data/spec/unit/mutant/reporter/cli/printer/config_spec.rb +4 -4
- data/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb +7 -7
- data/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb +2 -2
- data/spec/unit/mutant/reporter/cli/printer/status_progressive_spec.rb +2 -2
- data/spec/unit/mutant/reporter/cli/printer/status_spec.rb +12 -12
- data/spec/unit/mutant/reporter/cli/printer/subject_progress_spec.rb +1 -1
- data/spec/unit/mutant/reporter/cli_spec.rb +9 -10
- data/spec/unit/mutant/repository/diff_spec.rb +80 -0
- data/spec/unit/mutant/repository/subject_filter_spec.rb +28 -0
- data/spec/unit/mutant/result/env_spec.rb +1 -1
- data/spec/unit/mutant/runner_spec.rb +0 -1
- data/spec/unit/mutant/selector/expression_spec.rb +14 -14
- data/spec/unit/mutant/subject/method/instance_spec.rb +2 -2
- data/spec/unit/mutant/subject/method/singleton_spec.rb +2 -2
- data/spec/unit/mutant/subject_spec.rb +5 -2
- metadata +20 -3
- data/spec/support/mutation_verifier.rb +0 -96
@@ -51,7 +51,6 @@ module Mutant
|
|
51
51
|
# @return [undefined]
|
52
52
|
#
|
53
53
|
# @api private
|
54
|
-
#
|
55
54
|
def run
|
56
55
|
puts(mutation.identification)
|
57
56
|
print_details
|
@@ -60,22 +59,20 @@ module Mutant
|
|
60
59
|
|
61
60
|
private
|
62
61
|
|
63
|
-
#
|
62
|
+
# Print mutation details
|
64
63
|
#
|
65
64
|
# @return [undefined]
|
66
65
|
#
|
67
66
|
# @api private
|
68
|
-
#
|
69
67
|
def print_details
|
70
68
|
__send__(MAP.fetch(mutation.class))
|
71
69
|
end
|
72
70
|
|
73
|
-
#
|
71
|
+
# Evil mutation details
|
74
72
|
#
|
75
73
|
# @return [String]
|
76
74
|
#
|
77
75
|
# @api private
|
78
|
-
#
|
79
76
|
def evil_details
|
80
77
|
diff = Diff.build(mutation.original_source, mutation.source)
|
81
78
|
diff = color? ? diff.colorized_diff : diff.diff
|
@@ -91,7 +88,6 @@ module Mutant
|
|
91
88
|
# @return [undefined]
|
92
89
|
#
|
93
90
|
# @api private
|
94
|
-
#
|
95
91
|
def print_no_diff_message
|
96
92
|
info(
|
97
93
|
NO_DIFF_MESSAGE,
|
@@ -107,7 +103,6 @@ module Mutant
|
|
107
103
|
# @return [String]
|
108
104
|
#
|
109
105
|
# @api private
|
110
|
-
#
|
111
106
|
def noop_details
|
112
107
|
info(NOOP_MESSAGE)
|
113
108
|
visit_test_result
|
@@ -118,7 +113,6 @@ module Mutant
|
|
118
113
|
# @return [String]
|
119
114
|
#
|
120
115
|
# @api private
|
121
|
-
#
|
122
116
|
def neutral_details
|
123
117
|
info(NEUTRAL_MESSAGE, original_node.inspect, mutation.source)
|
124
118
|
visit_test_result
|
@@ -129,17 +123,15 @@ module Mutant
|
|
129
123
|
# @return [undefined]
|
130
124
|
#
|
131
125
|
# @api private
|
132
|
-
#
|
133
126
|
def visit_test_result
|
134
127
|
visit(TestResult, test_result)
|
135
128
|
end
|
136
129
|
|
137
|
-
#
|
130
|
+
# Original node
|
138
131
|
#
|
139
132
|
# @return [Parser::AST::Node]
|
140
133
|
#
|
141
134
|
# @api private
|
142
|
-
#
|
143
135
|
def original_node
|
144
136
|
mutation.subject.node
|
145
137
|
end
|
@@ -15,7 +15,6 @@ module Mutant
|
|
15
15
|
# @return [undefined]
|
16
16
|
#
|
17
17
|
# @api private
|
18
|
-
#
|
19
18
|
def run
|
20
19
|
visit(EnvProgress, payload)
|
21
20
|
job_status
|
@@ -30,7 +29,6 @@ module Mutant
|
|
30
29
|
# @return [undefined]
|
31
30
|
#
|
32
31
|
# @api private
|
33
|
-
#
|
34
32
|
def job_status
|
35
33
|
return if active_jobs.empty?
|
36
34
|
info(ACTIVE_JOB_HEADER)
|
@@ -39,12 +37,11 @@ module Mutant
|
|
39
37
|
end
|
40
38
|
end
|
41
39
|
|
42
|
-
#
|
40
|
+
# Active subject results
|
43
41
|
#
|
44
42
|
# @return [Array<Result::Subject>]
|
45
43
|
#
|
46
44
|
# @api private
|
47
|
-
#
|
48
45
|
def active_subject_results
|
49
46
|
active_subjects = active_jobs.map(&:payload).flat_map(&:subject)
|
50
47
|
|
@@ -21,7 +21,6 @@ module Mutant
|
|
21
21
|
# @return [undefined]
|
22
22
|
#
|
23
23
|
# @api private
|
24
|
-
#
|
25
24
|
def run
|
26
25
|
status(
|
27
26
|
FORMAT,
|
@@ -36,12 +35,11 @@ module Mutant
|
|
36
35
|
|
37
36
|
private
|
38
37
|
|
39
|
-
#
|
38
|
+
# Object being printed
|
40
39
|
#
|
41
40
|
# @return [Result::Env]
|
42
41
|
#
|
43
42
|
# @api private
|
44
|
-
#
|
45
43
|
def object
|
46
44
|
super.payload
|
47
45
|
end
|
@@ -23,7 +23,6 @@ module Mutant
|
|
23
23
|
# @return [undefined]
|
24
24
|
#
|
25
25
|
# @api private
|
26
|
-
#
|
27
26
|
def run
|
28
27
|
puts("#{subject.identification} mutations: #{amount_mutations}")
|
29
28
|
print_mutation_results
|
@@ -39,7 +38,6 @@ module Mutant
|
|
39
38
|
# @return [undefined]
|
40
39
|
#
|
41
40
|
# @api private
|
42
|
-
#
|
43
41
|
def print_stats
|
44
42
|
status(
|
45
43
|
FORMAT,
|
@@ -57,7 +55,6 @@ module Mutant
|
|
57
55
|
# @return [undefined]
|
58
56
|
#
|
59
57
|
# @api private
|
60
|
-
#
|
61
58
|
def print_tests
|
62
59
|
tests.each do |test|
|
63
60
|
puts "- #{test.identification}"
|
@@ -69,7 +66,6 @@ module Mutant
|
|
69
66
|
# @return [undefined]
|
70
67
|
#
|
71
68
|
# @api private
|
72
|
-
#
|
73
69
|
def print_progress_bar_finish
|
74
70
|
puts(nil) unless amount_mutation_results.zero?
|
75
71
|
end
|
@@ -79,7 +75,6 @@ module Mutant
|
|
79
75
|
# @return [undefined]
|
80
76
|
#
|
81
77
|
# @api private
|
82
|
-
#
|
83
78
|
def print_mutation_results
|
84
79
|
visit_collection(MutationProgressResult, object.mutation_results)
|
85
80
|
end
|
@@ -7,13 +7,15 @@ module Mutant
|
|
7
7
|
|
8
8
|
private_class_method :new
|
9
9
|
|
10
|
-
#
|
10
|
+
# Detected tput support
|
11
11
|
#
|
12
12
|
# @return [Tput]
|
13
13
|
# if tput support is present
|
14
14
|
#
|
15
15
|
# @return [nil]
|
16
16
|
# otherwise
|
17
|
+
#
|
18
|
+
# @api private
|
17
19
|
def self.detect
|
18
20
|
reset = capture('tput reset')
|
19
21
|
save = capture('tput sc') if reset
|
@@ -33,6 +35,7 @@ module Mutant
|
|
33
35
|
# @return [nil]
|
34
36
|
# otherwise
|
35
37
|
#
|
38
|
+
# @api private
|
36
39
|
def self.capture(command)
|
37
40
|
stdout, _stderr, exitstatus = Open3.capture3(command)
|
38
41
|
stdout if exitstatus.success?
|
@@ -4,12 +4,11 @@ module Mutant
|
|
4
4
|
class Trace
|
5
5
|
include Adamantium::Mutable, Anima.new(:start_calls, :progress_calls, :report_calls, :warn_calls)
|
6
6
|
|
7
|
-
#
|
7
|
+
# New trace reporter
|
8
8
|
#
|
9
9
|
# @return [Trace]
|
10
10
|
#
|
11
11
|
# @api private
|
12
|
-
#
|
13
12
|
def self.new
|
14
13
|
super(Hash[anima.attribute_names.map { |name| [name, []] }])
|
15
14
|
end
|
@@ -23,12 +22,11 @@ module Mutant
|
|
23
22
|
|
24
23
|
REPORT_DELAY = 0.0
|
25
24
|
|
26
|
-
#
|
25
|
+
# Report delay
|
27
26
|
#
|
28
27
|
# @return [Float]
|
29
28
|
#
|
30
29
|
# @api private
|
31
|
-
#
|
32
30
|
def delay
|
33
31
|
REPORT_DELAY
|
34
32
|
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module Mutant
|
2
|
+
module Repository
|
3
|
+
# Error raised on repository interaction problems
|
4
|
+
RepositoryError = Class.new(RuntimeError)
|
5
|
+
|
6
|
+
# Subject filter based on repository diff
|
7
|
+
class SubjectFilter
|
8
|
+
include Adamantium, Concord.new(:diff)
|
9
|
+
|
10
|
+
# Test if subject was touched in diff
|
11
|
+
#
|
12
|
+
# @param [Subject] subject
|
13
|
+
#
|
14
|
+
# @return [Boolean]
|
15
|
+
#
|
16
|
+
# @api private
|
17
|
+
def call(subject)
|
18
|
+
diff.touches?(subject.source_path, subject.source_lines)
|
19
|
+
end
|
20
|
+
|
21
|
+
end # SubjectFilter
|
22
|
+
|
23
|
+
# Diff between two objects in repository
|
24
|
+
class Diff
|
25
|
+
include Adamantium, Concord.new(:from, :to)
|
26
|
+
|
27
|
+
HEAD = 'HEAD'.freeze
|
28
|
+
private_constant(*constants(false))
|
29
|
+
|
30
|
+
# Create diff from head to revision
|
31
|
+
#
|
32
|
+
# @return [Diff]
|
33
|
+
#
|
34
|
+
# @api private
|
35
|
+
def self.from_head(to)
|
36
|
+
new(HEAD, to)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Test if diff changes file at line range
|
40
|
+
#
|
41
|
+
# @param [Pathname] path
|
42
|
+
# @param [Range<Fixnum>] line_range
|
43
|
+
#
|
44
|
+
# @return [Boolean]
|
45
|
+
#
|
46
|
+
# @raise [RepositoryError]
|
47
|
+
# when git command failed
|
48
|
+
#
|
49
|
+
# @api private
|
50
|
+
def touches?(path, line_range)
|
51
|
+
return false unless tracks?(path)
|
52
|
+
|
53
|
+
command = %W[
|
54
|
+
git log
|
55
|
+
#{from}...#{to}
|
56
|
+
-L #{line_range.begin},#{line_range.end}:#{path}
|
57
|
+
]
|
58
|
+
|
59
|
+
stdout, status = Open3.capture2(*command, binmode: true)
|
60
|
+
|
61
|
+
fail RepositoryError, "Command #{command} failed!" unless status.success?
|
62
|
+
|
63
|
+
!stdout.empty?
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
# Test if path is tracked in repository
|
69
|
+
#
|
70
|
+
# FIXME: Cache results, to avoid spending time on producing redundant results.
|
71
|
+
#
|
72
|
+
# @param [Pathname] path
|
73
|
+
#
|
74
|
+
# @return [Boolean]
|
75
|
+
#
|
76
|
+
# @api private
|
77
|
+
def tracks?(path)
|
78
|
+
command = %W[git ls-files --error-unmatch -- #{path}]
|
79
|
+
Kernel.system(
|
80
|
+
*command,
|
81
|
+
out: File::NULL,
|
82
|
+
err: File::NULL
|
83
|
+
)
|
84
|
+
end
|
85
|
+
|
86
|
+
end # Diff
|
87
|
+
end # Repository
|
88
|
+
end # Mutant
|
data/lib/mutant/result.rb
CHANGED
@@ -4,33 +4,21 @@ module Mutant
|
|
4
4
|
|
5
5
|
# Coverage mixin
|
6
6
|
module Coverage
|
7
|
+
FULL_COVERAGE = Rational(1).freeze
|
8
|
+
private_constant(*constants(false))
|
7
9
|
|
8
|
-
#
|
10
|
+
# Observed coverage
|
9
11
|
#
|
10
12
|
# @return [Rational]
|
11
13
|
#
|
12
14
|
# @api private
|
13
|
-
#
|
14
15
|
def coverage
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
# Hook called when module gets included
|
21
|
-
#
|
22
|
-
# @param [Class, Module] host
|
23
|
-
#
|
24
|
-
# @return [undefined]
|
25
|
-
#
|
26
|
-
# @api private
|
27
|
-
#
|
28
|
-
def self.included(host)
|
29
|
-
super
|
30
|
-
|
31
|
-
host.memoize(:coverage)
|
16
|
+
if amount_mutation_results.zero?
|
17
|
+
FULL_COVERAGE
|
18
|
+
else
|
19
|
+
Rational(amount_mutations_killed, amount_mutation_results)
|
20
|
+
end
|
32
21
|
end
|
33
|
-
|
34
22
|
end # Coverage
|
35
23
|
|
36
24
|
# Class level mixin
|
@@ -47,7 +35,6 @@ module Mutant
|
|
47
35
|
# @return [undefined]
|
48
36
|
#
|
49
37
|
# @api private
|
50
|
-
#
|
51
38
|
def sum(name, collection)
|
52
39
|
define_method(name) do
|
53
40
|
public_send(collection).map(&name).reduce(0, :+)
|
@@ -56,12 +43,17 @@ module Mutant
|
|
56
43
|
end
|
57
44
|
end # ClassMethods
|
58
45
|
|
59
|
-
|
46
|
+
private_constant(*constants(false))
|
47
|
+
|
48
|
+
# Mutant overhead running mutatet tests
|
49
|
+
#
|
50
|
+
# This is NOT the overhead of mutation testing, just an engine specific
|
51
|
+
# measurement for the efficiency of the parellelization engine, kill
|
52
|
+
# isolation etc.
|
60
53
|
#
|
61
54
|
# @return [Float]
|
62
55
|
#
|
63
56
|
# @api private
|
64
|
-
#
|
65
57
|
def overhead
|
66
58
|
runtime - killtime
|
67
59
|
end
|
@@ -73,7 +65,6 @@ module Mutant
|
|
73
65
|
# @return [undefined]
|
74
66
|
#
|
75
67
|
# @api private
|
76
|
-
#
|
77
68
|
def self.included(host)
|
78
69
|
host.class_eval do
|
79
70
|
include Adamantium, Anima::Update
|
@@ -90,18 +81,16 @@ module Mutant
|
|
90
81
|
# @return [Boolean]
|
91
82
|
#
|
92
83
|
# @api private
|
93
|
-
#
|
94
84
|
def success?
|
95
85
|
coverage.eql?(env.config.expected_coverage)
|
96
86
|
end
|
97
87
|
memoize :success?
|
98
88
|
|
99
|
-
#
|
89
|
+
# Failed subject results
|
100
90
|
#
|
101
91
|
# @return [Array<Result::Subject>]
|
102
92
|
#
|
103
93
|
# @api private
|
104
|
-
#
|
105
94
|
def failed_subject_results
|
106
95
|
subject_results.reject(&:success?)
|
107
96
|
end
|
@@ -111,22 +100,20 @@ module Mutant
|
|
111
100
|
sum :amount_mutations_killed, :subject_results
|
112
101
|
sum :killtime, :subject_results
|
113
102
|
|
114
|
-
#
|
103
|
+
# Amount of mutations
|
115
104
|
#
|
116
105
|
# @return [Fixnum]
|
117
106
|
#
|
118
107
|
# @api private
|
119
|
-
#
|
120
108
|
def amount_mutations
|
121
109
|
env.mutations.length
|
122
110
|
end
|
123
111
|
|
124
|
-
#
|
112
|
+
# Amount of subjects
|
125
113
|
#
|
126
114
|
# @return [Fixnum]
|
127
115
|
#
|
128
116
|
# @api private
|
129
|
-
#
|
130
117
|
def amount_subjects
|
131
118
|
env.subjects.length
|
132
119
|
end
|
@@ -155,7 +142,6 @@ module Mutant
|
|
155
142
|
# @return [Boolean]
|
156
143
|
#
|
157
144
|
# @api private
|
158
|
-
#
|
159
145
|
def success?
|
160
146
|
alive_mutation_results.empty?
|
161
147
|
end
|
@@ -165,68 +151,61 @@ module Mutant
|
|
165
151
|
# @return [Boolean]
|
166
152
|
#
|
167
153
|
# @api private
|
168
|
-
#
|
169
154
|
def continue?
|
170
155
|
mutation_results.all?(&:success?)
|
171
156
|
end
|
172
157
|
|
173
|
-
#
|
158
|
+
# Killed mutations
|
174
159
|
#
|
175
160
|
# @return [Array<Result::Mutation>]
|
176
161
|
#
|
177
162
|
# @api private
|
178
|
-
#
|
179
163
|
def alive_mutation_results
|
180
164
|
mutation_results.reject(&:success?)
|
181
165
|
end
|
182
166
|
memoize :alive_mutation_results
|
183
167
|
|
184
|
-
#
|
168
|
+
# Amount of mutations
|
185
169
|
#
|
186
170
|
# @return [Fixnum]
|
187
171
|
#
|
188
172
|
# @api private
|
189
|
-
#
|
190
173
|
def amount_mutation_results
|
191
174
|
mutation_results.length
|
192
175
|
end
|
193
176
|
|
194
|
-
#
|
177
|
+
# Amount of mutations
|
195
178
|
#
|
196
179
|
# @return [Fixnum]
|
197
180
|
#
|
198
181
|
# @api private
|
199
|
-
#
|
200
182
|
def amount_mutations
|
201
183
|
subject.mutations.length
|
202
184
|
end
|
203
185
|
|
204
|
-
#
|
186
|
+
# Number of killed mutations
|
205
187
|
#
|
206
188
|
# @return [Fixnum]
|
207
189
|
#
|
208
190
|
# @api private
|
209
|
-
#
|
210
191
|
def amount_mutations_killed
|
211
192
|
killed_mutation_results.length
|
212
193
|
end
|
213
194
|
|
214
|
-
#
|
195
|
+
# Number of alive mutations
|
215
196
|
#
|
216
197
|
# @return [Fixnum]
|
217
198
|
#
|
218
199
|
# @api private
|
219
|
-
#
|
220
200
|
def amount_mutations_alive
|
221
201
|
alive_mutation_results.length
|
222
202
|
end
|
223
203
|
|
224
|
-
#
|
204
|
+
# Alive mutations
|
225
205
|
#
|
226
206
|
# @return [Array<Result::Mutation>]
|
227
207
|
#
|
228
208
|
# @api private
|
229
|
-
#
|
230
209
|
def killed_mutation_results
|
231
210
|
mutation_results.select(&:success?)
|
232
211
|
end
|
@@ -238,12 +217,11 @@ module Mutant
|
|
238
217
|
class Mutation
|
239
218
|
include Result, Anima.new(:mutation, :test_result)
|
240
219
|
|
241
|
-
#
|
220
|
+
# The runtime
|
242
221
|
#
|
243
222
|
# @return [Float]
|
244
223
|
#
|
245
224
|
# @api private
|
246
|
-
#
|
247
225
|
def runtime
|
248
226
|
test_result.runtime
|
249
227
|
end
|
@@ -255,7 +233,6 @@ module Mutant
|
|
255
233
|
# @return [Boolean]
|
256
234
|
#
|
257
235
|
# @api private
|
258
|
-
#
|
259
236
|
def success?
|
260
237
|
mutation.class.success?(test_result)
|
261
238
|
end
|