covered 0.18.5 → 0.19.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/covered/capture.rb +21 -73
- data/lib/covered/config.rb +0 -4
- data/lib/covered/files.rb +4 -0
- data/lib/covered/persist.rb +2 -1
- data/lib/covered/policy.rb +14 -24
- data/lib/covered/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +3 -19
- metadata.gz.sig +0 -0
- data/lib/covered/cache.rb +0 -50
- data/lib/covered/source.rb +0 -163
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22da5b4e371b8fb06056b96b3f6a9a0d7755a1684e9e4371d45beae886ba9616
|
4
|
+
data.tar.gz: c841065dece4f121afd7e4b3fe070327c0de15c5fedd972e089950eccf11375b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c63bdb36d6fb7573cf9bd82fe2bc6f441729470d40b2b5043c164b4ff6d8d6e43513a88692443942613bbb307964814d5b7510325d1da53bdac93b2301d50328
|
7
|
+
data.tar.gz: eb1812bc6debd69bd01004ab0042aa45167a56788fecee49f2f1710689a1cd6fa6d99026352d5a45eaecb0f904720763d7cc3de600a870ac1fdb656a70b80406
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/covered/capture.rb
CHANGED
@@ -8,85 +8,33 @@ require_relative 'wrapper'
|
|
8
8
|
require 'coverage'
|
9
9
|
|
10
10
|
module Covered
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
unless self.coverage_with_eval?
|
18
|
-
class Capture < Wrapper
|
19
|
-
def initialize(output)
|
20
|
-
super(output)
|
21
|
-
|
22
|
-
begin
|
23
|
-
@trace = TracePoint.new(:line, :call, :c_call) do |trace|
|
24
|
-
if trace.event == :call
|
25
|
-
# Ruby doesn't always mark call-sites in sub-expressions, so we use this approach to compute a call site and mark it:
|
26
|
-
if location = caller_locations(2, 1).first and path = location.path
|
27
|
-
@output.mark(path, location.lineno, 1)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
if path = trace.path
|
32
|
-
@output.mark(path, trace.lineno, 1)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
rescue
|
36
|
-
warn "Line coverage disabled: #{$!}"
|
37
|
-
@trace = nil
|
38
|
-
end
|
39
|
-
end
|
11
|
+
class Capture < Wrapper
|
12
|
+
def enable
|
13
|
+
super
|
40
14
|
|
41
|
-
|
42
|
-
super
|
43
|
-
|
44
|
-
@trace&.enable
|
45
|
-
end
|
46
|
-
|
47
|
-
def disable
|
48
|
-
@trace&.disable
|
49
|
-
|
50
|
-
super
|
51
|
-
end
|
52
|
-
|
53
|
-
def execute(source, binding: TOPLEVEL_BINDING)
|
54
|
-
enable
|
55
|
-
|
56
|
-
eval(source.code!, binding, source.path)
|
57
|
-
ensure
|
58
|
-
disable
|
59
|
-
end
|
15
|
+
::Coverage.start(lines: true, eval: true)
|
60
16
|
end
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
super
|
65
|
-
|
66
|
-
::Coverage.start(lines: true, eval: true)
|
67
|
-
end
|
68
|
-
|
69
|
-
def disable
|
70
|
-
results = ::Coverage.result
|
17
|
+
|
18
|
+
def disable
|
19
|
+
results = ::Coverage.result
|
71
20
|
|
72
|
-
|
73
|
-
|
21
|
+
results.each do |path, result|
|
22
|
+
lines = result[:lines]
|
74
23
|
|
75
|
-
|
76
|
-
|
77
|
-
end
|
24
|
+
lines.each_with_index do |count, lineno|
|
25
|
+
@output.mark(path, lineno+1, count) if count
|
78
26
|
end
|
79
|
-
|
80
|
-
super
|
81
|
-
end
|
82
|
-
|
83
|
-
def execute(source, binding: TOPLEVEL_BINDING)
|
84
|
-
enable
|
85
|
-
|
86
|
-
eval(source.code!, binding, source.path)
|
87
|
-
ensure
|
88
|
-
disable
|
89
27
|
end
|
28
|
+
|
29
|
+
super
|
30
|
+
end
|
31
|
+
|
32
|
+
def execute(source, binding: TOPLEVEL_BINDING)
|
33
|
+
enable
|
34
|
+
|
35
|
+
eval(source.code!, binding, source.path, source.line_offset)
|
36
|
+
ensure
|
37
|
+
disable
|
90
38
|
end
|
91
39
|
end
|
92
40
|
end
|
data/lib/covered/config.rb
CHANGED
@@ -75,8 +75,6 @@ module Covered
|
|
75
75
|
|
76
76
|
# Override this method to implement your own policy.
|
77
77
|
def make_policy(policy)
|
78
|
-
policy.cache!
|
79
|
-
|
80
78
|
# Only files in the root would be tracked:
|
81
79
|
policy.root(@root)
|
82
80
|
|
@@ -88,8 +86,6 @@ module Covered
|
|
88
86
|
|
89
87
|
policy.persist!
|
90
88
|
|
91
|
-
policy.source
|
92
|
-
|
93
89
|
policy.reports!(@coverage)
|
94
90
|
end
|
95
91
|
end
|
data/lib/covered/files.rb
CHANGED
data/lib/covered/persist.rb
CHANGED
@@ -16,7 +16,7 @@ module Covered
|
|
16
16
|
def initialize(output, path = DEFAULT_PATH)
|
17
17
|
super(output)
|
18
18
|
|
19
|
-
@path = path
|
19
|
+
@path = self.expand_path(path)
|
20
20
|
@touched = Set.new
|
21
21
|
end
|
22
22
|
|
@@ -51,6 +51,7 @@ module Covered
|
|
51
51
|
def serialize(coverage)
|
52
52
|
{
|
53
53
|
# We want to use relative paths so that moving the repo won't break everything:
|
54
|
+
pid: Process.pid,
|
54
55
|
path: relative_path(coverage.path),
|
55
56
|
mtime: File.mtime(coverage.path).to_f,
|
56
57
|
counts: coverage.counts,
|
data/lib/covered/policy.rb
CHANGED
@@ -5,9 +5,7 @@
|
|
5
5
|
|
6
6
|
require_relative "summary"
|
7
7
|
require_relative "files"
|
8
|
-
require_relative "source"
|
9
8
|
require_relative "capture"
|
10
|
-
require_relative "cache"
|
11
9
|
require_relative "persist"
|
12
10
|
|
13
11
|
module Covered
|
@@ -29,32 +27,24 @@ module Covered
|
|
29
27
|
super
|
30
28
|
end
|
31
29
|
|
32
|
-
def
|
33
|
-
@output =
|
30
|
+
def include(...)
|
31
|
+
@output = Include.new(@output, ...)
|
34
32
|
end
|
35
33
|
|
36
|
-
def
|
37
|
-
@output =
|
34
|
+
def skip(...)
|
35
|
+
@output = Skip.new(@output, ...)
|
38
36
|
end
|
39
37
|
|
40
|
-
def
|
41
|
-
@output =
|
38
|
+
def only(...)
|
39
|
+
@output = Only.new(@output, ...)
|
42
40
|
end
|
43
41
|
|
44
|
-
def
|
45
|
-
@output =
|
42
|
+
def root(...)
|
43
|
+
@output = Root.new(@output, ...)
|
46
44
|
end
|
47
45
|
|
48
|
-
def
|
49
|
-
@output =
|
50
|
-
end
|
51
|
-
|
52
|
-
def cache!
|
53
|
-
@output = Cache.new(@output)
|
54
|
-
end
|
55
|
-
|
56
|
-
def persist!
|
57
|
-
@output = Persist.new(@output)
|
46
|
+
def persist!(...)
|
47
|
+
@output = Persist.new(@output, ...)
|
58
48
|
end
|
59
49
|
|
60
50
|
def capture
|
@@ -92,8 +82,8 @@ module Covered
|
|
92
82
|
return klass.new
|
93
83
|
end
|
94
84
|
|
95
|
-
def call(
|
96
|
-
self.new.call(
|
85
|
+
def call(...)
|
86
|
+
self.new.call(...)
|
97
87
|
end
|
98
88
|
|
99
89
|
def to_s
|
@@ -128,9 +118,9 @@ module Covered
|
|
128
118
|
end
|
129
119
|
end
|
130
120
|
|
131
|
-
def call(
|
121
|
+
def call(...)
|
132
122
|
@reports.each do |report|
|
133
|
-
report.call(self,
|
123
|
+
report.call(self, ...)
|
134
124
|
end
|
135
125
|
end
|
136
126
|
end
|
data/lib/covered/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: covered
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.19.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -41,7 +41,7 @@ cert_chain:
|
|
41
41
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
42
42
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
43
43
|
-----END CERTIFICATE-----
|
44
|
-
date: 2022-12-
|
44
|
+
date: 2022-12-30 00:00:00.000000000 Z
|
45
45
|
dependencies:
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: console
|
@@ -71,20 +71,6 @@ dependencies:
|
|
71
71
|
- - "~>"
|
72
72
|
- !ruby/object:Gem::Version
|
73
73
|
version: '1.0'
|
74
|
-
- !ruby/object:Gem::Dependency
|
75
|
-
name: parser
|
76
|
-
requirement: !ruby/object:Gem::Requirement
|
77
|
-
requirements:
|
78
|
-
- - ">="
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
version: '0'
|
81
|
-
type: :runtime
|
82
|
-
prerelease: false
|
83
|
-
version_requirements: !ruby/object:Gem::Requirement
|
84
|
-
requirements:
|
85
|
-
- - ">="
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
version: '0'
|
88
74
|
- !ruby/object:Gem::Dependency
|
89
75
|
name: bundler
|
90
76
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,7 +136,6 @@ files:
|
|
150
136
|
- bake/covered/debug.rb
|
151
137
|
- bake/covered/validate.rb
|
152
138
|
- lib/covered.rb
|
153
|
-
- lib/covered/cache.rb
|
154
139
|
- lib/covered/capture.rb
|
155
140
|
- lib/covered/config.rb
|
156
141
|
- lib/covered/coverage.rb
|
@@ -160,7 +145,6 @@ files:
|
|
160
145
|
- lib/covered/persist.rb
|
161
146
|
- lib/covered/policy.rb
|
162
147
|
- lib/covered/rspec.rb
|
163
|
-
- lib/covered/source.rb
|
164
148
|
- lib/covered/statistics.rb
|
165
149
|
- lib/covered/summary.rb
|
166
150
|
- lib/covered/sus.rb
|
@@ -181,7 +165,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
181
165
|
requirements:
|
182
166
|
- - ">="
|
183
167
|
- !ruby/object:Gem::Version
|
184
|
-
version: '
|
168
|
+
version: '3.2'
|
185
169
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
186
170
|
requirements:
|
187
171
|
- - ">="
|
metadata.gz.sig
CHANGED
Binary file
|
data/lib/covered/cache.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Released under the MIT License.
|
4
|
-
# Copyright, 2022, by Samuel Williams.
|
5
|
-
|
6
|
-
require_relative 'wrapper'
|
7
|
-
|
8
|
-
require 'coverage'
|
9
|
-
|
10
|
-
module Covered
|
11
|
-
class Cache < Wrapper
|
12
|
-
def initialize(output)
|
13
|
-
super(output)
|
14
|
-
|
15
|
-
@marks = nil
|
16
|
-
end
|
17
|
-
|
18
|
-
def mark(path, lineno, count = 1)
|
19
|
-
if @marks
|
20
|
-
@marks.push(path, lineno, count)
|
21
|
-
else
|
22
|
-
super
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def enable
|
27
|
-
@marks = []
|
28
|
-
|
29
|
-
super
|
30
|
-
end
|
31
|
-
|
32
|
-
def flush
|
33
|
-
if @marks
|
34
|
-
@marks.each_slice(3) do |path, lineno, count|
|
35
|
-
@output.mark(path, lineno, count)
|
36
|
-
end
|
37
|
-
|
38
|
-
@marks = nil
|
39
|
-
end
|
40
|
-
|
41
|
-
super
|
42
|
-
end
|
43
|
-
|
44
|
-
def disable
|
45
|
-
super
|
46
|
-
|
47
|
-
flush
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
data/lib/covered/source.rb
DELETED
@@ -1,163 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Released under the MIT License.
|
4
|
-
# Copyright, 2018-2022, by Samuel Williams.
|
5
|
-
|
6
|
-
require_relative 'wrapper'
|
7
|
-
|
8
|
-
require 'thread'
|
9
|
-
require 'parser/current'
|
10
|
-
|
11
|
-
module Covered
|
12
|
-
# The source map, loads the source file, parses the AST to generate which lines contain executable code.
|
13
|
-
class Source < Wrapper
|
14
|
-
def initialize(output)
|
15
|
-
super(output)
|
16
|
-
|
17
|
-
begin
|
18
|
-
@trace = TracePoint.new(:script_compiled) do |trace|
|
19
|
-
instruction_sequence = trace.instruction_sequence
|
20
|
-
|
21
|
-
# We only track source files which begin at line 1, as these represent whole files instead of monkey patches.
|
22
|
-
if instruction_sequence.first_lineno <= 1
|
23
|
-
# Extract the source path and source itself and save it for later:
|
24
|
-
if path = instruction_sequence.path and script = trace.eval_script
|
25
|
-
self.add(Coverage::Source.new(path, script, instruction_sequence.first_lineno))
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
rescue
|
30
|
-
warn "Script coverage disabled: #{$!}"
|
31
|
-
@trace = nil
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def enable
|
36
|
-
super
|
37
|
-
|
38
|
-
@trace&.enable
|
39
|
-
end
|
40
|
-
|
41
|
-
def disable
|
42
|
-
@trace&.disable
|
43
|
-
|
44
|
-
super
|
45
|
-
end
|
46
|
-
|
47
|
-
attr :paths
|
48
|
-
|
49
|
-
EXECUTABLE = {
|
50
|
-
send: true,
|
51
|
-
yield: true,
|
52
|
-
# Line trace point is not triggered for return statements.
|
53
|
-
# return: true,
|
54
|
-
def: true,
|
55
|
-
if: true,
|
56
|
-
lvasgn: true,
|
57
|
-
ivasgn: true,
|
58
|
-
cvasgn: true,
|
59
|
-
gvasgn: true,
|
60
|
-
match_pattern: true,
|
61
|
-
}
|
62
|
-
|
63
|
-
def executable?(node)
|
64
|
-
EXECUTABLE[node.type]
|
65
|
-
end
|
66
|
-
|
67
|
-
IGNORE = {
|
68
|
-
arg: true,
|
69
|
-
}
|
70
|
-
|
71
|
-
def ignore?(node)
|
72
|
-
node.nil? || IGNORE[node.type]
|
73
|
-
end
|
74
|
-
|
75
|
-
IGNORE_CHILDREN = {
|
76
|
-
hash: true,
|
77
|
-
array: true,
|
78
|
-
}
|
79
|
-
|
80
|
-
def ignore_children?(node)
|
81
|
-
IGNORE_CHILDREN[node.type]
|
82
|
-
end
|
83
|
-
|
84
|
-
IGNORE_METHOD = {
|
85
|
-
freeze: true
|
86
|
-
}
|
87
|
-
|
88
|
-
def ignore_method?(name)
|
89
|
-
IGNORE_METHOD[name]
|
90
|
-
end
|
91
|
-
|
92
|
-
def expand(node, coverage, level = 0)
|
93
|
-
if node.is_a? Parser::AST::Node
|
94
|
-
if ignore?(node)
|
95
|
-
# coverage.annotate(node.location.line, "ignoring #{node.type}")
|
96
|
-
elsif node.type == :begin
|
97
|
-
# if last_child = node.children&.last
|
98
|
-
# coverage.counts[last_child.location.line] ||= 0
|
99
|
-
# end
|
100
|
-
|
101
|
-
return expand(node.children, coverage, level + 1)
|
102
|
-
elsif node.type == :send
|
103
|
-
if ignore_method?(node.children[1])
|
104
|
-
# coverage.annotate(node.location.line, "ignoring #{node.type}")
|
105
|
-
return
|
106
|
-
else
|
107
|
-
# coverage.annotate(node.location.line, "accepting selector #{node.type}")
|
108
|
-
coverage.counts[node.location.selector.line] ||= 0
|
109
|
-
end
|
110
|
-
elsif node.type == :resbody
|
111
|
-
return expand(node.children[2], coverage, level + 1)
|
112
|
-
elsif executable?(node)
|
113
|
-
# coverage.annotate(node.location.line, "executable #{node.type}")
|
114
|
-
coverage.counts[node.location.line] ||= 0
|
115
|
-
end
|
116
|
-
|
117
|
-
if ignore_children?(node)
|
118
|
-
# coverage.annotate(node.location.line, "ignoring #{node.type} children")
|
119
|
-
else
|
120
|
-
expand(node.children, coverage, level + 1)
|
121
|
-
end
|
122
|
-
elsif node.is_a? Array
|
123
|
-
node.each do |child|
|
124
|
-
expand(child, coverage, level)
|
125
|
-
end
|
126
|
-
else
|
127
|
-
return false
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
def add(source)
|
132
|
-
if coverage = super
|
133
|
-
if top = self.parse(source)
|
134
|
-
self.expand(top, coverage)
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
return coverage
|
139
|
-
end
|
140
|
-
|
141
|
-
def parse(source)
|
142
|
-
if source.code?
|
143
|
-
Parser::CurrentRuby.parse(source.code, source.path, source.line_offset)
|
144
|
-
elsif path = source.path and File.exist?(path)
|
145
|
-
Parser::CurrentRuby.parse_file(path)
|
146
|
-
else
|
147
|
-
# warn "Couldn't parse #{path}, file doesn't exist?"
|
148
|
-
end
|
149
|
-
rescue
|
150
|
-
warn "Couldn't parse #{source}: #{$!}"
|
151
|
-
end
|
152
|
-
|
153
|
-
def each(&block)
|
154
|
-
@output.each do |coverage|
|
155
|
-
if top = parse(coverage.source)
|
156
|
-
self.expand(top, coverage)
|
157
|
-
end
|
158
|
-
|
159
|
-
yield coverage.freeze
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|