covered 0.16.5 → 0.16.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 866c111f17bb03b47aed6e71a6439f3847e08d0352ba82eac169269d072820c7
4
- data.tar.gz: a16bb2c36bcf50f0d26ce4576e741e512a144725a3c2b0f3c8724476fb64c7d4
3
+ metadata.gz: ab80834ad5a14e4853e865768e7cc51eb38497904e62818e81ce3633ac9f43d2
4
+ data.tar.gz: ce3a3757b0c08e8f6b09f8d0c3f7273a623ba293f9b56b81b4b5cff7662bf857
5
5
  SHA512:
6
- metadata.gz: 22f7f294cf342ae163dd9f1ba8f3f812e193f5f233592c274f84bd1d18e99b5ca0041d5391b88a6df3f21032779e5ebcc399131ab03bb295988c9a178f3d26fa
7
- data.tar.gz: 35d94a1e76a3640a22ad794c47c41a98562b1343964b5637d477b390875a4997cf054345470e7c2076f81fd182a344793f24bc2ebe67eca190c0737ff4274ef4
6
+ metadata.gz: c46120d01cc5a48d365f9e3d9dadb39b9f4825b42aee8f667e3a1a3298439f114f5cb29d34cdcf282bb89f2a9982f756892dfd808e406971876e36cfe5028c12
7
+ data.tar.gz: 58564662a71b2419a3ed02766614c0b26479702e8cb2d17e1efc0beb5b423b7444eb1b779f7ebc8f79fdf158e7f6ab4ce655af8bf75649fce2459d8f74e97c83
checksums.yaml.gz.sig CHANGED
Binary file
@@ -0,0 +1,32 @@
1
+
2
+ def initialize(context)
3
+ super
4
+
5
+ require_relative '../../lib/covered'
6
+ end
7
+
8
+ # Debug the coverage of a file. Show which lines should be executable.
9
+ #
10
+ # @parameter paths [Array(String)] The paths to parse.
11
+ # @parameter execute [Boolean] Whether to execute the code.
12
+ def parse(paths: [], execute: false)
13
+ files = output = Covered::Files.new
14
+ output = Covered::Source.new(output)
15
+
16
+ paths.each do |path|
17
+ output.mark(path, 0, 0)
18
+ end
19
+
20
+ if execute
21
+ capture = Covered::Capture.new(output)
22
+ capture.enable
23
+ paths.each do |path|
24
+ load path
25
+ end
26
+ capture.disable
27
+
28
+ files.paths = files.paths.slice(*paths)
29
+ end
30
+
31
+ Covered::Summary.new.call(output, $stderr)
32
+ end
data/lib/covered/files.rb CHANGED
@@ -31,7 +31,7 @@ module Covered
31
31
  @paths = {}
32
32
  end
33
33
 
34
- attr :paths
34
+ attr_accessor :paths
35
35
 
36
36
  def empty?
37
37
  @paths.empty?
@@ -79,7 +79,7 @@ module Covered
79
79
  ivasgn: true,
80
80
  cvasgn: true,
81
81
  gvasgn: true,
82
- match_pattern: true
82
+ match_pattern: true,
83
83
  }
84
84
 
85
85
  def executable?(node)
@@ -88,34 +88,42 @@ module Covered
88
88
 
89
89
  IGNORE = {
90
90
  arg: true,
91
- # Ruby doesn't appear to execute rescue lines.
92
- rescue: true
93
91
  }
94
92
 
95
93
  def ignore?(node)
96
94
  node.nil? || IGNORE[node.type]
97
95
  end
98
96
 
97
+ IGNORE_CHILDREN = {
98
+ hash: true,
99
+ array: true,
100
+ }
101
+
102
+ def ignore_children?(node)
103
+ IGNORE_CHILDREN[node.type]
104
+ end
105
+
99
106
  def expand(node, coverage, level = 0)
100
107
  if node.is_a? Parser::AST::Node
101
108
  if ignore?(node)
102
109
  # coverage.annotate(node.location.line, "ignoring #{node.type}")
103
- else
104
- if node.type == :send
105
- # We want to mark the line which has the method on it:
106
- coverage.counts[node.location.selector.line] ||= 0
107
- elsif executable?(node)
108
- # coverage.annotate(node.location.line, "executable #{node.type}")
109
- coverage.counts[node.location.line] ||= 0
110
- # elsif location = node.location
111
- # coverage.annotate(location.line, "not executable #{node.type}") rescue nil
110
+ elsif node.type == :begin
111
+ if last_child = node.children&.last
112
+ coverage.counts[last_child.location.line] ||= 0
112
113
  end
113
114
 
114
- # if node.type == :send
115
- # coverage.annotate(node.location.line, "ignoring #{node.type} children")
116
- # end
117
-
118
115
  expand(node.children, coverage, level + 1)
116
+ elsif node.type == :send
117
+ coverage.counts[node.location.selector.line] ||= 0
118
+ elsif executable?(node)
119
+ # coverage.annotate(node.location.line, "executable #{node.type}")
120
+ coverage.counts[node.location.line] ||= 0
121
+ else
122
+ if ignore_children?(node)
123
+ # coverage.annotate(node.location.line, "ignoring #{node.type} children")
124
+ else
125
+ expand(node.children, coverage, level + 1)
126
+ end
119
127
  end
120
128
  elsif node.is_a? Array
121
129
  node.each do |child|
data/lib/covered/sus.rb CHANGED
@@ -18,23 +18,28 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require_relative 'config'
22
-
23
21
  module Covered
24
22
  module Sus
25
23
  def initialize(...)
26
24
  super
27
25
 
28
- @covered = Covered::Config.load(root: self.root)
29
- if @covered.record?
30
- @covered.enable
26
+ # Defer loading the coverage configuration unless we are actually running with coverage enabled to avoid performance cost/overhead.
27
+ if ENV['COVERAGE']
28
+ require_relative 'config'
29
+
30
+ @covered = Covered::Config.load(root: self.root)
31
+ if @covered.record?
32
+ @covered.enable
33
+ end
34
+ else
35
+ @covered = nil
31
36
  end
32
37
  end
33
38
 
34
39
  def after_tests(assertions)
35
40
  super(assertions)
36
41
 
37
- if @covered.record?
42
+ if @covered&.record?
38
43
  @covered.disable
39
44
  @covered.call(self.output.io)
40
45
  end
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Covered
22
- VERSION = "0.16.5"
22
+ VERSION = "0.16.6"
23
23
  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.16.5
4
+ version: 0.16.6
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-08-24 00:00:00.000000000 Z
44
+ date: 2022-08-27 00:00:00.000000000 Z
45
45
  dependencies:
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: async-rest
@@ -161,6 +161,7 @@ executables: []
161
161
  extensions: []
162
162
  extra_rdoc_files: []
163
163
  files:
164
+ - bake/covered/debug.rb
164
165
  - bake/covered/validate.rb
165
166
  - lib/covered.rb
166
167
  - lib/covered/cache.rb
metadata.gz.sig CHANGED
Binary file