covered 0.17.1 → 0.18.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 +71 -55
- data/lib/covered/rspec.rb +1 -1
- data/lib/covered/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +3 -3
- 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: f8203a4eb44d2d3313e21789fa0c12d9c3922526908e8a4410dfa74a51f8a50e
|
4
|
+
data.tar.gz: 7bbf343d12b0cd93f96eb7ff25f192b819e2e55db17ff996b317dc2c7da693b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f580db7f466a44626c1d764ee427fa32c926370095843af0b4f09d818cf84024a1543bb3d6f3d6e88818f1d3a7b5a249166ab8a5321266942b3b5ec67fecd444
|
7
|
+
data.tar.gz: feca325f1e366a9083dfc9cd55d94d5cb3121c0bf8c621b22137be32460fa64587bb53de0b9ce02f7d35e783f9dbcf590a178c4c8f70b8dbb68e44b99cf069db
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/covered/capture.rb
CHANGED
@@ -8,69 +8,85 @@ require_relative 'wrapper'
|
|
8
8
|
require 'coverage'
|
9
9
|
|
10
10
|
module Covered
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
11
|
+
def self.coverage_with_eval?
|
12
|
+
if ::Coverage.respond_to?(:supported?)
|
13
|
+
::Coverage.supported?(:eval)
|
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)
|
21
33
|
end
|
22
34
|
end
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
35
|
+
rescue
|
36
|
+
warn "Line coverage disabled: #{$!}"
|
37
|
+
@trace = nil
|
27
38
|
end
|
28
|
-
rescue
|
29
|
-
warn "Line coverage disabled: #{$!}"
|
30
|
-
@trace = nil
|
31
39
|
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def enable
|
35
|
-
super
|
36
40
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
41
|
+
def enable
|
42
|
+
super
|
43
|
+
|
44
|
+
@trace&.enable
|
45
|
+
end
|
46
|
+
|
47
|
+
def disable
|
48
|
+
@trace&.disable
|
49
|
+
|
50
|
+
super
|
51
|
+
end
|
42
52
|
|
43
|
-
|
53
|
+
def execute(source, binding: TOPLEVEL_BINDING)
|
54
|
+
enable
|
55
|
+
|
56
|
+
eval(source.code!, binding, source.path)
|
57
|
+
ensure
|
58
|
+
disable
|
59
|
+
end
|
44
60
|
end
|
45
|
-
|
46
|
-
|
47
|
-
enable
|
61
|
+
else
|
62
|
+
class Capture < Wrapper
|
63
|
+
def enable
|
64
|
+
super
|
65
|
+
|
66
|
+
::Coverage.start(lines: true, eval: true)
|
67
|
+
end
|
48
68
|
|
49
|
-
|
50
|
-
|
51
|
-
|
69
|
+
def disable
|
70
|
+
results = ::Coverage.result
|
71
|
+
|
72
|
+
results.each do |path, result|
|
73
|
+
lines = result[:lines]
|
74
|
+
|
75
|
+
lines.each_with_index do |count, lineno|
|
76
|
+
@output.mark(path, lineno+1, count) if count
|
77
|
+
end
|
78
|
+
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
|
+
end
|
52
90
|
end
|
53
91
|
end
|
54
|
-
|
55
|
-
# class Capture < Wrapper
|
56
|
-
# def enable
|
57
|
-
# super
|
58
|
-
#
|
59
|
-
# ::Coverage.start
|
60
|
-
# end
|
61
|
-
#
|
62
|
-
# def disable
|
63
|
-
# result = ::Coverage.result
|
64
|
-
#
|
65
|
-
# puts result.inspect
|
66
|
-
#
|
67
|
-
# result.each do |path, lines|
|
68
|
-
# lines.each_with_index do |lineno, count|
|
69
|
-
# @output.mark(path, lineno, count)
|
70
|
-
# end
|
71
|
-
# end
|
72
|
-
#
|
73
|
-
# super
|
74
|
-
# end
|
75
|
-
# end
|
76
92
|
end
|
data/lib/covered/rspec.rb
CHANGED
@@ -4,7 +4,6 @@
|
|
4
4
|
# Copyright, 2018-2022, by Samuel Williams.
|
5
5
|
|
6
6
|
require_relative 'config'
|
7
|
-
|
8
7
|
require 'rspec/core/formatters'
|
9
8
|
|
10
9
|
$covered = Covered::Config.load
|
@@ -13,6 +12,7 @@ module Covered
|
|
13
12
|
module RSpec
|
14
13
|
module Policy
|
15
14
|
def load_spec_files
|
15
|
+
$stderr.puts "load_spec_files"
|
16
16
|
$covered.enable
|
17
17
|
|
18
18
|
super
|
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.18.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-09-
|
44
|
+
date: 2022-09-28 00:00:00.000000000 Z
|
45
45
|
dependencies:
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: async-rest
|
@@ -202,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
202
202
|
- !ruby/object:Gem::Version
|
203
203
|
version: '0'
|
204
204
|
requirements: []
|
205
|
-
rubygems_version: 3.
|
205
|
+
rubygems_version: 3.4.0.dev
|
206
206
|
signing_key:
|
207
207
|
specification_version: 4
|
208
208
|
summary: A modern approach to code coverage.
|
metadata.gz.sig
CHANGED
Binary file
|