covered 0.16.9 → 0.17.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 +2 -2
- data/lib/covered/coverage.rb +39 -8
- data/lib/covered/files.rb +4 -4
- data/lib/covered/persist.rb +13 -2
- data/lib/covered/rspec.rb +1 -15
- data/lib/covered/source.rb +12 -20
- data/lib/covered/version.rb +1 -1
- data/lib/covered/wrapper.rb +3 -3
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b906f699dc0a8c5ab648200ae5330cf12a0da31e5c6966bb105d1df387c7179
|
4
|
+
data.tar.gz: 6692c75aa8764654a5a278e248bf4b9f224a10e84363a7cbf0dfc68ba5d84be6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6656a91ce7b29c67c66dd9e1d63f9c38231b1bfbdedae4ce29b638468d55d0476d308522ecf24d07fee905081653d192cd90d73cf1772b59fd7534f87bfd2cbb
|
7
|
+
data.tar.gz: 21f2d81e59417f81bcf63c7c95e0a6023c67bd68985811f3e2184c1fdbd447be5dd4e74b373546ea5eb307365799b5bf9ea24d2243301cbd9c2abe5112f8382f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/covered/capture.rb
CHANGED
@@ -43,10 +43,10 @@ module Covered
|
|
43
43
|
super
|
44
44
|
end
|
45
45
|
|
46
|
-
def execute(
|
46
|
+
def execute(source, binding: TOPLEVEL_BINDING)
|
47
47
|
enable
|
48
48
|
|
49
|
-
eval(source
|
49
|
+
eval(source.code!, binding, source.path)
|
50
50
|
ensure
|
51
51
|
disable
|
52
52
|
end
|
data/lib/covered/coverage.rb
CHANGED
@@ -21,8 +21,38 @@ module Covered
|
|
21
21
|
end
|
22
22
|
|
23
23
|
class Coverage
|
24
|
-
|
25
|
-
|
24
|
+
Source = Struct.new(:path, :code, :line_offset) do
|
25
|
+
def to_s
|
26
|
+
"\#<#{self.class} path=#{path}>"
|
27
|
+
end
|
28
|
+
|
29
|
+
def read(&block)
|
30
|
+
if block_given?
|
31
|
+
File.open(self.path, "r", &block)
|
32
|
+
else
|
33
|
+
File.read(self.path)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def code!
|
38
|
+
self.code || self.read
|
39
|
+
end
|
40
|
+
|
41
|
+
def code?
|
42
|
+
!!self.code
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.source(path, code = nil, line_offset = 1)
|
47
|
+
Source.new(path, code, line_offset)
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.for(path, code = nil, line_offset = 1)
|
51
|
+
self.new(Source.new(path, code, line_offset))
|
52
|
+
end
|
53
|
+
|
54
|
+
def initialize(source, counts = [])
|
55
|
+
@source = source
|
26
56
|
@counts = counts
|
27
57
|
@total = 0
|
28
58
|
|
@@ -32,18 +62,19 @@ module Covered
|
|
32
62
|
@executed_lines = nil
|
33
63
|
end
|
34
64
|
|
35
|
-
|
65
|
+
def path
|
66
|
+
@source.path
|
67
|
+
end
|
68
|
+
|
69
|
+
attr_accessor :source
|
70
|
+
|
36
71
|
attr :counts
|
37
72
|
attr :total
|
38
73
|
|
39
74
|
attr :annotations
|
40
75
|
|
41
76
|
def read(&block)
|
42
|
-
|
43
|
-
File.open(@path, "r", &block)
|
44
|
-
else
|
45
|
-
File.read(@path)
|
46
|
-
end
|
77
|
+
@source.read(&block)
|
47
78
|
end
|
48
79
|
|
49
80
|
def freeze
|
data/lib/covered/files.rb
CHANGED
@@ -23,15 +23,15 @@ module Covered
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def mark(path, lineno, value)
|
26
|
-
coverage = (@paths[path] ||= Coverage.
|
26
|
+
coverage = (@paths[path] ||= Coverage.for(path))
|
27
27
|
|
28
28
|
coverage.mark(lineno, value)
|
29
29
|
|
30
30
|
return coverage
|
31
31
|
end
|
32
32
|
|
33
|
-
def add(
|
34
|
-
@paths[path] ||= Coverage.new(
|
33
|
+
def add(source)
|
34
|
+
@paths[source.path] ||= Coverage.new(source)
|
35
35
|
end
|
36
36
|
|
37
37
|
def each(&block)
|
@@ -73,7 +73,7 @@ module Covered
|
|
73
73
|
end
|
74
74
|
|
75
75
|
paths.each do |path|
|
76
|
-
yield Coverage.
|
76
|
+
yield Coverage.for(path)
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
data/lib/covered/persist.rb
CHANGED
@@ -40,7 +40,11 @@ module Covered
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
record[:
|
43
|
+
if source = record[:source]
|
44
|
+
@output.add(source)
|
45
|
+
end
|
46
|
+
|
47
|
+
record[:counts].each_with_index do |count, index|
|
44
48
|
@output.mark(path, index, count) if count
|
45
49
|
end
|
46
50
|
end
|
@@ -49,8 +53,9 @@ module Covered
|
|
49
53
|
{
|
50
54
|
# We want to use relative paths so that moving the repo won't break everything:
|
51
55
|
path: relative_path(coverage.path),
|
52
|
-
coverage: coverage.counts,
|
53
56
|
mtime: File.mtime(coverage.path).to_f,
|
57
|
+
counts: coverage.counts,
|
58
|
+
source: coverage.source,
|
54
59
|
}
|
55
60
|
end
|
56
61
|
|
@@ -128,6 +133,9 @@ module Covered
|
|
128
133
|
packer = MessagePack::Packer.new(io)
|
129
134
|
packer.register_type(0x00, Symbol, :to_msgpack_ext)
|
130
135
|
packer.register_type(0x01, Time) {|object| object.to_s}
|
136
|
+
packer.register_type(0x0F, Coverage::Source) do |object|
|
137
|
+
object.to_a.to_msgpack
|
138
|
+
end
|
131
139
|
|
132
140
|
return packer
|
133
141
|
end
|
@@ -136,6 +144,9 @@ module Covered
|
|
136
144
|
unpacker = MessagePack::Unpacker.new(io)
|
137
145
|
unpacker.register_type(0x00, Symbol, :from_msgpack_ext)
|
138
146
|
unpacker.register_type(0x01, Time, :parse)
|
147
|
+
unpacker.register_type(0x0F) do |data|
|
148
|
+
Coverage::Source.new(*MessagePack.unpack(data))
|
149
|
+
end
|
139
150
|
|
140
151
|
return unpacker
|
141
152
|
end
|
data/lib/covered/rspec.rb
CHANGED
@@ -11,19 +11,6 @@ $covered = Covered::Config.load
|
|
11
11
|
|
12
12
|
module Covered
|
13
13
|
module RSpec
|
14
|
-
class Formatter
|
15
|
-
# The name `dump_summary` of this method is significant:
|
16
|
-
::RSpec::Core::Formatters.register self, :dump_summary
|
17
|
-
|
18
|
-
def initialize(output)
|
19
|
-
@output = output
|
20
|
-
end
|
21
|
-
|
22
|
-
def dump_summary notification
|
23
|
-
$covered.call(@output)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
14
|
module Policy
|
28
15
|
def load_spec_files
|
29
16
|
$covered.enable
|
@@ -46,10 +33,9 @@ if $covered.record?
|
|
46
33
|
RSpec::Core::Configuration.prepend(Covered::RSpec::Policy)
|
47
34
|
|
48
35
|
RSpec.configure do |config|
|
49
|
-
config.add_formatter(Covered::RSpec::Formatter)
|
50
|
-
|
51
36
|
config.after(:suite) do
|
52
37
|
$covered.disable
|
38
|
+
$covered.call(config.output_stream)
|
53
39
|
end
|
54
40
|
end
|
55
41
|
end
|
data/lib/covered/source.rb
CHANGED
@@ -11,16 +11,9 @@ require 'parser/current'
|
|
11
11
|
module Covered
|
12
12
|
# The source map, loads the source file, parses the AST to generate which lines contain executable code.
|
13
13
|
class Source < Wrapper
|
14
|
-
Script = Struct.new(:path, :source, :line_offset)
|
15
|
-
|
16
14
|
def initialize(output)
|
17
15
|
super(output)
|
18
16
|
|
19
|
-
@paths = {}
|
20
|
-
@mutex = Mutex.new
|
21
|
-
|
22
|
-
@annotations = {}
|
23
|
-
|
24
17
|
begin
|
25
18
|
@trace = TracePoint.new(:script_compiled) do |trace|
|
26
19
|
instruction_sequence = trace.instruction_sequence
|
@@ -28,10 +21,8 @@ module Covered
|
|
28
21
|
# We only track source files which begin at line 1, as these represent whole files instead of monkey patches.
|
29
22
|
if instruction_sequence.first_lineno <= 1
|
30
23
|
# Extract the source path and source itself and save it for later:
|
31
|
-
if path = instruction_sequence.path and
|
32
|
-
|
33
|
-
@paths[path] = Script.new(path, source, instruction_sequence.first_lineno)
|
34
|
-
end
|
24
|
+
if path = instruction_sequence.path and script = trace.eval_script
|
25
|
+
self.add(Coverage::Source.new(path, script, instruction_sequence.first_lineno))
|
35
26
|
end
|
36
27
|
end
|
37
28
|
end
|
@@ -135,30 +126,31 @@ module Covered
|
|
135
126
|
end
|
136
127
|
end
|
137
128
|
|
138
|
-
def add(
|
129
|
+
def add(source)
|
139
130
|
if coverage = super
|
140
|
-
top =
|
141
|
-
|
131
|
+
if top = self.parse(source)
|
132
|
+
self.expand(top, coverage)
|
133
|
+
end
|
142
134
|
end
|
143
135
|
|
144
136
|
return coverage
|
145
137
|
end
|
146
138
|
|
147
|
-
def parse(
|
148
|
-
if
|
149
|
-
Parser::CurrentRuby.parse(
|
150
|
-
elsif File.exist?(path)
|
139
|
+
def parse(source)
|
140
|
+
if source.code?
|
141
|
+
Parser::CurrentRuby.parse(source.code, source.path, source.line_offset)
|
142
|
+
elsif path = source.path and File.exist?(path)
|
151
143
|
Parser::CurrentRuby.parse_file(path)
|
152
144
|
else
|
153
145
|
# warn "Couldn't parse #{path}, file doesn't exist?"
|
154
146
|
end
|
155
147
|
rescue
|
156
|
-
warn "Couldn't parse #{
|
148
|
+
warn "Couldn't parse #{source}: #{$!}"
|
157
149
|
end
|
158
150
|
|
159
151
|
def each(&block)
|
160
152
|
@output.each do |coverage|
|
161
|
-
if top = parse(coverage.
|
153
|
+
if top = parse(coverage.source)
|
162
154
|
self.expand(top, coverage)
|
163
155
|
end
|
164
156
|
|
data/lib/covered/version.rb
CHANGED
data/lib/covered/wrapper.rb
CHANGED
@@ -21,7 +21,7 @@ module Covered
|
|
21
21
|
def mark(path, lineno, value)
|
22
22
|
end
|
23
23
|
|
24
|
-
def add(
|
24
|
+
def add(source)
|
25
25
|
end
|
26
26
|
|
27
27
|
def each
|
@@ -63,8 +63,8 @@ module Covered
|
|
63
63
|
@output.mark(path, lineno, value)
|
64
64
|
end
|
65
65
|
|
66
|
-
def add(
|
67
|
-
@output.add(
|
66
|
+
def add(source)
|
67
|
+
@output.add(source)
|
68
68
|
end
|
69
69
|
|
70
70
|
# @yield [Coverage] the path to the file, and the execution counts.
|
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.17.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-09-
|
44
|
+
date: 2022-09-20 00:00:00.000000000 Z
|
45
45
|
dependencies:
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: async-rest
|
metadata.gz.sig
CHANGED
Binary file
|