covered 0.18.5 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/covered/capture.rb +20 -72
- data/lib/covered/config.rb +0 -2
- data/lib/covered/files.rb +4 -0
- data/lib/covered/policy.rb +0 -5
- data/lib/covered/version.rb +1 -1
- data.tar.gz.sig +4 -4
- metadata +3 -18
- metadata.gz.sig +0 -0
- 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: d7f641ef55ad67441aee4c21d0f7221b955f17340baf9e51d7c133c58c5343ae
|
4
|
+
data.tar.gz: 43ccf1cf59d39fef08a271a2a3b97c4756b9e08916a4fb31efcd5903d8ff14cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf1576281c6fb28953788771f793c88ed0cb96b26795d78fbbd15a60f216140c69f24b3a5621279e5bde25fb00e77bb3a8c398f2512c465d7fa62f85ff35a792
|
7
|
+
data.tar.gz: bfe434cc0c0d3162e87192b714d3459341178649907e187ec9d3aa93e2567f9eea98b9e0cc8831379a647913b9d1862d51e3dc852c42a7ffb37277f04640ff5b
|
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
|
40
|
-
|
41
|
-
def enable
|
42
|
-
super
|
43
|
-
|
44
|
-
@trace&.enable
|
45
|
-
end
|
46
|
-
|
47
|
-
def disable
|
48
|
-
@trace&.disable
|
49
|
-
|
50
|
-
super
|
51
|
-
end
|
11
|
+
class Capture < Wrapper
|
12
|
+
def enable
|
13
|
+
super
|
52
14
|
|
53
|
-
|
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
27
|
end
|
28
|
+
|
29
|
+
super
|
30
|
+
end
|
82
31
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
end
|
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
data/lib/covered/files.rb
CHANGED
data/lib/covered/policy.rb
CHANGED
@@ -5,7 +5,6 @@
|
|
5
5
|
|
6
6
|
require_relative "summary"
|
7
7
|
require_relative "files"
|
8
|
-
require_relative "source"
|
9
8
|
require_relative "capture"
|
10
9
|
require_relative "cache"
|
11
10
|
require_relative "persist"
|
@@ -29,10 +28,6 @@ module Covered
|
|
29
28
|
super
|
30
29
|
end
|
31
30
|
|
32
|
-
def source(*args)
|
33
|
-
@output = Source.new(@output, *args)
|
34
|
-
end
|
35
|
-
|
36
31
|
def include(*args)
|
37
32
|
@output = Include.new(@output, *args)
|
38
33
|
end
|
data/lib/covered/version.rb
CHANGED
data.tar.gz.sig
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
2
|
-
�
|
3
|
-
|
4
|
-
|
1
|
+
M��8�vd����I� |�8��?9�(Z�'�e�G�uz�2�y�0�֮b�-�
|
2
|
+
�Dm�1�r
|
3
|
+
���OP)~bپ���R����$�ʓ
|
4
|
+
�]C�t_�q��$�Ԟ�\:�:J���AL�ᣑ�@���){a3OK͖Y"�@0;݄��=�z"͐f]Ň2���C
|
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.0
|
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-29 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
|
@@ -160,7 +146,6 @@ files:
|
|
160
146
|
- lib/covered/persist.rb
|
161
147
|
- lib/covered/policy.rb
|
162
148
|
- lib/covered/rspec.rb
|
163
|
-
- lib/covered/source.rb
|
164
149
|
- lib/covered/statistics.rb
|
165
150
|
- lib/covered/summary.rb
|
166
151
|
- lib/covered/sus.rb
|
@@ -181,7 +166,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
181
166
|
requirements:
|
182
167
|
- - ">="
|
183
168
|
- !ruby/object:Gem::Version
|
184
|
-
version: '
|
169
|
+
version: '3.2'
|
185
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
186
171
|
requirements:
|
187
172
|
- - ">="
|
metadata.gz.sig
CHANGED
Binary file
|
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
|