covered 0.17.1 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b906f699dc0a8c5ab648200ae5330cf12a0da31e5c6966bb105d1df387c7179
4
- data.tar.gz: 6692c75aa8764654a5a278e248bf4b9f224a10e84363a7cbf0dfc68ba5d84be6
3
+ metadata.gz: f8203a4eb44d2d3313e21789fa0c12d9c3922526908e8a4410dfa74a51f8a50e
4
+ data.tar.gz: 7bbf343d12b0cd93f96eb7ff25f192b819e2e55db17ff996b317dc2c7da693b9
5
5
  SHA512:
6
- metadata.gz: 6656a91ce7b29c67c66dd9e1d63f9c38231b1bfbdedae4ce29b638468d55d0476d308522ecf24d07fee905081653d192cd90d73cf1772b59fd7534f87bfd2cbb
7
- data.tar.gz: 21f2d81e59417f81bcf63c7c95e0a6023c67bd68985811f3e2184c1fdbd447be5dd4e74b373546ea5eb307365799b5bf9ea24d2243301cbd9c2abe5112f8382f
6
+ metadata.gz: f580db7f466a44626c1d764ee427fa32c926370095843af0b4f09d818cf84024a1543bb3d6f3d6e88818f1d3a7b5a249166ab8a5321266942b3b5ec67fecd444
7
+ data.tar.gz: feca325f1e366a9083dfc9cd55d94d5cb3121c0bf8c621b22137be32460fa64587bb53de0b9ce02f7d35e783f9dbcf590a178c4c8f70b8dbb68e44b99cf069db
checksums.yaml.gz.sig CHANGED
Binary file
@@ -8,69 +8,85 @@ require_relative 'wrapper'
8
8
  require 'coverage'
9
9
 
10
10
  module Covered
11
- class Capture < Wrapper
12
- def initialize(output)
13
- super(output)
14
-
15
- begin
16
- @trace = TracePoint.new(:line, :call, :c_call) do |trace|
17
- if trace.event == :call
18
- # Ruby doesn't always mark call-sites in sub-expressions, so we use this approach to compute a call site and mark it:
19
- if location = caller_locations(2, 1).first and path = location.path
20
- @output.mark(path, location.lineno, 1)
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
- if path = trace.path
25
- @output.mark(path, trace.lineno, 1)
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
- @trace&.enable
38
- end
39
-
40
- def disable
41
- @trace&.disable
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
- super
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
- def execute(source, binding: TOPLEVEL_BINDING)
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
- eval(source.code!, binding, source.path)
50
- ensure
51
- disable
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
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2018-2022, by Samuel Williams.
5
5
 
6
6
  module Covered
7
- VERSION = "0.17.1"
7
+ VERSION = "0.18.0"
8
8
  end
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.17.1
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-20 00:00:00.000000000 Z
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.3.7
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