covered 0.4.1 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/covered.gemspec +2 -2
- data/lib/covered/source.rb +11 -8
- data/lib/covered/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ab7cb43335f9a1a56aefb96ceeca0258c84462ddf5657eeaed13e8662eb74e3
|
4
|
+
data.tar.gz: 68de7fc8c253d5237769e4b0a41383de404c37d6923a73d508401ace75c3f64a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 611f47e4457cbcf2e2b8ed0e3d29c9ef66168c4358c1fd2466278ed0663a222dcef15af62a8a28a0e36d802cdfccafc20ece100a78e6a7a2247e7f45105727f9
|
7
|
+
data.tar.gz: c1707dbc6141f38bc2782276237de511eb1750e7d5591382c15a8dad7a2cb381c1a45d4150f505f95d1abbb1c1bd113e9ebb805f817d4ebd1d219d99d30cbd53
|
data/README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
# Covered [![Build Status](https://travis-ci.com/ioquatix/covered.svg)](
|
1
|
+
# Covered [![Build Status](https://travis-ci.com/ioquatix/covered.svg)](https://travis-ci.com/ioquatix/covered)
|
2
2
|
|
3
|
-
Covered uses modern Ruby features to generate comprehensive coverage, including support for templates which are compiled into Ruby. **This only works with Ruby 2.6 and
|
3
|
+
Covered uses modern Ruby features to generate comprehensive coverage, including support for templates which are compiled into Ruby. **This only works with Ruby 2.6 and its experimental support for RubyVM::AbstractSyntaxTree**
|
4
4
|
|
5
5
|
![Screenshot](media/example.png)
|
6
6
|
|
7
7
|
## Motivation
|
8
8
|
|
9
|
-
Existing Ruby coverage tools are unable to handle `eval`ed code. This is because the `coverage` module built into Ruby doesn't expose the necessary hooks to capture it. With Ruby 2.6, `RubyVM::AST.parse(source)` came
|
9
|
+
Existing Ruby coverage tools are unable to handle `eval`ed code. This is because the `coverage` module built into Ruby doesn't expose the necessary hooks to capture it. With Ruby 2.6, `RubyVM::AST.parse(source)` came into existence, which gives us a fine grained tool for computing initial source coverage (i.e. what lines are executable), and thus making it possible to compute coverage for "templates".
|
10
10
|
|
11
11
|
It's still tricky to do it correctly, but it is feasible now to compute coverage of web application "views" by using this technique. This gem is an exploration to see what is possible.
|
12
12
|
|
data/covered.gemspec
CHANGED
@@ -18,13 +18,13 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.required_ruby_version = '~> 2.6.
|
21
|
+
spec.required_ruby_version = '~> 2.6.0.rc1'
|
22
22
|
|
23
23
|
spec.add_dependency "rainbow"
|
24
24
|
|
25
25
|
spec.add_development_dependency "trenni", "~> 3.6"
|
26
26
|
|
27
|
-
spec.add_development_dependency "bundler", "~>
|
27
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
28
28
|
spec.add_development_dependency "rake", "~> 10.0"
|
29
29
|
spec.add_development_dependency "rspec", "~> 3.0"
|
30
30
|
end
|
data/lib/covered/source.rb
CHANGED
@@ -26,14 +26,14 @@ require 'thread'
|
|
26
26
|
module Covered
|
27
27
|
# The source map, loads the source file, parses the AST to generate which lines contain executable code.
|
28
28
|
class Source < Wrapper
|
29
|
-
EXECUTABLE = /
|
29
|
+
EXECUTABLE = /(.?CALL|.VAR|.ASGN|DEFN)/.freeze
|
30
30
|
|
31
31
|
# Deviate from the standard policy above, because all the files are already loaded, so we skip NODE_FCALL.
|
32
|
-
DOGFOOD = /
|
32
|
+
DOGFOOD = /([V]?CALL|.VAR|.ASGN|DEFN)/.freeze
|
33
33
|
|
34
34
|
# Ruby trace points don't trigger for argument execution.
|
35
35
|
# Constants are loaded when the file loads, so they are less interesting.
|
36
|
-
IGNORE = /
|
36
|
+
IGNORE = /(ARGS|CDECL)/.freeze
|
37
37
|
|
38
38
|
def initialize(output, executable: EXECUTABLE, ignore: IGNORE)
|
39
39
|
super(output)
|
@@ -69,12 +69,12 @@ module Covered
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def executable?(node)
|
72
|
-
node.type =~ @executable
|
72
|
+
node.type.to_s =~ @executable
|
73
73
|
end
|
74
74
|
|
75
75
|
def ignore?(node)
|
76
76
|
# NODE_ARGS Ruby doesn't report execution of arguments in :line tracepoint.
|
77
|
-
node.type =~ @ignore
|
77
|
+
node.nil? or node.type.to_s =~ @ignore
|
78
78
|
end
|
79
79
|
|
80
80
|
def expand(node, counts)
|
@@ -82,8 +82,11 @@ module Covered
|
|
82
82
|
|
83
83
|
counts[node.first_lineno] ||= 0 if executable?(node)
|
84
84
|
|
85
|
+
# puts "#{node.inspect} #{node.to_s} -> #{node.children.inspect}"
|
85
86
|
node.children.each do |child|
|
86
|
-
next
|
87
|
+
next unless child.is_a? RubyVM::AbstractSyntaxTree::Node
|
88
|
+
|
89
|
+
next if ignore?(child)
|
87
90
|
|
88
91
|
expand(child, counts)
|
89
92
|
end
|
@@ -93,9 +96,9 @@ module Covered
|
|
93
96
|
# puts "Parse #{path}"
|
94
97
|
|
95
98
|
if source = @paths[path]
|
96
|
-
RubyVM::
|
99
|
+
RubyVM::AbstractSyntaxTree.parse(source)
|
97
100
|
elsif File.exist?(path)
|
98
|
-
RubyVM::
|
101
|
+
RubyVM::AbstractSyntaxTree.parse_file(path)
|
99
102
|
else
|
100
103
|
warn "Couldn't parse #{path}, file doesn't exist?"
|
101
104
|
end
|
data/lib/covered/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: covered
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07
|
11
|
+
date: 2018-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rainbow
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '2.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '2.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,7 +118,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
118
118
|
requirements:
|
119
119
|
- - "~>"
|
120
120
|
- !ruby/object:Gem::Version
|
121
|
-
version: 2.6.
|
121
|
+
version: 2.6.0.rc1
|
122
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
123
|
requirements:
|
124
124
|
- - ">="
|
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
126
|
version: '0'
|
127
127
|
requirements: []
|
128
128
|
rubyforge_project:
|
129
|
-
rubygems_version: 2.7.
|
129
|
+
rubygems_version: 2.7.8
|
130
130
|
signing_key:
|
131
131
|
specification_version: 4
|
132
132
|
summary: A modern approach to code coverage.
|